qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 27/32] machine: Print CPU model name instead of CPU type n


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 27/32] machine: Print CPU model name instead of CPU type name
Date: Thu, 7 Sep 2023 11:05:07 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0

On 7/9/23 02:35, 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 | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)


@@ -1373,11 +1374,18 @@ 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);
+            error_setg(errp, "Invalid CPU type: %s", model);
+            g_free(model);
+
+            model = cpu_model_from_type(mc->valid_cpu_types[0]);
+            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]);

cpu_model_from_type() can return NULL:

 char *cpu_model_from_type(const char *typename)
 {
     const char *suffix = "-" CPU_RESOLVING_TYPE;

     if (!object_class_by_name(typename)) {
         return NULL;
     }

Don't we want to skip that case?

                   if (!model) {
                       continue;
                   }

+                error_append_hint(errp, ", %s", model);
+                g_free(model);
              }
error_append_hint(errp, "\n");




reply via email to

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