diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-02-29 12:18:40 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-07 13:18:28 +0100 |
commit | c586eac33670c198c6c9ceb1419aa99dafcce907 (patch) | |
tree | 18ae9a6b76fb6125225bf47e36d668a9960aff4e /util | |
parent | 1464ad45cd6cdeb0b5c1a54d3d3791396e47e52f (diff) |
log: do not log if QEMU is daemonized but without -D
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 <jtomko@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/log.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/util/log.c b/util/log.c index a7ddc7ecd1..8b921de588 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(); } } |