diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2013-07-10 17:08:41 -0300 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2013-08-16 18:44:33 +0200 |
commit | 8231c2dd220336bbc7522c490d95742f6ba0adae (patch) | |
tree | 0c3fa9d769747a93ad5260e4451c531aa1bacf90 /qom | |
parent | 747b0cb4b51296e85add0a23d5fc1d24e250ec08 (diff) | |
download | qemu-8231c2dd220336bbc7522c490d95742f6ba0adae.tar.gz qemu-8231c2dd220336bbc7522c490d95742f6ba0adae.tar.bz2 qemu-8231c2dd220336bbc7522c490d95742f6ba0adae.zip |
qom: Introduce instance_post_init hook
This will allow classes to specify a function to be called after all
instance_init functions were called.
This will be used by DeviceState to call qdev_prop_set_globals() at the
right moment.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c index b2479d1c06..74fd241a02 100644 --- a/qom/object.c +++ b/qom/object.c @@ -51,6 +51,7 @@ struct TypeImpl void *class_data; void (*instance_init)(Object *obj); + void (*instance_post_init)(Object *obj); void (*instance_finalize)(Object *obj); bool abstract; @@ -111,6 +112,7 @@ static TypeImpl *type_register_internal(const TypeInfo *info) ti->class_data = info->class_data; ti->instance_init = info->instance_init; + ti->instance_post_init = info->instance_post_init; ti->instance_finalize = info->instance_finalize; ti->abstract = info->abstract; @@ -298,6 +300,17 @@ static void object_init_with_type(Object *obj, TypeImpl *ti) } } +static void object_post_init_with_type(Object *obj, TypeImpl *ti) +{ + if (ti->instance_post_init) { + ti->instance_post_init(obj); + } + + if (type_has_parent(ti)) { + object_post_init_with_type(obj, type_get_parent(ti)); + } +} + void object_initialize_with_type(void *data, TypeImpl *type) { Object *obj = data; @@ -313,6 +326,7 @@ void object_initialize_with_type(void *data, TypeImpl *type) object_ref(obj); QTAILQ_INIT(&obj->properties); object_init_with_type(obj, type); + object_post_init_with_type(obj, type); } void object_initialize(void *data, const char *typename) |