qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Eric Blake <eblake@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Gerd Hoffman <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 8/9] vl: add -query-capabilities
Date: Mon, 19 Mar 2012 10:09:22 -0500	[thread overview]
Message-ID: <1332169763-30665-9-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1332169763-30665-1-git-send-email-aliguori@us.ibm.com>

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 <aliguori@us.ibm.com>
---
 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);
     }
-- 
1.7.5.4

  parent reply	other threads:[~2012-03-19 15:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 15:09 [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 1/9] qemu-config: fix -writeconfig when using qemu_opt_set_bool Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 2/9] qemu-config: friends don't let friends use sscanf Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 3/9] vl: refactor command line parsing to allow options to be set via config Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 4/9] vl: mark system configuration options in qemu-options.hx Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 5/9] vl: enable system configuration to be used Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 6/9] vl: parse all options via QemuOpts Anthony Liguori
2012-03-19 15:09 ` [Qemu-devel] [PATCH 7/9] qmp: expose a command to query capabilities of config parser Anthony Liguori
2012-03-19 20:10   ` Eric Blake
2012-03-19 20:19     ` Anthony Liguori
2012-03-19 20:31       ` Eric Blake
2012-03-19 20:41         ` Anthony Liguori
2012-03-19 15:09 ` Anthony Liguori [this message]
2012-03-20  7:49   ` [Qemu-devel] [PATCH 8/9] vl: add -query-capabilities Gerd Hoffmann
2012-03-20 10:33     ` Daniel P. Berrange
2012-03-20 19:39   ` Eduardo Habkost
2012-03-19 15:09 ` [Qemu-devel] [PATCH 9/9] Add a management tool writer's guide Anthony Liguori
2012-03-19 16:09 ` [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes Paolo Bonzini
2012-03-19 16:31   ` Anthony Liguori
2012-03-19 16:33     ` Paolo Bonzini
2012-03-19 16:41       ` Anthony Liguori
2012-03-19 16:45         ` Paolo Bonzini
2012-03-19 16:53           ` Anthony Liguori
2012-03-19 17:03             ` Paolo Bonzini
2012-03-20  7:54     ` Gerd Hoffmann
2012-03-20 19:47   ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332169763-30665-9-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).