aboutsummaryrefslogtreecommitdiffstats
path: root/kvm-all.c
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2012-03-15 13:17:57 -0700
committerAndy McFadden <fadden@android.com>2012-03-15 13:21:09 -0700
commit7876c70c97140ac6a4469e04da1b377913da259a (patch)
treeba4d1ba29a959d71b96c13030e643ff166996679 /kvm-all.c
parent46ff3eaff40952df50ee14056cae88a3e7396a81 (diff)
downloadexternal_qemu-7876c70c97140ac6a4469e04da1b377913da259a.zip
external_qemu-7876c70c97140ac6a4469e04da1b377913da259a.tar.gz
external_qemu-7876c70c97140ac6a4469e04da1b377913da259a.tar.bz2
Don't crash if KVM is busy
Return an error when kvm_ioctl(KVM_CREATE_VM) fails, so we stop with an error message instead of a segmentation fault. Change-Id: Ie8f7efca6d50e096bd5f1c05bc91c53a9770b73c
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kvm-all.c b/kvm-all.c
index 0930d33..2865b2f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -427,8 +427,8 @@ int kvm_init(int smp_cpus)
s->vmfd = -1;
s->fd = open("/dev/kvm", O_RDWR);
if (s->fd == -1) {
- fprintf(stderr, "Could not access KVM kernel module: %m\n");
ret = -errno;
+ fprintf(stderr, "Could not access KVM kernel module: %m\n");
goto err;
}
@@ -447,8 +447,11 @@ int kvm_init(int smp_cpus)
}
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
- if (s->vmfd < 0)
+ if (s->vmfd < 0) {
+ ret = -errno;
+ fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %s\n", strerror(errno));
goto err;
+ }
/* initially, KVM allocated its own memory and we had to jump through
* hooks to make phys_ram_base point to this. Modern versions of KVM