All of lore.kernel.org
 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 v3 03/14] system/vl: Filter machine list available for a particular target binary
Date: Fri, 18 Apr 2025 19:28:57 +0200	[thread overview]
Message-ID: <20250418172908.25147-4-philmd@linaro.org> (raw)
In-Reply-To: <20250418172908.25147-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>
---
 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 49a050a28a3..168b07b5887 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 11b92796b28..e3344278a92 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;
 
 const TargetInfo *target_info(void);
diff --git a/include/qemu/target_info.h b/include/qemu/target_info.h
index 3f6cbbbd300..c67b97d66f3 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 d8a0fe713c9..8fb18f82e20 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 f15972c5b22..14e6d5e68d2 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 48c4a413326..1de4334ecc5 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-18 17:31 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 17:28 [RFC PATCH v3 00/14] single-binary: Make hw/arm/ common Philippe Mathieu-Daudé
2025-04-18 17:28 ` [RFC PATCH v3 01/14] qapi: Rename TargetInfo structure as BinaryTargetInfo Philippe Mathieu-Daudé
2025-04-18 17:33   ` Philippe Mathieu-Daudé
2025-04-21 15:47   ` Richard Henderson
2025-04-22  5:55   ` Markus Armbruster
2025-04-22  7:35     ` Philippe Mathieu-Daudé
2025-04-22  9:10       ` Markus Armbruster
2025-04-22  9:18         ` Philippe Mathieu-Daudé
2025-04-22 12:29         ` BALATON Zoltan
2025-04-22 17:37       ` Pierrick Bouvier
2025-04-18 17:28 ` [RFC PATCH v3 02/14] qemu: Convert target_name() to TargetInfo API Philippe Mathieu-Daudé
2025-04-21 15:56   ` Richard Henderson
2025-04-22  7:44     ` Philippe Mathieu-Daudé
2025-04-18 17:28 ` Philippe Mathieu-Daudé [this message]
2025-04-19  0:57   ` [RFC PATCH v3 03/14] system/vl: Filter machine list available for a particular target binary Pierrick Bouvier
2025-04-18 17:28 ` [RFC PATCH v3 04/14] hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces Philippe Mathieu-Daudé
2025-04-19  0:58   ` Pierrick Bouvier
2025-04-18 17:28 ` [RFC PATCH v3 05/14] hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine Philippe Mathieu-Daudé
2025-04-19  0:59   ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 06/14] hw/arm: Filter machine types for qemu-system-arm/aarch64 binaries Philippe Mathieu-Daudé
2025-04-19  0:59   ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 07/14] meson: Prepare to accept per-binary TargetInfo structure implementation Philippe Mathieu-Daudé
2025-04-19  0:59   ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 08/14] config/target: Implement per-binary TargetInfo structure (ARM, AARCH64) Philippe Mathieu-Daudé
2025-04-19  1:00   ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 09/14] hw/arm/aspeed: Build objects once Philippe Mathieu-Daudé
2025-04-18 17:29 ` [RFC PATCH v3 10/14] hw/arm/raspi: " Philippe Mathieu-Daudé
2025-04-18 17:29 ` [RFC PATCH v3 11/14] hw/core/machine: Allow dynamic registration of valid CPU types Philippe Mathieu-Daudé
2025-04-19  1:16   ` Pierrick Bouvier
2025-04-19  1:49     ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 12/14] hw/arm/virt: Register valid CPU types dynamically Philippe Mathieu-Daudé
2025-04-18 17:29 ` [RFC PATCH v3 13/14] qemu/target_info: Add target_aarch64() helper Philippe Mathieu-Daudé
2025-04-19  1:09   ` Pierrick Bouvier
2025-04-19 12:54     ` Philippe Mathieu-Daudé
2025-04-19 15:52       ` Pierrick Bouvier
2025-04-22  6:04         ` Markus Armbruster
2025-04-22 17:50           ` Pierrick Bouvier
2025-04-22 18:24             ` Markus Armbruster
2025-04-22 18:49               ` Pierrick Bouvier
2025-04-18 17:29 ` [RFC PATCH v3 14/14] hw/arm/virt: Replace TARGET_AARCH64 -> target_aarch64() Philippe Mathieu-Daudé

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=20250418172908.25147-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 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.