[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 44/48] qapi: add query-machines command
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 44/48] qapi: add query-machines command |
Date: |
Mon, 13 Aug 2012 16:49:05 -0300 |
From: Anthony Liguori <address@hidden>
This provides the same output as -M ? but in a structured way.
Signed-off-by: Anthony Liguori <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
qapi-schema.json | 28 ++++++++++++++++++++++++++++
qmp-commands.hx | 6 ++++++
vl.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+)
diff --git a/qapi-schema.json b/qapi-schema.json
index 1731a92..e51753c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2194,3 +2194,31 @@
# Since: 0.14.0
##
{ 'command': 'closefd', 'data': {'fdname': 'str'} }
+
+##
+# @MachineInfo:
+#
+# Information describing a machine.
+#
+# @name: the name of the machine
+#
+# @alias: #optional an alias for the machine name
+#
+# @default: #optional whether the machine is default
+#
+# Since: 1.2.0
+##
+{ 'type': 'MachineInfo',
+ 'data': { 'name': 'str', '*alias': 'str',
+ '*is-default': 'bool' } }
+
+##
+# @query-machines:
+#
+# Return a list of supported machines
+#
+# Returns: a list of MachineInfo
+#
+# Since: 1.2.0
+##
+{ 'command': 'query-machines', 'returns': ['MachineInfo'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e9e0410..fd87775 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2224,3 +2224,9 @@ EQMP
.mhandler.cmd_new = qmp_marshal_input_device_list_properties,
},
+ {
+ .name = "query-machines",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_machines,
+ },
+
diff --git a/vl.c b/vl.c
index 97ab39f..d01256a 100644
--- a/vl.c
+++ b/vl.c
@@ -1213,6 +1213,37 @@ QEMUMachine *find_default_machine(void)
return NULL;
}
+MachineInfoList *qmp_query_machines(Error **errp)
+{
+ MachineInfoList *mach_list = NULL;
+ QEMUMachine *m;
+
+ for (m = first_machine; m; m = m->next) {
+ MachineInfoList *entry;
+ MachineInfo *info;
+
+ info = g_malloc0(sizeof(*info));
+ if (m->is_default) {
+ info->has_is_default = true;
+ info->is_default = true;
+ }
+
+ if (m->alias) {
+ info->has_alias = true;
+ info->alias = g_strdup(m->alias);
+ }
+
+ info->name = g_strdup(m->name);
+
+ entry = g_malloc0(sizeof(*entry));
+ entry->value = info;
+ entry->next = mach_list;
+ mach_list = entry;
+ }
+
+ return mach_list;
+}
+
/***********************************************************/
/* main execution loop */
--
1.7.11.2.249.g31c7954.dirty
- [Qemu-devel] [PATCH 31/48] error: drop error_get_qobject()/error_set_qobject(), (continued)
- [Qemu-devel] [PATCH 31/48] error: drop error_get_qobject()/error_set_qobject(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 27/48] hmp: hmp_change(): use error_get_class(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 30/48] qemu-ga: switch to the new error format on the wire, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 41/48] qmp: add SUSPEND_DISK event, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 23/48] qerror: qerror_table: don't use C99 struct initializers, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 46/48] qapi: add query-cpu-definitions command (v2), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 39/48] qmp: qmp-events.txt: put events in alphabetical order, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 40/48] qmp: qmp-events.txt: add missing doc for the SUSPEND event, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 32/48] error, qerror: pass desc string to error calls, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 45/48] compiler: add macro for GCC weak symbols, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 44/48] qapi: add query-machines command,
Luiz Capitulino <=
- Re: [Qemu-devel] [PULL 00/48]: QMP queue, Anthony Liguori, 2012/08/13