diff mbox

[2/2] qemu_kill_report: Report PID name too

Message ID bb5d9825df6a7b96d56753dc12e7462f06775455.1474383125.git.mprivozn@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Privoznik Sept. 20, 2016, 2:54 p.m. UTC
When qemu is being killed, its last words are:

2016-08-31T11:48:15.293587Z qemu-system-x86_64: terminating on signal 15 from pid 11180

That's nice, but what process is 11180? What if I told you we can
do better:

2016-08-31T11:48:15.293587Z qemu-system-x86_64: terminating on signal 15 from pid 11180 (/usr/sbin/libvirtd)

And that's exactly what this patch does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 vl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Eric Blake Sept. 20, 2016, 3:07 p.m. UTC | #1
On 09/20/2016 09:54 AM, Michal Privoznik wrote:
> When qemu is being killed, its last words are:
> 
> 2016-08-31T11:48:15.293587Z qemu-system-x86_64: terminating on signal 15 from pid 11180
> 
> That's nice, but what process is 11180? What if I told you we can
> do better:
> 
> 2016-08-31T11:48:15.293587Z qemu-system-x86_64: terminating on signal 15 from pid 11180 (/usr/sbin/libvirtd)
> 
> And that's exactly what this patch does.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  vl.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

> +            error_report("terminating on signal %d from pid " FMT_pid " (%s)",
> +                         shutdown_signal, shutdown_pid,
> +                         shutdown_cmd ? shutdown_cmd : "");

Ending with " ()" looks weird if qemu_get_pid_name() can't find a name;
can we do something like " (<unknown process>)" if shutdown_cmd is NULL?

Otherwise looks like a nice idea;
Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/vl.c b/vl.c
index fca0487..71e8ead 100644
--- a/vl.c
+++ b/vl.c
@@ -1600,6 +1600,7 @@  static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
 static int reset_requested;
 static int shutdown_requested, shutdown_signal = -1;
 static pid_t shutdown_pid;
+static char *shutdown_cmd;
 static int powerdown_requested;
 static int debug_requested;
 static int suspend_requested;
@@ -1636,9 +1637,11 @@  static void qemu_kill_report(void)
              */
             error_report("terminating on signal %d", shutdown_signal);
         } else {
-            error_report("terminating on signal %d from pid " FMT_pid,
-                         shutdown_signal, shutdown_pid);
+            error_report("terminating on signal %d from pid " FMT_pid " (%s)",
+                         shutdown_signal, shutdown_pid,
+                         shutdown_cmd ? shutdown_cmd : "");
         }
+        g_free(shutdown_cmd);
         shutdown_signal = -1;
     }
 }
@@ -1809,6 +1812,7 @@  void qemu_system_killed(int signal, pid_t pid)
 {
     shutdown_signal = signal;
     shutdown_pid = pid;
+    shutdown_cmd = qemu_get_pid_name(pid);
     no_shutdown = 0;
 
     /* Cannot call qemu_system_shutdown_request directly because