From cab500ca23de3e811434a8bae2b818bfba9b0479 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 19 Aug 2026 15:13:31 +0200 Subject: [PATCH] libvirt-8.0.0-23.6.el8 - services: Weaken systemd dependency on virtlockd (RHEL-224988) - qemu: Ensure proper shutdown ordering of virtlockd/virtlogd daemons (RHEL-224988) - qemu: Fix proper ordering of 'virtlockd' shutdown (RHEL-224988) Resolves: RHEL-224988 --- ...dering-of-virtlockd-virtlogd-daemons.patch | 158 ++++++++++++++++++ ...roper-ordering-of-virtlockd-shutdown.patch | 66 ++++++++ ...aken-systemd-dependency-on-virtlockd.patch | 80 +++++++++ libvirt.spec | 10 +- 4 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 libvirt-qemu-Ensure-proper-shutdown-ordering-of-virtlockd-virtlogd-daemons.patch create mode 100644 libvirt-qemu-Fix-proper-ordering-of-virtlockd-shutdown.patch create mode 100644 libvirt-services-Weaken-systemd-dependency-on-virtlockd.patch diff --git a/libvirt-qemu-Ensure-proper-shutdown-ordering-of-virtlockd-virtlogd-daemons.patch b/libvirt-qemu-Ensure-proper-shutdown-ordering-of-virtlockd-virtlogd-daemons.patch new file mode 100644 index 0000000..a9307c3 --- /dev/null +++ b/libvirt-qemu-Ensure-proper-shutdown-ordering-of-virtlockd-virtlogd-daemons.patch @@ -0,0 +1,158 @@ +From 365f1e9e5a63bdd85acd77930022d580b309db71 Mon Sep 17 00:00:00 2001 +Message-ID: <365f1e9e5a63bdd85acd77930022d580b309db71.1787145211.git.jdenemar@redhat.com> +From: Peter Krempa +Date: Mon, 15 Jun 2026 13:01:01 +0200 +Subject: [PATCH] qemu: Ensure proper shutdown ordering of virtlockd/virtlogd + daemons + +For socket activation to work our systemd unit files use the following +pattern: + + [virtlogd.socket] <----(After)--- [virtlogd.service] + [virtqemud.socket] <----(After)--- [virtqemud.service] + +Now the qemu daemon also wants to use the services provided by those +daemons so we have dependency between the two too: + + [virtlogd.socket] <----(After)--- [virtlogd.service] + ^ + +-------------(After+Requires)-------+ + | + [virtqemud.socket] <----(After)--- [virtqemud.service] + +Now on startup everything is fine, because with socket activation, when +'virtqemud.service' wants to use 'virtlogd' services the socket is +already up due to the dependency+ordering and opening a connection will +cause 'virtlogd.service' to be socket-activated. + +On shutdown though there's no transitive 'After' ordering between +'virtqemud.service' and 'virtlogd.service' and thus nothing explicitly +telling systemd that if virtlogd was started. In fact systemd is free to +translate it that 'virtlogd' and 'virtqemud' need to be stopped before +stopping 'virtlogd.socket'. + +To illustrate what happens consider the following scenario: + +A host is running a VM under virtqemud. 'virtqemud' is configured to +attempt shutdown on the VMs before killing them (daemon-based guest +shutdown, but the same reproduces also with libvirt-guests). The host +is being rebooted. + + (virtqemud attempts to shut down guests, but guest takes more than the + configured shutdown inhibition timeout, journald output follows): + + 06:44:02 fedora systemd-logind[664]: Delay lock is active (UID 0/root, PID 991/virtqemud) but inhibitor timeout is reached. + 06:44:02 fedora systemd-logind[664]: System is rebooting. + [...] + 06:44:02 fedora virtlogd[802]: 802: debug : virSystemdNotify:667 : Notify 'STOPPING=1' + 06:44:02 fedora systemd[1]: Stopping virtlogd.service - libvirt logging daemon... + 06:44:02 fedora systemd[1]: Stopping virtqemud.service - libvirt QEMU daemon... + 06:44:02 fedora virtqemud[991]: 991: debug : virSystemdNotify:667 : Notify 'STOPPING=1' + 06:44:02 fedora systemd[1]: virtlogd.service: Deactivated successfully. + 06:44:02 fedora systemd[1]: Stopped virtlogd.service - libvirt logging daemon. + + (the shutdown times out, virtqemud kills the unresponsive vm) + + 06:44:27 fedora virtqemud[991]: 1053: debug : qemuProcessStop:8916 : Shutting down vm=0x7f71ac032670 name=virt-vm1 id=1 pid=805, reason=destroyed, asyncJob=none, flags=0x0 + 06:44:27 fedora virtqemud[991]: 1053: debug : qemuDomainLogAppendMessage:5757 : Append log message (vm='virt-vm1' message='2026-06-15 10:44:27.427+0000: shutting down, reason=destroyed + ) stdioLogD=1 + 06:44:27 fedora virtqemud[991]: 1053: error : virNetSocketReadWire:1767 : Cannot recv data: Connection reset by peer + 06:44:27 fedora virtqemud[991]: 1053: debug : qemuProcessKill:8811 : vm=0x7f71ac032670 name=virt-vm1 pid=805 flags=0x5 + +Now the log shows that we want to add VM log file message in +'qemuDomainLogAppendMessage' but it fails because virtlogd is dead +already. + +Now the same happens also with 'virtlockd' but with much worse outcome, +especially if the configured action is to save the VMs because shutdown +of 'virtlockd' when locks are held ends up 'fencing' the VMs by killing +them. + +The same also happens when libvirt-guests is used to shutdown the guests +instead. + +This patch adds an explicit 'After=virtlo[ck|g]d.service' to the daemons +containing the qemu driver to ensure that the shutdown ordering makes +sense. This doesn't break socket activation (e.g. the log/lock daemons +are not started unless first invoked). + +Signed-off-by: Peter Krempa +Reviewed-by: Jiri Denemark +(cherry picked from commit aa1bf13b9caa4ef893cd4fdbaa111d5da73aa120) + + Conflicts: + - src/qemu/virtqemud.service.in + - src/remote/libvirtd.service.in + + Upstream commit patches 'src/qemu/virtqemud.service.extra.in' + which doesn't exist downstream as commit: + + commit 0f09223fc5a09f438b3e19567a8630672f108cb3 + Author: Andrea Bolognani + Date: Tue Sep 19 20:41:06 2023 +0200 + + systemd: Switch virtqemud to common templates + + wasn't backported. This patch applies the same hunks to the previous + version of the file. + + This patch also backports 2 hunks which form the context which was + added by commit: + + commit 2ca96a810ed0b5e65a47fdbb9aaa3b2761c76332 + Author: Andrea Bolognani + Date: Mon Sep 25 17:16:20 2023 +0200 + + systemd: Augment Requires/Wants with After + + specifically: + + +After=virtlogd.socket + +After=virtlockd.socket + + The other hunks from that commit are too invasive and not related to + this patch, so backporting the commit as whole is IMO not waranted. + +https://redhat.atlassian.net/browse/RHEL-224988 +Signed-off-by: Peter Krempa +--- + src/qemu/virtqemud.service.in | 6 ++++++ + src/remote/libvirtd.service.in | 6 ++++++ + 2 files changed, 12 insertions(+) + +diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in +index a505e275b1..2e962e6ecd 100644 +--- a/src/qemu/virtqemud.service.in ++++ b/src/qemu/virtqemud.service.in +@@ -6,6 +6,12 @@ Requires=virtqemud.socket + Requires=virtqemud-ro.socket + Requires=virtqemud-admin.socket + Wants=virtlockd.socket ++After=virtlogd.socket ++After=virtlockd.socket ++# To ensure that our helper daemons are not shut down before the main daemon ++# shuts down we need also explicit ordering with the .service unit ++After=virtlogd.service ++After=virtlock.service + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in +index 32133bc0e1..12d93a21c6 100644 +--- a/src/remote/libvirtd.service.in ++++ b/src/remote/libvirtd.service.in +@@ -8,6 +8,12 @@ Wants=libvirtd.socket + Wants=libvirtd-ro.socket + Wants=libvirtd-admin.socket + Wants=virtlockd.socket ++After=virtlogd.socket ++After=virtlockd.socket ++# To ensure that our helper daemons are not shut down before the main daemon ++# shuts down we need also explicit ordering with the .service unit ++After=virtlogd.service ++After=virtlock.service + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +-- +2.55.0 diff --git a/libvirt-qemu-Fix-proper-ordering-of-virtlockd-shutdown.patch b/libvirt-qemu-Fix-proper-ordering-of-virtlockd-shutdown.patch new file mode 100644 index 0000000..a1efd56 --- /dev/null +++ b/libvirt-qemu-Fix-proper-ordering-of-virtlockd-shutdown.patch @@ -0,0 +1,66 @@ +From fbf34039e97023d3a63fa4e5c835a665ff92fe2d Mon Sep 17 00:00:00 2001 +Message-ID: +From: Peter Krempa +Date: Tue, 18 Aug 2026 10:09:06 +0200 +Subject: [PATCH] qemu: Fix proper ordering of 'virtlockd' shutdown + +In commit aa1bf13b9caa4ef893cd4fdbaa111d5da73aa120 I attempted to fix +the ordering of virtlockd and virtlogd during shutdown but I made a typo +in the name of 'virtlockd.service' (missing 'd'). + +Fixes: aa1bf13b9caa4ef893cd4fdbaa111d5da73aa120 +Signed-off-by: Peter Krempa +Reviewed-by: Pavel Hrdina +Reviewed-by: Martin Kletzander +(cherry picked from commit 82b39d0580ecb6aa4a6c88eabb85cc6d6bafd559) + + Conflits: + + - src/qemu/virtqemud.service.in + + Patched src/qemu/virtqemud.service.in instead of + src/qemu/virtqemud.service.extra.in as: + + commit 0f09223fc5a09f438b3e19567a8630672f108cb3 + Author: Andrea Bolognani + Date: Tue Sep 19 20:41:06 2023 +0200 + + systemd: Switch virtqemud to common templates + + wasn't backported. + +https://redhat.atlassian.net/browse/RHEL-224988 +Signed-off-by: Peter Krempa +--- + src/qemu/virtqemud.service.in | 2 +- + src/remote/libvirtd.service.in | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in +index 2e962e6ecd..40dda6d076 100644 +--- a/src/qemu/virtqemud.service.in ++++ b/src/qemu/virtqemud.service.in +@@ -11,7 +11,7 @@ After=virtlockd.socket + # To ensure that our helper daemons are not shut down before the main daemon + # shuts down we need also explicit ordering with the .service unit + After=virtlogd.service +-After=virtlock.service ++After=virtlockd.service + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in +index 12d93a21c6..29e7bbb9ae 100644 +--- a/src/remote/libvirtd.service.in ++++ b/src/remote/libvirtd.service.in +@@ -13,7 +13,7 @@ After=virtlockd.socket + # To ensure that our helper daemons are not shut down before the main daemon + # shuts down we need also explicit ordering with the .service unit + After=virtlogd.service +-After=virtlock.service ++After=virtlockd.service + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +-- +2.55.0 diff --git a/libvirt-services-Weaken-systemd-dependency-on-virtlockd.patch b/libvirt-services-Weaken-systemd-dependency-on-virtlockd.patch new file mode 100644 index 0000000..b5f075d --- /dev/null +++ b/libvirt-services-Weaken-systemd-dependency-on-virtlockd.patch @@ -0,0 +1,80 @@ +From a2ea3097459472e676bcd75887cf13a21ce4e2ab Mon Sep 17 00:00:00 2001 +Message-ID: +From: Jim Fehlig +Date: Fri, 13 Jan 2023 12:04:28 -0700 +Subject: [PATCH] services: Weaken systemd dependency on virtlockd +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The systemd service files of the qemu and libxl driver currently have a +'Requires' dependency on virtlockd, which is too strong since virtlockd +is not enabled by default in either driver. Change the dependency to a +'Wants' to avoid a package dependency between the driver subpackages and +the new libvirt-daemon-lock subpackage. + +Signed-off-by: Jim Fehlig +Reviewed-by: Andrea Bolognani +Reviewed-by: Daniel P. Berrangé +(cherry picked from commit cba964b145515e998a370cda6594d6d8c6d90ba2) + +https://redhat.atlassian.net/browse/RHEL-224988 +--- + src/libxl/virtxend.service.in | 2 +- + src/qemu/virtqemud.service.in | 2 +- + src/remote/libvirtd.service.in | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/libxl/virtxend.service.in b/src/libxl/virtxend.service.in +index 19b19ce3e6..fb14f3aad2 100644 +--- a/src/libxl/virtxend.service.in ++++ b/src/libxl/virtxend.service.in +@@ -1,10 +1,10 @@ + [Unit] + Description=Virtualization xen daemon + Conflicts=libvirtd.service +-Requires=virtlockd.socket + Requires=virtxend.socket + Requires=virtxend-ro.socket + Requires=virtxend-admin.socket ++Wants=virtlockd.socket + After=network.target + After=dbus.service + After=apparmor.service +diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in +index 20e1b43a6e..a505e275b1 100644 +--- a/src/qemu/virtqemud.service.in ++++ b/src/qemu/virtqemud.service.in +@@ -2,10 +2,10 @@ + Description=Virtualization qemu daemon + Conflicts=libvirtd.service + Requires=virtlogd.socket +-Requires=virtlockd.socket + Requires=virtqemud.socket + Requires=virtqemud-ro.socket + Requires=virtqemud-admin.socket ++Wants=virtlockd.socket + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in +index cc0d4e3693..32133bc0e1 100644 +--- a/src/remote/libvirtd.service.in ++++ b/src/remote/libvirtd.service.in +@@ -1,13 +1,13 @@ + [Unit] + Description=Virtualization daemon + Requires=virtlogd.socket +-Requires=virtlockd.socket + # Use Wants instead of Requires so that users + # can disable these three .socket units to revert + # to a traditional non-activation deployment setup + Wants=libvirtd.socket + Wants=libvirtd-ro.socket + Wants=libvirtd-admin.socket ++Wants=virtlockd.socket + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target +-- +2.55.0 diff --git a/libvirt.spec b/libvirt.spec index a4b874b..59889fd 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -210,7 +210,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.0.0 -Release: 23.5%{?dist}%{?extra_release} +Release: 23.6%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -332,6 +332,9 @@ Patch109: libvirt-qemu_capabilities-filter-deprecated-features-if-requested.patc Patch110: libvirt-virsh-add-disable-deprecated-features-flag-to-domcapabilities.patch Patch111: libvirt-conf-add-deprecated_features-attribute.patch Patch112: libvirt-virsh-Add-option-no-pkttyagent.patch +Patch113: libvirt-services-Weaken-systemd-dependency-on-virtlockd.patch +Patch114: libvirt-qemu-Ensure-proper-shutdown-ordering-of-virtlockd-virtlogd-daemons.patch +Patch115: libvirt-qemu-Fix-proper-ordering-of-virtlockd-shutdown.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2211,6 +2214,11 @@ exit 0 %changelog +* Wed Aug 19 2026 Jiri Denemark - 8.0.0-23.6.el8 +- services: Weaken systemd dependency on virtlockd (RHEL-224988) +- qemu: Ensure proper shutdown ordering of virtlockd/virtlogd daemons (RHEL-224988) +- qemu: Fix proper ordering of 'virtlockd' shutdown (RHEL-224988) + * Wed Jan 14 2026 Jiri Denemark - 8.0.0-23.5.el8 - virsh: Add option '--no-pkttyagent' (RHEL-134972)