All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 9/24] [xen-unstable.hg] make xs_domain_open fallback to /proc/xen/xenbus if unix domain socket fails because xenstore is in a stubdomain
Date: Mon, 23 Mar 2009 15:20:57 +0000	[thread overview]
Message-ID: <49C7A8D9.50308@eu.citrix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2 bytes --]




[-- Attachment #2: libxs_fallback_domain_open --]
[-- Type: text/plain, Size: 1844 bytes --]

If xenstored is running in a stub domain clients won't be able to open
a unix domain socket to it, but will be able to access it via xenbus.

To handle this situation this patch makes xs_daemon_open() fall back to
xs_domain_open() - which tries to open a connection via xenbus - if it
cannot open a unix domain socket.

Depends on linux xenbus commands whitelist patch. Enhanced by linux
xenbus aborting read/write if not ready, part of my big linux xenbus
patch.

I wasn't so sure what to do about the read-only connection, but I made
it fall back to the non-read-only socket/device if the read-only socket
isn't available.

Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
---

diff -r 5308892be11a tools/xenstore/xs.c
--- a/tools/xenstore/xs.c	Thu Mar 19 12:47:06 2009 +0000
+++ b/tools/xenstore/xs.c	Thu Mar 19 16:10:07 2009 +0000
@@ -210,12 +210,25 @@
 
 struct xs_handle *xs_daemon_open(void)
 {
-	return get_handle(xs_daemon_socket());
+	struct xs_handle *xsh;
+
+	xsh = get_handle(xs_daemon_socket());
+	if (xsh != NULL)
+		return xsh;
+
+	return xs_domain_open();
 }
 
 struct xs_handle *xs_daemon_open_readonly(void)
 {
-	return get_handle(xs_daemon_socket_ro());
+	struct xs_handle *xsh;
+
+	xsh = get_handle(xs_daemon_socket_ro());
+	if (xsh != NULL)
+		return xsh;
+
+	/* fall back to a read-write connection */
+	return xs_daemon_open();
 }
 
 struct xs_handle *xs_domain_open(void)
diff -r 5308892be11a tools/xenstore/xs.h
--- a/tools/xenstore/xs.h	Thu Mar 19 12:47:06 2009 +0000
+++ b/tools/xenstore/xs.h	Thu Mar 19 16:10:07 2009 +0000
@@ -37,6 +37,7 @@
 
 /* Connect to the xs daemon (readonly for non-root clients).
  * Returns a handle or NULL.
+ * Note: this may fall back to a read/write connection.
  */
 struct xs_handle *xs_daemon_open_readonly(void);
 



[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2009-03-23 15:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=49C7A8D9.50308@eu.citrix.com \
    --to=alex.zeffertt@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.