Patchwork [19/21] qdev: connect busses with their parent devices

login
register
mail settings
Submitter Paolo Bonzini
Date May 2, 2012, 11:31 a.m.
Message ID <1335958273-769-20-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/156448/
State New
Headers show

Comments

Paolo Bonzini - May 2, 2012, 11:31 a.m.
From: Anthony Liguori <aliguori@us.ibm.com>

This makes sysbus part of the root hierarchy and all busses children of their
respective parent DeviceState.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev.c   |    4 ++++
 hw/sysbus.c |    3 +++
 2 files changed, 7 insertions(+)
Andreas Färber - May 24, 2012, 4:49 p.m.
Am 02.05.2012 13:31, schrieb Paolo Bonzini:
> From: Anthony Liguori <aliguori@us.ibm.com>
> 
> This makes sysbus part of the root hierarchy and all busses children of their
> respective parent DeviceState.
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks, applied to qom-next:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-next

Andreas

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index b97ba00..decbcb1 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -404,6 +404,7 @@  static void do_qbus_create_inplace(BusState *bus, const char *typename,
     if (parent) {
         QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
         parent->num_child_bus++;
+        object_property_add_child(OBJECT(parent), bus->name, OBJECT(bus), NULL);
     } else if (bus != sysbus_get_default()) {
         /* TODO: once all bus devices are qdevified,
            only reset handler for main_system_bus should be registered here. */
@@ -651,6 +652,9 @@  static void device_initfn(Object *obj)
         class = object_class_get_parent(class);
     } while (class != object_class_by_name(TYPE_DEVICE));
     qdev_prop_set_globals(dev);
+
+    object_property_add_link(OBJECT(dev), "parent_bus", TYPE_BUS,
+                             (Object **)&dev->parent_bus, NULL);
 }
 
 /* Unlink device from bus and free the structure.  */
diff --git a/hw/sysbus.c b/hw/sysbus.c
index f10a7d1..417fbd4 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -275,6 +275,9 @@  static void main_system_bus_create(void)
     qbus_create_inplace(main_system_bus, TYPE_SYSTEM_BUS, NULL,
                         "main-system-bus");
     main_system_bus->qdev_allocated = 1;
+    object_property_add_child(container_get(qdev_get_machine(),
+                                            "/unattached"),
+                              "sysbus", OBJECT(main_system_bus), NULL);
 }
 
 BusState *sysbus_get_default(void)