qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 09/14] qdev: connect some links and move type to obj


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 09/14] qdev: connect some links and move type to object (v2)
Date: Tue, 1 May 2012 13:18:09 -0500

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

Signed-off-by: Anthony Liguori <address@hidden>
---
v1 -> v2
 - move sysbus to /machine/unattached (Andreas)
---
 hw/qdev.c    |   12 ++++++------
 qom/object.c |   12 ++++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 19d510e..87ff1a5 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -428,6 +428,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 != main_system_bus) {
         /* TODO: once all bus devices are qdevified,
            only reset handler for main_system_bus should be registered here. */
@@ -457,6 +458,9 @@ static void main_system_bus_create(void)
     /* assign main_system_bus before qbus_create_inplace()
      * in order to make "if (bus != main_system_bus)" work */
     main_system_bus = qbus_create(TYPE_SYSTEM_BUS, NULL, "main-system-bus");
+    object_property_add_child(container_get(qdev_get_machine(),
+                                            "/unattached"),
+                              "sysbus", OBJECT(main_system_bus), NULL);
 }
 
 void qbus_free(BusState *bus)
@@ -538,11 +542,6 @@ char *qdev_get_dev_path(DeviceState *dev)
     return NULL;
 }
 
-static char *qdev_get_type(Object *obj, Error **errp)
-{
-    return g_strdup(object_get_typename(obj));
-}
-
 /**
  * Legacy property handling
  */
@@ -658,7 +657,8 @@ static void device_initfn(Object *obj)
 
     qdev_add_properties(dev, dc->props);
 
-    object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL);
+    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/qom/object.c b/qom/object.c
index 94928c5..0268f2a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -256,12 +256,24 @@ static void object_interface_init(Object *obj, 
InterfaceImpl *iface)
     obj->interfaces = g_slist_prepend(obj->interfaces, iface_obj);
 }
 
+static char *object_get_typename_dup(Object *obj, Error **errp)
+{
+    return g_strdup(object_get_typename(obj));
+}
+
+static void object_base_init(Object *obj)
+{
+    object_property_add_str(obj, "type", object_get_typename_dup, NULL, NULL);
+}
+
 static void object_init_with_type(Object *obj, TypeImpl *ti)
 {
     int i;
 
     if (type_has_parent(ti)) {
         object_init_with_type(obj, type_get_parent(ti));
+    } else {
+        object_base_init(obj);
     }
 
     for (i = 0; i < ti->num_interfaces; i++) {
-- 
1.7.5.4




reply via email to

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