Received: from eggs.gnu.org ([2001:4830:134:3::10]:42000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsL-000149-T2 for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAtsC-0003e1-Hi for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:29 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:45839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsB-0003cv-Rv for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:20 -0400 From: Date: Sat, 26 Jul 2014 12:45:31 +0800 Message-ID: <1406349933-17536-6-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> References: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3 5/7] qmp: add set-bootindex command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, Gonglei , aliguori@amazon.com, gaowanlong@cn.fujitsu.com, ehabkost@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de From: Gonglei Adds "set-bootindex id=xx,bootindex=xx,suffix=xx" QMP command. Example QMP command: -> { "execute": "set-bootindex", "arguments": { "id": "ide0-0-1", "bootindex": 1, "suffix": "/disk@0"}} <- { "return": {} } Signed-off-by: Gonglei Signed-off-by: Chenliang --- qapi-schema.json | 16 ++++++++++++++++ qmp-commands.hx | 24 ++++++++++++++++++++++++ qmp.c | 17 +++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index b11aad2..a9ef0be 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1704,6 +1704,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: #optional a suffix of the device +# +# Returns: Nothing on success +# If @id is not a valid device, DeviceNotFound +# +# Since: 2.2 +## +{ '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 4be4765..2c89a97 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -330,6 +330,30 @@ Example: <- { "return": {} } EQMP + { + .name = "set-bootindex", + .args_type = "id:s,bootindex:l,suffix:s?", + .mhandler.cmd_new = qmp_marshal_input_set_bootindex, + }, + +SQMP +set-bootindex +-------------------- + +Set bootindex of a device + +Arguments: + +- "id": the device's ID (json-string) +- "bootindex": the device's bootindex (json-int) +- "suffix": the device's suffix in global boot list (json-string, optional) + +Example: + +-> { "execute": "set-bootindex", "arguments": { "id": "ide0-0-1", "bootindex": 1, "suffix": "/disk@0"}} +<- { "return": {} } + +EQMP { .name = "send-key", diff --git a/qmp.c b/qmp.c index 0d2553a..f2c3c14 100644 --- a/qmp.c +++ b/qmp.c @@ -684,6 +684,23 @@ void qmp_object_del(const char *id, Error **errp) object_unparent(obj); } +void qmp_set_bootindex(const char *id, int64_t bootindex, + bool has_suffix, 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; + } + if (has_suffix) { + modify_boot_device_path(bootindex, dev, suffix); + } else { + modify_boot_device_path(bootindex, dev, NULL); + } +} + MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) { MemoryDeviceInfoList *head = NULL; -- 1.7.12.4