xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: xen-devel@lists.xenproject.org
Cc: "Ian Campbell" <ian.campbell@citrix.com>,
	"Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
	"Luis R. Rodriguez" <mcgrof@suse.com>,
	"Jan Rękorajski" <baggins@pld-linux.org>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Jacek Konieczny" <jajcus@jajcus.net>,
	"M A Young" <m.a.young@durham.ac.uk>
Subject: [PATCH v4 01/15] xenstore: add support for a retry open limit on xenstored
Date: Tue, 29 Apr 2014 18:11:54 -0700	[thread overview]
Message-ID: <1398820328-15132-2-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1398820328-15132-1-git-send-email-mcgrof@do-not-panic.com>

From: "Luis R. Rodriguez" <mcgrof@suse.com>

This adds support for a customizable retry limit on trying to open
the xenstored unix domain socket, each retry is separated by 1 second.
This should allow us to simplify both our LSB init scripts. For systemd
we'll use socket activation.

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Jan Rękorajski <baggins@pld-linux.org>
Cc: M A Young <m.a.young@durham.ac.uk>
Cc: Jacek Konieczny <jajcus@jajcus.net>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 docs/man/xenstore.pod.1          |  7 ++++++-
 tools/xenstore/xenstore_client.c | 40 +++++++++++++++++++++++++++++-----------
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/docs/man/xenstore.pod.1 b/docs/man/xenstore.pod.1
index 7417289..9647143 100644
--- a/docs/man/xenstore.pod.1
+++ b/docs/man/xenstore.pod.1
@@ -4,12 +4,17 @@ xenstore - interact with Xenstore
 
 =head1 SYNOPSIS
 
-B<xenstore> I<CMD> ...
+B<xenstore> I<CMD> I[ --retries <num_open_retries> ] ...
 
 =head1 DESCRIPTION
 
 A set of utilities for interacting with Xenstore.
 
+All xenstore-* commands support the --retries long option which
+can be used to try to opening the unix domain socket a certain
+number of retries before giving up. Each new try occurs every
+second.
+
 =over
 
 =item B<xenstore-chmod>(1)
diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c
index 0ec103f..0ab40f7 100644
--- a/tools/xenstore/xenstore_client.c
+++ b/tools/xenstore/xenstore_client.c
@@ -77,27 +77,28 @@ usage(enum mode mode, int incl_mode, const char *progname)
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-p] [-s] key [...]",
+	     progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-s] key value [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-s] key value [...]", progname, mstr);
     case MODE_rm:
 	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-s] [-t] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-s] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-p] [-s] key [...]", progname, mstr);
     case MODE_ls:
 	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [-s] [path]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-f] [-p] [-s] [path]", progname, mstr);
     case MODE_chmod:
 	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] [-s] key <mode [modes...]>", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-u] [-r] [-s] key <mode [modes...]>", progname, mstr);
     case MODE_watch:
 	mstr = incl_mode ? "watch " : "";
-	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [ --retries <num_open_retries> ] [-n NR] key", progname, mstr);
     }
 }
 
@@ -493,9 +494,9 @@ static enum mode lookup_mode(const char *m)
 int
 main(int argc, char **argv)
 {
-    struct xs_handle *xsh;
+    struct xs_handle *xsh = NULL;
     xs_transaction_t xth = XBT_NULL;
-    int ret = 0, socket = 0;
+    int ret = 0, socket = 0, retries = 1;
     int prefix = 0;
     int tidy = 0;
     int upto = 0;
@@ -535,6 +536,7 @@ main(int argc, char **argv)
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
 	    {"recurse", 0, 0, 'r'}, /* MODE_chmod */
 	    {"number",  1, 0, 'n'}, /* MODE_watch */
+	    {"retries", 1, 0,  0 }, /* index 8 - MODE_* */
 	    {0, 0, 0, 0}
 	};
 
