aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-03-22 11:49:13 +0100
committerAvi Kivity <avi@redhat.com>2010-03-24 14:12:45 +0200
commitec0e84edaea62d1338c1c48299c1e56e797b921a (patch)
treef976b12ed4d2361a58136ca72144d0b36b78fa4b /qemu-kvm.c
parentMerge branch 'stable-0.12-merge' into stable-0.12 (diff)
downloadqemu-kvm-ec0e84edaea62d1338c1c48299c1e56e797b921a.tar.gz
qemu-kvm-ec0e84edaea62d1338c1c48299c1e56e797b921a.tar.bz2
qemu-kvm-ec0e84edaea62d1338c1c48299c1e56e797b921a.zip
Bail out when VCPU_CREATE fails
When we fail to create a VCPU we have no way to tell our callers that something failed. So the caller happily uses a completely broken state. This code should become deprecated in the process of converting qemu-kvm to qemu anyways, so let's not care about remdeling it but just bailing out when something breaks. Also give the user a hint on why the VCPU_CREATE might have failed. This fixes a segmentation fault with -smp > VCPU_MAX in the host kernel. Signed-off-by: Alexander Graf <agraf@suse.de> Reported-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'qemu-kvm.c')
-rw-r--r--qemu-kvm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 25addaf3b..8cc85bc4a 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -444,7 +444,8 @@ static void kvm_create_vcpu(CPUState *env, int id)
r = kvm_vm_ioctl(kvm_state, KVM_CREATE_VCPU, id);
if (r < 0) {
fprintf(stderr, "kvm_create_vcpu: %m\n");
- return;
+ fprintf(stderr, "Failed to create vCPU. Check the -smp parameter.\n");
+ goto err;
}
env->kvm_fd = r;
@@ -466,6 +467,9 @@ static void kvm_create_vcpu(CPUState *env, int id)
return;
err_fd:
close(env->kvm_fd);
+ err:
+ /* We're no good with semi-broken states. */
+ abort();
}
static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id)