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

[Xen-changelog] Implement xenbus_dev_error() and xenbus_dev_ok() functions



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 26e4e952c385894cec4a028eeceb102e348def27
# Parent  a9a9567489975493f0e90a4e8f96917756dab8a0
Implement xenbus_dev_error() and xenbus_dev_ok() functions
for better error reporting using the store.
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r a9a956748997 -r 26e4e952c385 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Tue Jul 26 
17:24:22 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Tue Jul 26 
17:25:57 2005
@@ -43,6 +43,7 @@
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
 
+static char printf_buffer[4096];
 static void *xs_in, *xs_out;
 static LIST_HEAD(watches);
 DECLARE_MUTEX(xenbus_lock);
@@ -339,17 +340,49 @@
 {
        va_list ap;
        int ret;
-       static char buffer[4096];
 
        BUG_ON(down_trylock(&xenbus_lock) == 0);
        va_start(ap, fmt);
-       ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
+       ret = vsnprintf(printf_buffer, sizeof(printf_buffer), fmt, ap);
        va_end(ap);
 
-       BUG_ON(ret > sizeof(buffer)-1);
-       return xenbus_write(dir, node, buffer, O_CREAT);
-}
-
+       BUG_ON(ret > sizeof(printf_buffer)-1);
+       return xenbus_write(dir, node, printf_buffer, O_CREAT);
+}
+
+/* Report a (negative) errno into the store, with explanation. */
+void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...)
+{
+       va_list ap;
+       int ret;
+       unsigned int len;
+
+       BUG_ON(down_trylock(&xenbus_lock) == 0);
+
+       len = sprintf(printf_buffer, "%i ", -err);
+       va_start(ap, fmt);
+       ret = vsnprintf(printf_buffer+len, sizeof(printf_buffer)-len, fmt, ap);
+       va_end(ap);
+
+       BUG_ON(len + ret > sizeof(printf_buffer)-1);
+       dev->has_error = 1;
+       if (xenbus_write(dev->nodename, "error", printf_buffer, O_CREAT) != 0)
+               printk("xenbus: failed to write error node for %s (%s)\n",
+                      dev->nodename, printf_buffer);
+}
+
+/* Clear any error. */
+void xenbus_dev_ok(struct xenbus_device *dev)
+{
+       if (dev->has_error) {
+               if (xenbus_rm(dev->nodename, "error") != 0)
+                       printk("xenbus: failed to clear error node for %s\n",
+                              dev->nodename);
+               else
+                       dev->has_error = 0;
+       }
+}
+       
 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
 int xenbus_gather(const char *dir, ...)
 {
diff -r a9a956748997 -r 26e4e952c385 
linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Tue Jul 26 17:24:22 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Tue Jul 26 17:25:57 2005
@@ -37,6 +37,7 @@
        char *subtype;
        char *nodename;
        struct device dev;
+       int has_error;
        void *data;
 };
 
@@ -97,6 +98,12 @@
  * sprintf-style type string, and pointer. Returns 0 or errno.*/
 int xenbus_gather(const char *dir, ...);
 
+/* Report a (negative) errno into the store, with explanation. */
+void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,...);
+
+/* Clear any error. */
+void xenbus_dev_ok(struct xenbus_device *dev);
+
 /* Register callback to watch this node. */
 struct xenbus_watch
 {

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


 


Rackspace

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