qdev: Push "type" property up to Object
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 2 Apr 2012 15:33:51 +0000 (17:33 +0200)
committerAndreas Färber <afaerber@suse.de>
Mon, 18 Jun 2012 13:14:37 +0000 (15:14 +0200)
Now that Object is a type, add an instance_init function and push
the "type" property from qdev to there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
hw/qdev.c
qom/object.c

index 6a8f6bda2bc3970b376b8cf88041fe96ae12f942..a9a9f891da0b1e206553695c88767735fb6fe7ab 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -515,11 +515,6 @@ char* qdev_get_fw_dev_path(DeviceState *dev)
     return strdup(path);
 }
 
-static char *qdev_get_type(Object *obj, Error **errp)
-{
-    return g_strdup(object_get_typename(obj));
-}
-
 /**
  * Legacy property handling
  */
@@ -638,7 +633,6 @@ static void device_initfn(Object *obj)
         qdev_property_add_static(dev, prop, NULL);
     }
 
-    object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL);
     qdev_prop_set_defaults(dev, qdev_get_props(dev));
 }
 
index cec2d406b8d1ef967b72646b6cda56baec46c911..d5c6ff74710e5bea8a969fcaaeca58061c85f571 100644 (file)
@@ -1231,6 +1231,16 @@ void object_property_add_str(Object *obj, const char *name,
                         prop, errp);
 }
 
+static char *qdev_get_type(Object *obj, Error **errp)
+{
+    return g_strdup(object_get_typename(obj));
+}
+
+static void object_instance_init(Object *obj)
+{
+    object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
+}
+
 static void register_types(void)
 {
     static TypeInfo interface_info = {
@@ -1242,6 +1252,7 @@ static void register_types(void)
     static TypeInfo object_info = {
         .name = TYPE_OBJECT,
         .instance_size = sizeof(Object),
+        .instance_init = object_instance_init,
         .abstract = true,
     };