Ian Jackson
2011-Feb-03 11:50 UTC
[Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
In Xen 4.0 there is no /etc/init.d/xencommons (and we do not want to
backport the refactoring of /etc/init.d/xend). 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 "xenlightdaemons" 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 (from testing.git 78c59993ab536b8c39c5a00a). The user
will still have to add appropriate rc links, and only a script for
Linux is provided.
Testing: I have done a build test on patch and the script does end up
in dist/install/etc/init.d/xenlightdaemons; the script itself is
tested as part of my automatic test system.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff -r 0b16e1d60871 tools/hotplug/Linux/Makefile
--- a/tools/hotplug/Linux/Makefile Wed Jan 26 09:05:53 2011 +0000
+++ b/tools/hotplug/Linux/Makefile Thu Feb 03 11:49:09 2011 +0000
@@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
# Init scripts.
XEND_INITD = init.d/xend
XEND_SYSCONFIG = init.d/sysconfig.xend
+XENLIGHTDAEMONS_INITD = init.d/xenlightdaemons
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) $(XENLIGHTDAEMONS_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 -r 0b16e1d60871 tools/hotplug/Linux/init.d/xenlightdaemons
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/init.d/xenlightdaemons Thu Feb 03 11:49:09 2011 +0000
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+# xenlightdaemons 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 $?
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Jackson
2011-Mar-03 17:05 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
Ian Jackson writes ("[Xen-devel] [PATCH, 4.0] tools: provide startup script
for libxl"):> In Xen 4.0 there is no /etc/init.d/xencommons (and we do not want to
> backport the refactoring of /etc/init.d/xend). 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 "xenlightdaemons" 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 (from testing.git 78c59993ab536b8c39c5a00a). The user
> will still have to add appropriate rc links, and only a script for
> Linux is provided.
>
> Testing: I have done a build test on patch and the script does end up
> in dist/install/etc/init.d/xenlightdaemons; the script itself is
> tested as part of my automatic test system.
>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
I have had a private email from Stefano, so
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Keir, would you apply this to 4.0 please ?
Thanks,
Ian.
diff -r 0b16e1d60871 tools/hotplug/Linux/Makefile
--- a/tools/hotplug/Linux/Makefile Wed Jan 26 09:05:53 2011 +0000
+++ b/tools/hotplug/Linux/Makefile Thu Feb 03 11:49:09 2011 +0000
@@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
# Init scripts.
XEND_INITD = init.d/xend
XEND_SYSCONFIG = init.d/sysconfig.xend
+XENLIGHTDAEMONS_INITD = init.d/xenlightdaemons
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) $(XENLIGHTDAEMONS_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 -r 0b16e1d60871 tools/hotplug/Linux/init.d/xenlightdaemons
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/init.d/xenlightdaemons Thu Feb 03 11:49:09 2011 +0000
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+# xenlightdaemons 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 $?
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-03 17:13 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
On Thu, 2011-03-03 at 17:05 +0000, Ian Jackson wrote:> Ian Jackson writes ("[Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl"): > > In Xen 4.0 there is no /etc/init.d/xencommons (and we do not want to > > backport the refactoring of /etc/init.d/xend). 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 "xenlightdaemons" 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 (from testing.git 78c59993ab536b8c39c5a00a). The user > > will still have to add appropriate rc links, and only a script for > > Linux is provided. > > > > Testing: I have done a build test on patch and the script does end up > > in dist/install/etc/init.d/xenlightdaemons; the script itself is > > tested as part of my automatic test system. > > > > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> > > I have had a private email from Stefano, so > > Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > Keir, would you apply this to 4.0 please ?I was confused by this for a bit. I think it is well worth a comment that this is the equivalent of the xencommons init script in 4.1+ Why does it get a different name in 4.0 anyway? Ian.> > Thanks, > Ian. > > diff -r 0b16e1d60871 tools/hotplug/Linux/Makefile > --- a/tools/hotplug/Linux/Makefile Wed Jan 26 09:05:53 2011 +0000 > +++ b/tools/hotplug/Linux/Makefile Thu Feb 03 11:49:09 2011 +0000 > @@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk > # Init scripts. > XEND_INITD = init.d/xend > XEND_SYSCONFIG = init.d/sysconfig.xend > +XENLIGHTDAEMONS_INITD = init.d/xenlightdaemons > 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) $(XENLIGHTDAEMONS_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 -r 0b16e1d60871 tools/hotplug/Linux/init.d/xenlightdaemons > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/tools/hotplug/Linux/init.d/xenlightdaemons Thu Feb 03 11:49:09 2011 +0000 > @@ -0,0 +1,81 @@ > +#!/bin/bash > +# > +# xenlightdaemons 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 $? > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Mar-03 17:28 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
Ian Campbell writes ("Re: [Xen-devel] [PATCH, 4.0] tools: provide startup
script for libxl"):> I was confused by this for a bit. I think it is well worth a comment
> that this is the equivalent of the xencommons init script in 4.1+
But, it''s not. In particular the xend script in 4.0 is not changed to
use it.
> Why does it get a different name in 4.0 anyway?
Because it''s only for libxl.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-03 17:32 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
On Thu, 2011-03-03 at 17:28 +0000, Ian Jackson wrote:> Ian Campbell writes ("Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl"): > > I was confused by this for a bit. I think it is well worth a comment > > that this is the equivalent of the xencommons init script in 4.1+ > > But, it''s not. In particular the xend script in 4.0 is not changed to > use it.Sure.> > Why does it get a different name in 4.0 anyway? > > Because it''s only for libxl.Right, but we are now introducing an extra, currently undocumented, upgrade step for people who upgrade from 4.0.N (for whichever N it ends up in and onwards) which people upgrading from 4.0.<N-1> don''t need to do. I don''t see what stops us calling this script xencommons in 4.0 and documenting that it is for the use of xl users only in 4. Then those users get a clean upgrade to 4.1. xend users get the same advice only when they switch to 4.1. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Mar-03 18:20 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
Ian Campbell writes ("Re: [Xen-devel] [PATCH, 4.0] tools: provide startup
script for libxl"):> Right, but we are now introducing an extra, currently undocumented,
> upgrade step for people who upgrade from 4.0.N (for whichever N it ends
> up in and onwards) which people upgrading from 4.0.<N-1>
don''t need to
> do.
Hrm, yes.
> I don''t see what stops us calling this script xencommons in 4.0
and
> documenting that it is for the use of xl users only in 4. Then those
> users get a clean upgrade to 4.1. xend users get the same advice only
> when they switch to 4.1.
That makes sense. I will make a new patch.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-03 19:34 UTC
Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl
On Thu, 2011-03-03 at 18:20 +0000, Ian Jackson wrote:> Ian Campbell writes ("Re: [Xen-devel] [PATCH, 4.0] tools: provide startup script for libxl"): > > Right, but we are now introducing an extra, currently undocumented, > > upgrade step for people who upgrade from 4.0.N (for whichever N it ends > > up in and onwards) which people upgrading from 4.0.<N-1> don''t need to > > do. > > Hrm, yes. > > > I don''t see what stops us calling this script xencommons in 4.0 and > > documenting that it is for the use of xl users only in 4. Then those > > users get a clean upgrade to 4.1. xend users get the same advice only > > when they switch to 4.1. > > That makes sense. I will make a new patch.Thanks. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel