Skip to contentSkip to conversation

cpus: Convert cpu_list definition to CPUClass:list_cpus callback

PATCH In review Philippe Mathieu-Daudé 5 participants 22 messages Mar 24, 2025 – Apr 17, 2025

lore
Share & tools
lore
#0 lore raw

v3 cover cpus: Convert cpu_list definition to CPUClass:list_cpus callback

Since v2
- Added R-b tags
- Added missing s390x hunk

Since v1 (Thomas review comments)
- Move s390_set_qemu_cpu_model/s390_cpu_list to "cpu_models.h"
- Correct 'target/s390x: Register CPUClass:list_cpus' subject

'cpu_list' might be defined per target, and force code to be built per-target. We can avoid that by introducing a CPUClass callback.

This series combined with another which converts CPU_RESOLVING_TYPE to a runtime helper, allows to move most of cpu-target to common.

Based-on: <[email protected]>

Philippe Mathieu-Daudé (7):
cpus: Introduce CPUClass::list_cpus() callback target/i386: Register CPUClass:list_cpus
target/ppc: Register CPUClass:list_cpus
target/sparc: Register CPUClass:list_cpus
target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h target/s390x: Register CPUClass:list_cpus
cpus: Remove #ifdef check on cpu_list definition

 include/hw/core/cpu.h      |  2 ++
 target/i386/cpu.h          |  3 ---
 target/ppc/cpu.h           |  4 ----
 target/s390x/cpu.h         |  7 -------
 target/s390x/cpu_models.h  |  3 +++
 target/sparc/cpu.h         |  3 ---
 cpu-target.c               | 25 ++++++++++++-------------
 hw/s390x/s390-virtio-ccw.c |  2 +-
 target/i386/cpu.c          |  3 ++-
 target/ppc/cpu_init.c      |  3 ++-
 target/s390x/cpu.c         |  1 +
 target/sparc/cpu.c         |  3 ++-
 12 files changed, 25 insertions(+), 34 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH v3 1/7 cpus: Introduce CPUClass::list_cpus() callback

Some targets define cpu_list to a method listing their CPUs on stdout. In order to make list_cpus() generic, introduce the CPUClass::list_cpus() callback. When no callback is registered, list_cpus() defaults to the cpu_list definition.

---
 include/hw/core/cpu.h | 2 ++
 cpu-target.c          | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
include/hw/core/cpu.h +2 -0
index 5d11d26556a..ccfcd3eb3a6 100644
@@ -102,6 +102,7 @@ struct SysemuCPUOps;
  * CPUClass:
  * @class_by_name: Callback to map -cpu command line model name to an
  *                 instantiatable CPU type.
+ * @list_cpus: list available CPU models and flags.
  * @parse_features: Callback to parse command line arguments.
  * @reset_dump_flags: #CPUDumpFlags to use for reset logging.
  * @mmu_index: Callback for choosing softmmu mmu index;
@@ -150,6 +151,7 @@ struct CPUClass {
     /*< public >*/
 
     ObjectClass *(*class_by_name)(const char *cpu_model);
+    void (*list_cpus)(void);
     void (*parse_features)(const char *typename, char *str, Error **errp);
 
     int (*mmu_index)(CPUState *cpu, bool ifetch);
cpu-target.c +7 -1
index cae77374b38..5947ca31a0a 100644
@@ -98,7 +98,13 @@ static void cpu_list(void)
 
 void list_cpus(void)
 {
-    cpu_list();
+    CPUClass *cc = CPU_CLASS(object_class_by_name(CPU_RESOLVING_TYPE));
+
+    if (cc->list_cpus) {
+        cc->list_cpus();
+    } else {
+        cpu_list();
+    }
 }
 
 /* enable or disable single step mode. EXCP_DEBUG is returned by the
Signature · 1 line
2.47.1
Reviewed-by on v3 1/7
#2 lore raw

Re: [PATCH v3 1/7] cpus: Introduce CPUClass::list_cpus() callback

Quoted 11 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:31 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 1/7] cpus: Introduce CPUClass::list_cpus() callback
X-Mailer: git-send-email 2.47.1

Some targets define cpu_list to a method listing their CPUs on stdout. In order to make list_cpus() generic, introduce the CPUClass::list_cpus() callback. When no callback is registered, list_cpus() defaults to the cpu_list definition.

Quoted 7 lines
---
 include/hw/core/cpu.h | 2 ++
 cpu-target.c          | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
#3 lore raw

PATCH v3 2/7 target/i386: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé

Register x86_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

---
 target/i386/cpu.h | 3 ---
 target/i386/cpu.c | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)
target/i386/cpu.h +0 -3
index 76f24446a55..28011eff0a8 100644
@@ -2367,7 +2367,6 @@ int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void x86_cpu_gdb_init(CPUState *cs);
 
-void x86_cpu_list(void);
 int cpu_x86_support_mca_broadcast(CPUX86State *env);
 
 #ifndef CONFIG_USER_ONLY
@@ -2561,8 +2560,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")
 #endif
 
-#define cpu_list x86_cpu_list
-
 /* MMU modes definitions */
 #define MMU_KSMAP64_IDX    0
 #define MMU_KSMAP32_IDX    1
target/i386/cpu.c +2 -1
index 1b64ceaaba4..1f502587c96 100644
@@ -6305,7 +6305,7 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data)
 }
 
 /* list available CPU models and flags */
