From: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: "Anton Johansson" <anjo@rev.ng>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>
Subject: [PATCH 01/14] qom/object: add is_available callback to TypeInfo
Date: Tue, 1 Sep 2026 20:20:30 +0000 [thread overview]
Message-ID: <20260901202043.26532-2-pierrick.bouvier@oss.qualcomm.com> (raw)
In-Reply-To: <20260901202043.26532-1-pierrick.bouvier@oss.qualcomm.com>
When removing target specific sections (#ifdef TARGET_X), we started
exposing types for different targets in the same file.
Previously, we implemented a filter based on interfaces, but it
proved to be too cumbersome, requiring duplication across architectures.
To simplify it, we add a new callback, is_available, to TypeInfo, that
will replace the existing filtering mechanism.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
include/qom/object.h | 3 +++
qom/object.c | 4 ++++
rust/qom/src/qom.rs | 1 +
3 files changed, 8 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index e24f0a2b2d0..7ecd0f210fb 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -469,6 +469,8 @@ struct Object
* @class_data: Data to pass to the @class_init,
* @class_base_init. This can be useful when building dynamic
* classes.
+ * @is_available: callback invoked at registration time, to dynamically check if
+ * this type should be available or not.
* @interfaces: The list of interfaces associated with this type. This
* should point to a static array that's terminated with a zero filled
* element.
@@ -491,6 +493,7 @@ struct TypeInfo
void (*class_base_init)(ObjectClass *klass, const void *data);
const void *class_data;
+ bool (*is_available)(void);
const InterfaceInfo *interfaces;
};
diff --git a/qom/object.c b/qom/object.c
index 85bbd7f9fe1..b1834a57cc9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -163,6 +163,10 @@ static TypeImpl *type_register_internal(const TypeInfo *info)
abort();
}
+ if (info->is_available && !info->is_available()) {
+ return NULL;
+ }
+
ti = type_new(info);
type_table_add(ti);
diff --git a/rust/qom/src/qom.rs b/rust/qom/src/qom.rs
index cc00ddcfc98..bbb485e2cfd 100644
--- a/rust/qom/src/qom.rs
+++ b/rust/qom/src/qom.rs
@@ -691,6 +691,7 @@ pub trait ObjectImpl: ObjectType + IsA<Object> {
class_init: Some(rust_class_init::<Self>),
class_base_init: Self::CLASS_BASE_INIT,
class_data: core::ptr::null(),
+ is_available: None,
interfaces: core::ptr::null(),
};
--
2.43.0
next prev parent reply other threads:[~2026-09-01 20:21 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 20:20 [PATCH 00/14] target-info: remove machine_typename Pierrick Bouvier
2026-09-01 20:20 ` Pierrick Bouvier [this message]
2026-09-02 15:53 ` [PATCH 01/14] qom/object: add is_available callback to TypeInfo Philippe Mathieu-Daudé
2026-09-02 17:40 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 02/14] hw/arm: filter minimal set of machines Pierrick Bouvier
2026-09-02 14:30 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 03/14] system: query machines using TYPE_MACHINE Pierrick Bouvier
2026-09-02 4:39 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 04/14] target-info: remove machine_typename Pierrick Bouvier
2026-09-02 4:36 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 05/14] configs/targets: remove target info definitions Pierrick Bouvier
2026-09-02 15:55 ` Philippe Mathieu-Daudé
2026-09-02 16:24 ` Pierrick Bouvier
2026-09-02 17:41 ` Pierrick Bouvier
2026-09-01 20:20 ` [PATCH 06/14] target-info: rename target-info-stub.c in target-info-def.c Pierrick Bouvier
2026-09-01 20:20 ` [PATCH 07/14] hw/arm: remove TYPE_TARGET_{AARCH64,ARM}_MACHINE Pierrick Bouvier
2026-09-02 4:37 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 08/14] hw/arm: remove {arm, arm_aarch64, aarch64}_machine_interfaces Pierrick Bouvier via qemu development
2026-09-02 4:37 ` Philippe Mathieu-Daudé
2026-09-03 4:06 ` Yonggang Luo
2026-09-01 20:20 ` [PATCH 09/14] hw/arm: remove DEFINE_MACHINE_{AARCH64,ARM} Pierrick Bouvier
2026-09-02 4:38 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 10/14] hw/arm: remove machines-qom.h Pierrick Bouvier
2026-09-02 4:38 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 11/14] hw/riscv: remove TYPE_TARGET_{RISCV32,RISCV64}_MACHINE Pierrick Bouvier
2026-09-02 4:38 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 12/14] hw/riscv: remove {riscv32, riscv32_64, riscv64}_machine_interfaces Pierrick Bouvier via qemu development
2026-09-02 4:39 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 13/14] hw/riscv: remove DEFINE_MACHINE_{RISCV32,RISCV64} Pierrick Bouvier
2026-09-02 4:39 ` Philippe Mathieu-Daudé
2026-09-01 20:20 ` [PATCH 14/14] hw/riscv: remove machines-qom.h Pierrick Bouvier
2026-09-02 4:39 ` Philippe Mathieu-Daudé
2026-09-02 17:54 ` [PATCH 00/14] target-info: remove machine_typename Philippe Mathieu-Daudé
2026-09-03 10:33 ` Yonggang Luo
2026-09-03 16:28 ` Pierrick Bouvier
2026-09-03 16:42 ` Yonggang Luo
2026-09-03 16:53 ` 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=20260901202043.26532-2-pierrick.bouvier@oss.qualcomm.com \
--to=pierrick.bouvier@oss.qualcomm.com \
--cc=anjo@rev.ng \
--cc=philmd@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.