qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCHv2] report that QEMU process was killed by a sign


From: Gleb Natapov
Subject: Re: [Qemu-devel] [PATCHv2] report that QEMU process was killed by a signal
Date: Mon, 14 Mar 2011 21:30:14 +0200

On Mon, Mar 14, 2011 at 09:20:43PM +0200, Blue Swirl wrote:
> On Mon, Mar 14, 2011 at 3:44 PM, Gleb Natapov <address@hidden> 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.
> 
> QEMU ;-)
> 
Eah and second "killed" should be "killer". Why can't spell checker be smarter.

> >
> > Signed-off-by: Gleb Natapov <address@hidden>
> > ---
> >  v1->v2:
> >  - print message from a main loop instead of signal handler
> >
> > diff --git a/os-posix.c b/os-posix.c
> > index 38c29d1..36d937c 100644
> > --- a/os-posix.c
> > +++ b/os-posix.c
> > @@ -61,9 +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)
> >  {
> > -    qemu_system_shutdown_request();
> > +    qemu_system_killed(info->si_signo, info->si_pid);
> >  }
> >
> >  static void sigchld_handler(int signal)
> > @@ -76,7 +76,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);
> > diff --git a/sysemu.h b/sysemu.h
> > index 0a83ab9..fc7048a 100644
> > --- a/sysemu.h
> > +++ b/sysemu.h
> > @@ -66,6 +66,8 @@ void qemu_system_vmstop_request(int reason);
> >  int qemu_shutdown_requested(void);
> >  int qemu_reset_requested(void);
> >  int qemu_powerdown_requested(void);
> > +void qemu_system_killed(int signal, int pid);
> 
> pid_t pid
> 
OK.

> > +void qemu_kill_report(void);
> >  extern qemu_irq qemu_system_powerdown;
> >  void qemu_system_reset(void);
> >
> > diff --git a/vl.c b/vl.c
> > index 5e007a7..d14c42d 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -1213,7 +1213,7 @@ typedef struct QEMUResetEntry {
> >  static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
> >     QTAILQ_HEAD_INITIALIZER(reset_handlers);
> >  static int reset_requested;
> > -static int shutdown_requested;
> > +static int shutdown_requested, shutdown_signal = -1, shutdown_pid;
> 
> static pid_t shutdown_pid;
> 
> >  static int powerdown_requested;
> >  static int debug_requested;
> >  static int vmstop_requested;
> > @@ -1225,6 +1225,15 @@ int qemu_shutdown_requested(void)
> >     return r;
> >  }
> >
> > +void qemu_kill_report(void)
> > +{
> > +    if (shutdown_signal != -1) {
> > +        fprintf(stderr, "Got signal %d from pid %d\n",
> 
> Are there any systems with 64 bit pid_t? Then a cast may be needed
> and/or format adjusted.
> 
Doubt there are any.

> > +                         shutdown_signal, shutdown_pid);
> > +        shutdown_signal = -1;
> > +    }
> > +}
> > +
> >  int qemu_reset_requested(void)
> >  {
> >     int r = reset_requested;
> > @@ -1298,6 +1307,13 @@ void qemu_system_reset_request(void)
> >     qemu_notify_event();
> >  }
> >
> > +void qemu_system_killed(int signal, int pid)
> 
> pid_t pid

--
                        Gleb.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]