aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDunrong Huang <riegamaths@gmail.com>2012-07-24 00:42:20 +0800
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-08-10 14:28:11 +0100
commitfb7c269ed694c103397c5fffbfcccd3e90aed23c (patch)
treedf70db387a83dbd0f44552d33eb67606c8404667
parent3d1d9652978ac5a32a0beb4bdf6065ca39440d89 (diff)
downloadqemu-kvm-fb7c269ed694c103397c5fffbfcccd3e90aed23c.tar.gz
vl.c: Exit QEMU early if no machine is found
We check whether the variable machine is NULL or not before accessing it. If machine is NULL, exit QEMU with an error, this can avoids a segfault error. Markus Armbruster <armbru@redhat.com> adds that the segfault can be reproduced as follows: $ qemu-system-xtensa -cpu help Signed-off-by: Dunrong Huang <riegamaths@gmail.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
-rw-r--r--vl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/vl.c b/vl.c
index a4a520fb7e6..48714288646 100644
--- a/vl.c
+++ b/vl.c
@@ -3204,6 +3204,11 @@ int main(int argc, char **argv, char **envp)
}
loc_set_none();
+ if (machine == NULL) {
+ fprintf(stderr, "No machine found.\n");
+ exit(1);
+ }
+
if (machine->hw_version) {
qemu_set_version(machine->hw_version);
}
@@ -3246,11 +3251,6 @@ 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.