aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2013-07-10 17:08:42 -0300
committerAndreas Färber <afaerber@suse.de>2013-08-16 18:44:33 +0200
commit99a0b03650176340ab6667fa1e5711a4552d4494 (patch)
treeea56cf5609df9202402efd8b04942f9ebafd9dbd /hw/core/qdev.c
parent8231c2dd220336bbc7522c490d95742f6ba0adae (diff)
qdev: Set globals in instance_post_init function
This way, properties registered in the instance_init function of child classes will be handled properly by qdev_prop_set_globals(), too. Includes a unit test for the new functionality. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9190a7ee76..758de9fccc 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -752,7 +752,6 @@ 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, &err);
if (err != NULL) {
qerror_report_err(err);
error_free(err);
@@ -764,6 +763,15 @@ static void device_initfn(Object *obj)
assert_no_error(err);
}
+static void device_post_init(Object *obj)
+{
+ DeviceState *dev = DEVICE(obj);
+ Error *err = NULL;
+
+ qdev_prop_set_globals(dev, &err);
+ assert_no_error(err);
+}
+
/* Unlink device from bus and free the structure. */
static void device_finalize(Object *obj)
{
@@ -853,6 +861,7 @@ static const TypeInfo device_type_info = {
.parent = TYPE_OBJECT,
.instance_size = sizeof(DeviceState),
.instance_init = device_initfn,
+ .instance_post_init = device_post_init,
.instance_finalize = device_finalize,
.class_base_init = device_class_base_init,
.class_init = device_class_init,