]> git.proxmox.com Git - mirror_qemu.git/commitdiff
container: make a decendent of Object
authorAnthony Liguori <aliguori@us.ibm.com>
Fri, 23 Dec 2011 15:08:05 +0000 (09:08 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 3 Feb 2012 16:41:08 +0000 (10:41 -0600)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Add license (Paolo)

Makefile.objs
hw/container.c [deleted file]
hw/qdev-monitor.c
qom/Makefile
qom/container.c [new file with mode: 0644]
qom/object.c

index 1a263499a80cf45c368ef92eafaaec5799886615..ec35320ff5c49f714d638597562ff78e94fae6c6 100644 (file)
@@ -286,7 +286,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 container.o
+hw-obj-y += qdev-addr.o
 
 # VGA
 hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
diff --git a/hw/container.c b/hw/container.c
deleted file mode 100644 (file)
index 1e97031..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "sysbus.h"
-
-static int container_initfn(SysBusDevice *dev)
-{
-    return 0;
-}
-
-static void container_class_init(ObjectClass *klass, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
-
-    k->init = container_initfn;
-    dc->no_user = 1;
-}
-
-static TypeInfo container_info = {
-    .name          = "container",
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(SysBusDevice),
-    .class_init    = container_class_init,
-};
-
-static void container_init(void)
-{
-    type_register_static(&container_info);
-}
-
-device_init(container_init);
index 56a34587b8c7121a26ac837d3cdbda198f8ea874..135c2bf23705e421ad98dcd89515a7eb09a7169f 100644 (file)
@@ -177,30 +177,28 @@ int qdev_device_help(QemuOpts *opts)
 
 static Object *qdev_get_peripheral(void)
 {
-    static DeviceState *dev;
+    static Object *dev;
 
     if (dev == NULL) {
-        dev = qdev_create(NULL, "container");
+        dev = object_new("container");
         object_property_add_child(object_get_root(), "peripheral",
                                   OBJECT(dev), NULL);
-        qdev_init_nofail(dev);
     }
 
-    return OBJECT(dev);
+    return dev;
 }
 
 static Object *qdev_get_peripheral_anon(void)
 {
-    static DeviceState *dev;
+    static Object *dev;
 
     if (dev == NULL) {
-        dev = qdev_create(NULL, "container");
+        dev = object_new("container");
         object_property_add_child(object_get_root(), "peripheral-anon",
                                   OBJECT(dev), NULL);
-        qdev_init_nofail(dev);
     }
 
-    return OBJECT(dev);
+    return dev;
 }
 
 static void qbus_list_bus(DeviceState *dev)
index a3c789207ef00dc97b55f9d6fb85438eafd0d07d..f33f0be8c9db6ddbf232f0e3cb206e82c3dbe4f6 100644 (file)
@@ -1 +1 @@
-qom-y = object.o
+qom-y = object.o container.o
diff --git a/qom/container.c b/qom/container.c
new file mode 100644 (file)
index 0000000..946cbff
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Device Container
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/object.h"
+#include "module.h"
+
+static TypeInfo container_info = {
+    .name          = "container",
+    .instance_size = sizeof(Object),
+    .parent        = TYPE_OBJECT,
+};
+
+static void container_init(void)
+{
+    type_register_static(&container_info);
+}
+
+device_init(container_init);
index 33217b820fc6f2cb1970d8635f11f25b92e43d25..426194484961eb663d23267fa3832070143bc21d 100644 (file)
@@ -662,14 +662,13 @@ const char *object_property_get_type(Object *obj, const char *name, Error **errp
 
 Object *object_get_root(void)
 {
-    static DeviceState *object_root;
+    static Object *root;
 
-    if (!object_root) {
-        object_root = qdev_create(NULL, "container");
-        qdev_init_nofail(object_root);
+    if (!root) {
+        root = object_new("container");
     }
 
-    return OBJECT(object_root);
+    return root;
 }
 
 static void object_get_child_property(Object *obj, Visitor *v, void *opaque,