-void x86_cpu_list(void)
+static void x86_cpu_list(void)
 {
     int i, j;
     GSList *list;
@@ -8924,6 +8924,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP;
 
     cc->class_by_name = x86_cpu_class_by_name;
+    cc->list_cpus = x86_cpu_list;
     cc->parse_features = x86_cpu_parse_featurestr;
     cc->mmu_index = x86_cpu_mmu_index;
     cc->dump_state = x86_cpu_dump_state;
Signature · 1 line
2.47.1
Reviewed-by on v3 2/7
#4 lore raw

Re: [PATCH v3 2/7] target/i386: Register CPUClass:list_cpus

Quoted 8 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:32 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 2/7] target/i386: Register CPUClass:list_cpus
X-Mailer: git-send-email 2.47.1

Register x86_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

Quoted 7 lines
---
 target/i386/cpu.h | 3 ---
 target/i386/cpu.c | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)
#5 lore raw

PATCH v3 3/7 target/ppc: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé

Register ppc_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

---
 target/ppc/cpu.h      | 4 ----
 target/ppc/cpu_init.c | 3 ++-
 2 files changed, 2 insertions(+), 5 deletions(-)
target/ppc/cpu.h +0 -4
index efab54a0683..0062579ef3e 100644
@@ -1597,8 +1597,6 @@ void ppc_store_dawrx1(CPUPPCState *env, uint32_t value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr(CPUPPCState *env, target_ulong value);
 
-void ppc_cpu_list(void);
-
 /* Time-base and decrementer management */
 uint64_t cpu_ppc_load_tbl(CPUPPCState *env);
 uint32_t cpu_ppc_load_tbu(CPUPPCState *env);
@@ -1660,8 +1658,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
 int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
 int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 
-#define cpu_list ppc_cpu_list
-
 /* MMU modes definitions */
 #define MMU_USER_IDX 0
 static inline int ppc_env_mmu_index(CPUPPCState *env, bool ifetch)
target/ppc/cpu_init.c +2 -1
index 8b590e7f17c..0ccb9068c89 100644
@@ -7184,7 +7184,7 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
     g_free(name);
 }
 
-void ppc_cpu_list(void)
+static void ppc_cpu_list(void)
 {
     GSList *list;
 
@@ -7525,6 +7525,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
                                        &pcc->parent_phases);
 
     cc->class_by_name = ppc_cpu_class_by_name;
+    cc->list_cpus = ppc_cpu_list;
     cc->mmu_index = ppc_cpu_mmu_index;
     cc->dump_state = ppc_cpu_dump_state;
     cc->set_pc = ppc_cpu_set_pc;
Signature · 1 line
2.47.1
Reviewed-by on v3 3/7
#6 lore raw

Re: [PATCH v3 3/7] target/ppc: Register CPUClass:list_cpus

Quoted 8 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:33 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 3/7] target/ppc: Register CPUClass:list_cpus
X-Mailer: git-send-email 2.47.1

Register ppc_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

Quoted 7 lines
---
 target/ppc/cpu.h      | 4 ----
 target/ppc/cpu_init.c | 3 ++-
 2 files changed, 2 insertions(+), 5 deletions(-)
