[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/9] vl: add -query-capabilities
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 8/9] vl: add -query-capabilities |
Date: |
Mon, 19 Mar 2012 10:09:22 -0500 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 2/9] qemu-config: friends don't let friends use sscanf, (continued)
[Qemu-devel] [PATCH 9/9] Add a management tool writer's guide, Anthony Liguori, 2012/03/19
[Qemu-devel] [PATCH 6/9] vl: parse all options via QemuOpts, Anthony Liguori, 2012/03/19
[Qemu-devel] [PATCH 8/9] vl: add -query-capabilities,
Anthony Liguori <=
Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Paolo Bonzini, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Anthony Liguori, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Paolo Bonzini, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Anthony Liguori, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Paolo Bonzini, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Anthony Liguori, 2012/03/19
- Re: [Qemu-devel] [RFC PATCH 0/9] qemu capabilities reporting and config changes, Paolo Bonzini, 2012/03/19