Skip to contentSkip to conversation

initialize CPU model list after handling -readconfig options

PATCH Applied Eduardo Habkost 2 participants 2 messages Mar 9, 2012 – Mar 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initialize CPU model list after handling -readconfig options

To properly load cpudefs using -readconfig, we have to call cpudef_init() after finishing the command-line option handling.

Consequently, the handling of "-cpu ?" has to be done after the command-line option handling loop, too.

Without this patch, "-readconfig configfile -cpu ?" fails to list the CPU definitions read from 'configfile'.

---
 vl.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
vl.c +13 -7
index 97ab2b9..65f11f2 100644
@@ -2359,7 +2359,6 @@ int main(int argc, char **argv, char **envp)
             exit(1);
         }
     }
-    cpudef_init();
 
     /* second pass of option parsing */
     optind = 1;
@@ -2382,12 +2381,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_cpu:
                 /* hw initialization will check this */
-                if (*optarg == '?') {
-                    list_cpus(stdout, &fprintf, optarg);
-                    exit(0);
-                } else {
-                    cpu_model = optarg;
-                }
+                cpu_model = optarg;
                 break;
             case QEMU_OPTION_hda:
                 {
@@ -3191,6 +3185,18 @@ int main(int argc, char **argv, char **envp)
     }
     loc_set_none();
 
+    /* Init CPU def lists, based on config
+     * - Must be called after all the qemu_read_config_file() calls
+     * - Must be called before list_cpus()
+     * - Must be called before machine->init()
+     */
+    cpudef_init();
+
+    if (cpu_model && *cpu_model == '?') {
+        list_cpus(stdout, &fprintf, optarg);
+        exit(0);
+    }
+
     /* Open the logfile at this point, if necessary. We can't open the logfile
      * when encountering either of the logging options (-d or -D) because the
      * other one may be encountered later on the command line, changing the
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 10 lines · Eduardo Habkost

To properly load cpudefs using -readconfig, we have to call cpudef_init() after finishing the command-line option handling.

Consequently, the handling of "-cpu ?" has to be done after the command-line option handling loop, too.

Without this patch, "-readconfig configfile -cpu ?" fails to list the CPU definitions read from 'configfile'.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 49 lines
---
  vl.c |   20 +++++++++++++-------
  1 files changed, 13 insertions(+), 7 deletions(-)
vl.c +13 -7
index 97ab2b9..65f11f2 100644
@@ -2359,7 +2359,6 @@ int main(int argc, char **argv, char **envp)
              exit(1);
          }
      }
-    cpudef_init();
 
      /* second pass of option parsing */
      optind = 1;
@@ -2382,12 +2381,7 @@ int main(int argc, char **argv, char **envp)
                  break;
              case QEMU_OPTION_cpu:
                  /* hw initialization will check this */
-                if (*optarg == '?') {
-                    list_cpus(stdout,&fprintf, optarg);
-                    exit(0);
-                } else {
-                    cpu_model = optarg;
-                }
+                cpu_model = optarg;
                  break;
              case QEMU_OPTION_hda:
                  {
@@ -3191,6 +3185,18 @@ int main(int argc, char **argv, char **envp)
      }
      loc_set_none();
 
+    /* Init CPU def lists, based on config
+     * - Must be called after all the qemu_read_config_file() calls
+     * - Must be called before list_cpus()
+     * - Must be called before machine->init()
+     */
+    cpudef_init();
+
+    if (cpu_model&&  *cpu_model == '?') {
+        list_cpus(stdout,&fprintf, optarg);
+        exit(0);
+    }
+
      /* Open the logfile at this point, if necessary. We can't open the logfile
       * when encountering either of the logging options (-d or -D) because the
       * other one may be encountered later on the command line, changing the