#7 lore raw

PATCH v3 4/7 target/sparc: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé

Register sparc_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

---
 target/sparc/cpu.h | 3 ---
 target/sparc/cpu.c | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)
target/sparc/cpu.h +0 -3
index 462bcb6c0e6..7c6296ae70e 100644
@@ -594,7 +594,6 @@ G_NORETURN void cpu_raise_exception_ra(CPUSPARCState *, int, uintptr_t);
 
 /* cpu_init.c */
 void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu);
-void sparc_cpu_list(void);
 /* mmu_helper.c */
 bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                         MMUAccessType access_type, int mmu_idx,
@@ -665,8 +664,6 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
 
 #define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
 
-#define cpu_list sparc_cpu_list
-
 /* MMU modes definitions */
 #if defined (TARGET_SPARC64)
 #define MMU_USER_IDX   0
target/sparc/cpu.c +2 -1
index 57161201173..635d5d81143 100644
@@ -579,7 +579,7 @@ static void print_features(uint32_t features, const char *prefix)
     }
 }
 
-void sparc_cpu_list(void)
+static void sparc_cpu_list(void)
 {
     unsigned int i;
 
@@ -1031,6 +1031,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)
                                        &scc->parent_phases);
 
     cc->class_by_name = sparc_cpu_class_by_name;
+    cc->list_cpus = sparc_cpu_list,
     cc->parse_features = sparc_cpu_parse_features;
     cc->mmu_index = sparc_cpu_mmu_index;
     cc->dump_state = sparc_cpu_dump_state;
Signature · 1 line
2.47.1
Reviewed-by on v3 4/7
#8 lore raw

Re: [PATCH v3 4/7] target/sparc: Register CPUClass:list_cpus

Quoted 8 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:34 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 4/7] target/sparc: Register CPUClass:list_cpus
X-Mailer: git-send-email 2.47.1

Register sparc_cpu_list() as CPUClass:list_cpus callback. Reduce its scope and remove the cpu_list definition.

Quoted 7 lines
---
 target/sparc/cpu.h | 3 ---
 target/sparc/cpu.c | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)
#9 lore raw

PATCH v3 5/7 target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h

In reply to Philippe Mathieu-Daudé

Both s390_cpu_list() and s390_set_qemu_cpu_model() are defined in cpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header in s390-virtio-ccw.c file.

---
 target/s390x/cpu.h         | 4 ----
 target/s390x/cpu_models.h  | 3 +++
 hw/s390x/s390-virtio-ccw.c | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)
target/s390x/cpu.h +0 -4
index 5b7992deda6..8dd1936e3e2 100644
@@ -900,11 +900,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)
 }
 
 
-/* cpu_models.c */
-void s390_cpu_list(void);
 #define cpu_list s390_cpu_list
-void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
-                             const S390FeatInit feat_init);
 
 
 /* helper.c */
target/s390x/cpu_models.h +3 -0
index 71d4bc2dd4a..f701bc0b532 100644
@@ -113,6 +113,9 @@ static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model)
 }
 S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
                                     S390FeatBitmap features);
+void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
+                             const S390FeatInit feat_init);
+void s390_cpu_list(void);
 
 bool kvm_s390_cpu_models_supported(void);
 bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp);
hw/s390x/s390-virtio-ccw.c +1 -1
index 75b32182eb0..4f11c75b625 100644
@@ -35,7 +35,7 @@
 #include "hw/s390x/css-bridge.h"
 #include "hw/s390x/ap-bridge.h"
 #include "migration/register.h"
-#include "cpu_models.h"
+#include "target/s390x/cpu_models.h"
 #include "hw/nmi.h"
 #include "hw/qdev-properties.h"
 #include "hw/s390x/tod.h"
Signature · 1 line
2.47.1
Reviewed-by on v3 5/7
#10 lore raw

Re: [PATCH v3 5/7] target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h

Quoted 48 lines · Philippe Mathieu-Daudé

Both s390_cpu_list() and s390_set_qemu_cpu_model() are defined in cpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header in s390-virtio-ccw.c file.

---
  target/s390x/cpu.h         | 4 ----
  target/s390x/cpu_models.h  | 3 +++
  hw/s390x/s390-virtio-ccw.c | 2 +-
  3 files changed, 4 insertions(+), 5 deletions(-)
