From patchwork Mon Jul 7 09:11:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 367454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 596431400B9 for ; Mon, 7 Jul 2014 19:13:04 +1000 (EST) Received: from localhost ([::1]:48983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X44ys-0000l4-H6 for incoming@patchwork.ozlabs.org; Mon, 07 Jul 2014 05:13:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X44yL-000062-Nn for qemu-devel@nongnu.org; Mon, 07 Jul 2014 05:12:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X44yG-00004r-1q for qemu-devel@nongnu.org; Mon, 07 Jul 2014 05:12:29 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:22014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X44yF-0008VX-Bu for qemu-devel@nongnu.org; Mon, 07 Jul 2014 05:12:23 -0400 Received: from 172.24.2.119 (EHLO szxeml451-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ARI22307; Mon, 07 Jul 2014 17:11:32 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml451-hub.china.huawei.com (10.82.67.194) with Microsoft SMTP Server id 14.3.158.1; Mon, 7 Jul 2014 17:11:24 +0800 From: To: Date: Mon, 7 Jul 2014 17:11:00 +0800 Message-ID: <1404724261-9412-5-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1404724261-9412-1-git-send-email-arei.gonglei@huawei.com> References: <1404724261-9412-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A02020A.53BA6445.00F0,ss=1,re=0.000,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2011-05-27 18:58:46 X-Mirapoint-Loop-Id: 74600cab8c8f4b2a4db198676f053187 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: peter.maydell@linaro.org, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, armbru@redhat.com, kraxel@redhat.com, dmitry@daynix.com, akong@redhat.com, agraf@suse.de, Gonglei , lersek@redhat.com, marcel.a@redhat.com, somlo@cmu.edu, luonengjun@huawei.com, peter.huangpeng@huawei.com, alex.williamson@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, rth@twiddle.net, kwolf@redhat.com, peter.crosthwaite@xilinx.com, Chenliang , imammedo@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [RFC PATCH 4/5] bootindex: add qmp to set boot index when vm is running 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Chenliang Signed-off-by: Chenliang Signed-off-by: Gonglei --- hmp.c | 11 +++++++++++ hmp.h | 1 + qapi-schema.json | 16 ++++++++++++++++ qmp-commands.hx | 16 ++++++++++++++++ qmp.c | 14 ++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/hmp.c b/hmp.c index dc3d279..b2c6b6c 100644 --- a/hmp.c +++ b/hmp.c @@ -1713,3 +1713,14 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) monitor_printf(mon, "\n"); } + +void hmp_set_bootindex(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *id = qdict_get_str(qdict, "id"); + int64_t bootindex = qdict_get_int(qdict, "bootindex"); + char *suffix = qdict_get_try_str(qdict, "suffix"); + + qmp_set_bootindex(id, bootindex, suffix, &err); + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index 4fd3c4a..eb2641a 100644 --- a/hmp.h +++ b/hmp.h @@ -94,6 +94,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_info_memdev(Monitor *mon, const QDict *qdict); +void hmp_set_bootindex(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/qapi-schema.json b/qapi-schema.json index e7727a1..b414cae 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1694,6 +1694,22 @@ { 'command': 'device_del', 'data': {'id': 'str'} } ## +# @set_bootindex: +# +# set bootindex of a devcie +# +# @id: the name of the device +# @bootindex: the bootindex of the device +# @suffix: the suffix of the device +# +# Returns: Nothing on success +# If @id is not a valid device, DeviceNotFound +# +# Since: 2.1 +## +{ 'command': 'set_bootindex', 'data': {'id': 'str', 'bootindex': 'int', 'suffix': 'str'} } + +## # @DumpGuestMemoryFormat: # # An enumeration of guest-memory-dump's format. diff --git a/qmp-commands.hx b/qmp-commands.hx index e4a1c80..03645b6 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3661,3 +3661,19 @@ Example: { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0} ]} EQMP + +SQMP +@set-bootindex +-------------------- + +Set boot index of one device + +Example: +-> { "execute": "set-bootindex", "arguments": { "id": "ide0-0-1", "bootindex": 1, "suffix": "/disk@0"}} + +EQMP + { + .name = "set-bootindex", + .args_type = "id:s,bootindex:l,suffix:s?", + .mhandler.cmd_new = qmp_marshal_input_set_bootindex, + }, diff --git a/qmp.c b/qmp.c index dca6efb..5ac9401 100644 --- a/qmp.c +++ b/qmp.c @@ -659,3 +659,17 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp) return head; } + +void qmp_set_bootindex(const char *id, int64_t bootindex, + const char *suffix, Error **errp) +{ + DeviceState *dev; + + dev = qdev_find_recursive(sysbus_get_default(), id); + if (NULL == dev) { + error_set(errp, QERR_DEVICE_NOT_FOUND, id); + return; + } + + modify_boot_device_path(bootindex, dev, strlen(suffix) ? suffix : NULL); +}