From patchwork Mon Mar 19 15:09:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 147562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 61052B6FA9 for ; Tue, 20 Mar 2012 02:46:46 +1100 (EST) Received: from localhost ([::1]:57490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9enE-0005gB-9x for incoming@patchwork.ozlabs.org; Mon, 19 Mar 2012 11:46:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eDJ-0003ju-QX for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:09:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9eDH-0000KZ-5M for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:09:37 -0400 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:47555 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eDG-0000KA-US for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:09:35 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id q2JF9XJF030954; Mon, 19 Mar 2012 10:09:33 -0500 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q2JF9Wgj030953; Mon, 19 Mar 2012 10:09:32 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2012 10:09:22 -0500 Message-Id: <1332169763-30665-9-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1332169763-30665-1-git-send-email-aliguori@us.ibm.com> References: <1332169763-30665-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Anthony Liguori , Eric Blake , Eduardo Habkost , Gerd Hoffman Subject: [Qemu-devel] [PATCH 8/9] vl: add -query-capabilities X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This dumps the results of query-version, query-commands, and query-config-capabilities into a single JSON object on stdout. Signed-off-by: Anthony Liguori --- qemu-options.hx | 4 ++++ vl.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 584dc76..4d760d8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2710,6 +2710,10 @@ the @var{simple} tracing backend. @end table ETEXI +DEF("query-capabilities", 0, QEMU_OPTION_query_capabilities, + "-query-capabilities print QEMU capabilities and exit\n", + QEMU_ARCH_ALL) + HXCOMM This is the last statement. Insert new options before this line! STEXI @end table diff --git a/vl.c b/vl.c index 5337e58..88626aa 100644 --- a/vl.c +++ b/vl.c @@ -2265,6 +2265,29 @@ int qemu_init_main_loop(void) return main_loop_init(); } +static void qemu_print_capabilities(void) +{ + QObject *version, *commands, *config; + QDict *dict; + QString *json; + + qmp_marshal_input_query_version(NULL, NULL, &version); + qmp_marshal_input_query_commands(NULL, NULL, &commands); + qmp_marshal_input_query_config_capabilities(NULL, NULL, &config); + + dict = qdict_new(); + qdict_put_obj(dict, "version", version); + qdict_put_obj(dict, "commands", commands); + qdict_put_obj(dict, "config", config); + + json = qobject_to_json_pretty(QOBJECT(dict)); + + printf("%s\n", qstring_get_str(json)); + + QDECREF(json); + QDECREF(dict); +} + typedef struct QemuOptions { QEMUMachine *machine; @@ -3123,6 +3146,10 @@ static void qemu_parse_option(int index, const char *optarg, QemuOptions *option fclose(fp); break; } + case QEMU_OPTION_query_capabilities: + qemu_print_capabilities(); + exit(0); + break; default: os_parse_cmd_args(index, optarg); }