From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Tue, 12 Jan 2021 14:12:20 +0100 Subject: [PATCH] PVE: redirect stderr to journal when daemonized QEMU uses the logging for error messages usually, so LOG_ERR is most fitting. Signed-off-by: Stefan Reiter Signed-off-by: Thomas Lamprecht --- meson.build | 3 ++- os-posix.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 3bc039f60f..067e8956a7 100644 --- a/meson.build +++ b/meson.build @@ -1923,6 +1923,7 @@ endif has_gettid = cc.has_function('gettid') libuuid = cc.find_library('uuid', required: true) +libsystemd = cc.find_library('systemd', required: true) libproxmox_backup_qemu = cc.find_library('proxmox_backup_qemu', required: true) # libselinux @@ -3530,7 +3531,7 @@ if have_block if host_os == 'windows' system_ss.add(files('os-win32.c')) else - blockdev_ss.add(files('os-posix.c')) + blockdev_ss.add(files('os-posix.c'), libsystemd) endif endif diff --git a/os-posix.c b/os-posix.c index a4284e2c07..197a2120fd 100644 --- a/os-posix.c +++ b/os-posix.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include "qemu/error-report.h" #include "qemu/log.h" @@ -302,9 +304,10 @@ void os_setup_post(void) dup2(fd, 0); dup2(fd, 1); - /* In case -D is given do not redirect stderr to /dev/null */ + /* In case -D is given do not redirect stderr to journal */ if (!qemu_log_enabled()) { - dup2(fd, 2); + int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0); + dup2(journal_fd, 2); } close(fd);