@@ -629,12 +629,12 @@ static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
{
ObjectClass *oc;
char *typename;
- char **cpuname;
+ char **model;
- cpuname = g_strsplit(cpu_model, ",", 1);
- typename = g_strdup_printf(RISCV_CPU_TYPE_NAME("%s"), cpuname[0]);
+ model = g_strsplit(cpu_model, ",", 1);
+ typename = g_strdup_printf(RISCV_CPU_TYPE_NAME("%s"), model[0]);
oc = object_class_by_name(typename);
- g_strfreev(cpuname);
+ g_strfreev(model);
g_free(typename);
return oc;
@@ -1644,9 +1644,10 @@ static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b)
static void riscv_cpu_list_entry(gpointer data, gpointer user_data)
{
const char *typename = object_class_get_name(OBJECT_CLASS(data));
- int len = strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX);
+ char *model = cpu_model_from_type(typename);
- qemu_printf("%.*s\n", len, typename);
+ qemu_printf(" %s\n", model);
+ g_free(model);
}
void riscv_cpu_list(void)
@@ -1655,6 +1656,7 @@ void riscv_cpu_list(void)
list = object_class_get_list(TYPE_RISCV_CPU, false);
list = g_slist_sort(list, riscv_cpu_list_compare);
+ qemu_printf("Available CPUs:\n");
g_slist_foreach(list, riscv_cpu_list_entry, NULL);
g_slist_free(list);
}
@@ -35,8 +35,7 @@ static void riscv_cpu_add_definition(gpointer data, gpointer user_data)
const char *typename = object_class_get_name(oc);
ObjectClass *dyn_class;
- info->name = g_strndup(typename,
- strlen(typename) - strlen("-" TYPE_RISCV_CPU));
+ info->name = cpu_model_from_type(typename);
info->q_typename = g_strdup(typename);
dyn_class = object_class_dynamic_cast(oc, TYPE_RISCV_DYNAMIC_CPU);