[Pkg-xen-devel] [PATCH 03/13] xen init script: Do nothing if running for wrong Xen package

Hans van Kranenburg hans at knorrie.org
Sun Feb 10 23:42:01 GMT 2019


From: Ian Jackson <ian.jackson at citrix.com>

See the big comment.  We think that this is responsible for various
bugs and, particularly, reports of mysteriously missing xenconsoled.

For example, this bug would mean that after a Xen version upgrade,
autoremoval of an obsolete xen-utils-V package would stop the running
xenconsoled.  This is obviously awkward to track down, and could occur
many weeks or months after the upgrade.

Closes: #851654
Signed-off-by: Ian Jackson <ian.jackson at citrix.com>
---
 debian/xen-utils-common.xen.init | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/debian/xen-utils-common.xen.init b/debian/xen-utils-common.xen.init
index da7d361453..b0df7be8ab 100644
--- a/debian/xen-utils-common.xen.init
+++ b/debian/xen-utils-common.xen.init
@@ -24,6 +24,35 @@ case "$(cat /sys/hypervisor/type 2>/dev/null)" in
 xen)		;;
 *)	exit 0	;; # not running under Xen
 esac
+
+VERSION=$(/usr/lib/xen-common/bin/xen-version)
+
+# The arrangements for the `xen' init script are a bit odd.
+# This script is part of xen-utils-common, of which there is one
+# version installed regardless of the Xen version.
+#
+# But it is called by the prerm and postinsts of xen-utils-VERSION.
+# The idea is that (for example) if xen-utils-VERSION is upgraded, the
+# daemons are restarted.
+#
+# However, this means that this script may be called by the
+# maintscript of a xen-utils-V package for a different V to the
+# running version of Xen (X, say).  Such a xen-utils-V package does
+# not actually want to start or stop its daemons.  Indeed, the version
+# selection machinery would redirect its efforts to the xen-utils-X
+# utilities.  But this is not right: we don't actually want to (for
+# example) stop xenconsoled from xen-utils-X just because some
+# not-currently-relevant xen-utils-V is installed/removed/whatever.
+#
+# So we use DPKG_MAINTSCRIPT_PACKAGE to detect this situation, and
+# turn these extraneous calls into no-ops.
+
+case $DPKG_MAINTSCRIPT_PACKAGE in
+xen-utils-$VERSION)	;;	# xen-utils-V maintscript, under Xen X=V
+xen-utils-*)		exit 0;; # xen-utils-V maintscript, but under Xen X!=V
+*)			;;	# maybe not under dpkg, etc.
+esac
+
 ROOT=$(/usr/lib/xen-common/bin/xen-dir 2>/dev/null)
 if [ $? -ne 0 ]; then
 	log_warning_msg "Not running within Xen or no compatible utils"
-- 
2.20.1




More information about the Pkg-xen-devel mailing list