]>
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> | |
437d6847 | 10 | --- |
817b7667 SR |
11 | meson.build | 2 ++ |
12 | os-posix.c | 7 +++++-- | |
13 | 2 files changed, 7 insertions(+), 2 deletions(-) | |
437d6847 | 14 | |
817b7667 SR |
15 | diff --git a/meson.build b/meson.build |
16 | index 4d156d35ce..737ea9e5d7 100644 | |
17 | --- a/meson.build | |
18 | +++ b/meson.build | |
19 | @@ -726,6 +726,7 @@ keyutils = dependency('libkeyutils', required: false, | |
20 | has_gettid = cc.has_function('gettid') | |
437d6847 | 21 | |
817b7667 SR |
22 | libuuid = cc.find_library('uuid', required: true) |
23 | +libsystemd = cc.find_library('systemd', required: true) | |
24 | libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true) | |
437d6847 | 25 | |
817b7667 SR |
26 | # Malloc tests |
27 | @@ -1539,6 +1540,7 @@ blockdev_ss.add(files( | |
28 | # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon, | |
29 | # os-win32.c does not | |
30 | blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c')) | |
31 | +blockdev_ss.add(when: 'CONFIG_POSIX', if_true: libsystemd) | |
32 | softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) | |
33 | ||
34 | common_ss.add(files('cpus-common.c')) | |
437d6847 | 35 | diff --git a/os-posix.c b/os-posix.c |
817b7667 | 36 | index 1de2839554..ac4f652923 100644 |
437d6847 SR |
37 | --- a/os-posix.c |
38 | +++ b/os-posix.c | |
39 | @@ -28,6 +28,8 @@ | |
40 | #include <pwd.h> | |
41 | #include <grp.h> | |
42 | #include <libgen.h> | |
43 | +#include <systemd/sd-journal.h> | |
44 | +#include <syslog.h> | |
45 | ||
46 | #include "qemu-common.h" | |
47 | /* Needed early for CONFIG_BSD etc. */ | |
817b7667 | 48 | @@ -288,9 +290,10 @@ void os_setup_post(void) |
437d6847 SR |
49 | |
50 | dup2(fd, 0); | |
51 | dup2(fd, 1); | |
52 | - /* In case -D is given do not redirect stderr to /dev/null */ | |
53 | + /* In case -D is given do not redirect stderr to journal */ | |
54 | if (!qemu_logfile) { | |
55 | - dup2(fd, 2); | |
56 | + int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0); | |
57 | + dup2(journal_fd, 2); | |
58 | } | |
59 | ||
60 | close(fd); |