提交 0be63901 编写于 作者: G Gonglei 提交者: Paolo Bonzini

qdev: support to get a device firmware path directly

commit 6b1566cb (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: NGonglei <arei.gonglei@huawei.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 edecf5ec
...@@ -210,7 +210,9 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) ...@@ -210,7 +210,9 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
char *list = NULL; char *list = NULL;
QTAILQ_FOREACH(i, &fw_boot_order, link) { QTAILQ_FOREACH(i, &fw_boot_order, link) {
char *devpath = NULL, *bootpath; char *devpath = NULL, *suffix = NULL;
char *bootpath;
char *d;
size_t len; size_t len;
if (i->dev) { if (i->dev) {
...@@ -218,21 +220,22 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) ...@@ -218,21 +220,22 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
assert(devpath); assert(devpath);
} }
if (i->suffix && !ignore_suffixes && devpath) { if (!ignore_suffixes) {
size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1; d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, i->dev);
if (d) {
bootpath = g_malloc(bootpathlen); assert(!i->suffix);
snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix); suffix = d;
g_free(devpath); } else {
} else if (devpath) { suffix = g_strdup(i->suffix);
bootpath = devpath; }
} else if (!ignore_suffixes) {
assert(i->suffix);
bootpath = g_strdup(i->suffix);
} else {
bootpath = g_strdup("");
} }
bootpath = g_strdup_printf("%s%s",
devpath ? devpath : "",
suffix ? suffix : "");
g_free(devpath);
g_free(suffix);
if (total) { if (total) {
list[total-1] = '\n'; list[total-1] = '\n';
} }
......
...@@ -818,6 +818,13 @@ static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev) ...@@ -818,6 +818,13 @@ static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
return d; return d;
} }
char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
{
Object *obj = OBJECT(dev);
return fw_path_provider_try_get_dev_path(obj, bus, dev);
}
static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size) static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
{ {
int l = 0; int l = 0;
......
...@@ -342,6 +342,7 @@ void qbus_reset_all_fn(void *opaque); ...@@ -342,6 +342,7 @@ void qbus_reset_all_fn(void *opaque);
BusState *sysbus_get_default(void); BusState *sysbus_get_default(void);
char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_fw_dev_path(DeviceState *dev);
char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
/** /**
* @qdev_machine_init * @qdev_machine_init
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册