@@ -1704,6 +1704,33 @@
{ 'command': 'device_del', 'data': {'id': 'str'} }
##
+# @BootindexInfo:
+#
+# Information about devcie's bootindex.
+#
+# @id: the name of a device owning the bootindex
+#
+# @bootindex: the bootindex number
+#
+# @suffix: the suffix a device's bootindex
+#
+# Since: 2.2
+##
+{ 'type': 'BootindexInfo',
+ 'data': {'id': 'str', 'bootindex': 'int', 'suffix': 'str'} }
+
+##
+# @query-bootindex:
+#
+# Returns information about bootindex
+#
+# Returns: a list of @BootindexInfo for existing device
+#
+# Since: 2.2
+##
+{ 'command': 'query-bootindex', 'returns': ['BootindexInfo'] }
+
+##
# @set-bootindex:
#
# set bootindex of a device
@@ -1715,6 +1742,8 @@
# Returns: Nothing on success
# If @id is not a valid device, DeviceNotFound
#
+# Note: suffix can be gotten by query-bootindex command
+#
# Since: 2.2
##
{ 'command': 'set-bootindex',
@@ -337,6 +337,47 @@ EQMP
},
SQMP
+query-bootindex
+---------------
+
+Show VM bootindex information.
+
+The returned value is a json-array of all device configured
+bootindex property. Each bootindex is represented by a json-object.
+
+The bootindex json-object contains the following:
+
+- "id": the name of a device owning the bootindex (json-string)
+- "bootindex": the bootindex number (json-int)
+- "suffix": the suffix a device's bootindex (json-string)
+
+Example:
+
+-> { "execute": "query-bootindex" }
+<- {
+ "return":[
+ {
+ "id":"ide0-0-0",
+ "bootindex":1,
+ "suffix":"/disk@0"
+ },
+ {
+ "id":"nic1",
+ "bootindex":2,
+ "suffix":"/ethernet-phy@0"
+ }
+ ]
+ }
+
+EQMP
+
+ {
+ .name = "query-bootindex",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_bootindex,
+ },
+
+SQMP
set-bootindex
-------------
@@ -1219,6 +1219,37 @@ static void restore_boot_order(void *opaque)
g_free(normal_boot_order);
}
+BootindexInfoList *qmp_query_bootindex(Error **errp)
+{
+ BootindexInfoList *booindex_list = NULL;
+ BootindexInfoList *info;
+ FWBootEntry *i;
+
+ QTAILQ_FOREACH(i, &fw_boot_order, link) {
+ info = g_new0(BootindexInfoList, 1);
+ info->value = g_new0(BootindexInfo, 1);
+
+ if (i->dev->id) {
+ info->value->id = g_strdup(i->dev->id);
+ } else {
+ /* For virtio devices, we should get id from they parent */
+ if (i->dev->parent_bus) {
+ DeviceState *dev = i->dev->parent_bus->parent;
+ info->value->id = g_strdup(dev->id);
+ } else {
+ info->value->id = g_strdup("");
+ }
+ }
+ info->value->bootindex = i->bootindex;
+ info->value->suffix = g_strdup(i->suffix);
+
+ info->next = booindex_list;
+ booindex_list = info;
+ }
+
+ return booindex_list;
+}
+
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix)
{