diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-12-08 13:35:09 +0200 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-12-11 21:32:48 +0000 |
commit | 962630f207a33b7de4316022884b5241e05491cd (patch) | |
tree | 456f98659094302366c6caa495b2511cd69b647b /vl.c | |
parent | 4cab946a4adc3094a846dd3c7ea104abe7bdc5f1 (diff) | |
download | qemu-962630f207a33b7de4316022884b5241e05491cd.zip qemu-962630f207a33b7de4316022884b5241e05491cd.tar.gz qemu-962630f207a33b7de4316022884b5241e05491cd.tar.bz2 |
Pass boot device list to firmware.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -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]; |