From: Anthony Liguori <anthony@codemonkey.ws>
To: Laszlo Ersek <lersek@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context
Date: Thu, 15 Sep 2011 14:16:51 -0500 [thread overview]
Message-ID: <4E724F23.1020901@codemonkey.ws> (raw)
In-Reply-To: <1316107350-31172-1-git-send-email-lersek@redhat.com>
On 09/15/2011 12:22 PM, Laszlo Ersek wrote:
> Make variables volatile ("sig_atomic_t" should cover "int" and "pid_t").
>
> Also replace calls to functions that are not required to be async-signal-safe
> [1]. (I haven't checked if any signal masks and/or previous suspension of the
> interrupted thread keep the current calls safe.)
>
> termsig_handler()
> -> qemu_system_killed(): shutdown_signal, shutdown_pid, no_shutdown [2]
> -> qemu_system_shutdown_request(): shutdown_requested
> -> qemu_notify_event()
> -> qemu_event_increment(): fprintf(), strerror(), exit()
>
> [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03_03
> [2] http://lists.nongnu.org/archive/html/qemu-devel/2011-09/msg01757.html
>
> "checkpatch.pl" warned four times about "volatile", and considered the
> zero-initialization of "no_shutdown" (which has static storage duration) an
> error.
>
> Build tested only. Please CC me on any followup, I'm not subscribed. Thank you.
>
> Signed-off-by: Laszlo Ersek<lersek@redhat.com>
> ---
> cpus.c | 13 ++++++++++---
> sysemu.h | 2 +-
> vl.c | 6 +++---
> 3 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 54c188c..ed51247 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -289,9 +289,16 @@ static void qemu_event_increment(void)
>
> /* EAGAIN is fine, a read must be pending. */
> if (ret< 0&& errno != EAGAIN) {
> - fprintf(stderr, "qemu_event_increment: write() failed: %s\n",
> - strerror(errno));
> - exit (1);
> + int len;
> + char buf[128];
> +
> + /* Don't bother with strerror_[rl]. Make a single attempt to write. */
> + len = snprintf(buf, sizeof buf,
> + "qemu_event_increment: write() failed: %d\n", errno);
I don't think you can rely on snprintf being signal safe. I think you should
just exit on failure.
OpenBSD lists snprintf as signal safe, but "probably not on other systems."
Regards,
Anthony Liguori
next prev parent reply other threads:[~2011-09-15 19:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-15 17:22 [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context Laszlo Ersek
2011-09-15 19:16 ` Anthony Liguori [this message]
2011-09-16 8:08 ` Laszlo Ersek
2011-09-15 19:44 ` Peter Maydell
2011-09-16 7:58 ` Laszlo Ersek
2011-09-16 9:09 ` Markus Armbruster
2011-09-16 8:52 ` [Qemu-devel] [PATCH v2] " Laszlo Ersek
-- strict thread matches above, loose matches on Subject: below --
2011-09-16 14:31 [Qemu-devel] [PATCH RFC] " Eric Blake
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=4E724F23.1020901@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=lersek@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).