From patchwork Tue Sep 20 14:54:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFByw612b3puw61r?= X-Patchwork-Id: 672299 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sdmB12RW6z9t15 for ; Wed, 21 Sep 2016 00:59:21 +1000 (AEST) Received: from localhost ([::1]:35887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmMVz-0008Lz-0Q for incoming@patchwork.ozlabs.org; Tue, 20 Sep 2016 10:59:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmMS0-0004kN-PU for qemu-devel@nongnu.org; Tue, 20 Sep 2016 10:55:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmMRs-00035K-UH for qemu-devel@nongnu.org; Tue, 20 Sep 2016 10:55:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmMRs-00034w-OR for qemu-devel@nongnu.org; Tue, 20 Sep 2016 10:55:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 344BC8AE72; Tue, 20 Sep 2016 14:55:04 +0000 (UTC) Received: from lisa.brq.redhat.com (dhcp129-142.brq.redhat.com [10.34.129.142]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8KEt0f3023412; Tue, 20 Sep 2016 10:55:03 -0400 From: Michal Privoznik To: qemu-devel@nongnu.org Date: Tue, 20 Sep 2016 16:54:53 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 20 Sep 2016 14:55:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] qemu_kill_report: Report PID name too X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, armbru@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Eric Blake --- vl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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