qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 26/31] machine: Print CPU model name instead of CPU type n


From: Richard Henderson
Subject: Re: [PATCH v5 26/31] machine: Print CPU model name instead of CPU type name
Date: Tue, 14 Nov 2023 17:32:05 -0800
User-agent: Mozilla Thunderbird

On 11/14/23 15:56, Gavin Shan wrote:
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;

Move to inner block.

@@ -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);

I see no reason for these asserts -- printf of NULL will print "(nil)".
Aborting in the middle of error reporting won't be helpful.



r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]