For target/ppc, the CPU type name can be: (1) The combination of the CPU model name and suffix; (2) the type name of the class whose PVR matches with the specified one; (3) alias of the CPU model, plus suffix; (4) MachineClass::default_cpu_type when the CPU model name is "max". All the possible information, the CPU model name, aliases of the CPU models and PVRs are all shown in ppc_cpu_list_entry().
Use generic helper cpu_model_from_type() in ppc_cpu_list_entry(), and rename @name to @model since it points to the CPU model name instead of the CPU type name. Signed-off-by: Gavin Shan <gs...@redhat.com> --- target/ppc/cpu_init.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 02b7aad9b0..7281402331 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7019,16 +7019,15 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data) PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); DeviceClass *family = DEVICE_CLASS(ppc_cpu_get_family_class(pcc)); const char *typename = object_class_get_name(oc); - char *name; + char *model; int i; if (unlikely(strcmp(typename, TYPE_HOST_POWERPC_CPU) == 0)) { return; } - name = g_strndup(typename, - strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); - qemu_printf("PowerPC %-16s PVR %08x\n", name, pcc->pvr); + model = cpu_model_from_type(typename); + qemu_printf("PowerPC %-16s PVR %08x\n", model, pcc->pvr); for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model); @@ -7045,10 +7044,10 @@ static void ppc_cpu_list_entry(gpointer data, gpointer user_data) alias->alias, family->desc); } else { qemu_printf("PowerPC %-16s (alias for %s)\n", - alias->alias, name); + alias->alias, model); } } - g_free(name); + g_free(model); } void ppc_cpu_list(void) -- 2.41.0