* [PATCH] Bail out when VCPU_CREATE fails
@ 2010-03-22 10:49 Alexander Graf
2010-03-24 9:32 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2010-03-22 10:49 UTC (permalink / raw)
To: KVM list
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Bail out when VCPU_CREATE fails
2010-03-22 10:49 [PATCH] Bail out when VCPU_CREATE fails Alexander Graf
@ 2010-03-24 9:32 ` Avi Kivity
2010-03-24 9:33 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2010-03-24 9:32 UTC (permalink / raw)
To: Alexander Graf; +Cc: KVM list
On 03/22/2010 12:49 PM, Alexander Graf wrote:
> 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.
>
>
Applied, thanks. Note, kvm reports the number of supported vcpus using
KVM_CAP_NR_VCPUS, so we can fail in vl.c.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bail out when VCPU_CREATE fails
2010-03-24 9:32 ` Avi Kivity
@ 2010-03-24 9:33 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2010-03-24 9:33 UTC (permalink / raw)
To: Avi Kivity; +Cc: KVM list
On 24.03.2010, at 10:32, Avi Kivity wrote:
> On 03/22/2010 12:49 PM, Alexander Graf wrote:
>> 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.
>>
>>
>
> Applied, thanks. Note, kvm reports the number of supported vcpus using KVM_CAP_NR_VCPUS, so we can fail in vl.c.
Sounds like the right fix to do for qemu.git. As soon as SMP support is in there.
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-24 9:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22 10:49 [PATCH] Bail out when VCPU_CREATE fails Alexander Graf
2010-03-24 9:32 ` Avi Kivity
2010-03-24 9:33 ` Alexander Graf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.