@@ -544,6 +546,15 @@ main(int argc, char **argv)
 	    break;
 
 	switch (c) {
+	case 0:
+	    if (index == 8 && optarg) {
+		retries = atoi(optarg);
+		if (retries < 0) {
+                    retries = 1;
+                    usage(mode, switch_argv, argv[0]);
+		}
+	    }
+	    break;
 	case 'h':
 	    usage(mode, switch_argv, argv[0]);
 	    /* NOTREACHED */
@@ -632,8 +643,15 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
-    if (xsh == NULL) err(1, "xs_open");
+    while (retries--) {
+	    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+	    if (xsh)
+		    break;
+	    if (retries)
+		    sleep(1);
+    }
+    if (!xsh)
+	    err(1, "xs_open");
 
 again:
     if (transaction) {
-- 
1.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-04-30  1:12 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30  1:11 [PATCH v4 00/15] xen: add systemd support Luis R. Rodriguez
2014-04-30  1:11 ` Luis R. Rodriguez [this message]
2014-05-07 15:03   ` [PATCH v4 01/15] xenstore: add support for a retry open limit on xenstored Ian Campbell
2014-05-12 13:50   ` Ian Jackson
2014-05-12 14:18     ` Ian Campbell
2014-05-12 14:40       ` Jacek Konieczny
2014-05-12 15:37         ` Ian Jackson
2014-05-12 18:59           ` Luis R. Rodriguez
2014-05-13 21:33           ` Luis R. Rodriguez
2014-04-30  1:11 ` [PATCH v4 02/15] xencommons: use the retry limit instead of implementing our own timeout Luis R. Rodriguez
2014-04-30  9:33   ` Andrew Cooper
2014-04-30 16:36     ` Luis R. Rodriguez
2014-05-07 15:05   ` Ian Campbell
2014-04-30  1:11 ` [PATCH v4 03/15] xenstored: enable usage of config.h on both xenstored and oxenstored Luis R. Rodriguez
2014-05-07 15:06   ` Ian Campbell
2014-04-30  1:11 ` [PATCH v4 04/15] cxenstored: add support for systemd active sockets Luis R. Rodriguez
2014-05-07 15:18   ` Ian Campbell
2014-05-07 15:46   ` Ian Campbell
2014-05-13 22:17     ` Luis R. Rodriguez
2014-05-14  8:44       ` Ian Campbell
2014-05-15  1:50         ` Luis R. Rodriguez
2014-04-30  1:11 ` [PATCH v4 05/15] oxenstored: " Luis R. Rodriguez
2014-04-30  8:35   ` Dave Scott
2014-04-30 17:30     ` Luis R. Rodriguez
2014-05-01 10:21       ` Dave Scott
2014-04-30  9:27   ` Anil Madhavapeddy
2014-04-30 17:35     ` Luis R. Rodriguez
2014-05-01  9:16       ` Anil Madhavapeddy
2014-05-07 15:20   ` Ian Campbell
2014-05-12 19:09     ` Luis R. Rodriguez
2014-05-12 13:57   ` Ian Jackson
2014-05-12 18:11     ` Luis R. Rodriguez
2014-05-13  8:53       ` Ian Campbell
2014-04-30  1:11 ` [PATCH v4 06/15] tools/xendomains: make xl the default Luis R. Rodriguez
2014-04-30  7:02   ` Olaf Hering
2014-04-30 17:43     ` Luis R. Rodriguez
2014-05-07 15:21       ` Ian Campbell
2014-04-30  1:12 ` [PATCH v4 07/15] tools/xendomains: do space cleanups Luis R. Rodriguez
2014-04-30  1:12 ` [PATCH v4 08/15] tools/xendomains: move to libexec and use a smaller init helper Luis R. Rodriguez
2014-05-07 15:24   ` Ian Campbell
2014-05-13 22:21     ` Luis R. Rodriguez
2014-04-30  1:12 ` [PATCH v4 09/15] autoconf: xen: force a refresh with autoconf Luis R. Rodriguez
2014-05-07 15:25   ` Ian Campbell
2014-05-07 16:12   ` Roger Pau Monné
2014-05-07 16:21     ` Ian Campbell
2014-05-07 16:44       ` Roger Pau Monné
2014-05-07 18:28         ` Luis R. Rodriguez
2014-05-12 14:00           ` Ian Jackson
2014-05-12 18:14             ` Luis R. Rodriguez
2014-04-30  1:12 ` [PATCH v4 10/15] autoconf: update m4/pkg.m4 Luis R. Rodriguez
2014-05-07 15:28   ` Ian Campbell
2014-05-13 22:32     ` Luis R. Rodriguez
2014-05-07 16:17   ` Roger Pau Monné
2014-04-30  1:12 ` [PATCH v4 11/15] autoconf: xen: move standard variables to a generic place Luis R. Rodriguez
2014-04-30  6:52   ` Jan Beulich
     [not found]   ` <5360B9CB020000780000D9BB@suse.com>
2014-04-30 17:53     ` Luis R. Rodriguez
2014-05-02  8:12       ` Jan Beulich
2014-05-13 23:03         ` Luis R. Rodriguez
2014-04-30  1:12 ` [PATCH v4 12/15] autoconf: xen: peg the xenstored preference onto the top level config Luis R. Rodriguez
2014-05-07 15:32   ` Ian Campbell
2014-05-13 23:05     ` Luis R. Rodriguez
2014-04-30  1:12 ` [PATCH v4 13/15] systemd: add xen systemd service and module files Luis R. Rodriguez
2014-05-07 15:46   ` Ian Campbell
2014-05-12 18:22     ` Luis R. Rodriguez
2014-05-13 23:28     ` Luis R. Rodriguez
2014-05-12 14:11   ` Ian Jackson
2014-05-12 14:32     ` Jacek Konieczny
2014-05-12 15:36       ` Ian Jackson
2014-05-12 18:55         ` Luis R. Rodriguez
2014-05-12 18:46     ` Luis R. Rodriguez
2014-05-13  8:57       ` Ian Campbell
2014-04-30  1:12 ` [PATCH v4 14/15] autoconf: xen: add systemd support into the build system Luis R. Rodriguez
2014-05-07 16:40   ` Roger Pau Monné
2014-05-15  1:58     ` Luis R. Rodriguez
2014-05-15  9:02       ` Ian Campbell
2014-04-30  1:12 ` [PATCH v4 15/15] autoconf: xen: trigger an update with autogen.sh Luis R. Rodriguez
2014-05-07 15:47   ` Ian Campbell
2014-05-07 18:34     ` Luis R. Rodriguez
2014-05-08  8:42       ` Ian Campbell
2014-04-30  1:15 ` [PATCH v4 00/15] xen: add systemd support Luis R. Rodriguez
2014-05-07 15:18   ` Ian Campbell
2014-05-08 11:28 ` Anthony PERARD
2014-05-15  2:12   ` Luis R. Rodriguez
2014-05-15  6:14   ` Luis R. Rodriguez

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=1398820328-15132-2-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=baggins@pld-linux.org \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jajcus@jajcus.net \
    --cc=m.a.young@durham.ac.uk \
    --cc=mcgrof@suse.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.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).