diff mbox

[1/4] qdev: support to get a device firmware path directly

Message ID 1421673818-11224-2-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) Jan. 19, 2015, 1:23 p.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

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>
---
 hw/core/qdev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Paolo Bonzini Jan. 20, 2015, 4:10 p.m. UTC | #1
On 19/01/2015 14:23, arei.gonglei@huawei.com wrote:
> @@ -780,6 +788,12 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
>              d = bus_get_fw_dev_path(dev->parent_bus, dev);
>          }
>          if (d) {
> +            l += snprintf(p + l, size - l, "%s/", d);
> +            g_free(d);
> +        }
> +
> +        d = qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, dev);

This changes preexisting behavior.  If d was true, you wouldn't go down
the following else.  Now it does.

I was thinking it should be handled though the "suffix" argument to
add_boot_device_path, but that's harder now that the suffix has to be
passed to device_add_bootindex_property.

Perhaps you could call qdev_get_own_fw_dev_path_from_handler in
get_boot_devices_list, and convert non-NULL suffixes to implementations
of FWPathProvider?

Paolo

> +        if (d) {
>              l += snprintf(p + l, size - l, "%s", d);
>              g_free(d);
>          } else {
diff mbox

Patch

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 901f289..fb0a150 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -768,6 +768,14 @@  static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
     return d;
 }
 
+static 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)
 {
     int l = 0;
@@ -780,6 +788,12 @@  static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
             d = bus_get_fw_dev_path(dev->parent_bus, dev);
         }
         if (d) {
+            l += snprintf(p + l, size - l, "%s/", d);
+            g_free(d);
+        }
+
+        d = qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, dev);
+        if (d) {
             l += snprintf(p + l, size - l, "%s", d);
             g_free(d);
         } else {