summary refs log tree commit diff stats
path: root/qom/object.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-02-03 12:35:39 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-05-20 08:18:53 +0200
commit220c739903cec99df032219ac94c45b5269a0ab5 (patch)
tree5fac63709fab495902a93ed1d40cb22fbaa2642f /qom/object.c
parent42bc8af14033b9eeeb535449f243767c015f027e (diff)
downloadfocaccia-qemu-220c739903cec99df032219ac94c45b5269a0ab5.tar.gz
focaccia-qemu-220c739903cec99df032219ac94c45b5269a0ab5.zip
qom: reverse order of instance_post_init calls
Currently, the instance_post_init calls are performed from the leaf
class and all the way up to Object.  This is incorrect because the
leaf class cannot observe property values applied by the superclasses;
for example, a compat property will be set on a device *after*
the class's post_init callback has run.

In particular this makes it impossible for implementations of
accel_cpu_instance_init() to operate based on the actual values of
the properties, though it seems that cxl_dsp_instance_post_init and
rp_instance_post_init might have similar issues.

Follow instead the same order as instance_init, starting with Object
and running the child class's instance_post_init after the parent.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--qom/object.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/qom/object.c b/qom/object.c
index 7b013f40a0..1856bb36c7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -431,13 +431,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);
+    }
 }
 
 bool object_apply_global_props(Object *obj, const GPtrArray *props,