Pass boot device list to firmware.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Gleb Natapov 2010-12-08 13:35:09 +02:00 committed by Blue Swirl
parent 4cab946a4a
commit 962630f207
3 changed files with 63 additions and 0 deletions

48
vl.c
View file

@ -736,6 +736,54 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
}
/*
* This function returns null terminated string that consist of new line
* separated device pathes.
*
* memory pointed by "size" is assigned total length of the array in bytes
*
*/
char *get_boot_devices_list(uint32_t *size)
{
FWBootEntry *i;
uint32_t total = 0;
char *list = NULL;
QTAILQ_FOREACH(i, &fw_boot_order, link) {
char *devpath = NULL, *bootpath;
int len;
if (i->dev) {
devpath = qdev_get_fw_dev_path(i->dev);
assert(devpath);
}
if (i->suffix && devpath) {
bootpath = qemu_malloc(strlen(devpath) + strlen(i->suffix) + 1);
sprintf(bootpath, "%s%s", devpath, i->suffix);
qemu_free(devpath);
} else if (devpath) {
bootpath = devpath;
} else {
bootpath = strdup(i->suffix);
assert(bootpath);
}
if (total) {
list[total-1] = '\n';
}
len = strlen(bootpath) + 1;
list = qemu_realloc(list, total + len);
memcpy(&list[total], bootpath, len);
total += len;
qemu_free(bootpath);
}
*size = total;
return list;
}
static void numa_add(const char *optarg)
{
char option[128];