From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0). Date: Mon, 20 Oct 2008 10:43:33 +0200 Message-ID: <48FC44B5.4010206@redhat.com> References: <42DFA526FC41B1429CE7279EF83C6BDC01B489F8@pdsmsx415.ccr.corp.intel.com> <48FC3204.4030902@redhat.com> <42DFA526FC41B1429CE7279EF83C6BDC01B48ADD@pdsmsx415.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm-ia64@vger.kernel.org, kvm@vger.kernel.org To: "Zhang, Xiantao" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58796 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724AbYJTIn1 (ORCPT ); Mon, 20 Oct 2008 04:43:27 -0400 In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC01B48ADD@pdsmsx415.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: 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. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.