From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaipO-000197-IQ for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:51:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaipN-0008Hw-HM for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:50:58 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:37366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaipN-0008Hg-32 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:50:57 -0500 Received: by mail-wm0-x22b.google.com with SMTP id p65so29795826wmp.0 for ; Tue, 01 Mar 2016 03:50:56 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 1 Mar 2016 12:50:53 +0100 Message-Id: <1456833053-8896-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] 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 Cc: jtomko@redhat.com, kraxel@redhat.com 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