From patchwork Fri Jan 22 13:20:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8090051 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01C57BEEE5 for ; Fri, 22 Jan 2016 13:23:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26FCF20457 for ; Fri, 22 Jan 2016 13:23:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F681203AA for ; Fri, 22 Jan 2016 13:23:38 +0000 (UTC) Received: from localhost ([::1]:53705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMbgf-0004CK-HD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jan 2016 08:23:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMbeS-0000cp-Sc for qemu-devel@nongnu.org; Fri, 22 Jan 2016 08:21:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMbeR-0002QE-5U for qemu-devel@nongnu.org; Fri, 22 Jan 2016 08:21:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMbeQ-0002Q2-U5 for qemu-devel@nongnu.org; Fri, 22 Jan 2016 08:21:19 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 935FF8E6EF for ; Fri, 22 Jan 2016 13:21:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0MDL5gJ021584; Fri, 22 Jan 2016 08:21:16 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 22 Jan 2016 14:20:58 +0100 Message-Id: <1453468862-118912-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1453468862-118912-1-git-send-email-imammedo@redhat.com> References: <1453468862-118912-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, mst@redhat.com, ghammer@redhat.com, lersek@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v18 5/9] qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v18: - add a new QMP type GuidInfo instead of reusing UuidInfo Eric Blake --- 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 diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 9b71351..b649a5d 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -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 diff --git a/hmp.c b/hmp.c index 54f2620..aeb753d 100644 --- a/hmp.c +++ b/hmp.c @@ -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); +} diff --git a/hmp.h b/hmp.h index a8c5b5a..21c5132 100644 --- a/hmp.h +++ b/hmp.h @@ -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 diff --git a/hw/misc/vmgenid.c b/hw/misc/vmgenid.c index a2fbdfc..24c0a4e 100644 --- a/hw/misc/vmgenid.c +++ b/hw/misc/vmgenid.c @@ -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; diff --git a/qapi-schema.json b/qapi-schema.json index b3038b2..d4e0463 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -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' } diff --git a/qmp-commands.hx b/qmp-commands.hx index db072a6..38e4e16 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -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"}} diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index d7898a0..c1ebfcc 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -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 diff --git a/stubs/vmgenid.c b/stubs/vmgenid.c new file mode 100644 index 0000000..1ff8cd2 --- /dev/null +++ b/stubs/vmgenid.c @@ -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; +}