From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: [PATCH 2 of 2] xencommons: Wait for xenstored to start before setting dom0 name Date: Tue, 29 Jun 2010 14:56:46 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org 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 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