1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stefan Reiter <s.reiter@proxmox.com>
3 Date: Tue, 30 Jun 2020 13:10:10 +0200
4 Subject: [PATCH] PVE: redirect stderr to journal when daemonized
6 QEMU uses the logging for error messages usually, so LOG_ERR is most
9 Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
12 os-posix.c | 7 +++++--
13 2 files changed, 6 insertions(+), 2 deletions(-)
15 diff --git a/Makefile.objs b/Makefile.objs
16 index 240eb503f2..c7ba4e11e7 100644
19 @@ -54,6 +54,7 @@ common-obj-y += net/
20 common-obj-y += qdev-monitor.o
21 common-obj-$(CONFIG_WIN32) += os-win32.o
22 common-obj-$(CONFIG_POSIX) += os-posix.o
23 +os-posix.o-libs := -lsystemd
25 common-obj-$(CONFIG_LINUX) += fsdev/
27 diff --git a/os-posix.c b/os-posix.c
28 index 3572db3f44..b45dde63ac 100644
35 +#include <systemd/sd-journal.h>
38 #include "qemu-common.h"
39 /* Needed early for CONFIG_BSD etc. */
40 @@ -312,9 +314,10 @@ void os_setup_post(void)
44 - /* In case -D is given do not redirect stderr to /dev/null */
45 + /* In case -D is given do not redirect stderr to journal */
48 + int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
49 + dup2(journal_fd, 2);