All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Yonggang Luo" <luoyonggang@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 02/48] target-info: add target_mask_selected()
Date: Thu, 12 Nov 2026 13:30:08 +0000	[thread overview]
Message-ID: <20261112133054.1977618-3-berrange@redhat.com> (raw)
In-Reply-To: <20261112133054.1977618-1-berrange@redhat.com>

From: Yonggang Luo <luoyonggang@gmail.com>

Return the QEMU_ARCH_* mask of the selected target. System mode
returns QEMU_ARCH_ALL until a target is selected. User mode returns
that target's bit. Tools return 0.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 include/qemu/target-info-init.h | 15 ++++++++++-----
 include/qemu/target-info.h      |  9 +++++++++
 stubs/meson.build               |  1 +
 stubs/target-mask-selected.c    | 13 +++++++++++++
 target-info-def.c               |  3 +++
 target-info-qom.c               | 10 ++++++++++
 6 files changed, 46 insertions(+), 5 deletions(-)
 create mode 100644 stubs/target-mask-selected.c

diff --git a/include/qemu/target-info-init.h b/include/qemu/target-info-init.h
index b7024c9faef..84929868328 100644
--- a/include/qemu/target-info-init.h
+++ b/include/qemu/target-info-init.h
@@ -24,12 +24,17 @@ module_init(do_qemu_init_target_info, MODULE_INIT_TARGET_INFO)
 
 /*
  * User mode does not support multiple targets in the same binary, so just
- * define target_info().
+ * define target_info() and target_mask_selected(). The target is always
+ * selected.
  */
