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@xxxxxxx> Reported-by: Michael Tokarev <mjt@xxxxxxxxxx> --- Please also commit this to the -stable branch. --- qemu-kvm.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 7772434..4d19c80 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -448,7 +448,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; @@ -476,6 +477,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) -- 1.6.0.2 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html