* [Qemu-devel] [PATCH] report that QEMU process was killed by a signal
@ 2011-03-14 12:58 Gleb Natapov
2011-03-14 13:07 ` Daniel P. Berrange
0 siblings, 1 reply; 3+ messages in thread
From: Gleb Natapov @ 2011-03-14 12:58 UTC (permalink / raw)
To: qemu-devel
Currently when rogue script kills QEMU process (using TERM/INT/HUP
signal) it looks indistinguishable from system shutdown. Lets report
that QMEU was killed and leave some clues about the killed identity.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/os-posix.c b/os-posix.c
index 38c29d1..7e175e8 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -61,8 +61,9 @@ void os_setup_early_signal_handling(void)
sigaction(SIGPIPE, &act, NULL);
}
-static void termsig_handler(int signal)
+static void termsig_handler(int signal, siginfo_t *info, void *c)
{
+ fprintf(stderr, "Got signal %d from pid %d\n", info->si_signo, info->si_pid);
qemu_system_shutdown_request();
}
@@ -76,7 +77,8 @@ void os_setup_signal_handling(void)
struct sigaction act;
memset(&act, 0, sizeof(act));
- act.sa_handler = termsig_handler;
+ act.sa_sigaction = termsig_handler;
+ act.sa_flags = SA_SIGINFO;
sigaction(SIGINT, &act, NULL);
sigaction(SIGHUP, &act, NULL);
sigaction(SIGTERM, &act, NULL);
--
Gleb.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] report that QEMU process was killed by a signal
2011-03-14 12:58 [Qemu-devel] [PATCH] report that QEMU process was killed by a signal Gleb Natapov
@ 2011-03-14 13:07 ` Daniel P. Berrange
2011-03-14 13:11 ` Gleb Natapov
0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrange @ 2011-03-14 13:07 UTC (permalink / raw)
To: Gleb Natapov; +Cc: qemu-devel
On Mon, Mar 14, 2011 at 02:58:55PM +0200, Gleb Natapov wrote:
> Currently when rogue script kills QEMU process (using TERM/INT/HUP
> signal) it looks indistinguishable from system shutdown. Lets report
> that QMEU was killed and leave some clues about the killed identity.
Good idea, but....
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/os-posix.c b/os-posix.c
> index 38c29d1..7e175e8 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -61,8 +61,9 @@ void os_setup_early_signal_handling(void)
> sigaction(SIGPIPE, &act, NULL);
> }
>
> -static void termsig_handler(int signal)
> +static void termsig_handler(int signal, siginfo_t *info, void *c)
> {
> + fprintf(stderr, "Got signal %d from pid %d\n", info->si_signo, info->si_pid);
> qemu_system_shutdown_request();
...fprintf() isn't async signal safe. It could deadlock the process
if it malloc()s while doing the arg formatting & the interrupted
thread was already holding a malloc() lock, or indeed if the stdio
impl itself has internal locks which are held. So this data needs
to be manually output using just write()
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] report that QEMU process was killed by a signal
2011-03-14 13:07 ` Daniel P. Berrange
@ 2011-03-14 13:11 ` Gleb Natapov
0 siblings, 0 replies; 3+ messages in thread
From: Gleb Natapov @ 2011-03-14 13:11 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-devel
On Mon, Mar 14, 2011 at 01:07:40PM +0000, Daniel P. Berrange wrote:
> On Mon, Mar 14, 2011 at 02:58:55PM +0200, Gleb Natapov wrote:
> > Currently when rogue script kills QEMU process (using TERM/INT/HUP
> > signal) it looks indistinguishable from system shutdown. Lets report
> > that QMEU was killed and leave some clues about the killed identity.
>
> Good idea, but....
>
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > diff --git a/os-posix.c b/os-posix.c
> > index 38c29d1..7e175e8 100644
> > --- a/os-posix.c
> > +++ b/os-posix.c
> > @@ -61,8 +61,9 @@ void os_setup_early_signal_handling(void)
> > sigaction(SIGPIPE, &act, NULL);
> > }
> >
> > -static void termsig_handler(int signal)
> > +static void termsig_handler(int signal, siginfo_t *info, void *c)
> > {
> > + fprintf(stderr, "Got signal %d from pid %d\n", info->si_signo, info->si_pid);
> > qemu_system_shutdown_request();
>
> ...fprintf() isn't async signal safe. It could deadlock the process
> if it malloc()s while doing the arg formatting & the interrupted
> thread was already holding a malloc() lock, or indeed if the stdio
> impl itself has internal locks which are held. So this data needs
> to be manually output using just write()
>
Or we can save info->si_signo && info->si_pid in global variables and
print this when shutdown is performed by main loop. Will send updated
patch.
--
Gleb.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-14 13:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 12:58 [Qemu-devel] [PATCH] report that QEMU process was killed by a signal Gleb Natapov
2011-03-14 13:07 ` Daniel P. Berrange
2011-03-14 13:11 ` Gleb Natapov
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).