@@ -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);
+}
@@ -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);
@@ -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.
@@ -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,
+ },
@@ -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);
+}