51 lines
1.4 KiB
Diff
51 lines
1.4 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Stefan Reiter <s.reiter@proxmox.com>
|
||
|
Date: Tue, 30 Jun 2020 13:10:10 +0200
|
||
|
Subject: [PATCH] PVE: redirect stderr to journal when daemonized
|
||
|
|
||
|
QEMU uses the logging for error messages usually, so LOG_ERR is most
|
||
|
fitting.
|
||
|
---
|
||
|
Makefile.objs | 1 +
|
||
|
os-posix.c | 7 +++++--
|
||
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/Makefile.objs b/Makefile.objs
|
||
|
index b7d58e592e..105f23bff7 100644
|
||
|
--- a/Makefile.objs
|
||
|
+++ b/Makefile.objs
|
||
|
@@ -55,6 +55,7 @@ common-obj-y += net/
|
||
|
common-obj-y += qdev-monitor.o
|
||
|
common-obj-$(CONFIG_WIN32) += os-win32.o
|
||
|
common-obj-$(CONFIG_POSIX) += os-posix.o
|
||
|
+os-posix.o-libs := -lsystemd
|
||
|
|
||
|
common-obj-$(CONFIG_LINUX) += fsdev/
|
||
|
|
||
|
diff --git a/os-posix.c b/os-posix.c
|
||
|
index 3cd52e1e70..ab4d052c62 100644
|
||
|
--- a/os-posix.c
|
||
|
+++ b/os-posix.c
|
||
|
@@ -28,6 +28,8 @@
|
||
|
#include <pwd.h>
|
||
|
#include <grp.h>
|
||
|
#include <libgen.h>
|
||
|
+#include <systemd/sd-journal.h>
|
||
|
+#include <syslog.h>
|
||
|
|
||
|
#include "qemu-common.h"
|
||
|
/* Needed early for CONFIG_BSD etc. */
|
||
|
@@ -309,9 +311,10 @@ void os_setup_post(void)
|
||
|
|
||
|
dup2(fd, 0);
|
||
|
dup2(fd, 1);
|
||
|
- /* In case -D is given do not redirect stderr to /dev/null */
|
||
|
+ /* In case -D is given do not redirect stderr to journal */
|
||
|
if (!qemu_logfile) {
|
||
|
- dup2(fd, 2);
|
||
|
+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
|
||
|
+ dup2(journal_fd, 2);
|
||
|
}
|
||
|
|
||
|
close(fd);
|