From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH 1/4] qom: Introduce TypeInfo::registerable() callback
Date: Wed, 5 Mar 2025 08:47:40 -0800 [thread overview]
Message-ID: <62dcbd00-0bb6-43ff-998d-a07b85917c99@linaro.org> (raw)
In-Reply-To: <20250305161248.54901-2-philmd@linaro.org>
On 3/5/25 08:12, Philippe Mathieu-Daudé wrote:
> Introduce the TypeInfo::registerable() callback to allow
> runtime decision on whether register a QOM type or not.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/qom/object.h | 1 +
> qom/object.c | 4 ++++
> qom/trace-events | 1 +
> 3 files changed, 6 insertions(+)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 9192265db76..f046791f60c 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -476,6 +476,7 @@ struct TypeInfo
> {
> const char *name;
> const char *parent;
> + bool (*registerable)(void);
>
> size_t instance_size;
> size_t instance_align;
> diff --git a/qom/object.c b/qom/object.c
> index 01618d06bd8..c62b7fd1695 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -168,6 +168,10 @@ static TypeImpl *type_register_internal(const TypeInfo *info)
> fprintf(stderr, "Registering '%s' with illegal type name\n", info->name);
> abort();
> }
> + if (info->registerable && !info->registerable()) {
> + trace_object_register_skipped(info->name);
> + return NULL;
> + }
>
> ti = type_new(info);
>
> diff --git a/qom/trace-events b/qom/trace-events
> index b2e9f4a7127..29af95d8507 100644
> --- a/qom/trace-events
> +++ b/qom/trace-events
> @@ -3,3 +3,4 @@
> # object.c
> object_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> object_class_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
> +object_register_skipped(const char *type) "Not registering '%s' type"
That's a good way to be able to select at runtime the objects enabled,
even though we'll have a binary with all qom objects code present.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
next prev parent reply other threads:[~2025-03-05 16:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 16:12 [RFC PATCH 0/4] hw/arm: Register target-specific QOM types at runtime Philippe Mathieu-Daudé
2025-03-05 16:12 ` [RFC PATCH 1/4] qom: Introduce TypeInfo::registerable() callback Philippe Mathieu-Daudé
2025-03-05 16:47 ` Pierrick Bouvier [this message]
2025-03-06 1:34 ` Richard Henderson
2025-03-05 16:12 ` [RFC PATCH 2/4] hw/arm/raspi: Replace TARGET_AARCH64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
2025-03-05 16:50 ` Pierrick Bouvier
2025-03-05 17:40 ` Thomas Huth
2025-03-05 18:12 ` Cédric Le Goater
2025-03-05 18:35 ` Thomas Huth
2025-03-05 19:07 ` Philippe Mathieu-Daudé
2025-03-05 20:41 ` BALATON Zoltan
2025-03-06 6:12 ` Thomas Huth
2025-03-06 9:21 ` Daniel P. Berrangé
2025-03-06 10:13 ` Peter Maydell
2025-03-05 16:12 ` [RFC PATCH 3/4] hw/arm/aspeed: " Philippe Mathieu-Daudé
2025-03-05 16:33 ` Cédric Le Goater
2025-03-05 17:07 ` Philippe Mathieu-Daudé
2025-03-05 17:43 ` Thomas Huth
2025-03-05 16:12 ` [RFC PATCH 4/4] hw/ppc: Remove TARGET_PPC64 use in ppc_create_page_sizes_prop() Philippe Mathieu-Daudé
2025-03-05 16:52 ` Pierrick Bouvier
2025-03-05 16:53 ` [RFC PATCH 0/4] hw/arm: Register target-specific QOM types at runtime 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=62dcbd00-0bb6-43ff-998d-a07b85917c99@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).