]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qom/object: register OBJECT and INTERFACE QOM types before main
authorPierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Thu, 14 May 2026 17:22:59 +0000 (10:22 -0700)
committerPierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Thu, 14 May 2026 17:41:17 +0000 (10:41 -0700)
Those types are special, as they are the base of all other QOM types. In
next commit, we'll introduce an extra step in module initialization for
target-info-* types.

However, those types depend on TYPE_OBJECT, which is only registered
at MODULE_INIT_QOM step.

To avoid having to introduce another step, and modify all code calling
module_call_init(MODULE_INIT_QOM), we simply register those base types
directly in the static constructor, before anything else.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/qemu-devel/20260514172303.1484273-2-pierrick.bouvier@oss.qualcomm.com
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
qom/object.c

index 59fd79738d20db2058b7053b7b936c1fd4c2b89c..b82b65a3a18cc8b8068f637be38685dc6bb87be7 100644 (file)
@@ -2844,7 +2844,7 @@ static void object_class_init(ObjectClass *klass, const void *data)
                                   NULL);
 }
 
-static void register_types(void)
+static void __attribute__((constructor)) register_types(void)
 {
     static const TypeInfo interface_info = {
         .name = TYPE_INTERFACE,
@@ -2862,5 +2862,3 @@ static void register_types(void)
     type_interface = type_register_internal(&interface_info);
     type_register_internal(&object_info);
 }
-
-type_init(register_types)