Skip to contentSkip to conversation

vl.c: fix regression when reading machine type from config file

PATCH In review Marcel Apfelbaum 2 participants 4 messages Jan 7, 2015

v2 of 3 In review Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vl.c: fix regression when reading machine type from config file

After 'Machine as QOM' series the machine type input triggers the creation of the machine class.
If the machine type is set in the configuration file, the machine class is not updated accordingly and remains the default.

Fixed that by querying the machine options after the configuration file is loaded.

---
v1 -> v2:
- Addressed Paolo Bonzini's comments:
- moved the call to machine_parse after the switch and brought QEMU_OPTION_M near QEMU_OPTION_machine

 vl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
vl.c +9 -8
index 7786b2f..da69dba 100644
@@ -2796,9 +2796,6 @@ int main(int argc, char **argv, char **envp)
                 exit(1);
             }
             switch(popt->index) {
-            case QEMU_OPTION_M:
-                machine_class = machine_parse(optarg);
-                break;
             case QEMU_OPTION_no_kvm_irqchip: {
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "kernel_irqchip=off", 0);
@@ -3420,17 +3417,14 @@ int main(int argc, char **argv, char **envp)
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "accel=kvm", 0);
                 break;
+            case QEMU_OPTION_M:
             case QEMU_OPTION_machine:
                 olist = qemu_find_opts("machine");
                 opts = qemu_opts_parse(olist, optarg, 1);
                 if (!opts) {
                     exit(1);
                 }
-                optarg = qemu_opt_get(opts, "type");
-                if (optarg) {
-                    machine_class = machine_parse(optarg);
-                }
-                break;
+               break;
              case QEMU_OPTION_no_kvm:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "accel=tcg", 0);
@@ -3752,6 +3746,13 @@ int main(int argc, char **argv, char **envp)
             }
         }
     }
+
+    opts = qemu_get_machine_opts();
+    optarg = qemu_opt_get(opts, "type");
+    if (optarg) {
+        machine_class = machine_parse(optarg);
+    }
+
     loc_set_none();
 
     os_daemonize();
Signature · 1 line
2.1.0
#1 lore raw
Quoted 41 lines · Marcel Apfelbaum

After 'Machine as QOM' series the machine type input triggers the creation of the machine class.
If the machine type is set in the configuration file, the machine class is not updated accordingly and remains the default.

Fixed that by querying the machine options after the configuration file is loaded.

---
v1 -> v2:
- Addressed Paolo Bonzini's comments:
- moved the call to machine_parse after the switch and brought QEMU_OPTION_M near QEMU_OPTION_machine

 vl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
vl.c +1 -3
index 7786b2f..da69dba 100644
@@ -2796,9 +2796,6 @@ int main(int argc, char **argv, char **envp)
                 exit(1);
             }
             switch(popt->index) {
-            case QEMU_OPTION_M:
-                machine_class = machine_parse(optarg);
-                break;
             case QEMU_OPTION_no_kvm_irqchip: {
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "kernel_irqchip=off", 0);
@@ -3420,17 +3417,14 @@ int main(int argc, char **argv, char **envp)
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "accel=kvm", 0);
                 break;
+            case QEMU_OPTION_M:
             case QEMU_OPTION_machine:
                 olist = qemu_find_opts("machine");

vl.c int main(int argc, char **argv, char **envp) · line 3427

Quoted 10 lines
vl.c +1 -5
                 opts = qemu_opts_parse(olist, optarg, 1);
                 if (!opts) {
                     exit(1);
                 }
-                optarg = qemu_opt_get(opts, "type");
-                if (optarg) {
-                    machine_class = machine_parse(optarg);
-                }
-                break;
+               break;

Unnecessary whitespace change? :(

Quoted 8 lines
vl.c +0 -0
              case QEMU_OPTION_no_kvm:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse(olist, "accel=tcg", 0);
@@ -3752,6 +3746,13 @@ int main(int argc, char **argv, char **envp)
             }
         }
     }

vl.c int main(int argc, char **argv, char **envp) · line 3758

Quoted 10 lines
vl.c +7 -0
+
+    opts = qemu_get_machine_opts();
+    optarg = qemu_opt_get(opts, "type");
+    if (optarg) {
+        machine_class = machine_parse(optarg);
+    }
+
     loc_set_none();
 
     os_daemonize();

Looks good apart from that.

Paolo

#2 lore raw
Quoted 48 lines · Paolo Bonzini
Quoted 45 lines · Marcel Apfelbaum

