cpus: Convert cpu_list definition to CPUClass:list_cpus callback
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
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
@@ -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
@@ -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
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: IntroduceCPUClass::list_cpus()callback
X-Mailer: git-send-email 2.47.1Some targets define
cpu_listto a method listing their CPUs on stdout. In order to makelist_cpus()generic, introduce theCPUClass::list_cpus()callback. When no callback is registered,list_cpus()defaults to thecpu_listdefinition.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- include/hw/core/cpu.h | 2 ++ cpu-target.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
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
@@ -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
@@ -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
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.1Register
x86_cpu_list()as CPUClass:list_cpus callback. Reduce its scope and remove thecpu_listdefinition.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/i386/cpu.h | 3 --- target/i386/cpu.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-)
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
@@ -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 0static inline int ppc_env_mmu_index (CPUPPCState *env,bool ifetch)
target/ppc/cpu_init.c +2 -1
@@ -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
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.1Register
ppc_cpu_list()as CPUClass:list_cpus callback. Reduce its scope and remove thecpu_listdefinition.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/ppc/cpu.h | 4 ---- target/ppc/cpu_init.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-)
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
@@ -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
@@ -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
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.1Register
sparc_cpu_list()as CPUClass:list_cpus callback. Reduce its scope and remove thecpu_listdefinition.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/sparc/cpu.h | 3 --- target/sparc/cpu.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-)
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
@@ -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
@@ -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
@@ -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
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()ands390_set_qemu_cpu_model()are defined incpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header ins390-virtio-ccw.cfile.Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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@@ -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@@ -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
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"
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 incpu_models.h
X-Mailer: git-send-email 2.47.1Both
s390_cpu_list()ands390_set_qemu_cpu_model()are defined incpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header ins390-virtio-ccw.cfile.
Quoted 7 lines
Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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(-)
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()ands390_set_qemu_cpu_model()are defined incpu_models.c, move their declarations in the related "cpu_models.h" header. Use full path to header ins390-virtio-ccw.cfile.
Quoted 7 lines
Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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)
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
@@ -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
@@ -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
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 thecpu_listdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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~
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 thecpu_listdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
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.
Thomas Huth
Reviewed-byRe: [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 thecpu_listdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
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!
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 thecpu_listdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/cpu.h | 3 --- target/s390x/cpu.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-)
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 thecpu_listdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/cpu.h | 3 --- target/s390x/cpu.c | 1 + 2 files changed, 1 insertion(+), 3 deletions(-)
Fine squashed with patch 5 or not...
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
@@ -71,7 +71,6 @@ const char *parse_cpu_option(const char *cpu_option)return cpu_type; } -#ifndef cpu_liststatic 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
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 oncpu_listdefinition
X-Mailer: git-send-email 2.47.1Since we removed all definitions of
cpu_list, the #ifdef check is always true. Remove it, inliningcpu_list().
Quoted 6 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- cpu-target.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
Quoted 8 lines · Philippe Mathieu-Daudé
Based-on: <[email protected]>
Philippe Mathieu-Daudé (7):
cpus: IntroduceCPUClass::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 incpu_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 oncpu_listdefinition