qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over use


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
Date: Sun, 23 May 2010 12:59:17 +0200

From: Jan Kiszka <address@hidden>

As the user may specify ambiguous device IDs, let's search for their
official names first before considering the user-supplied identifiers.

Signed-off-by: Jan Kiszka <address@hidden>
---
 docs/qdev-device-use.txt |    4 +++-
 hw/qdev.c                |   18 +++++++++---------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index 74d4960..0160191 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -25,7 +25,9 @@ omitted in the path.  Example: /i440FX-pcihost/PIIX3 
abbreviates
 /i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings.
 
 Existing devices can be addressed either via a unique ID if it was
-assigned during creation or via the device tree path:
+assigned during creation or via the device tree path. In conflicts,
+the latter has precedence. A device tree path has the following
+structure:
 
 /full_bus_address/driver_name[.instance_number]
     or
diff --git a/hw/qdev.c b/hw/qdev.c
index 6b4a629..eeadf4a 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -535,16 +535,10 @@ static DeviceState *qbus_find_dev(BusState *bus, const 
char *elem)
 
     /*
      * try to match in order:
-     *   (1) instance id, if present
-     *   (2) driver name [.instance]
-     *   (3) driver alias [.instance], if present
+     *   (1) driver name [.instance]
+     *   (2) driver alias [.instance], if present
+     *   (3) instance id, if present
      */
-    QLIST_FOREACH(dev, &bus->children, sibling) {
-        if (dev->id  &&  strcmp(dev->id, elem) == 0) {
-            return dev;
-        }
-    }
-
     if (sscanf(elem, "%127[^.].%u", buf, &instance) == 2) {
         elem = buf;
     } else {
@@ -565,6 +559,12 @@ static DeviceState *qbus_find_dev(BusState *bus, const 
char *elem)
             return dev;
         }
     }
+
+    QLIST_FOREACH(dev, &bus->children, sibling) {
+        if (dev->id && strcmp(dev->id, elem) == 0) {
+            return dev;
+        }
+    }
     return NULL;
 }
 
-- 
1.6.0.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]