qom/object: register OBJECT and INTERFACE QOM types before main
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>
Pierrick Bouvier committed
May 14, 2026 at 10:22 UTC
8758aeca2cae24b040eebcd6ded27edd9e6861a5
1 file changed
+1
-3
qom/object.c
+1
-3
@@ -2844,7 +2844,7 @@ static void object_class_init(ObjectClass *klass, const void *data)
2844
NULL);
2845
}
2846
2847
-static void register_types(void)
2847
+static void __attribute__((constructor)) register_types(void)
2848
{
2849
static const TypeInfo interface_info = {
2850
.name = TYPE_INTERFACE,
@@ -2862,5 +2862,3 @@ static void register_types(void)
2862
type_interface = type_register_internal(&interface_info);
2863
type_register_internal(&object_info);
2864
}
2865
-
2866
-type_init(register_types)