diff mbox series

[RFC,PATCH-for-10.1,02/19] qemu: Convert target_name() to TargetInfo API

Message ID 20250403234914.9154-3-philmd@linaro.org
State New
Headers show
Series qemu: Introduce TargetInfo API (for single binary) | expand

Commit Message

Philippe Mathieu-Daudé April 3, 2025, 11:48 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/cpu.h           | 2 --
 include/qemu/target_info-impl.h | 3 +++
 include/qemu/target_info.h      | 2 ++
 cpu-target.c                    | 5 -----
 hw/core/machine-qmp-cmds.c      | 1 +
 plugins/loader.c                | 2 +-
 system/vl.c                     | 2 +-
 target_info-stub.c              | 1 +
 target_info.c                   | 5 +++++
 9 files changed, 14 insertions(+), 9 deletions(-)

Comments

Pierrick Bouvier April 4, 2025, 4:42 p.m. UTC | #1
On 4/3/25 16:48, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/core/cpu.h           | 2 --
>   include/qemu/target_info-impl.h | 3 +++
>   include/qemu/target_info.h      | 2 ++
>   cpu-target.c                    | 5 -----
>   hw/core/machine-qmp-cmds.c      | 1 +
>   plugins/loader.c                | 2 +-
>   system/vl.c                     | 2 +-
>   target_info-stub.c              | 1 +
>   target_info.c                   | 5 +++++
>   9 files changed, 14 insertions(+), 9 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 5b645df59f5..9d9448341d1 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1115,8 +1115,6 @@  bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
 void cpu_exec_unrealizefn(CPUState *cpu);
 void cpu_exec_reset_hold(CPUState *cpu);
 
-const char *target_name(void);
-
 #ifdef COMPILING_PER_TARGET
 
 extern const VMStateDescription vmstate_cpu_common;
diff --git a/include/qemu/target_info-impl.h b/include/qemu/target_info-impl.h
index b340e192fce..00bb746572b 100644
--- a/include/qemu/target_info-impl.h
+++ b/include/qemu/target_info-impl.h
@@ -16,6 +16,9 @@  struct BinaryTargetInfo {
     /* runtime equivalent of TARGET_INFO_STUB_NEEDED definition */
     bool is_stub;
 
+    /* runtime equivalent of TARGET_NAME definition */
+    const char *const name;
+
 };
 
 #endif
diff --git a/include/qemu/target_info.h b/include/qemu/target_info.h
index fab3f3153ea..5b8f17a15a3 100644
--- a/include/qemu/target_info.h
+++ b/include/qemu/target_info.h
@@ -15,4 +15,6 @@  const BinaryTargetInfo *target_info(void);
 
 bool target_info_is_stub(void);
 
+const char *target_name(void);
+
 #endif
diff --git a/cpu-target.c b/cpu-target.c
index c99d208a7c4..3f82d3ea444 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -165,8 +165,3 @@  bool target_words_bigendian(void)
 {
     return TARGET_BIG_ENDIAN;
 }
-
-const char *target_name(void)
-{
-    return TARGET_NAME;
-}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3130c5cd456..6701e210f54 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -19,6 +19,7 @@ 
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/type-helpers.h"
 #include "qemu/uuid.h"
+#include "qemu/target_info.h"
 #include "qom/qom-qobject.h"
 #include "system/hostmem.h"
 #include "system/hw_accel.h"
diff --git a/plugins/loader.c b/plugins/loader.c
index 7523d554f03..36a4e88d4db 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -29,7 +29,7 @@ 
 #include "qemu/xxhash.h"
 #include "qemu/plugin.h"
 #include "qemu/memalign.h"
-#include "hw/core/cpu.h"
+#include "qemu/target_info.h"
 #include "exec/tb-flush.h"
 
 #include "plugin.h"
diff --git a/system/vl.c b/system/vl.c
index c17945c4939..d8a0fe713c9 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -40,6 +40,7 @@ 
 #include "qemu/help_option.h"
 #include "qemu/hw-version.h"
 #include "qemu/uuid.h"
+#include "qemu/target_info.h"
 #include "system/reset.h"
 #include "system/runstate.h"
 #include "system/runstate-action.h"
@@ -79,7 +80,6 @@ 
 #include "hw/block/block.h"
 #include "hw/i386/x86.h"
 #include "hw/i386/pc.h"
-#include "hw/core/cpu.h"
 #include "migration/cpr.h"
 #include "migration/misc.h"
 #include "migration/snapshot.h"
diff --git a/target_info-stub.c b/target_info-stub.c
index d683a05977d..db61a335908 100644
--- a/target_info-stub.c
+++ b/target_info-stub.c
@@ -13,6 +13,7 @@ 
 
 static const BinaryTargetInfo target_info_stub = {
     .is_stub = true,
+    .name = TARGET_NAME,
 };
 
 const BinaryTargetInfo *target_info(void)
diff --git a/target_info.c b/target_info.c
index cb17d29b86d..6b44ea9fc0e 100644
--- a/target_info.c
+++ b/target_info.c
@@ -14,3 +14,8 @@  bool target_info_is_stub(void)
 {
     return target_info()->is_stub;
 }
+
+const char *target_name(void)
+{
+    return target_info()->name;
+}