[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 18/33] target/s390x: Use generic helper to show CPU model name
From: |
Gavin Shan |
Subject: |
[PATCH v4 18/33] target/s390x: Use generic helper to show CPU model names |
Date: |
Thu, 2 Nov 2023 10:24:45 +1000 |
For target/s390x, the registered CPU type name is always the
combination of the CPU model name and suffix. Use cpu_model_from_type()
to show the CPU model names.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
target/s390x/cpu_models.c | 12 ++++++------
target/s390x/cpu_models_sysemu.c | 9 ++++-----
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 4dead48650..71635b92c8 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -339,7 +339,8 @@ static void s390_print_cpu_model_list_entry(gpointer data,
gpointer user_data)
{
const S390CPUClass *scc = S390_CPU_CLASS((ObjectClass *)data);
CPUClass *cc = CPU_CLASS(scc);
- char *name = g_strdup(object_class_get_name((ObjectClass *)data));
+ const char *typename = object_class_get_name(OBJECT_CLASS(data));
+ char *model = cpu_model_from_type(typename);
g_autoptr(GString) details = g_string_new("");
if (scc->is_static) {
@@ -356,14 +357,12 @@ static void s390_print_cpu_model_list_entry(gpointer
data, gpointer user_data)
g_string_truncate(details, details->len - 2);
}
- /* strip off the -s390x-cpu */
- g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
if (details->len) {
- qemu_printf("s390 %-15s %-35s (%s)\n", name, scc->desc, details->str);
+ qemu_printf("s390 %-15s %-35s (%s)\n", model, scc->desc, details->str);
} else {
- qemu_printf("s390 %-15s %-35s\n", name, scc->desc);
+ qemu_printf("s390 %-15s %-35s\n", model, scc->desc);
}
- g_free(name);
+ g_free(model);
}
static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)
@@ -408,6 +407,7 @@ void s390_cpu_list(void)
list = object_class_get_list(TYPE_S390_CPU, false);
list = g_slist_sort(list, s390_cpu_list_compare);
+ qemu_printf("Available CPUs:\n");
g_slist_foreach(list, s390_print_cpu_model_list_entry, NULL);
g_slist_free(list);
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 63981bf36b..c41af253d3 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -55,17 +55,16 @@ static void create_cpu_model_list(ObjectClass *klass, void
*opaque)
struct CpuDefinitionInfoListData *cpu_list_data = opaque;
CpuDefinitionInfoList **cpu_list = &cpu_list_data->list;
CpuDefinitionInfo *info;
- char *name = g_strdup(object_class_get_name(klass));
+ const char *typename = object_class_get_name(klass);
+ char *model = cpu_model_from_type(typename);
S390CPUClass *scc = S390_CPU_CLASS(klass);
- /* strip off the -s390x-cpu */
- g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
info = g_new0(CpuDefinitionInfo, 1);
- info->name = name;
+ info->name = model;
info->has_migration_safe = true;
info->migration_safe = scc->is_migration_safe;
info->q_static = scc->is_static;
- info->q_typename = g_strdup(object_class_get_name(klass));
+ info->q_typename = g_strdup(typename);
/* check for unavailable features */
if (cpu_list_data->model) {
Object *obj;
--
2.41.0
- [PATCH v4 08/33] target/cris: Use generic helper to show CPU model names, (continued)
- [PATCH v4 08/33] target/cris: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 09/33] target/hexagon: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 10/33] target/i386: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 11/33] target/loongarch: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 12/33] target/m68k: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 13/33] target/mips: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 14/33] target/openrisc: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 15/33] target/ppc: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 16/33] target/riscv: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 17/33] target/rx: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 18/33] target/s390x: Use generic helper to show CPU model names,
Gavin Shan <=
- [PATCH v4 19/33] target/sh4: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 20/33] target/tricore: Use generic helper to show CPU model names, Gavin Shan, 2023/11/01
- [PATCH v4 21/33] target/hppa: Implement hppa_cpu_list(), Gavin Shan, 2023/11/01
- [PATCH v4 22/33] target/microblaze: Implement microblaze_cpu_list(), Gavin Shan, 2023/11/01
- [PATCH v4 23/33] target/nios2: Implement nios2_cpu_list(), Gavin Shan, 2023/11/01
- [PATCH v4 24/33] cpu: Mark cpu_list() supported on all targets, Gavin Shan, 2023/11/01
- [PATCH v4 25/33] machine: Constify MachineClass::valid_cpu_types[i], Gavin Shan, 2023/11/01
- [PATCH v4 26/33] machine: Use error handling when CPU type is checked, Gavin Shan, 2023/11/01
- [PATCH v4 27/33] machine: Introduce helper is_cpu_type_supported(), Gavin Shan, 2023/11/01
- [PATCH v4 28/33] machine: Print CPU model name instead of CPU type name, Gavin Shan, 2023/11/01