diff options
author | Gonglei <arei.gonglei@huawei.com> | 2015-01-29 15:08:51 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-02-11 21:47:51 +0100 |
commit | 0be63901d2a33a6ed25caa5df3f530df75338f6a (patch) | |
tree | 646c8bc5c70c485cd6db1ab64f295c6875f6621c /bootdevice.c | |
parent | edecf5eced082cb45e213cb4e791b2fcf9f867c1 (diff) | |
download | qemu-0be63901d2a33a6ed25caa5df3f530df75338f6a.tar.gz qemu-0be63901d2a33a6ed25caa5df3f530df75338f6a.tar.bz2 qemu-0be63901d2a33a6ed25caa5df3f530df75338f6a.zip |
qdev: support to get a device firmware path directly
commit 6b1566c (qdev: Introduce FWPathProvider interface) did a
good job for supproting to get firmware path on some different
architectures.
Moreover further more, we can use the interface to get firmware
path name for a device which isn't attached a specific bus,
such as virtio-bus, scsi-bus etc.
When the device (such as vhost-scsi) realize the TYPE_FW_PATH_PROVIDER
interface, we should introduce a new function to get the correct firmware
path name for it.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'bootdevice.c')
-rw-r--r-- | bootdevice.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/bootdevice.c b/bootdevice.c index 5914417027..c3a010c094 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -210,7 +210,9 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) char *list = NULL; QTAILQ_FOREACH(i, &fw_boot_order, link) { - char *devpath = NULL, *bootpath; + char *devpath = NULL, *suffix = NULL; + char *bootpath; + char *d; size_t len; if (i->dev) { @@ -218,21 +220,22 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) assert(devpath); } - if (i->suffix && !ignore_suffixes && devpath) { - size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1; - - bootpath = g_malloc(bootpathlen); - snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix); - g_free(devpath); - } else if (devpath) { - bootpath = devpath; - } else if (!ignore_suffixes) { - assert(i->suffix); - bootpath = g_strdup(i->suffix); - } else { - bootpath = g_strdup(""); + if (!ignore_suffixes) { + d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, i->dev); + if (d) { + assert(!i->suffix); + suffix = d; + } else { + suffix = g_strdup(i->suffix); + } } + bootpath = g_strdup_printf("%s%s", + devpath ? devpath : "", + suffix ? suffix : ""); + g_free(devpath); + g_free(suffix); + if (total) { list[total-1] = '\n'; } |