[Pkg-libvirt-commits] [Git][libvirt-team/libvirt][debian/latest] 3 commits: systemd: Hardcode output of dh_installsystemd
Andrea Bolognani (@abologna)
gitlab at salsa.debian.org
Sat Mar 19 18:05:12 GMT 2022
Andrea Bolognani pushed to branch debian/latest at Libvirt Packaging Team / libvirt
Commits:
ba504f6c by Andrea Bolognani at 2022-03-16T14:12:09+01:00
systemd: Hardcode output of dh_installsystemd
As a first step towards working around #994204, we take the
output produced by dh_installsystemd/13.6 and include it
verbatim in the maintainer scripts.
This will allow us to tweak the behavior in a upcoming
commits.
Gbp-Dch: Ignore
- - - - -
f0df7c6d by Andrea Bolognani at 2022-03-16T14:12:14+01:00
systemd: Tweak comments
Remove all mentions of the code being automatically added,
which are not entirely accurate at this point and might cause
confusion for someone looking at the maintainer scripts, and
explain the situation in more detail.
Gbp-Dch: Ignore
- - - - -
4c893567 by Andrea Bolognani at 2022-03-16T14:12:14+01:00
systemd: Only ever restart libvirtd on upgrade
Restarting libvirt-guests.service would result in VMs being
either restarted or stopped, and restarting virtlogd.service
or any of the sockets might result in VMs crashing.
libvirtd, on the other hand, is safe to restart.
- - - - -
4 changed files:
- debian/libvirt-daemon-system.postinst
- debian/libvirt-daemon-system.postrm
- + debian/libvirt-daemon-system.prerm
- debian/rules
Changes:
=====================================
debian/libvirt-daemon-system.postinst
=====================================
@@ -162,6 +162,202 @@ esac
db_stop
+# Section copied verbatim from the output of dh_installsystemd/13.6
+#
+# Due to #994204, we are forced to handle systemd units ourselves to
+# avoid the restart of services/sockets which would result in VMs
+# being stopped or crashing.
+#
+# In order to do this, instead of calling dh_installsystemd in
+# debian/rules we take the output that those calls would generate
+# and hardcode it here, tweaking it as necessary to prevent the
+# problematic scenarios.
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'libvirtd.service' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'libvirtd.service'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'libvirtd.service' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'libvirtd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ deb-systemd-invoke restart 'libvirtd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'libvirt-guests.service' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'libvirt-guests.service'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'libvirt-guests.service' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'libvirt-guests.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlockd.service' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlockd.service'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlockd.service' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlockd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlogd.service' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlogd.service'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlogd.service' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlogd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ # We have already called 'reload' for virtlogd and virtlockd earlier if they were active
+ deb-systemd-invoke start 'libvirt-guests.service' 'virtlockd.service' 'virtlogd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'libvirtd-admin.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'libvirtd-admin.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'libvirtd-admin.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'libvirtd-admin.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'libvirtd-ro.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'libvirtd-ro.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'libvirtd-ro.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'libvirtd-ro.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'libvirtd.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'libvirtd.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'libvirtd.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'libvirtd.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlockd-admin.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlockd-admin.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlockd-admin.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlockd-admin.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlockd.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlockd.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlockd.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlockd.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlogd-admin.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlogd-admin.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlogd-admin.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlogd-admin.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ # This will only remove masks created by d-s-h on package removal.
+ deb-systemd-helper unmask 'virtlogd.socket' >/dev/null || true
+
+ # was-enabled defaults to true, so new installations run enable.
+ if deb-systemd-helper --quiet was-enabled 'virtlogd.socket'; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable 'virtlogd.socket' >/dev/null || true
+ else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state 'virtlogd.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
+ if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ deb-systemd-invoke start 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.socket' >/dev/null || true
+ fi
+fi
+# End of section copied verbatim
+
#DEBHELPER#
exit 0
=====================================
debian/libvirt-daemon-system.postrm
=====================================
@@ -142,6 +142,63 @@ case "$1" in
;;
esac
+# Section copied verbatim from the output of dh_installsystemd/13.6
+#
+# Due to #994204, we are forced to handle systemd units ourselves to
+# avoid the restart of services/sockets which would result in VMs
+# being stopped or crashing.
+#
+# In order to do this, instead of calling dh_installsystemd in
+# debian/rules we take the output that those calls would generate
+# and hardcode it here, tweaking it as necessary to prevent the
+# problematic scenarios.
+if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ systemctl --system daemon-reload >/dev/null || true
+fi
+if [ "$1" = "remove" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper mask 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.socket' >/dev/null || true
+ fi
+fi
+
+if [ "$1" = "purge" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper purge 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.socket' >/dev/null || true
+ deb-systemd-helper unmask 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.socket' >/dev/null || true
+ fi
+fi
+if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ systemctl --system daemon-reload >/dev/null || true
+fi
+if [ "$1" = "remove" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper mask 'libvirt-guests.service' 'virtlockd.service' 'virtlogd.service' >/dev/null || true
+ fi
+fi
+
+if [ "$1" = "purge" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper purge 'libvirt-guests.service' 'virtlockd.service' 'virtlogd.service' >/dev/null || true
+ deb-systemd-helper unmask 'libvirt-guests.service' 'virtlockd.service' 'virtlogd.service' >/dev/null || true
+ fi
+fi
+if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ systemctl --system daemon-reload >/dev/null || true
+fi
+if [ "$1" = "remove" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper mask 'libvirtd.service' >/dev/null || true
+ fi
+fi
+
+if [ "$1" = "purge" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper purge 'libvirtd.service' >/dev/null || true
+ deb-systemd-helper unmask 'libvirtd.service' >/dev/null || true
+ fi
+fi
+# End of section copied verbatim
+
#DEBHELPER#
exit 0
=====================================
debian/libvirt-daemon-system.prerm
=====================================
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+# summary of how this script can be called:
+# * <prerm> `remove`
+# * <old-prerm> `upgrade` <new-version>
+# * <new-prerm> `failed-upgrade` <old-version <new-version>
+# * <prerm> `deconfigure` `in-favour` <new-package> <new-version>
+# * <prerm> `remove` `in-favour` <new-package> <new-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+# Section copied verbatim from the output of dh_installsystemd/13.6
+#
+# Due to #994204, we are forced to handle systemd units ourselves to
+# avoid the restart of services/sockets which would result in VMs
+# being stopped or crashing.
+#
+# In order to do this, instead of calling dh_installsystemd in
+# debian/rules we take the output that those calls would generate
+# and hardcode it here, tweaking it as necessary to prevent the
+# problematic scenarios.
+if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ deb-systemd-invoke stop 'libvirtd-admin.socket' 'libvirtd-ro.socket' 'libvirtd.socket' 'virtlockd-admin.socket' 'virtlockd.socket' 'virtlogd-admin.socket' 'virtlogd.socket' >/dev/null || true
+fi
+if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ deb-systemd-invoke stop 'libvirt-guests.service' 'virtlockd.service' 'virtlogd.service' >/dev/null || true
+fi
+if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+ deb-systemd-invoke stop 'libvirtd.service' >/dev/null || true
+fi
+# End of section copied verbatim
+
+#DEBHELPER#
+
+exit 0
=====================================
debian/rules
=====================================
@@ -145,23 +145,6 @@ DEB_CONFIGURE_EXTRA_ARGS := \
-Dwireshark_dissector=enabled \
$(NULL)
-# Those have to stay up through upgrades to avoid interruptions
-LIBVIRT_SYSTEM_SERVICES = \
- virtlogd.service \
- virtlockd.service \
- libvirt-guests.service \
- $(NULL)
-
-LIBVIRT_SOCKETS = \
- libvirtd.socket \
- libvirtd-ro.socket \
- libvirtd-admin.socket \
- virtlogd.socket \
- virtlogd-admin.socket \
- virtlockd.socket \
- virtlockd-admin.socket \
- $(NULL)
-
APPARMOR_ABSTRACTIONS = \
libvirt-lxc \
libvirt-qemu \
@@ -312,9 +295,11 @@ override_dh_installinit:
dh_installinit -p libvirt-daemon-system --name=libvirt-guests --no-scripts
override_dh_installsystemd:
- dh_installsystemd -p libvirt-daemon-system --no-also --restart-after-upgrade libvirtd.service
- dh_installsystemd -p libvirt-daemon-system --no-also --no-stop-on-upgrade $(LIBVIRT_SYSTEM_SERVICES)
- dh_installsystemd -p libvirt-daemon-system --no-also --no-stop-on-upgrade $(LIBVIRT_SOCKETS)
+ # Due to #994204, we are forced to handle systemd units ourselves to
+ # avoid the restart of services/sockets which would result in VMs
+ # being stopped or crashing.
+ #
+ # See libvirt-daemon-system.{pre,post}{inst,rm} for details.
override_dh_installdocs:
dh_installdocs -plibvirt-doc --doc-main-package libvirt-doc
View it on GitLab: https://salsa.debian.org/libvirt-team/libvirt/-/compare/aa44cfb37662339d7bcfbd00739ac37ed6bcee65...4c89356787d24993032dd504bd33a7083a4f3aaa
--
View it on GitLab: https://salsa.debian.org/libvirt-team/libvirt/-/compare/aa44cfb37662339d7bcfbd00739ac37ed6bcee65...4c89356787d24993032dd504bd33a7083a4f3aaa
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-libvirt-commits/attachments/20220319/7d51f9ad/attachment-0001.htm>
More information about the Pkg-libvirt-commits
mailing list