@@ -787,6 +787,19 @@ Display the value of a storage key (s390 only)
ETEXI
STEXI
+@item info vm-generation-id
+Show Virtual Machine Generation ID
+ETEXI
+
+ {
+ .name = "vm-generation-id",
+ .args_type = "",
+ .params = "",
+ .help = "Show Virtual Machine Generation ID",
+ .mhandler.cmd = hmp_info_vm_generation_id,
+ },
+
+STEXI
@end table
ETEXI
@@ -2375,3 +2375,12 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
qapi_free_RockerOfDpaGroupList(list);
}
+
+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);
+}
@@ -131,5 +131,6 @@ void hmp_rocker(Monitor *mon, const QDict *qdict);
void hmp_rocker_ports(Monitor *mon, const QDict *qdict);
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_vm_generation_id(Monitor *mon, const QDict *qdict);
#endif
@@ -16,6 +16,7 @@
#include "hw/misc/vmgenid.h"
#include "hw/acpi/acpi.h"
#include "qapi/visitor.h"
+#include "qmp-commands.h"
#define VMGENID(obj) OBJECT_CHECK(VmGenIdState, (obj), VMGENID_DEVICE)
@@ -38,6 +39,25 @@ Object *find_vmgneid_dev(Error **errp)
return obj;
}
+GuidInfo *qmp_query_vm_generation_id(Error **errp)
+{
+ GuidInfo *info;
+ VmGenIdState *vdev;
+ Object *obj = find_vmgneid_dev(errp);
+
+ if (!obj) {
+ return NULL;
+ }
+ vdev = VMGENID(obj);
+ info = g_malloc0(sizeof(*info));
+ info->guid = g_strdup_printf(UUID_FMT, vdev->guid[0], vdev->guid[1],
+ vdev->guid[2], vdev->guid[3], vdev->guid[4], vdev->guid[5],
+ vdev->guid[6], vdev->guid[7], vdev->guid[8], vdev->guid[9],
+ vdev->guid[10], vdev->guid[11], vdev->guid[12], vdev->guid[13],
+ vdev->guid[14], vdev->guid[15]);
+ return info;
+}
+
static void vmgenid_update_guest(VmGenIdState *s)
{
Object *acpi_obj;
@@ -4081,3 +4081,23 @@
##
{ 'enum': 'ReplayMode',
'data': [ 'none', 'record', 'play' ] }
+
+##
+# @GuidInfo:
+#
+# GUID information.
+#
+# @guid: the globally unique identifier
+#
+# Since: 2.6
+##
+{ 'struct': 'GuidInfo', 'data': {'guid': 'str'} }
+
+##
+# @query-vm-generation-id
+#
+# Show Virtual Machine Generation ID
+#
+# Since 2.6
+##
+{ 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
@@ -4795,3 +4795,22 @@ Example:
{"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840,
"pop-vlan": 1, "id": 251658240}
]}
+
+EQMP
+
+ {
+ .name = "query-vm-generation-id",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_query_vm_generation_id,
+ },
+
+SQMP
+Show Virtual Machine Generation ID counter
+-----
+
+Arguments: none
+
+Example:
+
+-> { "execute": "query-vm-generation-id" }
+<- {"return": {"guid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"}}
@@ -38,3 +38,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 += vhost.o
+stub-obj-y += vmgenid.o
new file mode 100644
@@ -0,0 +1,7 @@
+#include "qmp-commands.h"
+
+GuidInfo *qmp_query_vm_generation_id(Error **errp)
+{
+ error_setg(errp, "this command is not currently supported");
+ return NULL;
+}
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> --- v18: - add a new QMP type GuidInfo instead of reusing UuidInfo Eric Blake <eblake@redhat.com> --- hmp-commands-info.hx | 13 +++++++++++++ hmp.c | 9 +++++++++ hmp.h | 1 + hw/misc/vmgenid.c | 20 ++++++++++++++++++++ qapi-schema.json | 20 ++++++++++++++++++++ qmp-commands.hx | 19 +++++++++++++++++++ stubs/Makefile.objs | 1 + stubs/vmgenid.c | 7 +++++++ 8 files changed, 90 insertions(+) create mode 100644 stubs/vmgenid.c