[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 4/5] bootindex: add qmp to set boot index when v
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [RFC PATCH 4/5] bootindex: add qmp to set boot index when vm is running |
Date: |
Mon, 7 Jul 2014 17:11:00 +0800 |
From: Chenliang <address@hidden>
Signed-off-by: Chenliang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
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
address@hidden
+--------------------
+
+Set boot index of one device
+
+Example:
+-> { "execute": "set-bootindex", "arguments": { "id": "ide0-0-1", "bootindex":
1, "suffix": "/address@hidden"}}
+
+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);
+}
--
1.7.12.4
[Qemu-devel] [RFC PATCH 2/5] bootindex: reset bootindex when vm reset, arei.gonglei, 2014/07/07
[Qemu-devel] [RFC PATCH 3/5] bootindex: delete boot index when device is removed, arei.gonglei, 2014/07/07
[Qemu-devel] [RFC PATCH 5/5] bootindex: fix memory leak when set boot index, arei.gonglei, 2014/07/07
Re: [Qemu-devel] [RFC PATCH 0/5] modify boot order when vm is running, Michael S. Tsirkin, 2014/07/07