From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xen.org
Cc: Juergen Gross <jgross@suse.com>,
wei.liu2@citrix.com, andrew.cooper3@citrix.com,
ian.jackson@eu.citrix.com, ross.lagerwall@citrix.com,
dave@recoil.org
Subject: [PATCH v3 3/4] tools: use pidfile for test if xenstored is running
Date: Fri, 22 Jul 2016 17:09:30 +0200 [thread overview]
Message-ID: <1469200171-19703-4-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1469200171-19703-1-git-send-email-jgross@suse.com>
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@suse.com>
---
tools/hotplug/Linux/init.d/xencommons.in | 2 +-
tools/hotplug/Linux/launch-xenstore.in | 58 +++++++++++++++++++-------------
2 files changed, 35 insertions(+), 25 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 a0cbfd3..2bd9f64 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
+test_xenstore () {
+ test -f /var/run/xenstored.pid
+ return $?
+}
-if ! `${bindir}/xenstore-read -s / >/dev/null 2>&1`
-then
- test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@"
- rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/null
- test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T @XEN_LOG_DIR@/xenstored-trace.log"
+timeout_xenstore () {
+ local time=0
+ local timeout=30
- 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
-
- # 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* 2>/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
--
2.6.6
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-22 15:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 15:09 [PATCH v3 0/4] tools: make xenstore domain/daemon configurable Juergen Gross
2016-07-22 15:09 ` [PATCH v3 1/4] tools: remove systemd xenstore socket definitions Juergen Gross
2016-07-22 16:31 ` Wei Liu
2016-07-22 18:49 ` Juergen Gross
2016-07-22 18:51 ` Wei Liu
2016-07-25 4:33 ` Juergen Gross
2016-07-25 11:05 ` Wei Liu
2016-07-25 12:21 ` Juergen Gross
2016-07-22 15:09 ` [PATCH v3 2/4] tools: split out xenstored starting form xencommons Juergen Gross
2016-07-25 13:43 ` Wei Liu
2016-07-22 15:09 ` Juergen Gross [this message]
2016-08-02 10:23 ` [PATCH v3 3/4] tools: use pidfile for test if xenstored is running Wei Liu
2016-08-02 10:26 ` Juergen Gross
2016-07-22 15:09 ` [PATCH v3 4/4] tools: make xenstore domain easy configurable Juergen Gross
2016-07-25 13:43 ` Wei Liu
2016-07-25 13:56 ` Juergen Gross
2016-07-25 14:01 ` Wei Liu
2016-07-25 14:06 ` Juergen Gross
2016-07-25 14:11 ` Wei Liu
2016-07-25 14:16 ` Juergen Gross
2016-07-25 14:27 ` Wei Liu
2016-07-25 13:43 ` [PATCH v3 0/4] tools: make xenstore domain/daemon configurable Wei Liu
2016-08-01 8:02 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469200171-19703-4-git-send-email-jgross@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dave@recoil.org \
--cc=ian.jackson@eu.citrix.com \
--cc=ross.lagerwall@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).