Skip to contentSkip to conversation

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

PATCH Superseded Marcel Apfelbaum 2 participants 3 messages Jan 6, 2015 – Jan 7, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
vl.c +5 -0
index 7786b2f..ecd8c93 100644
@@ -3659,6 +3659,11 @@ int main(int argc, char **argv, char **envp)
                             strerror(-ret));
                         exit(1);
                     }
+                    opts = qemu_get_machine_opts();
+                    optarg = qemu_opt_get(opts, "type");
+                    if (optarg) {
+                        machine_class = machine_parse(optarg);
+                    }
                     break;
                 }
             case QEMU_OPTION_spice:
Signature · 1 line
2.1.0
#1 lore raw
Quoted 22 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.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
vl.c +0 -0
index 7786b2f..ecd8c93 100644
@@ -3659,6 +3659,11 @@ int main(int argc, char **argv, char **envp)
                             strerror(-ret));

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

Quoted 10 lines
vl.c +5 -0
                         exit(1);
                     }
+                    opts = qemu_get_machine_opts();
+                    optarg = qemu_opt_get(opts, "type");
+                    if (optarg) {
+                        machine_class = machine_parse(optarg);
+                    }
                     break;
                 }
             case QEMU_OPTION_spice:

This suggests that these five lines should be moved after the switch, and "-M" should become simply a synonym of "-machine" (that's the other place where we invoke machine_parse).

Paolo

#2 lore raw
Quoted 31 lines · Paolo Bonzini
Quoted 28 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.

---
  vl.c | 5 +++++
  1 file changed, 5 insertions(+)
vl.c +5 -0
index 7786b2f..ecd8c93 100644
@@ -3659,6 +3659,11 @@ int main(int argc, char **argv, char **envp)
                              strerror(-ret));
                          exit(1);
                      }
+                    opts = qemu_get_machine_opts();
+                    optarg = qemu_opt_get(opts, "type");
+                    if (optarg) {
+                        machine_class = machine_parse(optarg);
+                    }
Quoted 8 lines

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

Quoted 4 lines
vl.c +0 -0
                      break;
                  }
              case QEMU_OPTION_spice:

This suggests that these five lines should be moved after the switch, and "-M" should become simply a synonym of "-machine" (that's the other place where we invoke machine_parse).

Hi Paolo,
Thanks for the review.

It makes sense. I will change this and submit again.

Thanks,
Marcel

Quoted 3 lines

Paolo