Skip to contentSkip to conversation

vl.c: Fail gracefully if no machine is found

PATCH Applied Andreas Färber 2 participants 2 messages Nov 10, 2011 – Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl.c: Fail gracefully if no machine is found

machine defaults to find_default_machine(),
then gets overridden via -M and machine_parse().

If no -M is specified and find_default_machine() returns NULL (when no machine compiled in), exit with an error.

Avoids a segfault when setting machine->max_cpus.

---
 vl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
vl.c +5 -0
index f169aac..16fa222 100644
@@ -3089,6 +3089,11 @@ int main(int argc, char **argv, char **envp)
         data_dir = CONFIG_QEMU_DATADIR;
     }
 
+    if (machine == NULL) {
+        fprintf(stderr, "No machine found.\n");
+        exit(1);
+    }
+
     /*
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
Signature · 1 line
1.7.7
#1 lore raw
Quoted 9 lines · Andreas Färber

machine defaults to find_default_machine(),
then gets overridden via -M and machine_parse().

If no -M is specified and find_default_machine() returns NULL (when no machine compiled in), exit with an error.

Avoids a segfault when setting machine->max_cpus.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 20 lines
---
  vl.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
vl.c +5 -0
index f169aac..16fa222 100644
@@ -3089,6 +3089,11 @@ int main(int argc, char **argv, char **envp)
          data_dir = CONFIG_QEMU_DATADIR;
      }
 
+    if (machine == NULL) {
+        fprintf(stderr, "No machine found.\n");
+        exit(1);
+    }
+
      /*
       * Default to max_cpus = smp_cpus, in case the user doesn't
       * specify a max_cpus value.