Re: [PATCH-for-10.1 v7 3/8] qemu/target-info: Add %target_arch field to TargetInfo

2025-07-08 Thread Pierrick Bouvier

On 7/8/25 10:19 AM, Philippe Mathieu-Daudé wrote:

Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
  include/qemu/target-info-impl.h | 4 +++-
  target-info-stub.c  | 1 +
  target-info.c   | 9 +++--
  3 files changed, 11 insertions(+), 3 deletions(-)


Reviewed-by: Pierrick Bouvier 




[PATCH-for-10.1 v7 3/8] qemu/target-info: Add %target_arch field to TargetInfo

2025-07-08 Thread Philippe Mathieu-Daudé
Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/qemu/target-info-impl.h | 4 +++-
 target-info-stub.c  | 1 +
 target-info.c   | 9 +++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
index 1b51cbcfe1b..a8b34d150ab 100644
--- a/include/qemu/target-info-impl.h
+++ b/include/qemu/target-info-impl.h
@@ -9,11 +9,13 @@
 #ifndef QEMU_TARGET_INFO_IMPL_H
 #define QEMU_TARGET_INFO_IMPL_H
 
-#include "qemu/target-info.h"
+#include "qapi/qapi-types-machine.h"
 
 typedef struct TargetInfo {
 /* runtime equivalent of TARGET_NAME definition */
 const char *target_name;
+/* related to TARGET_ARCH definition */
+SysEmuTarget target_arch;
 /* runtime equivalent of TARGET_LONG_BITS definition */
 unsigned long_bits;
 /* runtime equivalent of CPU_RESOLVING_TYPE definition */
diff --git a/target-info-stub.c b/target-info-stub.c
index fecc0e71286..2e4407ff04b 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -14,6 +14,7 @@
 
 static const TargetInfo target_info_stub = {
 .target_name = TARGET_NAME,
+.target_arch = SYS_EMU_TARGET__MAX,
 .long_bits = TARGET_LONG_BITS,
 .cpu_type = CPU_RESOLVING_TYPE,
 .machine_typename = TYPE_MACHINE,
diff --git a/target-info.c b/target-info.c
index 9ebabec988f..8e29553b4ef 100644
--- a/target-info.c
+++ b/target-info.c
@@ -24,8 +24,13 @@ unsigned target_long_bits(void)
 
 SysEmuTarget target_arch(void)
 {
-return qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
-   &error_abort);
+SysEmuTarget arch = target_info()->target_arch;
+
+if (arch == SYS_EMU_TARGET__MAX) {
+arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
+   &error_abort);
+}
+return arch;
 }
 
 const char *target_cpu_type(void)
-- 
2.49.0