[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools: use pidfile for test if xenstored is running



commit c74dd50bc0c575ea7cbfc6aaeb71320378f1db13
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Aug 2 18:10:46 2016 +0200
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Fri Aug 5 10:37:11 2016 +0100

    tools: use pidfile for test if xenstored is running
    
    Instead of trying to read xenstore via xenstore-read use the pidfile
    of xenstored for the test whether xenstored is running. This prepares
    support of xenstore domain, as trying to read xenstore will block
    for ever in case xenstore domain is started after trying to read.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/hotplug/Linux/init.d/xencommons.in |  2 +-
 tools/hotplug/Linux/launch-xenstore.in   | 60 +++++++++++++++++++-------------
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/tools/hotplug/Linux/init.d/xencommons.in 
b/tools/hotplug/Linux/init.d/xencommons.in
index a32608c..a6a40d6 100644
--- a/tools/hotplug/Linux/init.d/xencommons.in
+++ b/tools/hotplug/Linux/init.d/xencommons.in
@@ -96,7 +96,7 @@ case "$1" in
        do_start
        ;;
   status)
-        ${bindir}/xenstore-read -s /
+        test -f @XEN_RUN_DIR@/xenstored.pid
        ;;
   stop)
        do_stop
diff --git a/tools/hotplug/Linux/launch-xenstore.in 
b/tools/hotplug/Linux/launch-xenstore.in
index 61541be..32de540 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -18,38 +18,48 @@
 XENSTORED=@XENSTORED@
 
 . @XEN_SCRIPT_DIR@/hotplugpath.sh
-test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . 
@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
 
-time=0
-timeout=30
-
-if ! `${bindir}/xenstore-read -s / >/dev/null 2>&1`
-then
-       test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
-       rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
-       test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T 
@XEN_LOG_DIR@/xenstored-trace.log"
-
-       if [ -n "$XENSTORED" ] ; then
-           echo -n Starting $XENSTORED...
-           $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
-       else
-           echo "No xenstored found"
-           exit 1
-       fi
+test_xenstore () {
+       test -f @XEN_RUN_DIR@/xenstored.pid
+       return $?
+}
+
+timeout_xenstore () {
+       local time=0
+       local timeout=30
 
-       # 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
+       while [ $time -lt $timeout ] && ! test_xenstore ; 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
+               echo "Could not start $@"
+               return 1
        fi
+
+       return 0
+}
+
+test_xenstore && exit 0
+
+test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . 
@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons
+
+test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
+rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
+test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T 
@XEN_LOG_DIR@/xenstored-trace.log"
+
+if [ -n "$XENSTORED" ] ; then
+       echo -n Starting $XENSTORED...
+       $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
+else
+       echo "No xenstored found"
+       exit 1
 fi
 
+timeout_xenstore $XENSTORED || exit 1
+
 exit 0
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.