After 'Machine as QOM' series the machine type input triggers the creation of the machine class.
If the machine type is set in the configuration file, the machine class is not updated accordingly and remains the default.

Fixed that by querying the machine options after the configuration file is loaded.

---
v1 -> v2:
- Addressed Paolo Bonzini's comments:
- moved the call to machine_parse after the switch and brought QEMU_OPTION_M near QEMU_OPTION_machine

  vl.c | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
vl.c +1 -3
index 7786b2f..da69dba 100644
@@ -2796,9 +2796,6 @@ int main(int argc, char **argv, char **envp)
                  exit(1);
              }
              switch(popt->index) {
-            case QEMU_OPTION_M:
-                machine_class = machine_parse(optarg);
-                break;
              case QEMU_OPTION_no_kvm_irqchip: {
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "kernel_irqchip=off", 0);
@@ -3420,17 +3417,14 @@ int main(int argc, char **argv, char **envp)
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "accel=kvm", 0);
                  break;
+            case QEMU_OPTION_M:
              case QEMU_OPTION_machine:
                  olist = qemu_find_opts("machine");
                  opts = qemu_opts_parse(olist, optarg, 1);
                  if (!opts) {
                      exit(1);
                  }
Quoted 8 lines

vl.c int main(int argc, char **argv, char **envp) · line 3427

Quoted 6 lines
vl.c +1 -5
-                optarg = qemu_opt_get(opts, "type");
-                if (optarg) {
-                    machine_class = machine_parse(optarg);
-                }
-                break;
+               break;

Unnecessary whitespace change? :(

Ooops! Sent v3, thanks for catching it!
Marcel

Quoted 24 lines
Quoted 9 lines
vl.c +0 -0
               case QEMU_OPTION_no_kvm:
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "accel=tcg", 0);
@@ -3752,6 +3746,13 @@ int main(int argc, char **argv, char **envp)
              }
          }
      }

vl.c int main(int argc, char **argv, char **envp) · line 3758

Quoted 10 lines
vl.c +7 -0
+
+    opts = qemu_get_machine_opts();
+    optarg = qemu_opt_get(opts, "type");
+    if (optarg) {
+        machine_class = machine_parse(optarg);
+    }
+
      loc_set_none();
 
      os_daemonize();

Looks good apart from that.

Paolo

#3 lore raw
In reply to Marcel Apfelbaum
Quoted 7 lines · Marcel Apfelbaum

After 'Machine as QOM' series the machine type input triggers the creation of the machine class.
If the machine type is set in the configuration file, the machine class is not updated accordingly and remains the default.

Fixed that by querying the machine options after the configuration file is loaded.

I sent first the patch only to reviewers and not to the list! I am sorry about that.
I also didn't actually CC-ed the stable list, doing it now...

Thanks,
Marcel

Quoted 62 lines

---
v1 -> v2:
- Addressed Paolo Bonzini's comments:
- moved the call to machine_parse after the switch and brought QEMU_OPTION_M near QEMU_OPTION_machine

  vl.c | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
vl.c +9 -8
index 7786b2f..da69dba 100644
@@ -2796,9 +2796,6 @@ int main(int argc, char **argv, char **envp)
                  exit(1);
              }
              switch(popt->index) {
-            case QEMU_OPTION_M:
-                machine_class = machine_parse(optarg);
-                break;
              case QEMU_OPTION_no_kvm_irqchip: {
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "kernel_irqchip=off", 0);
@@ -3420,17 +3417,14 @@ int main(int argc, char **argv, char **envp)
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "accel=kvm", 0);
                  break;
+            case QEMU_OPTION_M:
              case QEMU_OPTION_machine:
                  olist = qemu_find_opts("machine");
                  opts = qemu_opts_parse(olist, optarg, 1);
                  if (!opts) {
                      exit(1);
                  }
-                optarg = qemu_opt_get(opts, "type");
-                if (optarg) {
-                    machine_class = machine_parse(optarg);
-                }
-                break;
+               break;
               case QEMU_OPTION_no_kvm:
                  olist = qemu_find_opts("machine");
                  qemu_opts_parse(olist, "accel=tcg", 0);
@@ -3752,6 +3746,13 @@ int main(int argc, char **argv, char **envp)
              }
          }
      }
+
+    opts = qemu_get_machine_opts();
+    optarg = qemu_opt_get(opts, "type");
+    if (optarg) {
+        machine_class = machine_parse(optarg);
+    }
+
      loc_set_none();
 
      os_daemonize();