xenstore: new XS_OPEN_SOCKETONLY flag; honour "-s" on tools' cmdline
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 14 Dec 2010 16:56:54 +0000 (16:56 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 14 Dec 2010 16:56:54 +0000 (16:56 +0000)
The "-s" option to xenstore-ls is used by the xencommons startup
script to check whether xenstored is already running, before starting
it.

Since 22498:a40455ae9ad3, "-s" has been a no-op, and libxenstore will
always fall back to using xenbus.  The combined effect is that the
xencommons script deadlocks: xenstore-ls hangs waiting for xenstored,
which isn't started by xencommons because xencommons is waiting for
xenstore-ls.

In this patch, we:
 * Introduce a new XS_OPEN_SOCKETONLY flag which disables the
   fallback behaviour;
 * Make the xenstore command line tools use the new xs_open call
   rather than the old, deprecated xs_open_* calls (which are
   now identical).
 * Plumb the xenstore command line tools "-s" option to set the
   XS_OPEN_SOCKETONLY flag.
 * Change the type of the XS_OPEN_* flags so that they naturally have
   type unsigned long.

The "-s" option to xenstore-ls et al, and the XS_OPEN_SOCKETONLY flag,
are intended for use by toolstack infrastructure and should not
normally be used by higher-level code.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xenstore/xenstore_client.c
tools/xenstore/xs.c
tools/xenstore/xs.h

index fe63b6b0c8871a77c7f5de5be7f6220bdd2b01b6..94b82b99af820dcde1ea0837a05d754eddaf4fe6 100644 (file)
@@ -633,9 +633,8 @@ main(int argc, char **argv)
            max_width = ws.ws_col - 2;
     }
 
-    xsh = socket ? xs_daemon_open() : xs_domain_open();
-    if (xsh == NULL)
-       err(1, socket ? "xs_daemon_open" : "xs_domain_open");
+    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+    if (xsh == NULL) err(1, "xs_open");
 
 again:
     if (transaction) {
index f3532b03c15d4ab5e59598d5fcd20e190d470820..c72ea83d96c479aa032c8df2114019e1ff6baed9 100644 (file)
@@ -262,7 +262,7 @@ struct xs_handle *xs_open(unsigned long flags)
        else
                xsh = get_handle(xs_daemon_socket(), flags);
 
-       if (!xsh)
+       if (!xsh && !(flags & XS_OPEN_SOCKETONLY))
                xsh = get_handle(xs_domain_dev(), flags);
 
        return xsh;
index 1e28849eac167d000d8194dfde6cf458e970ee01..1cbe255a41ed769be726d65f44a1a63667fca72c 100644 (file)
@@ -24,7 +24,8 @@
 
 #define XBT_NULL 0
 
-#define XS_OPEN_READONLY       1<<0
+#define XS_OPEN_READONLY       1UL<<0
+#define XS_OPEN_SOCKETONLY      1UL<<1
 
 struct xs_handle;
 typedef uint32_t xs_transaction_t;