@samitouri / QOSamiQemu / commits / b5757f1967

hw/qdev: Prefix bus type in qdev_get_printable_name() device paths

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 <armbru@redhat.com> Signed-off-by: Alessandro Ratti <alessandro@0x65c.net> Reviewed-by: Markus Armbruster <armbru@redhat.com> Link: https://lore.kernel.org/r/20260321100405.1525059-3-alessandro@0x65c.net Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Alessandro Ratti committed Mar 21, 2026 at 11:04 UTC b5757f1967a3b425617992c691d57a60d01372bd
1 file changed +5 -3
hw/core/qdev.c
+5 -3
@@ -419,11 +419,13 @@ const char *qdev_get_printable_name(DeviceState *dev)
419 }
420 /*
421 * Fall back to a bus-specific device path, if the bus
422 - * provides one (e.g. PCI address "0000:00:04.0").
422 + * provides one (e.g. "PCI device 0000:00:04.0").
423 */
424 - const char *path = qdev_get_dev_path(dev);
424 + g_autofree char *path = qdev_get_dev_path(dev);
425 if (path) {
426 - return path;
426 + const char *bus_type = object_get_typename(OBJECT(dev->parent_bus));
427 + char *name = g_strdup_printf("%s device %s", bus_type, path);
428 + return name;
429 }
430
431 return object_get_canonical_path(OBJECT(dev));