From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: qemu-devel@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Anton Johansson" <anjo@rev.ng>,
marcandre.lureau@redhat.com,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Max Filippov" <jcmvbkbc@gmail.com>
Subject: Re: [PATCH v2 3/7] qom/object: register OBJECT and INTERFACE QOM types before main
Date: Thu, 30 Apr 2026 18:07:05 +0100 [thread overview]
Message-ID: <afOMOcbpEnjzfyj6@redhat.com> (raw)
In-Reply-To: <d95d58da-764d-4967-ae93-2cb7418d8c5d@oss.qualcomm.com>
On Thu, Apr 30, 2026 at 09:03:52AM -0700, Pierrick Bouvier wrote:
> On 4/30/2026 12:12 AM, Daniel P. Berrangé wrote:
> > On Wed, Apr 29, 2026 at 08:56:22PM -0700, Pierrick Bouvier wrote:
> >> 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.
> >>
> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> >> ---
> >> qom/object.c | 4 +---
> >> 1 file changed, 1 insertion(+), 3 deletions(-)
> >>
> >> diff --git a/qom/object.c b/qom/object.c
> >> index f981e270440..a5d268d0722 100644
> >> --- a/qom/object.c
> >> +++ b/qom/object.c
> >> @@ -2839,7 +2839,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,
> >> @@ -2857,5 +2857,3 @@ static void register_types(void)
> >> type_interface = type_register_internal(&interface_info);
> >> type_register_internal(&object_info);
> >> }
> >> -
> >> -type_init(register_types)
> >
> > IMHO this should have been done using the MODULE_INIT_QOM_EARLY
> > approach that I suggested on v1, rather than special casing both
> > the base classes and MODULE_INIT_TARGET_INFO
> >
>
> I'm ok to follow your approach if you really prefer it.
> However, can you specify what should be the semantic to put in comment
> for it? I have trouble finding to explain what is early vs non early,
> while it's clear for me what is TARGET_INFO vs REST_OF_QOM.
I don't think we need to set our strong rules. It is just an early
startup hook to be used by classes which are a dependency of other
initialization code. Conceptually this is similar to what we did
in system/vl.c, where we have various stages for creating -object
args. What goes in each stage is simply determined by a functional
need at the point in time.
> As well, adding a INIT_QOM_EARLY implies we need to call it in all
> locations where we already call INIT_QOM for future-proofing, which
> seems very redundant. Should we had it or not?
Yep, that's true, but not the end of the world imho.
Ultimately an solution is a bit of a hack. Long term what we need
to do is follow glib's approach from GType and have "just in time"
initialization on first use which will make everything "just work"
without having to think about ordering. I didn't want to suggest
that now though, as it has potential to be a can of worms.
next prev parent reply other threads:[~2026-04-30 17:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 3:56 [PATCH v2 0/7] single-binary: deduplicate target_info() Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 1/7] target-info: extract target_info() definition in target-info-init.h Pierrick Bouvier
2026-04-30 8:03 ` Marc-André Lureau
2026-04-30 16:23 ` Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 2/7] target-info: introduce TargetInfo in QOM Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 3/7] qom/object: register OBJECT and INTERFACE QOM types before main Pierrick Bouvier
2026-04-30 7:12 ` Daniel P. Berrangé
2026-04-30 16:03 ` Pierrick Bouvier
2026-04-30 17:07 ` Daniel P. Berrangé [this message]
2026-04-30 17:28 ` Pierrick Bouvier
2026-04-30 17:37 ` Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 4/7] target/xtensa/core: register types using type_init Pierrick Bouvier
2026-04-30 4:48 ` Philippe Mathieu-Daudé
2026-04-30 3:56 ` [PATCH v2 5/7] system/vl: register target info types first in qom Pierrick Bouvier
2026-04-30 7:47 ` Daniel P. Berrangé
2026-04-30 18:57 ` Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 6/7] target-info-qom: detect target from QOM Pierrick Bouvier
2026-04-30 3:56 ` [PATCH v2 7/7] target-info: replace target_info() in system-mode Pierrick Bouvier
2026-04-30 20:40 ` [PATCH v2 0/7] single-binary: deduplicate target_info() Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=afOMOcbpEnjzfyj6@redhat.com \
--to=berrange@redhat.com \
--cc=anjo@rev.ng \
--cc=armbru@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.