qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org, Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Anton Johansson <anjo@rev.ng>
Subject: [RFC PATCH v4 03/19] system/vl: Filter machine list available for a particular target binary
Date: Tue, 22 Apr 2025 16:54:45 +0200	[thread overview]
Message-ID: <20250422145502.70770-4-philmd@linaro.org> (raw)
In-Reply-To: <20250422145502.70770-1-philmd@linaro.org>

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>
---
 meson.build                     |  1 +
 include/qemu/target-info-impl.h |  3 +++
 include/qemu/target-info.h      |  8 ++++++++
 system/vl.c                     |  3 ++-
 target-info-qom.c               | 15 +++++++++++++++
 target-info-stub.c              |  2 ++
 target-info.c                   |  5 +++++
 7 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 target-info-qom.c

diff --git a/meson.build b/meson.build
index 09b16e2f7ae..a1109b6db3f 100644
--- a/meson.build
+++ b/meson.build
@@ -3808,6 +3808,7 @@ common_ss.add(pagevary)
 specific_ss.add(files('page-target.c', 'page-vary-target.c'))
 
 common_ss.add(files('target-info.c'))
+system_ss.add(files('target-info-qom.c'))
 specific_ss.add(files('target-info-stub.c'))
 
 subdir('backends')
diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
index c276b84ceca..4ef54c5136a 100644
--- a/include/qemu/target-info-impl.h
+++ b/include/qemu/target-info-impl.h
@@ -16,6 +16,9 @@ typedef struct TargetInfo {
     /* runtime equivalent of TARGET_NAME definition */
     const char *const target_name;
 
+    /* QOM typename machines for this binary must implement */
+    const char *const machine_typename;
+
 } TargetInfo;
 
 /**
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 1007dc9a5e4..0224b35b166 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -16,4 +16,12 @@
  */
 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);
+
 #endif
