From: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Anton Johansson" <anjo@rev.ng>
Subject: Re: [PATCH v5 6/6] target-info-qom: use a single class_init for target-info-* classes
Date: Sat, 9 May 2026 14:29:21 -0700 [thread overview]
Message-ID: <626b60c0-2d2d-4ef9-a5fc-48ea192dd2b9@oss.qualcomm.com> (raw)
In-Reply-To: <7bdc61c1-3dad-49b5-b385-4e9fbd0fc1c6@linaro.org>
On 5/9/2026 8:03 AM, Richard Henderson wrote:
> On 5/8/26 19:59, Pierrick Bouvier wrote:
>> On 5/8/2026 5:54 PM, Pierrick Bouvier wrote:
>>> Instead of defining a class_init per class, just use a common
>>> constructor and set class_data to corresponding TargetInfo structure.
>>>
>>> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
>>> ---
>>> include/qemu/target-info-init.h | 14 ++------------
>>> include/qemu/target-info-qom.h | 1 +
>>> target-info-qom.c | 6 ++++++
>>> 3 files changed, 9 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/include/qemu/target-info-init.h b/include/qemu/target-
>>> info-init.h
>>> index 176fd975a16..3945f2998e0 100644
>>> --- a/include/qemu/target-info-init.h
>>> +++ b/include/qemu/target-info-init.h
>>> @@ -37,8 +37,6 @@ const TargetInfo *target_info(void) \
>>> #include "qemu/target-info-qom.h"
>>> #include "qom/object.h"
>>> -#define TYPE_TARGET_INFO_TARGET TYPE_TARGET_INFO"-"TARGET_NAME
>>> -
>>> typedef struct TargetInfoQomTarget {
>>> TargetInfoQom parent;
>>> } TargetInfoQomTarget;
>>> @@ -47,24 +45,16 @@ typedef struct TargetInfoQomTargetClass {
>>> TargetInfoQomClass parent_class;
>>> } TargetInfoQomTargetClass;
>>> -OBJECT_DECLARE_TYPE(TargetInfoQomTarget, TargetInfoQomTargetClass,
>>> TARGET_INFO_TARGET)
>>> -
>>> #define
>>> target_info_init(ti_var) \
>>> -static void target_info_qom_class_init(ObjectClass *oc, const void *
>>> data) \
>>> -
>>> { \
>>> - TargetInfoQomTargetClass *klass =
>>> TARGET_INFO_TARGET_CLASS(oc); \
>>> - klass->parent_class.target_info =
>>> &ti_var; \
>>> -} \
>>> -
>>> \
>>> static const TypeInfo target_info_qom_target_type_info =
>>> { \
>>> - .name =
>>> TYPE_TARGET_INFO_TARGET, \
>>> + .name =
>>> TYPE_TARGET_INFO"-"TARGET_NAME, \
>>> .parent =
>>> TYPE_TARGET_INFO, \
>>> .instance_size =
>>> sizeof(TargetInfoQomTarget), \
>>> .class_size =
>>> sizeof(TargetInfoQomTargetClass), \
>>> .class_init =
>>> target_info_qom_class_init, \
>>> + .class_data =
>>> &ti_var, \
>>> .abstract =
>>> false, \
>>> }; \
>>> -
>>> \
>>> DEFINE_TARGET_INFO_TYPE(target_info_qom_target_type_info)
>>> #endif /* CONFIG_USER_ONLY */
>>> diff --git a/include/qemu/target-info-qom.h b/include/qemu/target-
>>> info-qom.h
>>> index 91be415ed33..a37c3e101e0 100644
>>> --- a/include/qemu/target-info-qom.h
>>> +++ b/include/qemu/target-info-qom.h
>>> @@ -25,6 +25,7 @@ typedef struct TargetInfoQomClass {
>>> OBJECT_DECLARE_TYPE(TargetInfoQom, TargetInfoQomClass, TARGET_INFO)
>>> +void target_info_qom_class_init(ObjectClass *oc, const void * data);
>>> void target_info_qom_set_target(void);
>>> #endif /* QEMU_TARGET_INFO_QOM_H */
>>> diff --git a/target-info-qom.c b/target-info-qom.c
>>> index cc470b3b4d6..5b0498ca654 100644
>>> --- a/target-info-qom.c
>>> +++ b/target-info-qom.c
>>> @@ -37,6 +37,12 @@ static const TypeInfo target_info_parent_type = {
>>> DEFINE_TARGET_INFO_TYPE(target_info_parent_type)
>>> +void target_info_qom_class_init(ObjectClass *oc, const void * data)
>>> +{
>>> + TargetInfoQomClass *klass = TARGET_INFO_CLASS(oc);
>>> + klass->target_info = data;
>>> +}
>>> +
>>> static const TargetInfo *target_info_ptr;
>>> const TargetInfo *target_info(void)
>>
>> This patch can be squashed with 3, but I thought it might be better for
>> review to keep it on top for now.
>
> Mmm. You've missed the part about using class_base_init instead of
> class_init, so that you don't need the extern function declaration. See
> review of patch 3.
>
I feel that this pattern of using a super ctor with a data set by child
is very counter intuitive, but I'll trust your judgment on how QOM is
supposed to work.
I'll squash this with patch 3 in next version so there is no confusion also.
>
> r~
Regards,
Pierrick
next prev parent reply other threads:[~2026-05-09 21:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 0:54 [PATCH v5 0/6] single-binary: deduplicate target_info() Pierrick Bouvier
2026-05-09 0:54 ` [PATCH v5 1/6] qom/object: register OBJECT and INTERFACE QOM types before main Pierrick Bouvier
2026-05-11 10:24 ` Philippe Mathieu-Daudé
2026-05-09 0:54 ` [PATCH v5 2/6] qom/object: initialize type_table in static ctor with fundamental QOM types Pierrick Bouvier
2026-05-09 14:21 ` Richard Henderson
2026-05-11 10:25 ` Philippe Mathieu-Daudé
2026-05-09 0:54 ` [PATCH v5 3/6] target-info: extract target_info() definition in target-info-init.h Pierrick Bouvier
2026-05-09 15:01 ` Richard Henderson
2026-05-09 21:21 ` Pierrick Bouvier
2026-05-09 0:54 ` [PATCH v5 4/6] target-info-qom: detect target from QOM Pierrick Bouvier
2026-05-09 0:54 ` [PATCH v5 5/6] target-info: replace target_info() in system-mode Pierrick Bouvier
2026-05-09 0:54 ` [PATCH v5 6/6] target-info-qom: use a single class_init for target-info-* classes Pierrick Bouvier
2026-05-09 0:59 ` Pierrick Bouvier
2026-05-09 15:03 ` Richard Henderson
2026-05-09 21:29 ` Pierrick Bouvier [this message]
2026-05-12 15:03 ` [PATCH v5 0/6] 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=626b60c0-2d2d-4ef9-a5fc-48ea192dd2b9@oss.qualcomm.com \
--to=pierrick.bouvier@oss.qualcomm.com \
--cc=anjo@rev.ng \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--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.