Avi Kivity wrote: > Zhang, Xiantao wrote: >> Avi Kivity wrote: >> >>> Zhang, Xiantao wrote: >>> >>>> Before Aps going to block status, it should make sure SIGINT is >>>> masked, otherwise, it may eat SIGINT from user killing the guest, >>>> and results in Qemu hanging there, becasue main thread can't get >>>> it to free guest's resource. >>>> >>>> >>>> vcpu_load(vcpu); >>>> >>>> + if (vcpu->sigset_active) >>>> + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + >>>> if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) >>>> >> { >> >>>> kvm_vcpu_block(vcpu); >>>> clear_bit(KVM_REQ_UNHALT, &vcpu->requests); >>>> @@ -680,9 +683,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu >>>> *vcpu, struct kvm_run *kvm_run) return -EAGAIN; >>>> >>>> >>> The 'return' here means you are returning with the wrong signal >>> mask. >>> >> >> Yes, but the signal is eaten by the thread, and can't be delivered to >> main thread when returing to usespace. So in order to ensure the main >> thread receive the signal SIGINT we should mask this signal on Aps >> going into halt, and only main thread can receive such signals. >> >> > > Then you should block SIGINT in the vcpu thread in userspace. > > This patch is correct, except that it leaks the signal mask. You need > to restore it when you return -EAGAIN. Hi, Avi Thank you for pointing out this. Yes, we need to restore the singal mask before returning to userspace. Updated the patch. Xiantao >From 5434384ea573f8430b258163c1c07c695a0de5cc Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@xxxxxxxxx> Date: Mon, 20 Oct 2008 15:36:42 +0800 Subject: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Before Aps going to block status, it should make sure SIGINT is masked, otherwise, it may eat SIGINT from user killing the guest, and results in Qemu hanging there, becasue main thread can't get it to free guest's resource. Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx> --- arch/ia64/kvm/kvm-ia64.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a40223f..502b6fc 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -673,16 +673,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu_load(vcpu); + if (vcpu->sigset_active) + sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); + if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - vcpu_put(vcpu); - return -EAGAIN; + r = -EAGAIN; + goto out; } - if (vcpu->sigset_active) - sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); - if (vcpu->mmio_needed) { memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); kvm_set_mmio_data(vcpu); @@ -690,7 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vcpu->mmio_needed = 0; } r = __vcpu_run(vcpu, kvm_run); - +out: if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL); -- 1.5.1
Attachment:
0001-kvm-ia64-Ensure-SIGINT-delivered-to-main-thread-vc.patch
Description: 0001-kvm-ia64-Ensure-SIGINT-delivered-to-main-thread-vc.patch