aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2011-03-10 18:39:48 +0000
committerIan Jackson <ian.jackson@eu.citrix.com>2011-03-10 18:39:48 +0000
commit48dc4855022cdedbd6c1cfd6d2c6eb70350aa7b1 (patch)
treeef0c3241b4b62012e8286fe910c13c37121db847
parent355cbd253e8363a1f599f3508dca89877836d0c4 (diff)
downloadxen-48dc4855022cdedbd6c1cfd6d2c6eb70350aa7b1.tar.gz
xen-48dc4855022cdedbd6c1cfd6d2c6eb70350aa7b1.tar.bz2
xen-48dc4855022cdedbd6c1cfd6d2c6eb70350aa7b1.zip
tools: provide startup script for libxl
In Xen 4.0 there is no /etc/init.d/xencommons. This means that in most situations you don't get xenstored, and xl doesn't work, unless you do something shonky like starting and then immediately stopping xend. To test xl, my automatic testing system therefore provides its own init script to start xenstored and xenconsoled. This script was created by borrowing from /etc/init.d/xend and other init scripts in various versions of xen.hg. Here it is[1], as a new "xencommons" script. The user will still have to add appropriate rc links, and only a script for Linux is provided. We do not want to backport the refactoring of /etc/init.d/xend, so xend users should not enable this script. [1] Copied from osstest.git#78c59993ab536b8c39c5a00a xenlightdaemons. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
-rw-r--r--tools/hotplug/Linux/Makefile2
-rw-r--r--tools/hotplug/Linux/init.d/xencommons81
2 files changed, 83 insertions, 0 deletions
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index fa9e2b5c45..b7d858f691 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
# Init scripts.
XEND_INITD = init.d/xend
XEND_SYSCONFIG = init.d/sysconfig.xend
+XENCOMMONS_INITD = init.d/xencommons
XENDOMAINS_INITD = init.d/xendomains
XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
@@ -65,6 +66,7 @@ install-initd:
[ -d $(DESTDIR)$(CONFIG_DIR)/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)$(CONFIG_DIR)/sysconfig
$(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
$(INSTALL_PROG) $(XEND_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xend
+ $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
$(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xendomains
diff --git a/tools/hotplug/Linux/init.d/xencommons b/tools/hotplug/Linux/init.d/xencommons
new file mode 100644
index 0000000000..df34c8a3f5
--- /dev/null
+++ b/tools/hotplug/Linux/init.d/xencommons
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+# xencommons Script to start and stop xenstored and xenconsoled
+# FOR USE WITH LIBXL, not xend
+#
+# Author: Ian Jackson <ian.jackson@eu.citrix.com>
+#
+# chkconfig: 2345
+# description: Starts and stops the Xen control daemon.
+### BEGIN INIT INFO
+# Provides: xenstored xenconsoled
+# Required-Start: $syslog $remote_fs
+# Should-Start:
+# Required-Stop: $syslog $remote_fs
+# Should-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 1
+# Default-Enabled: yes
+# Short-Description: Start/stop xenstored and xenconsoled
+# Description: Starts and stops the daemons neeeded for xl/libxenlight
+### END INIT INFO
+
+XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+
+shopt -s extglob
+test -f /etc/sysconfig/xend && . /etc/sysconfig/xend
+
+if test "x$1" = xstart && \
+ test -d /proc/xen && \
+ ! test -d /proc/xen/capabilities && \
+ grep ' xenfs$' /proc/filesystems >/dev/null && \
+ ! grep '^xenfs ' /proc/mounts >/dev/null;
+then
+ mount -t xenfs xenfs /proc/xen
+fi
+
+if ! grep -q "control_d" /proc/xen/capabilities ; then
+ exit 0
+fi
+
+do_start () {
+ test -z "$XENSTORED_ROOTDIR" || export XENSTORED_ROOTDIR
+ [[ "$XENSTORED_TRACE" == @(yes|on|1) ]] && export XENSTORED_TRACE
+ xenstore-read -s / >/dev/null 2>&1 || xenstored
+
+ test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE"
+ xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS $XENCONSOLED_OPTIONS
+}
+do_stop () {
+ if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then
+ kill $pid
+ while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+ rm -f $XENCONSOLED_PIDFILE
+ fi
+}
+
+case "$1" in
+ start)
+ do_start
+ ;;
+ status)
+ xenstore-read -s /
+ ;;
+ stop)
+ do_stop
+ ;;
+ reload)
+ echo >&2 'Reload not available; use force-reload'; exit 1
+ ;;
+ force-reload|restart)
+ do_stop
+ do_start
+ ;;
+ *)
+ # do not advertise unreasonable commands that there is no reason
+ # to use with this device
+ echo $"Usage: $0 {start|stop|status|restart|force-reload}"
+ exit 1
+esac
+
+exit $?