]>
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 |
dc9827a6 | 17 | index d3783a83e4..715245ba20 100644 |
817b7667 SR |
18 | --- a/meson.build |
19 | +++ b/meson.build | |
dc9827a6 | 20 | @@ -1268,6 +1268,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 |
dc9827a6 | 28 | @@ -2861,6 +2862,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 | 36 | diff --git a/os-posix.c b/os-posix.c |
dc9827a6 | 37 | index 24692c8593..d1bc5ac12d 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 | ||
47 | #include "qemu-common.h" | |
48 | /* Needed early for CONFIG_BSD etc. */ | |
8dca018b | 49 | @@ -291,9 +293,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 */ | |
55 | if (!qemu_logfile) { | |
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); |