qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands

Add commands to query Virtual Machine Generation ID counter.

QMP command example:
    { "execute": "query-vm-generation-id" }

HMP command example:
    info vm-generation-id

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2017-02-16 15:15:37 -08:00 committed by Michael S. Tsirkin
parent d03637bcfb
commit 39164c136c
7 changed files with 70 additions and 0 deletions

View File

@ -801,6 +801,20 @@ STEXI
Show information about hotpluggable CPUs
ETEXI
STEXI
@item info vm-generation-id
@findex vm-generation-id
Show Virtual Machine Generation ID
ETEXI
{
.name = "vm-generation-id",
.args_type = "",
.params = "",
.help = "Show Virtual Machine Generation ID",
.cmd = hmp_info_vm_generation_id,
},
STEXI
@end table
ETEXI

9
hmp.c
View File

@ -2576,3 +2576,12 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
qapi_free_HotpluggableCPUList(saved);
}
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
{
GuidInfo *info = qmp_query_vm_generation_id(NULL);
if (info) {
monitor_printf(mon, "%s\n", info->guid);
}
qapi_free_GuidInfo(info);
}

1
hmp.h
View File

@ -137,5 +137,6 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict);
void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
void hmp_info_dump(Monitor *mon, const QDict *qdict);
void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
#endif

View File

@ -240,3 +240,19 @@ static void vmgenid_register_types(void)
}
type_init(vmgenid_register_types)
GuidInfo *qmp_query_vm_generation_id(Error **errp)
{
GuidInfo *info;
VmGenIdState *vms;
Object *obj = find_vmgenid_dev();
if (!obj) {
return NULL;
}
vms = VMGENID(obj);
info = g_malloc0(sizeof(*info));
info->guid = qemu_uuid_unparse_strdup(&vms->guid);
return info;
}

View File

@ -6188,3 +6188,23 @@
#
##
{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] }
##
# @GuidInfo:
#
# GUID information.
#
# @guid: the globally unique identifier
#
# Since: 2.9
##
{ 'struct': 'GuidInfo', 'data': {'guid': 'str'} }
##
# @query-vm-generation-id:
#
# Show Virtual Machine Generation ID
#
# Since 2.9
##
{ 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }

View File

@ -36,3 +36,4 @@ stub-obj-y += qmp_pc_dimm_device_list.o
stub-obj-y += target-monitor-defs.o
stub-obj-y += target-get-monitor-def.o
stub-obj-y += pc_madt_cpu_entry.o
stub-obj-y += vmgenid.o

9
stubs/vmgenid.c Normal file
View File

@ -0,0 +1,9 @@
#include "qemu/osdep.h"
#include "qmp-commands.h"
#include "qapi/qmp/qerror.h"
GuidInfo *qmp_query_vm_generation_id(Error **errp)
{
error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}