@samitouri / QOSamiQemu / commits / 7f2cef7f55

hw/qdev: Document qdev_get_dev_path()

We don't document qdev_get_dev_path() at all; in particular we do not mention that it returns a string that the caller must free. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260307155046.3940197-2-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Peter Maydell committed Mar 7, 2026 at 15:50 UTC 7f2cef7f559601f20b675a8532ec96d0e7354061
1 file changed +23
include/hw/core/qdev.h
+23
@@ -324,6 +324,10 @@ struct BusClass {
324
325 /* FIXME first arg should be BusState */
326 void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
327 + /*
328 + * Return a newly allocated string containing the path of the
329 + * device on this bus.
330 + */
331 char *(*get_dev_path)(DeviceState *dev);
332
333 /*
@@ -1060,6 +1064,25 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp);
1064
1065 extern bool qdev_hot_removed;
1066
1067 +/**
1068 + * qdev_get_dev_path(): Return the path of a device on its bus
1069 + * @dev: device to get the path of
1070 + *
1071 + * Returns: A newly allocated string containing the dev path of
1072 + * @dev. The caller must free this with g_free().
1073 + * The format of the string depends on the bus; for instance a
1074 + * PCI device's path will be in the format::
1075 + *
1076 + * Domain:00:Slot.Function:Slot.Function....:Slot.Function
1077 + *
1078 + * and a SCSI device's path will be::
1079 + *
1080 + * channel:ID:LUN
1081 + *
1082 + * (possibly prefixed by the path of the SCSI controller).
1083 + *
1084 + * If @dev is NULL or not on a bus, returns NULL.
1085 + */
1086 char *qdev_get_dev_path(DeviceState *dev);
1087 const char *qdev_get_printable_name(DeviceState *dev);
1088