From: Jan Kiszka <jan.kis...@siemens.com> We allow to address a bus only using its local name. This is ambiguous but unfortunately so handy that people (specifically libvirt) will likely complain if bus=pci.0 needs to be replaced with bus=/i440FX-pcihost/pci.0 all over the place. So keep this for now but drop at least support for starting a qtree walks with an abbreviated bus name.
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- hw/qdev.c | 22 +++++++--------------- 1 files changed, 7 insertions(+), 15 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 7c4f039..c272c51 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -564,25 +564,17 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem) static BusState *qbus_find(const char *path) { DeviceState *dev; - BusState *bus; + BusState *bus = main_system_bus; char elem[128]; - int pos, len; + int len, pos = 0; - /* find start element */ - if (path[0] == '/') { - bus = main_system_bus; - pos = 0; - } else { - if (sscanf(path, "%127[^/]%n", elem, &len) != 1) { - assert(!path[0]); - elem[0] = len = 0; - } - bus = qbus_find_recursive(main_system_bus, elem, NULL); + /* search for bus name recursively if path is not absolute */ + if (path[0] != '/') { + bus = qbus_find_recursive(bus, path, NULL); if (!bus) { - qerror_report(QERR_BUS_NOT_FOUND, elem); - return NULL; + qerror_report(QERR_BUS_NOT_FOUND, path); } - pos = len; + return bus; } for (;;) { -- 1.6.0.2