]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
system/vl: Filter machine list available for a particular target binary
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Sun, 23 Mar 2025 21:46:34 +0000 (22:46 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Wed, 30 Apr 2025 19:51:51 +0000 (12:51 -0700)
Binaries can register a QOM type to filter their machines
by filling their TargetInfo::machine_typename field.

This can be used by example by main() -> machine_help_func()
to filter the machines list.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
include/qemu/target-info-impl.h
include/qemu/target-info.h
system/vl.c
target-info-stub.c
target-info.c

index d30805f7f28e60139fd75f23b6d29e53a24e8c57..d0e8c86176cd08d88718c3903fb6f2fbcb68b059 100644 (file)
@@ -14,6 +14,8 @@
 typedef struct TargetInfo {
     /* runtime equivalent of TARGET_NAME definition */
     const char *target_name;
+    /* QOM typename machines for this binary must implement */
+    const char *machine_typename;
 } TargetInfo;
 
 /**
index 58d41368974e07ca27fad82ca56f7ec5e97f8bab..2b6ccabb118b208779686abc88933f9999a65bfd 100644 (file)
  */
 const char *target_name(void);
 
+/**
+ * target_machine_typename:
+ *
+ * Returns: Name of the QOM interface implemented by machines
+ *          usable on this target binary.
+ */
+const char *target_machine_typename(void);
+
 /**
  * target_cpu_type:
  *
index 520956f4a19551d5d659240fbaff7e32a7cb3467..7223f1ff17377017a32b27c74f966a180624be9d 100644 (file)
@@ -27,6 +27,7 @@
 #include "qemu/datadir.h"
 #include "qemu/units.h"
 #include "qemu/module.h"
+#include "qemu/target-info.h"
 #include "exec/cpu-common.h"
 #include "exec/page-vary.h"
 #include "hw/qdev-properties.h"
@@ -1564,7 +1565,7 @@ static void machine_help_func(const QDict *qdict)
     GSList *el;
     const char *type = qdict_get_try_str(qdict, "type");
 
-    machines = object_class_get_list(TYPE_MACHINE, false);
+    machines = object_class_get_list(target_machine_typename(), false);
     if (type) {
         ObjectClass *machine_class = OBJECT_CLASS(find_machine(type, machines));
         if (machine_class) {
index 773a10188c882dac84580795f3c53569846f11b0..bcf834f71d3ea44094e0746629f1fbbef4ad5ab1 100644 (file)
@@ -9,10 +9,12 @@
 #include "qemu/osdep.h"
 #include "qemu/target-info.h"
 #include "qemu/target-info-impl.h"
+#include "hw/boards.h"
 #include "cpu.h"
 
 static const TargetInfo target_info_stub = {
     .target_name = TARGET_NAME,
+    .machine_typename = TYPE_MACHINE,
 };
 
 const TargetInfo *target_info(void)
index 84b18931e7eff456f5b2e056a2a69671d10b1450..0042769e3a2e1c4fc2e643d809fd79cfd9aae2c9 100644 (file)
@@ -14,3 +14,8 @@ const char *target_name(void)
 {
     return target_info()->target_name;
 }
+
+const char *target_machine_typename(void)
+{
+    return target_info()->machine_typename;
+}