# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1213083359 -3600
# Node ID 8523584ffaa3b0f6ecce36b826a2c7b26aef61b7
# Parent 4f29b009b8b47fb75adc5a214aaee4790d22b84b
Export additional data from watch events through to userspace xenbus clients.
This functionality is already available when connecting directly to
xenstore in dom0 or from within the kernel, but the xenbus dev which
is used from userspace to access xenbus over the kernel's xenbus
connection lacks this functionality -- it will only pass the path
where the watch fired and the token.
xend uses this functionality already when firing the @releaseDomain
watch from xenstored and passing the uuid of the domain which was
released.
The diff changes the implementation of split to return an additional
entry marking the end of the final string, in case the final string is
not null terminated. None of the callers to split are affected by this
change. The other change in the diff is to change the watch firing code
to return the additional data.
Signed-off-by: Christian Limpach <christian.limpach@xxxxxxxxxx>
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
drivers/xen/xenbus/xenbus_dev.c | 10 +++++++---
drivers/xen/xenbus/xenbus_xs.c | 3 ++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff -r 4f29b009b8b4 -r 8523584ffaa3 drivers/xen/xenbus/xenbus_dev.c
--- a/drivers/xen/xenbus/xenbus_dev.c Mon Jun 09 09:49:13 2008 +0100
+++ b/drivers/xen/xenbus/xenbus_dev.c Tue Jun 10 08:35:59 2008 +0100
@@ -169,14 +169,16 @@ static void watch_fired(struct xenbus_wa
container_of(watch, struct watch_adapter, watch);
struct xsd_sockmsg hdr;
const char *path, *token;
- int path_len, tok_len, body_len;
-
+ int path_len, tok_len, body_len, data_len = 0;
+
path = vec[XS_WATCH_PATH];
token = adap->token;
path_len = strlen(path) + 1;
tok_len = strlen(token) + 1;
- body_len = path_len + tok_len;
+ if (len > 2)
+ data_len = vec[len] - vec[2] + 1;
+ body_len = path_len + tok_len + data_len;
hdr.type = XS_WATCH_EVENT;
hdr.len = body_len;
@@ -185,6 +187,8 @@ static void watch_fired(struct xenbus_wa
queue_reply(adap->dev_data, (char *)&hdr, sizeof(hdr));
queue_reply(adap->dev_data, (char *)path, path_len);
queue_reply(adap->dev_data, (char *)token, tok_len);
+ if (len > 2)
+ queue_reply(adap->dev_data, (char *)token, data_len);
mutex_unlock(&adap->dev_data->reply_mutex);
}
diff -r 4f29b009b8b4 -r 8523584ffaa3 drivers/xen/xenbus/xenbus_xs.c
--- a/drivers/xen/xenbus/xenbus_xs.c Mon Jun 09 09:49:13 2008 +0100
+++ b/drivers/xen/xenbus/xenbus_xs.c Tue Jun 10 08:35:59 2008 +0100
@@ -302,7 +302,7 @@ static char **split(char *strings, unsig
char *p, **ret;
/* Count the strings. */
- *num = count_strings(strings, len);
+ *num = count_strings(strings, len) + 1;
/* Transfer to one big alloc for easy freeing. */
ret = kmalloc(*num * sizeof(char *) + len, GFP_KERNEL|__GFP_HIGH);
@@ -316,6 +316,7 @@ static char **split(char *strings, unsig
strings = (char *)&ret[*num];
for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1)
ret[(*num)++] = p;
+ ret[*num] = strings + len;
return ret;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|