[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v9 2/3] autoconf: xen: enable explicit preference option for xenstored preference
From: "Luis R. Rodriguez" <mcgrof@xxxxxxxx> 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@xxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Keir Fraser <keir@xxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx> --- README | 32 +++++ m4/xenstored.m4 | 56 ++++++++ tools/configure.ac | 19 ++- tools/hotplug/Linux/init.d/sysconfig.xencommons | 33 ----- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 42 ++++++ tools/hotplug/Linux/init.d/xencommons.in | 153 --------------------- tools/hotplug/Linux/init.d/xencommons.in.in | 149 ++++++++++++++++++++ 7 files changed, 295 insertions(+), 189 deletions(-) create mode 100644 m4/xenstored.m4 delete mode 100644 tools/hotplug/Linux/init.d/sysconfig.xencommons create mode 100644 tools/hotplug/Linux/init.d/sysconfig.xencommons.in delete mode 100644 tools/hotplug/Linux/init.d/xencommons.in create mode 100644 tools/hotplug/Linux/init.d/xencommons.in.in diff --git a/README b/README index 0c8c7aa..7c27fbb 100644 --- a/README +++ b/README @@ -129,6 +129,38 @@ performed with root privileges.] versions of those scripts, so that you can copy the dist directory to another machine and install from that distribution. +xenstore: xenstored and oxenstored +==================================== + +Xen uses a configuration database called xenstore [0] to maintain configuration +and status information shared between domains. A daemon is implemented as part +of xenstore to act as an interface for access to the database for dom0 and +guests. Two xenstored daemons are supported, one written in C which we refer +to as the xenstored (sometimes referred to as cxenstored), and another written +in Ocaml called oxenstored. Details for xenstore and the different +implementations can be found on the wiki's xenstore reference guide [1] and +the xenstored [2] page. You can choose which xenstore you want to enable as +default on a system through configure: + + ./configure --with-xenstored=xenstored + ./configure --with-xenstored=oxenstored + +By default oxenstored will be used if the ocaml development tools are found. +If you enable oxenstored the xenstored will still be built and installed, +the xenstored used can be changed through the configuration file: + +/etc/sysconfig/xencommons +or +/etc/default/xencommons + +You can change the preferred xenstored you want to use in the configuration +but since we cannot stop the daemon a reboot will be required to make the +change take effect. + +[0] http://wiki.xen.org/wiki/XenStore +[1] http://wiki.xen.org/wiki/XenStoreReference +[2] http://wiki.xen.org/wiki/Xenstored + Python Runtime Libraries ======================== diff --git a/m4/xenstored.m4 b/m4/xenstored.m4 new file mode 100644 index 0000000..30b44c9 --- /dev/null +++ b/m4/xenstored.m4 @@ -0,0 +1,56 @@ +AC_DEFUN([AX_XEN_OCAML_XENSTORE_CHECK], [ + AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ + AC_MSG_ERROR([Missing ocaml dependencies for oxenstored, try installing ocaml ocaml-compiler-libs ocaml-runtime ocaml-findlib]) + ]) +]) + +AC_DEFUN([AX_XEN_OCAML_XENSTORE_DEFAULTS], [ + xenstore="oxenstored" + xenstored=$SBINDIR/oxenstored + AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ + xenstore="xenstored" + xenstored=$SBINDIR/xenstored + ]) +]) + +AC_DEFUN([AX_XENSTORE_OPTIONS], [ +AS_IF([test "x$XENSTORE" = "x"], [ +AC_ARG_WITH([xenstored], + AS_HELP_STRING([--with-xenstored@<:@=oxenstored|xenstored@:>@], + [This lets you choose which xenstore daemon you want, you have + two options: the original xenstored written in C (xenstored) + or the newer and robust one written in Ocaml (oxenstored). + The oxenstored daemon is the default but will but can only + be used if you have ocaml library / build dependencies solved, + if you have not specified a preference and do not have ocaml + dependencies resolved we'll enable the C xenstored for you. If + you ask for oxenstored we'll complain until you resolve those + dependencies]), + [ + AS_IF([test "x$withval" = "xxenstored"], [ + xenstore=$withval + xenstored=$SBINDIR/xenstored + ]) + AS_IF([test "x$withval" = "xoxenstored"], [ + xenstore=$withval + xenstored=$SBINDIR/oxenstored + AX_XEN_OCAML_XENSTORE_CHECK() + ]) + AS_IF([test "x$withval" != "xoxenstored" && test "x$withval" != "xxenstored"], [ + AC_MSG_ERROR([Unsupported xenstored specified, supported types: oxenstored xenstored]) + ]) + ], + [ + AX_XEN_OCAML_XENSTORE_DEFAULTS() + ]) +]) +]) + +AC_DEFUN([AX_XENSTORE_SET], [ + XENSTORE=$xenstore + + AS_IF([test "x$XENSTORED" = "x"], [ + XENSTORED=$xenstored + ]) + AC_SUBST(XENSTORED) +]) diff --git a/tools/configure.ac b/tools/configure.ac index 629d6a0..e74fe4b 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -5,7 +5,11 @@ AC_PREREQ([2.67]) AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]), [xen-devel@xxxxxxxxxxxxx], [xen], [http://www.xen.org/]) AC_CONFIG_SRCDIR([libxl/libxl.c]) -AC_CONFIG_FILES([../config/Tools.mk]) +AC_CONFIG_FILES([ +../config/Tools.mk +hotplug/Linux/init.d/xencommons.in +hotplug/Linux/init.d/sysconfig.xencommons +]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([../]) @@ -53,6 +57,10 @@ m4_include([../m4/ptyfuncs.m4]) m4_include([../m4/extfs.m4]) m4_include([../m4/fetcher.m4]) m4_include([../m4/ax_compare_version.m4]) +m4_include([../m4/paths.m4]) +m4_include([../m4/xenstored.m4]) + +AX_XEN_EXPAND_CONFIG() # Enable/disable options AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP]) @@ -203,9 +211,14 @@ AC_PROG_INSTALL AC_PATH_PROG([BISON], [bison]) AC_PATH_PROG([FLEX], [flex]) AX_PATH_PROG_OR_FAIL([PERL], [perl]) + +AC_PROG_OCAML +AC_PROG_FINDLIB + +AX_XENSTORE_OPTIONS +AX_XENSTORE_SET + AS_IF([test "x$ocamltools" = "xy"], [ - AC_PROG_OCAML - AC_PROG_FINDLIB AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"], [ AS_IF([test "x$enable_ocamltools" = "xyes"], [ AC_MSG_ERROR([Ocaml tools enabled, but unable to find Ocaml])]) diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons b/tools/hotplug/Linux/init.d/sysconfig.xencommons deleted file mode 100644 index 25f7f00..0000000 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons +++ /dev/null @@ -1,33 +0,0 @@ -## Path: System/Virtualization -## Type: string -## Default: "none" -# -# Log xenconsoled messages (cf xl dmesg) -#XENCONSOLED_TRACE=[none|guest|hv|all] - -## Type: string -## Default: xenstored -# -# Select xenstored implementation -#XENSTORED=[oxenstored|xenstored] - -## Type: string -## Default: Not defined, tracing off -# -# Log xenstored messages -#XENSTORED_TRACE=[yes|on|1] - -## Type: string -## Default: "/var/lib/xenstored" -# -# Running xenstored on XENSTORED_ROOTDIR -#XENSTORED_ROOTDIR=/var/lib/xenstored - -## Type: string -## Default: Not defined, xenbackendd debug mode off -# -# Running xenbackendd in debug mode -#XENBACKENDD_DEBUG=[yes|on|1] - -# qemu path -#QEMU_XEN=/usr/lib/xen/bin/qemu-system-i386 diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in new file mode 100644 index 0000000..d423ff8 --- /dev/null +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -0,0 +1,42 @@ +## Path: System/Virtualization +## Type: string +## Default: "none" +# +# Log xenconsoled messages (cf xl dmesg) +#XENCONSOLED_TRACE=[none|guest|hv|all] + +## Type: string +## Default: xenstored +# +# Select xenstore implementation, this can be either +# of these below. If using systemd it's preferred that you +# just edit the xenstored.service unit file and change +# the XENSTORED variable there. +# +# This can be either of: +# * @SBINDIR@/oxenstored +# * @SBINDIR@/xenstored +# +# Changing this requires a reboot to take effect. +#XENSTORED=@XENSTORED@ + +## Type: string +## Default: Not defined, tracing off +# +# Log xenstored messages +#XENSTORED_TRACE=[yes|on|1] + +## Type: string +## Default: "/var/lib/xenstored" +# +# Running xenstored on XENSTORED_ROOTDIR +#XENSTORED_ROOTDIR=/var/lib/xenstored + +## Type: string +## Default: Not defined, xenbackendd debug mode off +# +# Running xenbackendd in debug mode +#XENBACKENDD_DEBUG=[yes|on|1] + +# qemu path +#QEMU_XEN=/usr/lib/xen/bin/qemu-system-i386 diff --git a/tools/hotplug/Linux/init.d/xencommons.in b/tools/hotplug/Linux/init.d/xencommons.in deleted file mode 100644 index 3939bcc..0000000 --- a/tools/hotplug/Linux/init.d/xencommons.in +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# xencommons Script to start and stop xenstored and xenconsoled -# -# Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> -# -# 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 - -. /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 - elif [ -x ${SBINDIR}/oxenstored ] ; then - echo -n Starting oxenstored... - ${SBINDIR}/oxenstored --pid-file /var/run/xenstored.pid $XENSTORED_ARGS - elif [ -x ${SBINDIR}/xenstored ] ; then - echo -n Starting C xenstored... - ${SBINDIR}/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 $? diff --git a/tools/hotplug/Linux/init.d/xencommons.in.in b/tools/hotplug/Linux/init.d/xencommons.in.in new file mode 100644 index 0000000..b311bb8 --- /dev/null +++ b/tools/hotplug/Linux/init.d/xencommons.in.in @@ -0,0 +1,149 @@ +#!/bin/bash +# +# xencommons Script to start and stop xenstored and xenconsoled +# +# Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> +# +# 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 $? -- 2.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |