target-info-qom: detect target from QOM
For now, we expect only one target to be available at runtime. This will change with the single-binary and we'll detect which one to use dynamically. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260514172303.1484273-5-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
This commit is contained in:
@@ -25,4 +25,6 @@ typedef struct TargetInfoQomClass {
|
||||
|
||||
OBJECT_DECLARE_TYPE(TargetInfoQom, TargetInfoQomClass, TARGET_INFO)
|
||||
|
||||
void target_info_qom_set_target(void);
|
||||
|
||||
#endif /* QEMU_TARGET_INFO_QOM_H */
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "qemu/units.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/target-info.h"
|
||||
#include "qemu/target-info-qom.h"
|
||||
#include "exec/cpu-common.h"
|
||||
#include "exec/page-vary.h"
|
||||
#include "hw/core/qdev-properties.h"
|
||||
@@ -2890,6 +2891,7 @@ void qemu_init(int argc, char **argv)
|
||||
os_setup_limits();
|
||||
|
||||
module_call_init(MODULE_INIT_TARGET_INFO);
|
||||
target_info_qom_set_target();
|
||||
|
||||
module_init_info(qemu_modinfo);
|
||||
module_allow_arch(target_name());
|
||||
|
||||
@@ -46,3 +46,19 @@ static const TypeInfo target_info_parent_type = {
|
||||
};
|
||||
|
||||
DEFINE_TARGET_INFO_TYPE(target_info_parent_type)
|
||||
|
||||
static const TargetInfo *target_info_ptr;
|
||||
|
||||
void target_info_qom_set_target(void)
|
||||
{
|
||||
g_autoptr(GSList) targets = object_class_get_list(TYPE_TARGET_INFO, false);
|
||||
|
||||
size_t num_found = g_slist_length(targets);
|
||||
if (num_found != 1) {
|
||||
error_setg(&error_fatal, num_found == 0 ?
|
||||
"no target-info is available" :
|
||||
"more than one target-info is available");
|
||||
}
|
||||
|
||||
target_info_ptr = TARGET_INFO_CLASS(targets->data)->target_info;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "system/runstate.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "qemu/target-info-qom.h"
|
||||
#include "tests/qtest/libqtest.h"
|
||||
#include "tests/qtest/libqos/qgraph.h"
|
||||
#include "fuzz.h"
|
||||
@@ -173,6 +174,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
|
||||
/* Initialize qgraph and modules */
|
||||
qos_graph_init();
|
||||
module_call_init(MODULE_INIT_TARGET_INFO);
|
||||
target_info_qom_set_target();
|
||||
module_call_init(MODULE_INIT_FUZZ_TARGET);
|
||||
module_call_init(MODULE_INIT_QOM);
|
||||
module_call_init(MODULE_INIT_LIBQOS);
|
||||
|
||||
Reference in New Issue
Block a user