]> git.proxmox.com Git - qemu.git/commitdiff
qom: introduce root device
authorAnthony Liguori <aliguori@us.ibm.com>
Mon, 12 Dec 2011 20:29:28 +0000 (14:29 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 15 Dec 2011 15:20:47 +0000 (09:20 -0600)
This is based on Jan's suggestion for how to do unique naming.  The root device
is the root of composition.  All devices are reachable via child<> links from
this device.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Makefile.objs
hw/container.c [new file with mode: 0644]
hw/qdev.c
hw/qdev.h

index 281b698c3c43ee999ddf8954708118548dee0c47..f753d838ffda5b2de3495725efa38a27d5d61c14 100644 (file)
@@ -278,7 +278,7 @@ hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o
 hw-obj-$(CONFIG_ESP) += esp.o
 
 hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
-hw-obj-y += qdev-addr.o
+hw-obj-y += qdev-addr.o container.o
 
 # VGA
 hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
diff --git a/hw/container.c b/hw/container.c
new file mode 100644 (file)
index 0000000..9cbf399
--- /dev/null
@@ -0,0 +1,20 @@
+#include "sysbus.h"
+
+static int container_initfn(SysBusDevice *dev)
+{
+    return 0;
+}
+
+static SysBusDeviceInfo container_info = {
+    .init = container_initfn,
+    .qdev.name = "container",
+    .qdev.size = sizeof(SysBusDevice),
+    .qdev.no_user = 1,
+};
+
+static void container_init(void)
+{
+    sysbus_register_withprop(&container_info);
+}
+
+device_init(container_init);
index 6f77af91ef74ca40955d3b673a4edb1515b5262c..bb0b9f7d6a8d56fdf7bded154facebc953da189a 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -1161,3 +1161,15 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop,
 
     g_free(type);
 }
+
+DeviceState *qdev_get_root(void)
+{
+    static DeviceState *qdev_root;
+
+    if (!qdev_root) {
+        qdev_root = qdev_create(NULL, "container");
+        qdev_init_nofail(qdev_root);
+    }
+
+    return qdev_root;
+}
index 3b629d4fbd4acf08aa0c65f11aed7f16fd3ffbc0..52aadd2f1f612aaeb2405a8f8fe47f5c4409a240 100644 (file)
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -482,4 +482,12 @@ const char *qdev_property_get_type(DeviceState *dev, const char *name,
  */
 void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp);
 
+/**
+ * @qdev_get_root - returns the root device of the composition tree
+ *
+ * Returns:
+ *   The root of the composition tree.
+ */
+DeviceState *qdev_get_root(void);
+
 #endif