-#define target_info_init(ti_var)        \
-const TargetInfo *target_info(void)     \
-{                                       \
-    return &ti_var;                     \
+#define target_info_init(ti_var)                           \
+const TargetInfo *target_info(void)                        \
+{                                                          \
+    return &ti_var;                                        \
+}                                                          \
+uint64_t target_mask_selected(void)                        \
+{                                                          \
+    return QEMU_ARCH_BIT((ti_var).target_arch);            \
 }
 
 #else /* CONFIG_USER_ONLY */
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 2cd4cc5671b..5673d10ebae 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -134,4 +134,13 @@ bool target_base_riscv(void);
  */
 bool target_riscv64(void);
 
+/**
+ * target_mask_selected:
+ *
+ * Returns the QEMU_ARCH_* mask of the selected target. System mode
+ * returns QEMU_ARCH_ALL until a target is selected. User mode returns
+ * that target's bit. Tools return 0.
+ */
+uint64_t target_mask_selected(void);
+
 #endif
diff --git a/stubs/meson.build b/stubs/meson.build
index 744fb759a2f..49cede8582f 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -12,6 +12,7 @@ stub_ss.add(files('monitor-hmp.c'))
 stub_ss.add(files('qapi-event-emit.c'))
 stub_ss.add(files('replay-mode.c'))
 stub_ss.add(files('trace-control.c'))
+stub_ss.add(files('target-mask-selected.c'))
 
 if have_block
   stub_ss.add(files('bdrv-next-monitor-owned.c'))
diff --git a/stubs/target-mask-selected.c b/stubs/target-mask-selected.c
new file mode 100644
index 00000000000..510a515851c
--- /dev/null
+++ b/stubs/target-mask-selected.c
@@ -0,0 +1,13 @@
+/*
+ * Tools have no selected target.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/target-info.h"
+
+uint64_t target_mask_selected(void)
+{
+    return 0;
+}
diff --git a/target-info-def.c b/target-info-def.c
index bcf9cfe1e43..a9920196266 100644
--- a/target-info-def.c
+++ b/target-info-def.c
@@ -9,6 +9,9 @@
 #include "qemu/osdep.h"
 #include "qemu/target-info.h"
 #include "qemu/target-info-def.h"
+#ifdef CONFIG_USER_ONLY
+#include "qemu/base-arch-defs.h"
+#endif
 #include "qemu/target-info-init.h"
 #include "hw/core/boards.h"
 #include "cpu.h"
diff --git a/target-info-qom.c b/target-info-qom.c
index aeeedb7e818..fb4c9835e5a 100644
--- a/target-info-qom.c
+++ b/target-info-qom.c
@@ -9,6 +9,8 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qom/object.h"
+#include "qemu/base-arch-defs.h"
+#include "qemu/target-info.h"
 #include "qemu/target-info-def.h"
 #include "qemu/target-info-init.h"
 #include "qemu/target-info-qom.h"
@@ -40,6 +42,14 @@ const TargetInfo *target_info(void)
     return target_info_ptr;
 }
 
+uint64_t target_mask_selected(void)
+{
+    if (!target_info_ptr) {
+        return QEMU_ARCH_ALL;
+    }
+    return QEMU_ARCH_BIT(target_info_ptr->target_arch);
+}
+
 void target_info_qom_set_target(void)
 {
     g_autoptr(GSList) targets = object_class_get_list(TYPE_TARGET_INFO, false);
-- 
2.56.1



  parent reply	other threads:[~2026-11-12 13:36 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 13:30 [PATCH 00/48] hw: resolve QOM type conflicts in multi-target builds Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 01/48] iotests: better heuristics to find I/O tests build/source dirs Daniel P. Berrangé
2026-11-12 13:30 ` Daniel P. Berrangé [this message]
2026-11-12 13:30 ` [PATCH 03/48] qom: define a TargetSpecific interface Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 04/48] qom: define an Aliased interface Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 05/48] hw: tweak approach to setting alias in machine macros Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 06/48] hw/core: implement TYPE_ALIASED interface in machines Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 07/48] qapi: report multiple aliases in MachineInfo Daniel P. Berrangé
2026-11-13  7:41   ` Markus Armbruster
2026-11-12 13:30 ` [PATCH 08/48] system: report multiple machine aliases in help output Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 09/48] system: increase space for machine name in '-machine help' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 10/48] system: resolve multiple aliases when creating machines Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 11/48] qapi: deprecate 'alias' field in MachineInfo Daniel P. Berrangé
2026-11-13  7:51   ` Markus Armbruster
2026-11-12 13:30 ` [PATCH 12/48] hw/arm: convert machines to use AliasedClass interface Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 13/48] hw/avr: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 14/48] hw/hexagon: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 15/48] hw/i386: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 16/48] hw/loongarch: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 17/48] hw/m68k: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 18/48] hw/ppc: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 19/48] hw/s390x: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 20/48] include/hw: convert machine docs " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 21/48] hw: drop 'alias' field from MachineClass Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 22/48] hw/arm: rename the 'virt' machines to 'arm-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 23/48] hw/riscv: rename the 'virt' machines to 'riscv-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 24/48] hw/hexagon: rename the 'virt' machine to 'hexagon-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 25/48] hw/loongarch: rename the 'virt' machine to 'loongarch-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 26/48] hw/m68k: rename the 'virt' machine to 'm68k-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 27/48] hw/or1k: rename the 'virt' machine to 'or1k-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 28/48] hw/xtensa: rename the 'virt' machine to 'xtensa-virt' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 29/48] system: stop sorting machine names based on 'family' Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 30/48] system: put machine aliases in alphbetical order Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 31/48] system: filter machine type list if a target is selected Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 32/48] hw/core: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 33/48] system: filter machines based on target during creation Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 34/48] hw/core: implement TYPE_TARGET_SPECIFIC for machine Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 35/48] qapi: report target compatibility for machine types Daniel P. Berrangé
2026-11-13  7:53   ` Markus Armbruster
2026-11-12 13:30 ` [PATCH 36/48] hw/arm: declare arm machine targets Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 37/48] hw/hexagon: declare hexagon machine target Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 38/48] hw/m68k: declare m68k " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 39/48] hw/or1k: declare or1k " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 40/48] hw/riscv: declare riscv " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 41/48] accel: make TYPE_ACCEL_CPU name target independent Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 42/48] Revert "multi-target: restrict whpx-accel-*-cpu to matching target" Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 43/48] Revert "target/riscv/kvm: restrict kvm-accel-riscv-cpu to riscv targets" Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 44/48] Revert "target/riscv/tcg: restrict tcg-accel-riscv-cpu " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 45/48] qom: drop the 'is_available' callback from TypeInfo Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 46/48] hw/pci: unconditionally expose the 'loadparm' property Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 47/48] hw/scsi: " Daniel P. Berrangé
2026-11-12 13:30 ` [PATCH 48/48] hw/virtio/virtio-mem: unconditionally expose 'unplugged-inaccessible' Daniel P. Berrangé
2026-11-12 15:08 ` [PATCH 00/48] hw: resolve QOM type conflicts in multi-target builds Yonggang Luo

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=20261112133054.1977618-3-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=luoyonggang@gmail.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.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.