xencommons init script improvements
PATCH 1/1 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. :-)
PATCH 1/1 xencommons: Make init script more verbose
tools/hotplug/Linux/init.d/xencommons +7 -0
@@ -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
PATCH 1/1 xencommons: Wait for xenstored to start before setting dom0 name
In reply to George DunlapOn 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.
tools/hotplug/Linux/init.d/xencommons +19 -1
@@ -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
Re: [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
Quoted 4 lines · George Dunlap
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.
Re: [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
In reply to George DunlapQuoted 17 lines · George Dunlap
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 <[email protected]>diff -r
ad0f9cc72415-rdc49f02fc463tools/hotplug/Linux/init.d/xencommonstools/hotplug/Linux/init.d/xencommons +3
-0@@ -37,14 +37,32 @@ fi do_start () { + local time=0 + local timeout=30 +
tools/hotplug/Linux/init.d/xencommons line 51
Quoted 10 lines
tools/hotplug/Linux/init.d/xencommons +1
-1if ! `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
Quoted 25 lines
tools/hotplug/Linux/init.d/xencommons +15
-0+ + # 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
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
Quoted 4 lines · Jeremy Fitzhardinge
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 <[email protected]>
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).
But it was reverted shortly after:
changeset: 17304:ed67f68ae2a7
user: Keir Fraser <[email protected]>
date: Thu Mar 27 09:12:09 2008 +0000
files: tools/misc/xend tools/xenstore/xenstored_core.c description:
Revert 17296:21d9575c669e.
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.
Re: [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name
Quoted 6 lines · Ian Campbell
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