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

[Xen-devel] [PATCH v2 11/11] tools/libvchan: libxenvchan_client_init: use ENOENT for no server



* Promise that we will set errno to ENOENT if the server is not
  yet set up.
* Arrange that all ENOENT returns other than from the read of ring-ref
  are turned into EIO, logging when we do so.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
 tools/libvchan/init.c        | 11 ++++++++++-
 tools/libvchan/libxenvchan.h |  4 ++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/libvchan/init.c b/tools/libvchan/init.c
index d987acd338..e58f6bf9ac 100644
--- a/tools/libvchan/init.c
+++ b/tools/libvchan/init.c
@@ -45,6 +45,7 @@
 #include <xen/sys/gntalloc.h>
 #include <xen/sys/gntdev.h>
 #include <libxenvchan.h>
+#include <xentoollog.h>
 
 #ifndef PAGE_SHIFT
 #define PAGE_SHIFT 12
@@ -419,7 +420,7 @@ struct libxenvchan *libxenvchan_client_init(struct 
xentoollog_logger *logger,
        snprintf(buf, sizeof buf, "%s/ring-ref", xs_path);
        ref = xs_read(xs, 0, buf, &len);
        if (!ref)
-               goto fail;
+               goto fail_allow_enoent;
        ring_ref = atoi(ref);
        free(ref);
        if (!ring_ref)
@@ -452,7 +453,15 @@ struct libxenvchan *libxenvchan_client_init(struct 
xentoollog_logger *logger,
        if (xs)
                xs_daemon_close(xs);
        return ctrl;
+
  fail:
+       if (errno == ENOENT) {
+               xtl_log(logger, XTL_ERROR, errno, "vchan",
+                       "error talking to server `%s', returning EIO",
+                       xs_path);
+               errno = EIO;
+       }
+ fail_allow_enoent:
        libxenvchan_close(ctrl);
        ctrl = NULL;
        goto out;
diff --git a/tools/libvchan/libxenvchan.h b/tools/libvchan/libxenvchan.h
index e4ccca1ff0..8a4ec2ce4c 100644
--- a/tools/libvchan/libxenvchan.h
+++ b/tools/libvchan/libxenvchan.h
@@ -105,6 +105,10 @@ struct libxenvchan *libxenvchan_server_init(struct 
xentoollog_logger *logger,
  * safely, however no locking is performed, so you must prevent multiple 
clients
  * from connecting to a single server.
  *
+ * Failing with ENOENT means the server has not yet called
+ * libxenvchan_server_init, You may wait for a server to appear by
+ * setting a xenstore watch on xs_path.
+ *
  * @param logger Logger for libxc errors
  * @param domain The peer domain to connect to
  * @param xs_path Base xenstore path for storing ring/event data
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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