ia64/linux-2.6.18-xen.hg

changeset 571:8523584ffaa3

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@citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Ian Campbell <ian.campbell@citrix.com>
date Tue Jun 10 08:35:59 2008 +0100 (2008-06-10)
parents 4f29b009b8b4
children 5db911a71eac
files drivers/xen/xenbus/xenbus_dev.c drivers/xen/xenbus/xenbus_xs.c
line diff
     1.1 --- a/drivers/xen/xenbus/xenbus_dev.c	Mon Jun 09 09:49:13 2008 +0100
     1.2 +++ b/drivers/xen/xenbus/xenbus_dev.c	Tue Jun 10 08:35:59 2008 +0100
     1.3 @@ -169,14 +169,16 @@ static void watch_fired(struct xenbus_wa
     1.4              container_of(watch, struct watch_adapter, watch);
     1.5  	struct xsd_sockmsg hdr;
     1.6  	const char *path, *token;
     1.7 -	int path_len, tok_len, body_len;
     1.8 -
     1.9 +	int path_len, tok_len, body_len, data_len = 0;
    1.10 +	
    1.11  	path = vec[XS_WATCH_PATH];
    1.12  	token = adap->token;
    1.13  
    1.14  	path_len = strlen(path) + 1;
    1.15  	tok_len = strlen(token) + 1;
    1.16 -	body_len = path_len + tok_len;
    1.17 +	if (len > 2)
    1.18 +		data_len = vec[len] - vec[2] + 1;
    1.19 +	body_len = path_len + tok_len + data_len;
    1.20  
    1.21  	hdr.type = XS_WATCH_EVENT;
    1.22  	hdr.len = body_len;
    1.23 @@ -185,6 +187,8 @@ static void watch_fired(struct xenbus_wa
    1.24  	queue_reply(adap->dev_data, (char *)&hdr, sizeof(hdr));
    1.25  	queue_reply(adap->dev_data, (char *)path, path_len);
    1.26  	queue_reply(adap->dev_data, (char *)token, tok_len);
    1.27 +	if (len > 2)
    1.28 +		queue_reply(adap->dev_data, (char *)token, data_len);
    1.29  	mutex_unlock(&adap->dev_data->reply_mutex);
    1.30  }
    1.31  
     2.1 --- a/drivers/xen/xenbus/xenbus_xs.c	Mon Jun 09 09:49:13 2008 +0100
     2.2 +++ b/drivers/xen/xenbus/xenbus_xs.c	Tue Jun 10 08:35:59 2008 +0100
     2.3 @@ -302,7 +302,7 @@ static char **split(char *strings, unsig
     2.4  	char *p, **ret;
     2.5  
     2.6  	/* Count the strings. */
     2.7 -	*num = count_strings(strings, len);
     2.8 +	*num = count_strings(strings, len) + 1;
     2.9  
    2.10  	/* Transfer to one big alloc for easy freeing. */
    2.11  	ret = kmalloc(*num * sizeof(char *) + len, GFP_KERNEL|__GFP_HIGH);
    2.12 @@ -316,6 +316,7 @@ static char **split(char *strings, unsig
    2.13  	strings = (char *)&ret[*num];
    2.14  	for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1)
    2.15  		ret[(*num)++] = p;
    2.16 +	ret[*num] = strings + len;
    2.17  
    2.18  	return ret;
    2.19  }