mirror of
https://github.com/xemu-project/xemu.git
synced 2025-02-01 01:32:34 +00:00
qapi: add query-machines command
This provides the same output as -M ? but in a structured way. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
5192082097
commit
01d3c80d68
@ -2194,3 +2194,31 @@
|
|||||||
# Since: 0.14.0
|
# Since: 0.14.0
|
||||||
##
|
##
|
||||||
{ 'command': 'closefd', 'data': {'fdname': 'str'} }
|
{ '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'] }
|
||||||
|
@ -2224,3 +2224,9 @@ EQMP
|
|||||||
.mhandler.cmd_new = qmp_marshal_input_device_list_properties,
|
.mhandler.cmd_new = qmp_marshal_input_device_list_properties,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
.name = "query-machines",
|
||||||
|
.args_type = "",
|
||||||
|
.mhandler.cmd_new = qmp_marshal_input_query_machines,
|
||||||
|
},
|
||||||
|
|
||||||
|
31
vl.c
31
vl.c
@ -1213,6 +1213,37 @@ QEMUMachine *find_default_machine(void)
|
|||||||
return NULL;
|
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 */
|
/* main execution loop */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user