target/s390x/cpu.h +0 -4
index 5b7992deda6..8dd1936e3e2 100644
@@ -900,11 +900,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)
  }
 
 
-/* cpu_models.c */
-void s390_cpu_list(void);
  #define cpu_list s390_cpu_list
-void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
-                             const S390FeatInit feat_init);
 
 
  /* helper.c */
target/s390x/cpu_models.h +3 -0
index 71d4bc2dd4a..f701bc0b532 100644
@@ -113,6 +113,9 @@ static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model)
  }
  S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
                                      S390FeatBitmap features);
+void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
+                             const S390FeatInit feat_init);
+void s390_cpu_list(void);
 
  bool kvm_s390_cpu_models_supported(void);
  bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp);
hw/s390x/s390-virtio-ccw.c +0 -0
index 75b32182eb0..4f11c75b625 100644

hw/s390x/s390-virtio-ccw.c line 41

Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -35,7 +35,7 @@
  #include "hw/s390x/css-bridge.h"
  #include "hw/s390x/ap-bridge.h"
  #include "migration/register.h"
-#include "cpu_models.h"
+#include "target/s390x/cpu_models.h"
  #include "hw/nmi.h"
  #include "hw/qdev-properties.h"
  #include "hw/s390x/tod.h"
Reviewed-by on v3 5/7
#11 lore raw

Re: [PATCH v3 5/7] target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:35 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 5/7] target/s390x: Declare
s390_set_qemu_cpu_model/cpu_list in cpu_models.h
X-Mailer: git-send-email 2.47.1

Both s390_cpu_list() and s390_set_qemu_cpu_model() are defined in cpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header in s390-virtio-ccw.c file.

Quoted 7 lines
---
 target/s390x/cpu.h         | 4 ----
 target/s390x/cpu_models.h  | 3 +++
 hw/s390x/s390-virtio-ccw.c | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)
Reviewed-by on v3 5/7
#12 lore raw

Re: [PATCH v3 5/7] target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h

In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Both s390_cpu_list() and s390_set_qemu_cpu_model() are defined in cpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header in s390-virtio-ccw.c file.

Quoted 7 lines
---
 target/s390x/cpu.h         | 4 ----
 target/s390x/cpu_models.h  | 3 +++
 hw/s390x/s390-virtio-ccw.c | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

(resending with reply-all)

#13 lore raw

PATCH v3 6/7 target/s390x: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
 target/s390x/cpu.h | 3 ---
 target/s390x/cpu.c | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)
target/s390x/cpu.h +0 -3
index 8dd1936e3e2..1012be35d25 100644
@@ -900,9 +900,6 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)
 }
 
 
-#define cpu_list s390_cpu_list
-
-
 /* helper.c */
 #define CPU_RESOLVING_TYPE TYPE_S390_CPU
 
target/s390x/cpu.c +1 -0
index 1f75629ddc2..ac05e82f0ac 100644
@@ -378,6 +378,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
                                        &scc->parent_phases);
 
     cc->class_by_name = s390_cpu_class_by_name;
+    cc->list_cpus = s390_cpu_list;
     cc->mmu_index = s390x_cpu_mmu_index;
     cc->dump_state = s390_cpu_dump_state;
     cc->query_cpu_fast = s390_query_cpu_fast;
Signature · 1 line
2.47.1
#14 lore raw

Re: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus

Quoted 8 lines · Philippe Mathieu-Daudé

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
  target/s390x/cpu.h | 3 ---
  target/s390x/cpu.c | 1 +
  2 files changed, 1 insertion(+), 3 deletions(-)

I really think this has to be merged with the previous. I strongly suspect that it either doesn't compile separately, or doesn't function as desired.

r~

#15 lore raw

Re: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus

Quoted 10 lines · Richard Henderson
Quoted 8 lines · Philippe Mathieu-Daudé

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
  target/s390x/cpu.h | 3 ---
  target/s390x/cpu.c | 1 +

  2 files changed, 1 insertion(+), 3 deletions(-)
Quoted 3 lines

I really think this has to be merged with the previous. I strongly suspect that it either doesn't compile separately, or doesn't function as desired.

