qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC PATCH v2 11/13] qdev: introduce automatic creation of


From: Paolo Bonzini
Subject: [Qemu-devel] [RFC PATCH v2 11/13] qdev: introduce automatic creation of buses
Date: Mon, 6 Jun 2011 18:04:20 +0200

When a logical unit is hung directly below an HBA, we want to introduce
the "missing levels" to avoid duplicating generic target code across
all devices.  To do this, I introduce a callback in qdev that is given
the bus specified by the user, and returns the actual bus to use.

Signed-off-by: Paolo Bonzini <address@hidden>
Cc: Markus Armbruster <address@hidden>
---
 hw/qdev.c |   13 +++++++++++++
 hw/qdev.h |    3 +++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 9519f5d..847bcda 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -204,6 +204,17 @@ int qdev_device_help(QemuOpts *opts)
     return 1;
 }
 
+static BusState *qbus_realize_topology(BusState *bus, DeviceInfo *info,
+                                      QemuOpts *opts)
+{
+    BusState *old = NULL;
+    while (old != bus && bus->info->realize_topology) {
+        old = bus;
+        bus = bus->info->realize_topology(bus, info, opts);
+    }
+    return bus;
+}
+
 DeviceState *qdev_device_add(QemuOpts *opts)
 {
     const char *driver, *path, *id;
@@ -245,6 +256,8 @@ DeviceState *qdev_device_add(QemuOpts *opts)
             return NULL;
         }
     }
+
+    bus = qbus_realize_topology(bus, info, opts);
     if (qdev_hotplug && !bus->allow_hotplug) {
         qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
         return NULL;
diff --git a/hw/qdev.h b/hw/qdev.h
index 8a13ec9..ae18406 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -56,6 +56,8 @@ typedef char *(*bus_get_dev_path)(DeviceState *dev);
  */
 typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
 typedef int (qbus_resetfn)(BusState *bus);
+typedef BusState *(*bus_realize_topology)(BusState *bus, DeviceInfo *dev,
+                                          QemuOpts *opts);
 
 struct BusInfo {
     const char *name;
@@ -63,6 +65,7 @@ struct BusInfo {
     bus_dev_printfn print_dev;
     bus_get_dev_path get_dev_path;
     bus_get_fw_dev_path get_fw_dev_path;
+    bus_realize_topology realize_topology;
     qbus_resetfn *reset;
     Property *props;
 };
-- 
1.7.4.4





reply via email to

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