diff --git a/system/vl.c b/system/vl.c
index cdf6eb9ee49..e8706a9ce87 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -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) {
diff --git a/target-info-qom.c b/target-info-qom.c
new file mode 100644
index 00000000000..a6fd8f1d5a3
--- /dev/null
+++ b/target-info-qom.c
@@ -0,0 +1,15 @@
+/*
+ * QEMU binary/target API (QOM types)
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qom/object.h"
+
+static const TypeInfo target_info_types[] = {
+};
+
+DEFINE_TYPES(target_info_types)
diff --git a/target-info-stub.c b/target-info-stub.c
index 076b9254dd0..218e5898e7f 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -8,9 +8,11 @@
 
 #include "qemu/osdep.h"
 #include "qemu/target-info-impl.h"
+#include "hw/boards.h"
 
 static const TargetInfo target_info_stub = {
     .target_name = TARGET_NAME,
+    .machine_typename = TYPE_MACHINE,
 };
 
 const TargetInfo *target_info(void)
diff --git a/target-info.c b/target-info.c
index 84b18931e7e..0042769e3a2 100644
--- a/target-info.c
+++ b/target-info.c
@@ -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;
+}
-- 
2.47.1



  parent reply	other threads:[~2025-04-22 14:56 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 14:54 [RFC PATCH v4 00/19] single-binary: Make hw/arm/ common Philippe Mathieu-Daudé
2025-04-22 14:54 ` [RFC PATCH v4 01/19] qapi: Rename TargetInfo structure as QemuTargetInfo Philippe Mathieu-Daudé
2025-04-22 14:57   ` Philippe Mathieu-Daudé
2025-04-22 17:33   ` Markus Armbruster
2025-04-22 14:54 ` [RFC PATCH v4 02/19] qemu: Convert target_name() to TargetInfo API Philippe Mathieu-Daudé
2025-04-22 17:27   ` Richard Henderson
2025-04-22 17:28   ` Richard Henderson
2025-04-22 14:54 ` Philippe Mathieu-Daudé [this message]
2025-04-22 17:29   ` [RFC PATCH v4 03/19] system/vl: Filter machine list available for a particular target binary Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 04/19] hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces Philippe Mathieu-Daudé
2025-04-22 17:31   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 05/19] hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine Philippe Mathieu-Daudé
2025-04-22 17:34   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 06/19] hw/arm: Filter machine types for qemu-system-arm/aarch64 binaries Philippe Mathieu-Daudé
2025-04-22 17:40   ` Richard Henderson
2025-04-23 16:34     ` Philippe Mathieu-Daudé
2025-04-23 17:43       ` Pierrick Bouvier
2025-04-23 19:12         ` Richard Henderson
2025-04-23 19:33           ` Pierrick Bouvier
2025-04-23 19:53             ` Philippe Mathieu-Daudé
2025-04-23 20:10               ` Pierrick Bouvier
2025-04-23 20:04             ` Richard Henderson
2025-04-23 20:12               ` Pierrick Bouvier
2025-04-23 17:07     ` Philippe Mathieu-Daudé
2025-04-22 14:54 ` [RFC PATCH v4 07/19] meson: Prepare to accept per-binary TargetInfo structure implementation Philippe Mathieu-Daudé
2025-04-22 17:41   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 08/19] config/target: Implement per-binary TargetInfo structure (ARM, AARCH64) Philippe Mathieu-Daudé
2025-04-22 17:42   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 09/19] hw/arm/aspeed: Build objects once Philippe Mathieu-Daudé
2025-04-22 17:42   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 10/19] hw/arm/raspi: " Philippe Mathieu-Daudé
2025-04-22 17:43   ` Richard Henderson
2025-04-22 14:54 ` [RFC PATCH v4 11/19] hw/core/machine: Allow dynamic registration of valid CPU types Philippe Mathieu-Daudé
2025-04-22 17:54   ` Richard Henderson
2025-04-22 18:06     ` Pierrick Bouvier
2025-04-22 14:54 ` [RFC PATCH v4 12/19] hw/arm/virt: Register valid CPU types dynamically Philippe Mathieu-Daudé
2025-04-22 17:56   ` Richard Henderson
2025-04-22 18:10     ` Pierrick Bouvier
2025-04-22 18:18     ` Philippe Mathieu-Daudé
2025-04-22 14:54 ` [RFC PATCH v4 13/19] hw/arm/virt: Check accelerator availability at runtime Philippe Mathieu-Daudé
2025-04-22 17:56   ` Richard Henderson
2025-04-22 18:18   ` Pierrick Bouvier
2025-04-22 14:54 ` [RFC PATCH v4 14/19] qemu/target_info: Add %target_arch field to TargetInfo Philippe Mathieu-Daudé
2025-04-22 17:46   ` Richard Henderson
2025-04-22 18:20   ` Pierrick Bouvier
2025-04-22 18:24     ` Philippe Mathieu-Daudé
2025-04-22 18:30       ` Pierrick Bouvier
2025-04-23  5:34         ` Philippe Mathieu-Daudé
2025-04-23  6:24           ` Pierrick Bouvier
2025-04-23  6:28             ` Pierrick Bouvier
2025-04-23  9:14             ` Philippe Mathieu-Daudé
2025-04-23 14:59               ` Pierrick Bouvier
2025-04-22 14:54 ` [RFC PATCH v4 15/19] qemu/target_info: Add target_aarch64() helper Philippe Mathieu-Daudé
2025-04-22 17:46   ` Richard Henderson
2025-04-22 18:21   ` Pierrick Bouvier
2025-04-22 14:54 ` [RFC PATCH v4 16/19] hw/arm/virt: Replace TARGET_AARCH64 -> target_aarch64() Philippe Mathieu-Daudé
2025-04-22 17:47   ` Richard Henderson
2025-04-22 18:22   ` Pierrick Bouvier
2025-04-22 14:54 ` [RFC PATCH v4 17/19] hw/core: Get default_cpu_type calling machine_class_default_cpu_type() Philippe Mathieu-Daudé
2025-04-22 17:58   ` Richard Henderson
2025-04-22 18:23   ` Pierrick Bouvier
2025-04-22 14:55 ` [RFC PATCH v4 18/19] hw/core: Introduce MachineClass::get_default_cpu_type() helper Philippe Mathieu-Daudé
2025-04-22 17:59   ` Richard Henderson
2025-04-22 18:24     ` Pierrick Bouvier
2025-04-22 14:55 ` [RFC PATCH v4 19/19] hw/arm/virt: Get default CPU type at runtime Philippe Mathieu-Daudé
2025-04-22 18:06   ` Richard Henderson

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=20250422145502.70770-4-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=pierrick.bouvier@linaro.org \
    --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 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).