qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/core: Get default_cpu_type calling machine_class_default_cpu_type()
@ 2025-04-22  8:41 Philippe Mathieu-Daudé
  2025-04-24 15:37 ` Zhao Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-22  8:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Zhao Liu, Markus Armbruster, Philippe Mathieu-Daudé,
	Nicholas Piggin, Marcel Apfelbaum, Eduardo Habkost,
	Daniel Henrique Barboza, qemu-ppc, Yanan Wang, qemu-stable,
	Gavin Shan

Since commit 62b4a227a33 the default cpu type can come from the
valid_cpu_types[] array. Call the machine_class_default_cpu_type()
instead of accessing MachineClass::default_cpu_type field.

Cc: qemu-stable@nongnu.org
Fixes: 62b4a227a33 ("hw/core: Add machine_class_default_cpu_type()")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Cc: Gavin Shan <gshan@redhat.com>
---
 hw/core/machine-qmp-cmds.c | 5 +++--
 target/ppc/cpu_init.c      | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3130c5cd456..1bc21b84a4f 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -72,6 +72,7 @@ MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props,
 
     for (el = machines; el; el = el->next) {
         MachineClass *mc = el->data;
+        const char *default_cpu_type = machine_class_default_cpu_type(mc);
         MachineInfo *info;
 
         info = g_malloc0(sizeof(*info));
@@ -90,8 +91,8 @@ MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props,
         info->numa_mem_supported = mc->numa_mem_supported;
         info->deprecated = !!mc->deprecation_reason;
         info->acpi = !!object_class_property_find(OBJECT_CLASS(mc), "acpi");
-        if (mc->default_cpu_type) {
-            info->default_cpu_type = g_strdup(mc->default_cpu_type);
+        if (default_cpu_type) {
+            info->default_cpu_type = g_strdup(default_cpu_type);
         }
         if (mc->default_ram_id) {
             info->default_ram_id = g_strdup(mc->default_ram_id);
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index f81cb680fc3..21a76e904af 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7082,7 +7082,7 @@ ObjectClass *ppc_cpu_class_by_name(const char *name)
     if (strcmp(name, "max") == 0) {
         MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
         if (mc) {
-            return object_class_by_name(mc->default_cpu_type);
+            return object_class_by_name(machine_class_default_cpu_type(mc));
         }
     }
 #endif
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hw/core: Get default_cpu_type calling machine_class_default_cpu_type()
  2025-04-22  8:41 [PATCH] hw/core: Get default_cpu_type calling machine_class_default_cpu_type() Philippe Mathieu-Daudé
@ 2025-04-24 15:37 ` Zhao Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Zhao Liu @ 2025-04-24 15:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Markus Armbruster, Nicholas Piggin, Marcel Apfelbaum,
	Eduardo Habkost, Daniel Henrique Barboza, qemu-ppc, Yanan Wang,
	qemu-stable, Gavin Shan

On Tue, Apr 22, 2025 at 10:41:14AM +0200, Philippe Mathieu-Daudé wrote:
> Date: Tue, 22 Apr 2025 10:41:14 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH] hw/core: Get default_cpu_type calling
>  machine_class_default_cpu_type()
> X-Mailer: git-send-email 2.47.1
> 
> Since commit 62b4a227a33 the default cpu type can come from the
> valid_cpu_types[] array. Call the machine_class_default_cpu_type()
> instead of accessing MachineClass::default_cpu_type field.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: 62b4a227a33 ("hw/core: Add machine_class_default_cpu_type()")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Cc: Gavin Shan <gshan@redhat.com>
> ---
>  hw/core/machine-qmp-cmds.c | 5 +++--
>  target/ppc/cpu_init.c      | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-24 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22  8:41 [PATCH] hw/core: Get default_cpu_type calling machine_class_default_cpu_type() Philippe Mathieu-Daudé
2025-04-24 15:37 ` Zhao Liu

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).