Message ID | 1500279971-13875-5-git-send-email-peterx@redhat.com |
---|---|
State | New |
Headers | show |
On Mon, Jul 17, 2017 at 04:26:04PM +0800, Peter Xu wrote: > It makes more sense to call the post_init() hook of the parent first > then the child, just like what we do in the rest of the hooks. I suggest documenting the existing instance_post_init users in the commit message (TYPE_DEVICE and TYPE_ARM_CPU, as far as I can see), and explain why they won't be affected (or if they are affected, why the new behavior is better). Also, can you please update the @instance_post_init documentation in qom/object.h to mention the new ordering? Maybe something like: - * @instance_post_init: This function is called to finish initialization of - * an object, after all @instance_init functions were called. + * @instance_post_init: Finish initialization of an object. This + * function is called after the @instance_init functions for + * all subclasses were called, but before the @instance_post_init + * function for the subclasses are called. > > CC: Andreas Färber <afaerber@suse.de> > CC: Markus Armbruster <armbru@redhat.com> > CC: Eduardo Habkost <ehabkost@redhat.com> > Signed-off-by: Peter Xu <peterx@redhat.com> > --- > qom/object.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/qom/object.c b/qom/object.c > index dfdbd50..e2c9c4a 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -347,13 +347,13 @@ 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)); > } > + > + if (ti->instance_post_init) { > + ti->instance_post_init(obj); > + } > } > > static void object_initialize_with_type(void *data, size_t size, TypeImpl *type) > -- > 2.7.4 >
diff --git a/qom/object.c b/qom/object.c index dfdbd50..e2c9c4a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -347,13 +347,13 @@ 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)); } + + if (ti->instance_post_init) { + ti->instance_post_init(obj); + } } static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
It makes more sense to call the post_init() hook of the parent first then the child, just like what we do in the rest of the hooks. CC: Andreas Färber <afaerber@suse.de> CC: Markus Armbruster <armbru@redhat.com> CC: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- qom/object.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)