From 437d68473cb8e8071850a325a9ff83614a935f54 Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Tue, 30 Jun 2020 14:06:20 +0200 Subject: [PATCH] Add systemd journal logging patch Prints QEMU errors that occur *after* the "-daemonize" fork to the systemd journal, instead of pushing them into /dev/null like before. Signed-off-by: Stefan Reiter --- debian/control | 1 + ...ct-stderr-to-journal-when-daemonized.patch | 50 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 52 insertions(+) create mode 100644 debian/patches/pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch diff --git a/debian/control b/debian/control index 1dabf99..7a6fc35 100644 --- a/debian/control +++ b/debian/control @@ -25,6 +25,7 @@ Build-Depends: autotools-dev, libseccomp-dev, libspice-protocol-dev (>= 0.12.14~), libspice-server-dev (>= 0.14.0~), + libsystemd-dev, libusb-1.0-0-dev (>= 1.0.17-1), libusbredirparser-dev (>= 0.6-2), python3-minimal, diff --git a/debian/patches/pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch b/debian/patches/pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch new file mode 100644 index 0000000..f73de53 --- /dev/null +++ b/debian/patches/pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stefan Reiter +Date: Tue, 30 Jun 2020 13:10:10 +0200 +Subject: [PATCH] PVE: redirect stderr to journal when daemonized + +QEMU uses the logging for error messages usually, so LOG_ERR is most +fitting. +--- + Makefile.objs | 1 + + os-posix.c | 7 +++++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/Makefile.objs b/Makefile.objs +index b7d58e592e..105f23bff7 100644 +--- a/Makefile.objs ++++ b/Makefile.objs +@@ -55,6 +55,7 @@ common-obj-y += net/ + common-obj-y += qdev-monitor.o + common-obj-$(CONFIG_WIN32) += os-win32.o + common-obj-$(CONFIG_POSIX) += os-posix.o ++os-posix.o-libs := -lsystemd + + common-obj-$(CONFIG_LINUX) += fsdev/ + +diff --git a/os-posix.c b/os-posix.c +index 3cd52e1e70..ab4d052c62 100644 +--- a/os-posix.c ++++ b/os-posix.c +@@ -28,6 +28,8 @@ + #include + #include + #include ++#include ++#include + + #include "qemu-common.h" + /* Needed early for CONFIG_BSD etc. */ +@@ -309,9 +311,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_logfile) { +- dup2(fd, 2); ++ int journal_fd = sd_journal_stream_fd("QEMU", LOG_ERR, 0); ++ dup2(journal_fd, 2); + } + + close(fd); diff --git a/debian/patches/series b/debian/patches/series index 59e3a29..0a9c5c9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -48,3 +48,4 @@ pve/0046-pbs-fix-missing-crypt-and-compress-parameters.patch pve/0047-PVE-handle-PBS-write-callback-with-big-blocks-correc.patch pve/0048-PVE-add-zero-block-handling-to-PBS-dump-callback.patch pve/0049-PVE-add-query-pbs-bitmap-info-QMP-call.patch +pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch