report that QEMU process was killed by a signal
PATCH 1/1 report that QEMU process was killed by a signal
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.
os-posix.c +4 -2
@@ -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.
Quoted 3 lines · Gleb Natapov
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....
Quoted 7 lines
Signed-off-by Gleb Natapov <[email protected]>os-posix.c +0
-0
os-posix.c void os_setup_early_signal_handling(void) · line 67
Quoted 8 lines
os-posix.c +2
-1@@ -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
Signature · 4 lines
|: 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 :|
Quoted 17 lines · Daniel P. Berrange
Quoted 3 lines · Gleb Natapov
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....
Quoted 10 lines
Signed-off-by Gleb Natapov <[email protected]>os-posix.c +0
-0@@ -61,8 +61,9 @@ void os_setup_early_signal_handling(void)sigaction (SIGPIPE , &act,NULL ); }
Quoted 12 lines
os-posix.c void os_setup_early_signal_handling(void) · line 67
Quoted 5 lines
os-posix.c +2
-1-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 justwrite()
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.