]>
Commit | Line | Data |
---|---|---|
437d6847 SR |
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 | |
5 | ||
6 | QEMU uses the logging for error messages usually, so LOG_ERR is most | |
7 | fitting. | |
72ae34ec SR |
8 | |
9 | Signed-off-by: Stefan Reiter <s.reiter@proxmox.com> | |
437d6847 SR |
10 | --- |
11 | Makefile.objs | 1 + | |
12 | os-posix.c | 7 +++++-- | |
13 | 2 files changed, 6 insertions(+), 2 deletions(-) | |
14 | ||
15 | diff --git a/Makefile.objs b/Makefile.objs | |
d333327a | 16 | index 240eb503f2..c7ba4e11e7 100644 |
437d6847 SR |
17 | --- a/Makefile.objs |
18 | +++ b/Makefile.objs | |
d333327a | 19 | @@ -54,6 +54,7 @@ common-obj-y += net/ |
437d6847 SR |
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 | |
24 | ||
25 | common-obj-$(CONFIG_LINUX) += fsdev/ | |
26 | ||
27 | diff --git a/os-posix.c b/os-posix.c | |
d333327a | 28 | index 3572db3f44..b45dde63ac 100644 |
437d6847 SR |
29 | --- a/os-posix.c |
30 | +++ b/os-posix.c | |
31 | @@ -28,6 +28,8 @@ | |
32 | #include <pwd.h> | |
33 | #include <grp.h> | |
34 | #include <libgen.h> | |
35 | +#include <systemd/sd-journal.h> | |
36 | +#include <syslog.h> | |
37 | ||
38 | #include "qemu-common.h" | |
39 | /* Needed early for CONFIG_BSD etc. */ | |
d333327a | 40 | @@ -312,9 +314,10 @@ void os_setup_post(void) |
437d6847 SR |
41 | |
42 | dup2(fd, 0); | |
43 | dup2(fd, 1); | |
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 */ | |
46 | if (!qemu_logfile) { | |
47 | - dup2(fd, 2); | |
48 | + int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0); | |
49 | + dup2(journal_fd, 2); | |
50 | } | |
51 | ||
52 | close(fd); |