All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm-ia64@vger.kernel.org
Subject: Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu
Date: Mon, 20 Oct 2008 08:43:33 +0000	[thread overview]
Message-ID: <48FC44B5.4010206@redhat.com> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC01B489F8@pdsmsx415.ccr.corp.intel.com>

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.


WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi@redhat.com>
To: "Zhang, Xiantao" <xiantao.zhang@intel.com>
Cc: kvm-ia64@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0).
Date: Mon, 20 Oct 2008 10:43:33 +0200	[thread overview]
Message-ID: <48FC44B5.4010206@redhat.com> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC01B48ADD@pdsmsx415.ccr.corp.intel.com>

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.


  parent reply	other threads:[~2008-10-20  8:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-20  5:58 [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Zhang, Xiantao
2008-10-20  5:58 ` Zhang, Xiantao
2008-10-20  7:23 ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu Avi Kivity
2008-10-20  7:23   ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Avi Kivity
2008-10-20  8:08 ` Zhang, Xiantao
2008-10-20  8:08   ` Zhang, Xiantao
2008-10-20  8:43 ` Avi Kivity [this message]
2008-10-20  8:43   ` Avi Kivity
2008-10-20  9:03 ` Zhang, Xiantao
2008-10-20  9:03   ` Zhang, Xiantao
2008-10-22  3:13 ` Zhang, Xiantao
2008-10-22  3:13   ` Zhang, Xiantao
2008-10-22 10:47 ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu Avi Kivity
2008-10-22 10:47   ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Avi Kivity
2008-10-23  2:00 ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu Zhang, Xiantao
2008-10-23  2:00   ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Zhang, Xiantao
2008-10-23  4:31 ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu Avi Kivity
2008-10-23  4:31   ` [PATCH] kvm/ia64: Ensure SIGINT delivered to main thread (vcpu 0) Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48FC44B5.4010206@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.