]> git.proxmox.com Git - pve-qemu.git/commitdiff
Add systemd journal logging patch
authorStefan Reiter <s.reiter@proxmox.com>
Tue, 30 Jun 2020 12:06:20 +0000 (14:06 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 8 Sep 2020 15:13:29 +0000 (17:13 +0200)
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 <s.reiter@proxmox.com>
debian/control
debian/patches/pve/0050-PVE-redirect-stderr-to-journal-when-daemonized.patch [new file with mode: 0644]
debian/patches/series

index 1dabf99376a71383025f0ff55aa9c782631a84eb..7a6fc352155bf8231ca17963e00c12707a35dd38 100644 (file)
@@ -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 (file)
index 0000000..f73de53
--- /dev/null
@@ -0,0 +1,50 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Stefan Reiter <s.reiter@proxmox.com>
+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 <pwd.h>
+ #include <grp.h>
+ #include <libgen.h>
++#include <systemd/sd-journal.h>
++#include <syslog.h>
+ #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);
index 59e3a29b70f16dabc583cdbb6f717173d891f9b6..0a9c5c95848118899dbe01ad7477e7b789a82ab8 100644 (file)
@@ -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