Commit ef242a70 authored by Ian Jackson's avatar Ian Jackson Committed by Hans van Kranenburg
Browse files

xen init script: Do nothing if running for wrong Xen package



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: default avatarIan Jackson <ian.jackson@citrix.com>
Acked-by: default avatarHans van Kranenburg <hans@knorrie.org>
parent 30c9a3c5
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -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"