[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 26/31] machine: Print CPU model name instead of CPU type name
From: |
Gavin Shan |
Subject: |
[PATCH v5 26/31] machine: Print CPU model name instead of CPU type name |
Date: |
Wed, 15 Nov 2023 09:56:23 +1000 |
The names of supported CPU models instead of CPU types should be
printed when the user specified CPU type isn't supported, to be
consistent with the output from '-cpu ?'.
Correct the error messages to print CPU model names instead of CPU
type names.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
hw/core/machine.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 49e0bc874d..58512b4b89 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1392,6 +1392,7 @@ static void is_cpu_type_supported(MachineState *machine,
Error **errp)
MachineClass *mc = MACHINE_GET_CLASS(machine);
ObjectClass *oc = object_class_by_name(machine->cpu_type);
CPUClass *cc;
+ char *model;
int i;
/*
@@ -1408,11 +1409,21 @@ static void is_cpu_type_supported(MachineState
*machine, Error **errp)
/* The user specified CPU type isn't valid */
if (!mc->valid_cpu_types[i]) {
- error_setg(errp, "Invalid CPU type: %s", machine->cpu_type);
- error_append_hint(errp, "The valid types are: %s",
- mc->valid_cpu_types[0]);
+ model = cpu_model_from_type(machine->cpu_type);
+ g_assert(model != NULL);
+ error_setg(errp, "Invalid CPU type: %s", model);
+ g_free(model);
+
+ model = cpu_model_from_type(mc->valid_cpu_types[0]);
+ g_assert(model != NULL);
+ error_append_hint(errp, "The valid types are: %s", model);
+ g_free(model);
+
for (i = 1; mc->valid_cpu_types[i]; i++) {
- error_append_hint(errp, ", %s", mc->valid_cpu_types[i]);
+ model = cpu_model_from_type(mc->valid_cpu_types[i]);
+ g_assert(model != NULL);
+ error_append_hint(errp, ", %s", model);
+ g_free(model);
}
error_append_hint(errp, "\n");
--
2.41.0
- [PATCH v5 20/31] target/tricore: Use generic cpu_list(), (continued)
- [PATCH v5 20/31] target/tricore: Use generic cpu_list(), Gavin Shan, 2023/11/14
- [PATCH v5 22/31] target: Use generic cpu_model_from_type(), Gavin Shan, 2023/11/14
- [PATCH v5 23/31] machine: Constify MachineClass::valid_cpu_types[i], Gavin Shan, 2023/11/14
- [PATCH v5 24/31] machine: Use error handling when CPU type is checked, Gavin Shan, 2023/11/14
- [PATCH v5 25/31] machine: Introduce helper is_cpu_type_supported(), Gavin Shan, 2023/11/14
- [PATCH v5 27/31] hw/arm/virt: Hide host CPU model for tcg, Gavin Shan, 2023/11/14
- [PATCH v5 26/31] machine: Print CPU model name instead of CPU type name,
Gavin Shan <=
- [PATCH v5 28/31] hw/arm/virt: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/11/14
- [PATCH v5 29/31] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/11/14
- [PATCH v5 30/31] hw/arm: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/11/14
- [PATCH v5 31/31] hw/riscv/shakti_c: Check CPU type in machine_run_board_init(), Gavin Shan, 2023/11/14
- Re: [PATCH v5 00/31] Unified CPU type check, Philippe Mathieu-Daudé, 2023/11/16
- Re: [PATCH v5 00/31] Unified CPU type check, Philippe Mathieu-Daudé, 2023/11/16