提交 7dc5af55 编写于 作者: D Dominik Dingel 提交者: Alexander Graf

Common: Add quick access to first boot device

Instead of manually parsing the boot_list as character stream,
we can access the nth boot device, specified by the position in the
boot order.
Signed-off-by: NDominik Dingel <dingel@linux.vnet.ibm.com>
Reviewed-by: NAnthony Liguori <aliguori@us.ibm.com>
Signed-off-by: NAlexander Graf <agraf@suse.de>
上级 ba747cc8
......@@ -181,6 +181,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
const char *suffix);
char *get_boot_devices_list(size_t *size);
DeviceState *get_boot_device(uint32_t position);
bool usb_enabled(bool default_usb);
extern QemuOptsList qemu_drive_opts;
......
......@@ -1222,6 +1222,24 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
}
DeviceState *get_boot_device(uint32_t position)
{
uint32_t counter = 0;
FWBootEntry *i = NULL;
DeviceState *res = NULL;
if (!QTAILQ_EMPTY(&fw_boot_order)) {
QTAILQ_FOREACH(i, &fw_boot_order, link) {
if (counter == position) {
res = i->dev;
break;
}
counter++;
}
}
return res;
}
/*
* This function returns null terminated string that consist of new line
* separated device paths.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册