It does compile, because "cpu.h" includes "cpu_models.h".

I don't mind squashing if Thomas is OK.

Thanks,

Phil.

Reviewed-by
#16 lore raw

Re: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus

Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Richard Henderson
Quoted 8 lines · Philippe Mathieu-Daudé

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
  target/s390x/cpu.h | 3 ---
  target/s390x/cpu.c | 1 +

  2 files changed, 1 insertion(+), 3 deletions(-)
Quoted 7 lines
Quoted 3 lines

I really think this has to be merged with the previous. I strongly suspect that it either doesn't compile separately, or doesn't function as desired.

It does compile, because "cpu.h" includes "cpu_models.h".

I don't mind squashing if Thomas is OK.

I don't mind either way!

Reviewed-by on v3 6/7
#17 lore raw

Re: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:36 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus
X-Mailer: git-send-email 2.47.1

Quoted 8 lines

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
 target/s390x/cpu.h | 3 ---
 target/s390x/cpu.c | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)
Reviewed-by on v3 6/7
#18 lore raw

Re: [PATCH v3 6/7] target/s390x: Register CPUClass:list_cpus

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Register s390_cpu_list() as CPUClass:list_cpus callback and remove the cpu_list definition.

---
 target/s390x/cpu.h | 3 ---
 target/s390x/cpu.c | 1 +
 2 files changed, 1 insertion(+), 3 deletions(-)

Fine squashed with patch 5 or not...

#19 lore raw

PATCH v3 7/7 cpus: Remove #ifdef check on cpu_list definition

In reply to Philippe Mathieu-Daudé

Since we removed all definitions of cpu_list, the #ifdef check is always true. Remove it, inlining cpu_list().

---
 cpu-target.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
cpu-target.c +6 -13
index 5947ca31a0a..30598619581 100644
@@ -71,7 +71,6 @@ const char *parse_cpu_option(const char *cpu_option)
     return cpu_type;
 }
 
-#ifndef cpu_list
 static void cpu_list_entry(gpointer data, gpointer user_data)
 {
     CPUClass *cc = CPU_CLASS(OBJECT_CLASS(data));
@@ -85,17 +84,6 @@ static void cpu_list_entry(gpointer data, gpointer user_data)
     }
 }
 
-static void cpu_list(void)
-{
-    GSList *list;
-
-    list = object_class_get_list_sorted(TYPE_CPU, false);
-    qemu_printf("Available CPUs:\n");
-    g_slist_foreach(list, cpu_list_entry, NULL);
-    g_slist_free(list);
-}
-#endif
-
 void list_cpus(void)
 {
     CPUClass *cc = CPU_CLASS(object_class_by_name(CPU_RESOLVING_TYPE));
@@ -103,7 +91,12 @@ void list_cpus(void)
     if (cc->list_cpus) {
         cc->list_cpus();
     } else {
-        cpu_list();
+        GSList *list;
+
+        list = object_class_get_list_sorted(TYPE_CPU, false);
+        qemu_printf("Available CPUs:\n");
+        g_slist_foreach(list, cpu_list_entry, NULL);
+        g_slist_free(list);
     }
 }
 
Signature · 1 line
2.47.1
Reviewed-by on v3 7/7
#20 lore raw

Re: [PATCH v3 7/7] cpus: Remove #ifdef check on cpu_list definition

Quoted 8 lines · Philippe Mathieu-Daudé

Date: Mon, 24 Mar 2025 19:58:37 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH v3 7/7] cpus: Remove #ifdef check on cpu_list definition
X-Mailer: git-send-email 2.47.1

Since we removed all definitions of cpu_list, the #ifdef check is always true. Remove it, inlining cpu_list().

Quoted 6 lines
---
 cpu-target.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
#21 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Based-on: <[email protected]>

Philippe Mathieu-Daudé (7):
cpus: Introduce CPUClass::list_cpus() callback target/i386: Register CPUClass:list_cpus
target/ppc: Register CPUClass:list_cpus
target/sparc: Register CPUClass:list_cpus
target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h

While this patch builds correctly, I'm squashing it with next one as suggested by Richard, and queuing the whole series.

Thanks all for the reviews!

Quoted 2 lines

target/s390x: Register CPUClass:list_cpus
cpus: Remove #ifdef check on cpu_list definition