[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 5/8] qmp: add set-bootindex command
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v4 5/8] qmp: add set-bootindex command |
Date: |
Thu, 31 Jul 2014 17:47:30 +0800 |
From: Gonglei <address@hidden>
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":
"/address@hidden"}}
<- { "return": {} }
Signed-off-by: Gonglei <address@hidden>
Signed-off-by: Chenliang <address@hidden>
---
qapi-schema.json | 17 +++++++++++++++++
qmp-commands.hx | 25 +++++++++++++++++++++++++
qmp.c | 17 +++++++++++++++++
3 files changed, 59 insertions(+)
diff --git a/qapi-schema.json b/qapi-schema.json
index b11aad2..30bd6ad 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1704,6 +1704,23 @@
{ 'command': 'device_del', 'data': {'id': 'str'} }
##
+# @set-bootindex:
+#
+# set bootindex of a device
+#
+# @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..19cc3b8 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -330,6 +330,31 @@ 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":
"/address@hidden"}}
+<- { "return": {} }
+
+EQMP
{
.name = "send-key",
diff --git a/qmp.c b/qmp.c
index 0d2553a..e046200 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 (!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
- [Qemu-devel] [PATCH v4 0/8] modify boot order of guest, and take effect after rebooting, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 2/8] bootindex: add del_boot_device_path function, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 6/8] qemu-monitor: HMP set-bootindex wrapper, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 4/8] bootindex: delete bootindex when device is removed, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 3/8] fw_cfg: add fw_cfg_machine_reset function, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 1/8] bootindex: add modify_boot_device_path function, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 7/8] qmp: add query-bootindex command, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 8/8] qemu-monitor: add HMP "info-bootindex" command, arei.gonglei, 2014/07/31
- [Qemu-devel] [PATCH v4 5/8] qmp: add set-bootindex command,
arei.gonglei <=