From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Thomas Huth" <thuth@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Subject: [PATCH v3 1/5] qemu/target-info: Factor target_system_arch() out
Date: Fri, 2 May 2025 23:45:47 +0200 [thread overview]
Message-ID: <20250502214551.80401-2-philmd@linaro.org> (raw)
In-Reply-To: <20250502214551.80401-1-philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/target-info.h | 9 +++++++++
hw/core/machine-qmp-cmds.c | 6 ++----
target-info.c | 12 ++++++++++++
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 850a2958b9c..87b4b0e0cbb 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -9,6 +9,8 @@
#ifndef QEMU_TARGET_INFO_H
#define QEMU_TARGET_INFO_H
+#include "qapi/qapi-types-machine.h"
+
/**
* target_name:
*
@@ -16,6 +18,13 @@
*/
const char *target_name(void);
+/**
+ * target_system_arch:
+ *
+ * Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_I386).
+ */
+SysEmuTarget target_system_arch(void);
+
/**
* target_long_bits:
*
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index d82043e1c68..8f491dba441 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -37,8 +37,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
MachineState *ms = MACHINE(qdev_get_machine());
MachineClass *mc = MACHINE_GET_CLASS(ms);
CpuInfoFastList *head = NULL, **tail = &head;
- SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, target_name(),
- -1, &error_abort);
+ SysEmuTarget target = target_system_arch();
CPUState *cpu;
CPU_FOREACH(cpu) {
@@ -139,8 +138,7 @@ QemuTargetInfo *qmp_query_target(Error **errp)
{
QemuTargetInfo *info = g_malloc0(sizeof(*info));
- info->arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
- &error_abort);
+ info->arch = target_system_arch();
return info;
}
diff --git a/target-info.c b/target-info.c
index 16fdca7aaaf..8232d488870 100644
--- a/target-info.c
+++ b/target-info.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "qemu/target-info.h"
#include "qemu/target-info-impl.h"
+#include "qapi/error.h"
const char *target_name(void)
{
@@ -20,6 +21,17 @@ unsigned target_long_bits(void)
return target_info()->long_bits;
}
+SysEmuTarget target_system_arch(void)
+{
+ static SysEmuTarget system_arch = SYS_EMU_TARGET__MAX;
+
+ if (system_arch == SYS_EMU_TARGET__MAX) {
+ system_arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
+ &error_abort);
+ }
+ return system_arch;
+}
+
const char *target_cpu_type(void)
{
return target_info()->cpu_type;
--
2.47.1
next prev parent reply other threads:[~2025-05-02 21:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 21:45 [PATCH v3 0/5] hw/virtio: Build virtio-mem.c once Philippe Mathieu-Daudé
2025-05-02 21:45 ` Philippe Mathieu-Daudé [this message]
2025-05-04 21:16 ` [PATCH v3 1/5] qemu/target-info: Factor target_system_arch() out Pierrick Bouvier
2025-05-02 21:45 ` [PATCH v3 2/5] qemu/target-info: Add %target_arch field to TargetInfo Philippe Mathieu-Daudé
2025-05-04 21:21 ` Pierrick Bouvier
2025-05-02 21:45 ` [PATCH v3 3/5] hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime Philippe Mathieu-Daudé
2025-05-04 21:17 ` Pierrick Bouvier
2025-05-05 7:02 ` David Hildenbrand
2025-05-02 21:45 ` [PATCH v3 4/5] hw/virtio/virtio-mem: Convert VIRTIO_MEM_HAS_LEGACY_GUESTS " Philippe Mathieu-Daudé
2025-05-04 21:18 ` Pierrick Bouvier
2025-05-05 7:03 ` David Hildenbrand
2025-05-02 21:45 ` [PATCH v3 5/5] hw/virtio: Compile virtio-mem.c once Philippe Mathieu-Daudé
2025-05-04 21:18 ` Pierrick Bouvier
2025-05-05 7:04 ` David Hildenbrand
2025-05-11 18:39 ` [PATCH v3 0/5] hw/virtio: Build " Michael S. Tsirkin
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=20250502214551.80401-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).