Files
xen/tools/hotplug/Linux/init.d/xencommons.in.in
T
Luis R. Rodriguez dff4c31163 autoconf: xen: enable explicit preference option for xenstored preference
As it stands oxenstored will be used by default if ocaml tools are
found, the init system will also try to use oxenstored first if its
found otherwise the cxenstored will be used. Lets simplify the init
script and let users be explicit about the preference through configure.

This adds support to let you be explicit about the xenstored preference,
you can only use one of these two options:

./configure --with-xenstored=xenstored
./configure --with-xenstored=oxenstored

We continue with the old behaviour and default oxenstored will be used
but only if you have ocaml dependencies. Since the xenstored preference
is explicit now and since we require configure substitutions for it we
make use of the AX_XEN_EXPAND_CONFIG() helpers as otherwise substitution
for SBINDIR is not propagated from the top level configuration.

All this allows us to simplify the init script to use the configured
xenstore from the start. We update the sysconfig/default xencommons file
with the paths for the different options though, this can be used by
users to override the default xenstored, this follows the old behaviour
but we now just explicitly provide the full configured paths for users.

As before, changing the xenstore requires a reboot.

In order to help with documentation we update the README with some
details on configure usage refer to the wiki [0] [1] [2] for more elaborate
details.

Since we are now parsing an entry within Paths.mk.in on tools we let
the move the parsing of the file to be the tool's configure.

[0] http://wiki.xen.org/wiki/Xenstored
[1] http://wiki.xen.org/wiki/XenStore
[2] http://wiki.xen.org/wiki/XenStoreReference

Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]
2014-08-04 14:58:24 +01:00

150 lines
3.8 KiB
Bash

#!/bin/bash
#
# xencommons Script to start and stop xenstored and xenconsoled
#
# Author: Ian Jackson <ian.jackson@eu.citrix.com>
#
# chkconfig: 2345 70 10
# description: Starts and stops xenstored and xenconsoled
### BEGIN INIT INFO
# Provides: xenstored xenconsoled
# Required-Start: $syslog $remote_fs
# Should-Start:
# Required-Stop: $syslog $remote_fs
# Should-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop xenstored and xenconsoled
# Description: Starts and stops the daemons neeeded for xl/xend
### END INIT INFO
XENSTORED=@XENSTORED@
. /etc/xen/scripts/hotplugpath.sh
if [ -d /etc/sysconfig ]; then
xencommons_config=/etc/sysconfig
else
xencommons_config=/etc/default
fi
test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
QEMU_PIDFILE=/var/run/qemu-dom0.pid
shopt -s extglob
# not running in Xen dom0 or domU
if ! test -d /proc/xen ; then
exit 0
fi
# mount xenfs in dom0 or domU with a pv_ops kernel
if test "x$1" = xstart && \
! test -f /proc/xen/capabilities && \
! grep '^xenfs ' /proc/mounts >/dev/null;
then
mount -t xenfs xenfs /proc/xen
fi
# run this script only in dom0:
# no capabilities file in xenlinux domU kernel
# empty capabilities file in pv_ops domU kernel
if test -f /proc/xen/capabilities && \
! grep -q "control_d" /proc/xen/capabilities ; then
exit 0
fi
do_start () {
local time=0
local timeout=30
@LOAD_MODULES@
mkdir -p /var/run/xen
if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
then
test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="/var/lib/xenstored"
rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T /var/log/xen/xenstored-trace.log"
if [ -n "$XENSTORED" ] ; then
echo -n Starting $XENSTORED...
$XENSTORED --pid-file /var/run/xenstored.pid $XENSTORED_ARGS
else
echo "No xenstored found"
exit 1
fi
# Wait for xenstored to actually come up, timing out after 30 seconds
while [ $time -lt $timeout ] && ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1` ; do
echo -n .
time=$(($time+1))
sleep 1
done
echo
# Exit if we timed out
if ! [ $time -lt $timeout ] ; then
echo Could not start xenstored
exit 1
fi
echo Setting domain 0 name and domid...
${BINDIR}/xenstore-write "/local/domain/0/name" "Domain-0"
${BINDIR}/xenstore-write "/local/domain/0/domid" 0
fi
echo Starting xenconsoled...
test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE"
${SBINDIR}/xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS
echo Starting QEMU as disk backend for dom0
test -z "$QEMU_XEN" && QEMU_XEN="${LIBEXEC}/qemu-system-i386"
$QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize \
-monitor /dev/null -serial /dev/null -parallel /dev/null \
-pidfile $QEMU_PIDFILE
}
do_stop () {
echo Stopping xenconsoled
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
echo Stopping QEMU
if read 2>/dev/null <$QEMU_PIDFILE pid; then
kill $pid
while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
rm -f $QEMU_PIDFILE
fi
echo WARNING: Not stopping xenstored, as it cannot be restarted.
}
case "$1" in
start)
do_start
;;
status)
${BINDIR}/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 $?