George Dunlap
2010-Jun-29 13:56 UTC
[Xen-devel] [PATCH 0 of 2] xencommons init script improvements
Rework of patches from yesterday, without the first one: * Make xencommons more verbose, as normal init scripts are * Wait for xenstored to start before attempting to set the domain name. - Time out after 30 seconds - Exit the script if the timeout fails. If exiting is not the preferred behavior, feel free to elide the error check. :-) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
George Dunlap
2010-Jun-29 13:56 UTC
[Xen-devel] [PATCH 1 of 2] xencommons: Make init script more verbose
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> diff -r 3ea84fd20b26 -r ad0f9cc72415 tools/hotplug/Linux/init.d/xencommons --- a/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 13:43:18 2010 +0100 +++ b/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 14:56:28 2010 +0100 @@ -42,21 +42,28 @@ 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" + + echo Starting xenstored... xenstored --pid-file=/var/run/xenstore.pid $XENSTORED_ARGS + echo Setting domain 0 name... xenstore-write "/local/domain/0/name" "Domain-0" fi + echo Starting xenconsoled... test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" -T /var/log/xen/xenstored-trace.log" xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS test -z "$XENBACKENDD_DEBUG" || XENBACKENDD_ARGS="-d" test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS } 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 WARNING: Not stopping xenstored, as it cannot be restarted. } case "$1" in _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
George Dunlap
2010-Jun-29 13:56 UTC
[Xen-devel] [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
On one of my boxes, the xenstore-write setting dom0''s name starts before xenstored is actually ready to handle the connection properly, resulting in the name set failing. Wait for xenstored to be up and responding to reads before continuing, timing out after 30 seconds. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> diff -r ad0f9cc72415 -r dc49f02fc463 tools/hotplug/Linux/init.d/xencommons --- a/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 14:56:28 2010 +0100 +++ b/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 14:56:28 2010 +0100 @@ -37,14 +37,32 @@ fi do_start () { + local time=0 + local timeout=30 + if ! `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" - echo Starting xenstored... + echo -n Starting xenstored... xenstored --pid-file=/var/run/xenstore.pid $XENSTORED_ARGS + + # Wait for xenstored to actually come up, timing out after 30 seconds + while [ $time -lt $timeout ] && ! `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... xenstore-write "/local/domain/0/name" "Domain-0" fi _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2010-Jun-29 14:10 UTC
Re: [Xen-devel] [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
On Tue, 2010-06-29 at 14:56 +0100, George Dunlap wrote:> On one of my boxes, the xenstore-write setting dom0''s name starts > before xenstored is actually ready to handle the connection properly, > resulting in the name set failing. Wait for xenstored to be up and > responding to reads before continuing, timing out after 30 seconds.Does this make the xenstored in a stub-dom case more complicated? (due to use of "-s") Is the domain 0 name node special enough that we could just make xenstored set it itself at start of day? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Jun-29 14:37 UTC
Re: [Xen-devel] [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
On 06/29/2010 03:56 PM, George Dunlap wrote:> On one of my boxes, the xenstore-write setting dom0''s name starts > before xenstored is actually ready to handle the connection properly, > resulting in the name set failing. Wait for xenstored to be up and > responding to reads before continuing, timing out after 30 seconds. > > Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> > > diff -r ad0f9cc72415 -r dc49f02fc463 tools/hotplug/Linux/init.d/xencommons > --- a/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 14:56:28 2010 +0100 > +++ b/tools/hotplug/Linux/init.d/xencommons Tue Jun 29 14:56:28 2010 +0100 > @@ -37,14 +37,32 @@ > fi > > do_start () { > + local time=0 > + local timeout=30 > + > if ! `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" > > - echo Starting xenstored... > + echo -n Starting xenstored... > xenstored --pid-file=/var/run/xenstore.pid $XENSTORED_ARGS >Why isn''t xenstored ready by the time the main process exits? Seems like a bug in xenstored. Does oxenstored get this right? J> + > + # Wait for xenstored to actually come up, timing out after 30 seconds > + while [ $time -lt $timeout ] && ! `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... > xenstore-write "/local/domain/0/name" "Domain-0" > fi > > _______________________________________________ > 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 Campbell
2010-Jun-29 15:02 UTC
Re: [Xen-devel] [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
On Tue, 2010-06-29 at 15:37 +0100, Jeremy Fitzhardinge wrote:> > > Why isn''t xenstored ready by the time the main process exits? Seems > like a bug in xenstored. Does oxenstored get this right?Looks like Bastian tried to fix this in C xenstored years ago with: changeset: 17296:21d9575c669e user: Keir Fraser <keir.fraser@citrix.com> date: Wed Mar 26 13:21:42 2008 +0000 files: tools/misc/xend tools/xenstore/xenstored_core.c description: xenstored: Delay forking until after listening sockets are opened. Also, in startup xend script, delay further startup until xenstored initial child process has exited. This serialises xenstored startup with that of other daemons (e.g., xenconsoled). Signed-off-by: Bastian Blank <waldi@debian.org> But it was reverted shortly after: changeset: 17304:ed67f68ae2a7 user: Keir Fraser <keir.fraser@citrix.com> date: Thu Mar 27 09:12:09 2008 +0000 files: tools/misc/xend tools/xenstore/xenstored_core.c description: Revert 17296:21d9575c669e. Signed-off-by: Keir Fraser <keir.fraser@citrix.com> because it broke something. The thread at http://lists.xensource.com/archives/html/xen-devel/2008-03/msg00758.html has more details. I''m not especially inclined to fix the C xenstored, lets hasten the switch to oxenstored instead. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2010-Jun-29 15:06 UTC
Re: [Xen-devel] [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
On 29/06/2010 16:02, "Ian Campbell" <Ian.Campbell@citrix.com> wrote:> because it broke something. The thread at > http://lists.xensource.com/archives/html/xen-devel/2008-03/msg00758.html > has more details. > > I''m not especially inclined to fix the C xenstored, lets hasten the > switch to oxenstored instead.I''d suggest disabling C xenstored build by default and install xenstored as a symlink to oxenstored. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel