@@ -20,6 +20,10 @@ bus named pci.0. To put a FOO device into its slot 4, use -device
FOO,bus=/i440FX-pcihost/pci.0,addr=4. The abbreviated form bus=pci.0
also works as long as the bus name is unique.
+Furthermore, if a device only hosts a single bus, the bus name can be
+omitted in the path. Example: /i440FX-pcihost/PIIX3 abbreviates
+/i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings.
+
Note: the USB device address can't be controlled at this time.
=== Block Devices ===
@@ -557,7 +557,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)
static BusState *qbus_find(const char *path)
{
- DeviceState *dev;
+ DeviceState *dev, *next_dev;
BusState *bus;
char elem[128];
int pos, len;
@@ -603,6 +603,7 @@ static BusState *qbus_find(const char *path)
return NULL;
}
+search_dev_bus:
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
@@ -633,6 +634,15 @@ static BusState *qbus_find(const char *path)
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
+ if (dev->num_child_bus == 1) {
+ /* Last element might have been a short-cut to a device on
+ * the single child bus of the parent device. */
+ next_dev = qbus_find_dev(QTAILQ_FIRST(&dev->child_bus), elem);
+ if (next_dev) {
+ dev = next_dev;
+ goto search_dev_bus;
+ }
+ }
qerror_report(QERR_BUS_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);