From patchwork Thu Jan 28 10:54:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8149101 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6314C9FBF9 for ; Thu, 28 Jan 2016 10:55:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A746D202F8 for ; Thu, 28 Jan 2016 10:55:07 +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 CBD7B20154 for ; Thu, 28 Jan 2016 10:55:06 +0000 (UTC) Received: from localhost ([::1]:55242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkEE-00028V-4y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 05:55:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkDv-0001zr-43 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 05:54:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOkDt-0005EC-Ox for qemu-devel@nongnu.org; Thu, 28 Jan 2016 05:54:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkDt-0005E6-ID for qemu-devel@nongnu.org; Thu, 28 Jan 2016 05:54:45 -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 25A358E6EF for ; Thu, 28 Jan 2016 10:54:45 +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 u0SAsUrv001804; Thu, 28 Jan 2016 05:54:43 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 28 Jan 2016 11:54:28 +0100 Message-Id: <1453978470-222624-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1453978470-222624-1-git-send-email-imammedo@redhat.com> References: <1453978470-222624-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 Subject: [Qemu-devel] [PATCH v19 6/9] qmp/hmp: add set-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 set-vm-generation-id command to set Virtual Machine Generation ID counter. QMP command example: { "execute": "set-vm-generation-id", "arguments": { "guid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } HMP command example: set-vm-generation-id 324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87 Signed-off-by: Igor Mammedov Reviewed-by: Eric Blake --- v18: - use new GuidInfo type introduced in previous patch and fix argument to lowercase and corresponding example. Eric Blake - s/if (errp != NULL)/if (errp)/ Eric Blake --- hmp-commands.hx | 13 +++++++++++++ hmp.c | 12 ++++++++++++ hmp.h | 1 + hw/misc/vmgenid.c | 11 +++++++++++ qapi-schema.json | 11 +++++++++++ qmp-commands.hx | 22 ++++++++++++++++++++++ stubs/vmgenid.c | 6 ++++++ 7 files changed, 76 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index bb52e4d..d310707 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1756,5 +1756,18 @@ ETEXI }, STEXI +@item set-vm-generation-id @var{uuid} +Set Virtual Machine Generation ID counter to @var{guid} +ETEXI + + { + .name = "set-vm-generation-id", + .args_type = "guid:s", + .params = "guid", + .help = "Set Virtual Machine Generation ID counter", + .mhandler.cmd = hmp_set_vm_generation_id, + }, + +STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index aeb753d..c1f3a7a 100644 --- a/hmp.c +++ b/hmp.c @@ -2384,3 +2384,15 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) } qapi_free_GuidInfo(info); } + +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict) +{ + Error *errp = NULL; + const char *guid = qdict_get_str(qdict, "guid"); + + qmp_set_vm_generation_id(guid, &errp); + if (errp) { + hmp_handle_error(mon, &errp); + return; + } +} diff --git a/hmp.h b/hmp.h index 21c5132..cbf2045 100644 --- a/hmp.h +++ b/hmp.h @@ -132,5 +132,6 @@ 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); +void hmp_set_vm_generation_id(Monitor *mon, const QDict *qdict); #endif diff --git a/hw/misc/vmgenid.c b/hw/misc/vmgenid.c index 24c0a4e..4fa52bc 100644 --- a/hw/misc/vmgenid.c +++ b/hw/misc/vmgenid.c @@ -58,6 +58,17 @@ GuidInfo *qmp_query_vm_generation_id(Error **errp) return info; } +void qmp_set_vm_generation_id(const char *guid, Error **errp) +{ + Object *obj = find_vmgneid_dev(errp); + + if (!obj) { + return; + } + + object_property_set_str(obj, guid, VMGENID_GUID, errp); +} + static void vmgenid_update_guest(VmGenIdState *s) { Object *acpi_obj; diff --git a/qapi-schema.json b/qapi-schema.json index 3f99549..770d451 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4103,3 +4103,14 @@ # Since 2.6 ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } + +## +# @set-vm-generation-id +# +# Set Virtual Machine Generation ID +# +# @guid: new GUID to set as Virtual Machine Generation ID +# +# Since 2.6 +## +{ 'command': 'set-vm-generation-id', 'data': { 'guid': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 38e4e16..84738c7 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4814,3 +4814,25 @@ Example: -> { "execute": "query-vm-generation-id" } <- {"return": {"guid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"}} + +EQMP + + { + .name = "set-vm-generation-id", + .args_type = "guid:s", + .mhandler.cmd_new = qmp_marshal_set_vm_generation_id, + }, + +SQMP +Set Virtual Machine Generation ID counter +----- + +Arguments: + +- "guid": counter ID in GUID string representation (json-string)" + +Example: + +-> { "execute": "set-vm-generation-id" , + "arguments": { "guid": "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" } } +<- {"return": {}} diff --git a/stubs/vmgenid.c b/stubs/vmgenid.c index 1ff8cd2..6af0b73 100644 --- a/stubs/vmgenid.c +++ b/stubs/vmgenid.c @@ -5,3 +5,9 @@ GuidInfo *qmp_query_vm_generation_id(Error **errp) error_setg(errp, "this command is not currently supported"); return NULL; } + +void qmp_set_vm_generation_id(const char *guid, Error **errp) +{ + error_setg(errp, "this command is not currently supported"); + return; +}