xendomains stalls when using XAPI

Bug #1194983 reported by TJ
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xen
Fix Released
Unknown
xen (Ubuntu)
New
Undecided
Unassigned

Bug Description

Ubuntu 13.04 Raring amd64

On a Xen system with

$ apt-cache policy xen-utils-common | head -2
xen-utils-common:
  Installed: 4.2.1-0ubuntu3.2

/etc/init.d/xendomains will hang at start-up or when the service is (re)started manually.

I've just tracked the Debian bug #680528 down as the cause of an init-script hang with xen 4.2 when using the xapi toolstack.

The patch used for this bug-fix was implemented too late in the execution of /etc/init.d/xendomains and results in
a permanently stuck task "/etc/rc2.d/S21xendomains start" which has the child process "xapi list". The test for xm || xl should have been inserted before "xen list".

$ ps -efly | egrep '(init.d|rc2.d|/usr/sbin/xapi|xcp-fe)'
S root 1557 1 0 80 0 740 1110 wait 17:26 ? 00:00:00 /bin/sh /etc/init.d/rc 2
S root 1841 1 0 80 0 3368 3395 skb_re 17:26 ? 00:00:00 /usr/sbin/xcp-fe -daemon
S root 2128 1557 0 80 0 1616 4522 wait 17:26 ? 00:00:00 /bin/bash /etc/rc2.d/S21xendomains start
S root 2131 2128 0 80 0 14360 10966 unix_s 17:26 ? 00:00:00 /usr/sbin/xapi list
S root 2142 1 0 80 0 2968 3395 wait 17:26 ? 00:00:00 /usr/sbin/xcp-fe -daemon
S root 2143 2142 0 80 0 27536 186366 poll_s 17:26 ? 00:00:02 /usr/sbin/xapi -nowatchdog list

The first thing the init script does is run the toolstack's "list" command which is expected to returns true (0) or false. In the case of 'xm' and 'xl' this is fine but for 'xapi' there is no such command-line option (as it is a daemon) and consequently it ends up never returning.

----- /etc/init.d/xendomains -----
xen list &> /dev/null
if test $? -ne 0
then
        exit 0;
fi
-----

"xen" expands to "/usr/sbin/xapi" via /usr/sbin/xen:

----- /usr/sbin/xen -----
TOOLSTACK=$(. /usr/lib/xen-common/bin/xen-toolstack); RET=$?; [ $RET -eq 0 ] || exit $RET

exec "$TOOLSTACK" "$@"
-----

My changes which fix this issue are in-line below, and result in:

$ ps -efly | egrep '(init.d|rc2.d|/usr/sbin/xapi|xcp-fe)'
S root 1876 1 0 80 0 3336 3395 skb_re 19:15 ? 00:00:00 /usr/sbin/xcp-fe -daemon
S root 2172 1 0 80 0 10652 10966 unix_s 19:15 ? 00:00:00 /usr/sbin/xapi -daemon -writereadyfile /var/run/xapi_startup.cookie -writeinitcomplete /var/run/xapi_init_complete.cookie -onsystemboot
S root 2175 1 0 80 0 2968 3395 wait 19:15 ? 00:00:00 /usr/sbin/xcp-fe -daemon
S root 2176 2175 0 80 0 24800 184294 poll_s 19:15 ? 00:00:00 /usr/sbin/xapi -nowatchdog -writereadyfile /var/run/xapi_startup.cookie -writeinitcomplete /var/run/xapi_init_complete.cookie -onsystemboot

-----
# diff -u xendomains.bugged xendomains
--- xendomains.bugged 2013-06-26 17:13:17.239660000 +0100
+++ xendomains 2013-06-26 17:14:17.643660000 +0100
@@ -17,12 +17,6 @@
 . /lib/init/vars.sh
 . /lib/lsb/init-functions

-xen list &> /dev/null
-if test $? -ne 0
-then
- exit 0;
-fi
-
 TOOLSTACK=$(/usr/lib/xen-common/bin/xen-toolstack 2>/dev/null)
 if [ $? -ne 0 ]; then
         log_warning_msg "No usable Xen toolstack selected"
@@ -32,6 +26,12 @@
        exit 0
 fi

+xen list &> /dev/null
+if test $? -ne 0
+then
+ exit 0;
+fi
+
 if ! [ -e /proc/xen/privcmd ]; then
        exit 0
 fi

Changed in ubuntu-xen:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.