qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Tristan Gingold <gingold@adacore.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Re: [PATCH] Use sigwait instead of sigwaitinfo.
Date: Fri, 18 Feb 2011 17:16:56 +0100	[thread overview]
Message-ID: <4D5E9B78.3030109@siemens.com> (raw)
In-Reply-To: <ACCD9893-5AF4-4BF2-A501-448C54D7552C@adacore.com>

On 2011-02-18 16:50, Tristan Gingold wrote:
> 
> On Feb 18, 2011, at 4:34 PM, Jan Kiszka wrote:
>>
>> This and the above handling of sigwait return codes changes the error
>> handling strategy.
> 
> Did it ?  I don't think so.
> 
>> So far we silently skipped errors, now we silently
>> terminate the compatfd thread. I think none of both approaches is good.
> 
> I think that both silently terminate the compatfd.  The previous code is:
> 
>   do {
>         siginfo_t siginfo;
> 
>         err = sigwaitinfo(&info->mask, &siginfo);
>         if (err == -1 && errno == EINTR) {
>             err = 0;
>             continue;
>         }
> 
>         if (err > 0) {
>             char buffer[128];
>             size_t offset = 0;
> 
>             memcpy(buffer, &err, sizeof(err));
>             while (offset < sizeof(buffer)) {
>                 ssize_t len;
> 
>                 len = write(info->fd, buffer + offset,
>                             sizeof(buffer) - offset);
>                 if (len == -1 && errno == EINTR)
>                     continue;
> 
>                 if (len <= 0) {
>                     err = -1;
>                     break;
>                 }
> 
>                 offset += len;
>             }
>         }
>     } while (err >= 0);
> 
> So in case of any error, err is set to a negative value which exits the thread.

Ah, sorry, oversaw that. In that case the patch is fine as it does not
change the existing behavior.

> 
>> Failing sigwait is likely a reason to bail out, but loudly, writing some
>> error message to the console and triggering a shutdown of qemu.
> 
> I agree with that.
> 
>> An overflow of the compatfd pipe to the main thread may be due to some
>> very unfortunate overload scenario. Not sure if that qualifies for a
>> thread termination (definitely not for a silent one).
> 
> What do you mean by overflow ?  Unless I am wrong, the fd is not non-blocking, write will block.

True. So any error returned here is a real one.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  reply	other threads:[~2011-02-18 16:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 16:24 [Qemu-devel] [PATCH] Use sigwait instead og sigwaitinfo Tristan Gingold
2011-02-17 17:06 ` [Qemu-devel] " Paolo Bonzini
2011-02-18 13:17 ` [Qemu-devel] [PATCH] Use sigwait instead of sigwaitinfo Tristan Gingold
2011-02-18 14:09   ` [Qemu-devel] " Paolo Bonzini
2011-02-18 15:34   ` Jan Kiszka
2011-02-18 15:50     ` Tristan Gingold
2011-02-18 16:16       ` Jan Kiszka [this message]
2011-02-18 18:15   ` [Qemu-devel] " Blue Swirl
2011-02-25 20:58   ` Blue Swirl

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=4D5E9B78.3030109@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=gingold@adacore.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).