]>
Commit | Line | Data |
---|---|---|
437d6847 SR |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Stefan Reiter <s.reiter@proxmox.com> | |
817b7667 | 3 | Date: Tue, 12 Jan 2021 14:12:20 +0100 |
437d6847 SR |
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> | |
ddbf7a87 | 10 | Signed-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 | 16 | diff --git a/meson.build b/meson.build |
10e10933 | 17 | index cbfc9a43fb..8206270272 100644 |
817b7667 SR |
18 | --- a/meson.build |
19 | +++ b/meson.build | |
10e10933 | 20 | @@ -1779,6 +1779,7 @@ endif |
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 |
10e10933 | 28 | @@ -3406,6 +3407,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) | |
10e10933 | 33 | system_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) |
8dca018b | 34 | endif |
817b7667 | 35 | |
437d6847 | 36 | diff --git a/os-posix.c b/os-posix.c |
10e10933 | 37 | index cfcb96533c..fb2ad87009 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" |
10e10933 | 49 | @@ -310,9 +312,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); |