[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Instead of writing errors to
# HG changeset patch # User emellor@xxxxxxxxxxxxxxxxxxxxxx # Node ID 5a728a884242b7aa2a0ab6d998adbc117b0ef917 # Parent 2c0b3b8077564205640952f8919e39ee05872cfd Instead of writing errors to /local/domain/0/backend/<devclass>/<dom>/<devid>/error, write them instead to /local/domain/0/error/backend/<yada>. This is not the best place for them perhaps, but it moves them out of the backend directory, on which the drivers have a watch. This fixes the problem whereby writing an error will trigger a watch, causing the error message to be written again, and repeat. Fixes bug #286. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> diff -r 2c0b3b807756 -r 5a728a884242 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Sun Oct 23 15:54:51 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Sun Oct 23 21:34:13 2005 @@ -516,17 +516,38 @@ } EXPORT_SYMBOL(xenbus_printf); +/** + * Return the path to the error node for the given device, or NULL on failure. + * If the value returned is non-NULL, then it is the caller's to kfree. + */ +static char *error_path(struct xenbus_device *dev) +{ + char *path_buffer = kmalloc(strlen("error/") + strlen(dev->nodename) + + 1, GFP_KERNEL); + if (path_buffer == NULL) { + return NULL; + } + + strcpy(path_buffer, "error/"); + strcpy(path_buffer + strlen("error/"), dev->nodename); + + return path_buffer; +} + /* 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; - char *printf_buffer; + char *printf_buffer = NULL, *path_buffer = NULL; printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL); - if (printf_buffer == NULL) + if (printf_buffer == NULL) { + printk("xenbus: failed to write error node for %s (%d): %d\n", + dev->nodename, err, errno); goto fail; + } len = sprintf(printf_buffer, "%i ", -err); va_start(ap, fmt); @@ -535,15 +556,26 @@ BUG_ON(len + ret > PRINTF_BUFFER_SIZE-1); dev->has_error = 1; - if (xenbus_write(NULL, dev->nodename, "error", printf_buffer) != 0) + + path_buffer = error_path(dev); + + if (path_buffer == NULL) { + printk("xenbus: failed to write error node for %s (%s): %d\n", + dev->nodename, printf_buffer, errno); goto fail; - - kfree(printf_buffer); - return; - - fail: - printk("xenbus: failed to write error node for %s (%s)\n", - dev->nodename, printf_buffer); + } + + if (xenbus_write(NULL, path_buffer, "error", printf_buffer) != 0) { + printk("xenbus: failed to write error node for %s (%s)\n", + dev->nodename, printf_buffer); + goto fail; + } + +fail: + if (printf_buffer) + kfree(printf_buffer); + if (path_buffer) + kfree(path_buffer); } EXPORT_SYMBOL(xenbus_dev_error); @@ -551,11 +583,21 @@ void xenbus_dev_ok(struct xenbus_device *dev) { if (dev->has_error) { - if (xenbus_rm(NULL, dev->nodename, "error") != 0) + char *path_buffer = error_path(dev); + + if (path_buffer == NULL) { + printk("xenbus: failed to clear error node for %s: " + "%d\n", dev->nodename, errno); + return; + } + + if (xenbus_rm(NULL, path_buffer, "error") != 0) printk("xenbus: failed to clear error node for %s\n", dev->nodename); else dev->has_error = 0; + + kfree(path_buffer); } } EXPORT_SYMBOL(xenbus_dev_ok); diff -r 2c0b3b807756 -r 5a728a884242 tools/examples/xen-backend.agent --- a/tools/examples/xen-backend.agent Sun Oct 23 15:54:51 2005 +++ b/tools/examples/xen-backend.agent Sun Oct 23 21:34:13 2005 @@ -15,9 +15,13 @@ vbd) /etc/xen/scripts/block unbind ;; + vif) + [ -n "$script" ] && $script down + ;; esac # remove device backend store entries xenstore-rm -t "$XENBUS_PATH" + xenstore-rm -t "error/$XENBUS_PATH" ;; online) case "$XENBUS_TYPE" in diff -r 2c0b3b807756 -r 5a728a884242 tools/python/xen/util/diagnose.py --- a/tools/python/xen/util/diagnose.py Sun Oct 23 15:54:51 2005 +++ b/tools/python/xen/util/diagnose.py Sun Oct 23 21:34:13 2005 @@ -107,7 +107,9 @@ print ("Cannot find backend path for device %s, %s." % (deviceClass, device)) else: - backend_error = xstransact.Read(backendPath, 'error') + backend_error = xstransact.Read( + backendPath.replace('backend/', 'error/backend/'), + 'error') if backend_error: diagnose_device_error(backend_error) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |