Raw get_dev_path() output (e.g. "0000:00:04.0", "/1") is ambiguous
without knowing which bus produced it. Prefix the path with the bus
type name so error messages become self-describing.

Examples:
  - PCIE device 0000:00:04.0
  - virtio-pci-bus device 0000:00:03.0

Suggested-by: Markus Armbruster <[email protected]>
Signed-off-by: Alessandro Ratti <[email protected]>
---
 hw/core/qdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index c44616b4b8..904e710f8e 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -418,11 +418,13 @@ const char *qdev_get_printable_name(DeviceState *dev)
     }
     /*
      * Fall back to a bus-specific device path, if the bus
-     * provides one (e.g. PCI address "0000:00:04.0").
+     * provides one (e.g. "PCI device 0000:00:04.0").
      */
-    const char *path = qdev_get_dev_path(dev);
+    g_autofree char *path = qdev_get_dev_path(dev);
     if (path) {
-        return path;
+        const char *bus_type = object_get_typename(OBJECT(dev->parent_bus));
+        char *name = g_strdup_printf("%s device %s", bus_type, path);
+        return name;
     }
 
     return object_get_canonical_path(OBJECT(dev));
-- 
2.53.0


Reply via email to