]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
c5be26b68bb68f9d9557c3befcdb99a2ff359df1
[pve-qemu.git] / debian / patches / pve / 0036-PVE-redirect-stderr-to-journal-when-daemonized.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stefan Reiter <s.reiter@proxmox.com>
3 Date: Tue, 12 Jan 2021 14:12:20 +0100
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.
8
9 Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
10 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 ---
12 meson.build | 2 ++
13 os-posix.c | 7 +++++--
14 2 files changed, 7 insertions(+), 2 deletions(-)
15
16 diff --git a/meson.build b/meson.build
17 index be4785e2f6..3fc7c8d435 100644
18 --- a/meson.build
19 +++ b/meson.build
20 @@ -1463,6 +1463,7 @@ keyutils = dependency('libkeyutils', required: false,
21 has_gettid = cc.has_function('gettid')
22
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)
26
27 # libselinux
28 @@ -3105,6 +3106,7 @@ if have_block
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
35
36 diff --git a/os-posix.c b/os-posix.c
37 index 321fc4bd13..b1870d2690 100644
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
47 /* Needed early for CONFIG_BSD etc. */
48 #include "net/slirp.h"
49 @@ -281,9 +283,10 @@ void os_setup_post(void)
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 */
55 if (!qemu_log_enabled()) {
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);