Add a none target for when no TargetInfo is selected. It is last
so existing SYS_EMU_TARGET_* values stay put, and it is not a
qemu-system- executable name. target_is_none() and target_none()
report that state.

Signed-off-by: Yonggang Luo <[email protected]>
---
 include/qemu/target-info.h | 15 +++++++++++++++
 qapi/machine.json          | 13 +++++++++----
 target-info.c              | 10 ++++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index a5dcf60dd9e..812e4b04a7b 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -90,6 +90,21 @@ bool target_big_endian(void);
  */
 bool target_is_any(const TargetInfo *ti);
 
+/**
+ * target_is_none:
+ * @ti: TargetInfo to inspect
+ *
+ * Returns whether @ti is SYS_EMU_TARGET_NONE.
+ */
+bool target_is_none(const TargetInfo *ti);
+
+/**
+ * target_none:
+ *
+ * Returns: %true if the current TargetInfo is SYS_EMU_TARGET_NONE.
+ */
+bool target_none(void);
+
 /**
  * target_is_base_arm:
  * @ti: TargetInfo to inspect
diff --git a/qapi/machine.json b/qapi/machine.json
index b1be5608b61..6aaa2af709a 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -22,6 +22,10 @@
 # The individual target constants are not documented here, for the
 # time being.
 #
+# @none: no TargetInfo selected.  Not a qemu-system- executable name.
+#     Last enumerator so existing SYS_EMU_TARGET_* values stay put.
+#     (since 11.2)
+#
 # @rx: since 5.0
 #
 # @avr: since 5.1
@@ -30,9 +34,10 @@
 #
 # @hexagon: since 11.0
 #
-# .. note:: The resulting QMP strings can be appended to the
-#    "qemu-system-" prefix to produce the corresponding QEMU
-#    executable name.  This is true even for "qemu-system-x86_64".
+# .. note:: Except for ``none``, the resulting QMP strings can be
+#    appended to the "qemu-system-" prefix to produce the
+#    corresponding QEMU executable name.  This is true even for
+#    "qemu-system-x86_64".
 #
 # Since: 3.0
 ##
@@ -42,7 +47,7 @@
              'mips64el', 'mipsel', 'or1k', 'ppc',
              'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
              'sh4eb', 'sparc', 'sparc64', 'tricore',
-             'x86_64', 'xtensa', 'xtensaeb' ] }
+             'x86_64', 'xtensa', 'xtensaeb', 'none' ] }
 
 ##
 # @S390CpuState:
diff --git a/target-info.c b/target-info.c
index 1bdf3869605..b25e2ada438 100644
--- a/target-info.c
+++ b/target-info.c
@@ -112,6 +112,16 @@ bool target_is_any(const TargetInfo *ti)
     return true;
 }
 
+bool target_is_none(const TargetInfo *ti)
+{
+    return ti->target_arch == SYS_EMU_TARGET_NONE;
+}
+
+bool target_none(void)
+{
+    return target_is_none(target_info());
+}
+
 bool target_is_base_arm(const TargetInfo *ti)
 {
     switch (ti->target_arch) {
-- 
2.52.0.windows.1


Reply via email to