aboutsummaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorDimitris Aragiorgis <dimara@arrikto.com>2016-02-18 13:38:38 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-02-22 18:40:29 +0100
commit96c33a4523ee1abe382ce4ff3e82b90ba78aa186 (patch)
tree607b65f8018eb543241c4cffd2825bc395f3e463 /os-posix.c
parentd42a0d1484f03d05184ed9bb867fee42476a588f (diff)
log: Redirect stderr to logfile if deamonized
In case of daemonize, use the logfile passed with the -D option in order to redirect stderr to it instead of /dev/null. Also remove some unused code in log.h. Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com> Message-Id: <1455795518-19205-1-git-send-email-dimara@arrikto.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/os-posix.c b/os-posix.c
index cce62ed92b..92fa3baa1a 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -37,6 +37,7 @@
#include "qemu-options.h"
#include "qemu/rcu.h"
#include "qemu/error-report.h"
+#include "qemu/log.h"
#ifdef CONFIG_LINUX
#include <sys/prctl.h>
@@ -275,7 +276,10 @@ void os_setup_post(void)
dup2(fd, 0);
dup2(fd, 1);
- dup2(fd, 2);
+ /* In case -D is given do not redirect stderr to /dev/null */
+ if (!qemu_logfile) {
+ dup2(fd, 2);
+ }
close(fd);