[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 02/15] qdev: Fix scanning across single-bus devic
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v2 02/15] qdev: Fix scanning across single-bus devices |
Date: |
Sat, 22 May 2010 10:17:59 +0200 |
From: Jan Kiszka <address@hidden>
As long as we allow /dev.1 as shortcut for /dev1/bus1, we also have to
make sure that /dev1/dev2 works for /dev1/bus1/dev2/bus2 - as long as
there is only one child bus per device.
Signed-off-by: Jan Kiszka <address@hidden>
---
docs/qdev-device-use.txt | 4 ++++
hw/qdev.c | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index f252c8e..9ac1fa1 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -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 ===
diff --git a/hw/qdev.c b/hw/qdev.c
index aa2ce01..2e50531 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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);
--
1.6.0.2