On 14/5/26 19:23, Pierrick Bouvier wrote:
For the single-binary, we want to be able to retrieve at runtime the
current target among the different ones available.
A consequence is that we can't rely on existing target_info() definition
since it will create a conflict once more than one target is available.
To solve this, we add TargetInfo in QOM, with this hierarchy.
We define one class "target-info-X" per target, that inherits from
abstract class "target-info". Using concrete vs abstract class ensure we
can easily filter "target-info-X" from all QOM types.
Associated TargetInfo is directly set through class initialization,
without relying on any instance.
For user mode, we simply define target_info() like it was done
previously. In this patch, we keep the same definition for system-mode
also, and it will be replaced in next commits.
We will introduce detection of target from QOM, so we need to make sure
those types are registered early.
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
---
configs/targets/aarch64-softmmu.c | 6 ++--
configs/targets/arm-softmmu.c | 6 ++--
include/qemu/module.h | 1 +
include/qemu/target-info-init.h | 58 +++++++++++++++++++++++++++++++
include/qemu/target-info-qom.h | 28 +++++++++++++++
system/vl.c | 2 ++
target-info-qom.c | 24 +++++++++++++
target-info-stub.c | 6 ++--
tests/qtest/fuzz/fuzz.c | 1 +
9 files changed, 120 insertions(+), 12 deletions(-)
create mode 100644 include/qemu/target-info-init.h
create mode 100644 include/qemu/target-info-qom.h
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index d2355989616..de230d20e0f 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -172,6 +172,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char
***envp)
/* Initialize qgraph and modules */
qos_graph_init();
+ module_call_init(MODULE_INIT_TARGET_INFO);
module_call_init(MODULE_INIT_FUZZ_TARGET);
module_call_init(MODULE_INIT_QOM);
module_call_init(MODULE_INIT_LIBQOS);
LGTM.