From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acz5g-0003as-AN for qemu-devel@nongnu.org; Mon, 07 Mar 2016 12:37:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acz5d-0003Ef-4G for qemu-devel@nongnu.org; Mon, 07 Mar 2016 12:37:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acz5c-0003EF-Ui for qemu-devel@nongnu.org; Mon, 07 Mar 2016 12:37:05 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 96C81C00DE06 for ; Mon, 7 Mar 2016 17:37:04 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u27Hb1ZS001810 for ; Mon, 7 Mar 2016 12:37:03 -0500 From: Paolo Bonzini Date: Mon, 7 Mar 2016 18:36:47 +0100 Message-Id: <1457372221-19285-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1457372221-19285-1-git-send-email-pbonzini@redhat.com> References: <1457372221-19285-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 01/15] log: do not log if QEMU is daemonized but without -D List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Commit 96c33a4 ("log: Redirect stderr to logfile if deamonized", 2016-02-22) wanted to move stderr of a daemonized QEMU to the file specified with -D. However, if -D was not passed, the patch had the side effect of not redirecting stderr to /dev/null. This happened because qemu_logfile was set to stderr rather than the expected value of NULL. The fix is simply in the "if" condition of do_qemu_set_log; the "if" for closing the file is also changed to match. Reported-by: Jan Tomko Signed-off-by: Paolo Bonzini --- util/log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/log.c b/util/log.c index a7ddc7e..8b921de 100644 --- a/util/log.c +++ b/util/log.c @@ -56,7 +56,8 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) #ifdef CONFIG_TRACE_LOG qemu_loglevel |= LOG_TRACE; #endif - if ((qemu_loglevel || is_daemonized()) && !qemu_logfile) { + if (!qemu_logfile && + (is_daemonized() ? logfilename != NULL : qemu_loglevel)) { if (logfilename) { qemu_logfile = fopen(logfilename, log_append ? "a" : "w"); if (!qemu_logfile) { @@ -72,6 +73,7 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) } } else { /* Default to stderr if no log file specified */ + assert(!is_daemonized()); qemu_logfile = stderr; } /* must avoid mmap() usage of glibc by setting a buffer "by hand" */ @@ -89,7 +91,8 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers) log_append = 1; } } - if (!qemu_loglevel && !is_daemonized() && qemu_logfile) { + if (qemu_logfile && + (is_daemonized() ? logfilename == NULL : !qemu_loglevel)) { qemu_log_close(); } } -- 2.5.0