]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
update submodule and patches to 7.2.0
[pve-qemu.git] / debian / patches / pve / 0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
CommitLineData
437d6847
SR
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Stefan Reiter <s.reiter@proxmox.com>
817b7667 3Date: Tue, 12 Jan 2021 14:12:20 +0100
437d6847
SR
4Subject: [PATCH] PVE: redirect stderr to journal when daemonized
5
6QEMU uses the logging for error messages usually, so LOG_ERR is most
7fitting.
72ae34ec
SR
8
9Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
ddbf7a87 10Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
437d6847 11---
817b7667
SR
12 meson.build | 2 ++
13 os-posix.c | 7 +++++--
14 2 files changed, 7 insertions(+), 2 deletions(-)
437d6847 15
817b7667 16diff --git a/meson.build b/meson.build
d03e1b3c 17index f7f5b3f253..283b0e356e 100644
817b7667
SR
18--- a/meson.build
19+++ b/meson.build
d03e1b3c 20@@ -1526,6 +1526,7 @@ keyutils = dependency('libkeyutils', required: false,
817b7667 21 has_gettid = cc.has_function('gettid')
437d6847 22
817b7667
SR
23 libuuid = cc.find_library('uuid', required: true)
24+libsystemd = cc.find_library('systemd', required: true)
25 libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true)
437d6847 26
4567474e 27 # libselinux
d03e1b3c 28@@ -3096,6 +3097,7 @@ if have_block
8dca018b
SR
29 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
30 # os-win32.c does not
31 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
32+ blockdev_ss.add(when: 'CONFIG_POSIX', if_true: libsystemd)
33 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
34 endif
817b7667 35
437d6847 36diff --git a/os-posix.c b/os-posix.c
d03e1b3c 37index 4858650c3e..c5cb12226a 100644
437d6847
SR
38--- a/os-posix.c
39+++ b/os-posix.c
40@@ -28,6 +28,8 @@
41 #include <pwd.h>
42 #include <grp.h>
43 #include <libgen.h>
44+#include <systemd/sd-journal.h>
45+#include <syslog.h>
46
437d6847 47 /* Needed early for CONFIG_BSD etc. */
5b15e2ec 48 #include "net/slirp.h"
d03e1b3c 49@@ -287,9 +289,10 @@ void os_setup_post(void)
437d6847
SR
50
51 dup2(fd, 0);
52 dup2(fd, 1);
53- /* In case -D is given do not redirect stderr to /dev/null */
54+ /* In case -D is given do not redirect stderr to journal */
5b15e2ec 55 if (!qemu_log_enabled()) {
437d6847
SR
56- dup2(fd, 2);
57+ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0);
58+ dup2(journal_fd, 2);
59 }
60
61 close(fd);