Skip to content

Commit 5584ea2

Browse files
jgross1bostrovs
authored andcommitted
xen: modify xenstore watch event interface
Today a Xenstore watch event is delivered via a callback function declared as: void (*callback)(struct xenbus_watch *, const char **vec, unsigned int len); As all watch events only ever come with two parameters (path and token) changing the prototype to: void (*callback)(struct xenbus_watch *, const char *path, const char *token); is the natural thing to do. Apply this change and adapt all users. Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Paul Durrant <[email protected]> Reviewed-by: Wei Liu <[email protected]> Reviewed-by: Roger Pau Monné <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent 332f791 commit 5584ea2

File tree

14 files changed

+59
-69
lines changed

14 files changed

+59
-69
lines changed

drivers/block/xen-blkback/xenbus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ struct backend_info {
3838
static struct kmem_cache *xen_blkif_cachep;
3939
static void connect(struct backend_info *);
4040
static int connect_ring(struct backend_info *);
41-
static void backend_changed(struct xenbus_watch *, const char **,
42-
unsigned int);
41+
static void backend_changed(struct xenbus_watch *, const char *,
42+
const char *);
4343
static void xen_blkif_free(struct xen_blkif *blkif);
4444
static void xen_vbd_free(struct xen_vbd *vbd);
4545

@@ -661,7 +661,7 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
661661
* ready, connect.
662662
*/
663663
static void backend_changed(struct xenbus_watch *watch,
664-
const char **vec, unsigned int len)
664+
const char *path, const char *token)
665665
{
666666
int err;
667667
unsigned major;

drivers/net/xen-netback/xenbus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
734734
}
735735

736736
static void xen_net_rate_changed(struct xenbus_watch *watch,
737-
const char **vec, unsigned int len)
737+
const char *path, const char *token)
738738
{
739739
struct xenvif *vif = container_of(watch, struct xenvif, credit_watch);
740740
struct xenbus_device *dev = xenvif_to_xenbus_device(vif);
@@ -791,7 +791,7 @@ static void xen_unregister_credit_watch(struct xenvif *vif)
791791
}
792792

793793
static void xen_mcast_ctrl_changed(struct xenbus_watch *watch,
794-
const char **vec, unsigned int len)
794+
const char *path, const char *token)
795795
{
796796
struct xenvif *vif = container_of(watch, struct xenvif,
797797
mcast_ctrl_watch);
@@ -866,8 +866,8 @@ static void unregister_hotplug_status_watch(struct backend_info *be)
866866
}
867867

868868
static void hotplug_status_changed(struct xenbus_watch *watch,
869-
const char **vec,
870-
unsigned int vec_size)
869+
const char *path,
870+
const char *token)
871871
{
872872
struct backend_info *be = container_of(watch,
873873
struct backend_info,

drivers/xen/cpu_hotplug.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ static void vcpu_hotplug(unsigned int cpu)
6868
}
6969

7070
static void handle_vcpu_hotplug_event(struct xenbus_watch *watch,
71-
const char **vec, unsigned int len)
71+
const char *path, const char *token)
7272
{
7373
unsigned int cpu;
7474
char *cpustr;
75-
const char *node = vec[XS_WATCH_PATH];
7675

77-
cpustr = strstr(node, "cpu/");
76+
cpustr = strstr(path, "cpu/");
7877
if (cpustr != NULL) {
7978
sscanf(cpustr, "cpu/%u", &cpu);
8079
vcpu_hotplug(cpu);

drivers/xen/manage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static struct shutdown_handler shutdown_handlers[] = {
218218
};
219219

220220
static void shutdown_handler(struct xenbus_watch *watch,
221-
const char **vec, unsigned int len)
221+
const char *path, const char *token)
222222
{
223223
char *str;
224224
struct xenbus_transaction xbt;
@@ -266,8 +266,8 @@ static void shutdown_handler(struct xenbus_watch *watch,
266266
}
267267

268268
#ifdef CONFIG_MAGIC_SYSRQ
269-
static void sysrq_handler(struct xenbus_watch *watch, const char **vec,
270-
unsigned int len)
269+
static void sysrq_handler(struct xenbus_watch *watch, const char *path,
270+
const char *token)
271271
{
272272
char sysrq_key = '\0';
273273
struct xenbus_transaction xbt;

drivers/xen/xen-balloon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int register_balloon(struct device *dev);
5555

5656
/* React to a change in the target key */
5757
static void watch_target(struct xenbus_watch *watch,
58-
const char **vec, unsigned int len)
58+
const char *path, const char *token)
5959
{
6060
unsigned long long new_target;
6161
int err;

drivers/xen/xen-pciback/xenbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev)
652652
}
653653

654654
static void xen_pcibk_be_watch(struct xenbus_watch *watch,
655-
const char **vec, unsigned int len)
655+
const char *path, const char *token)
656656
{
657657
struct xen_pcibk_device *pdev =
658658
container_of(watch, struct xen_pcibk_device, be_watch);

drivers/xen/xenbus/xenbus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ struct xen_bus_type {
4040
int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename);
4141
int (*probe)(struct xen_bus_type *bus, const char *type,
4242
const char *dir);
43-
void (*otherend_changed)(struct xenbus_watch *watch, const char **vec,
44-
unsigned int len);
43+
void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
44+
const char *token);
4545
struct bus_type bus;
4646
};
4747

@@ -84,7 +84,7 @@ int xenbus_dev_resume(struct device *dev);
8484
int xenbus_dev_cancel(struct device *dev);
8585

8686
void xenbus_otherend_changed(struct xenbus_watch *watch,
87-
const char **vec, unsigned int len,
87+
const char *path, const char *token,
8888
int ignore_on_shutdown);
8989

9090
int xenbus_read_otherend_details(struct xenbus_device *xendev,

drivers/xen/xenbus/xenbus_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(xenbus_strstate);
115115
int xenbus_watch_path(struct xenbus_device *dev, const char *path,
116116
struct xenbus_watch *watch,
117117
void (*callback)(struct xenbus_watch *,
118-
const char **, unsigned int))
118+
const char *, const char *))
119119
{
120120
int err;
121121

@@ -153,7 +153,7 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path);
153153
int xenbus_watch_pathfmt(struct xenbus_device *dev,
154154
struct xenbus_watch *watch,
155155
void (*callback)(struct xenbus_watch *,
156-
const char **, unsigned int),
156+
const char *, const char *),
157157
const char *pathfmt, ...)
158158
{
159159
int err;

drivers/xen/xenbus/xenbus_dev_frontend.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,26 +258,23 @@ static struct watch_adapter *alloc_watch_adapter(const char *path,
258258
}
259259

260260
static void watch_fired(struct xenbus_watch *watch,
261-
const char **vec,
262-
unsigned int len)
261+
const char *path,
262+
const char *token)
263263
{
264264
struct watch_adapter *adap;
265265
struct xsd_sockmsg hdr;
266-
const char *path, *token;
267-
int path_len, tok_len, body_len, data_len = 0;
266+
const char *token_caller;
267+
int path_len, tok_len, body_len;
268268
int ret;
269269
LIST_HEAD(staging_q);
270270

271271
adap = container_of(watch, struct watch_adapter, watch);
272272

273-
path = vec[XS_WATCH_PATH];
274-
token = adap->token;
273+
token_caller = adap->token;
275274

276275
path_len = strlen(path) + 1;
277-
tok_len = strlen(token) + 1;
278-
if (len > 2)
279-
data_len = vec[len] - vec[2] + 1;
280-
body_len = path_len + tok_len + data_len;
276+
tok_len = strlen(token_caller) + 1;
277+
body_len = path_len + tok_len;
281278

282279
hdr.type = XS_WATCH_EVENT;
283280
hdr.len = body_len;
@@ -288,9 +285,7 @@ static void watch_fired(struct xenbus_watch *watch,
288285
if (!ret)
289286
ret = queue_reply(&staging_q, path, path_len);
290287
if (!ret)
291-
ret = queue_reply(&staging_q, token, tok_len);
292-
if (!ret && len > 2)
293-
ret = queue_reply(&staging_q, vec[2], data_len);
288+
ret = queue_reply(&staging_q, token_caller, tok_len);
294289

295290
if (!ret) {
296291
/* success: pass reply list onto watcher */

drivers/xen/xenbus/xenbus_probe.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int xenbus_read_otherend_details(struct xenbus_device *xendev,
169169
EXPORT_SYMBOL_GPL(xenbus_read_otherend_details);
170170

171171
void xenbus_otherend_changed(struct xenbus_watch *watch,
172-
const char **vec, unsigned int len,
172+
const char *path, const char *token,
173173
int ignore_on_shutdown)
174174
{
175175
struct xenbus_device *dev =
@@ -180,18 +180,15 @@ void xenbus_otherend_changed(struct xenbus_watch *watch,
180180
/* Protect us against watches firing on old details when the otherend
181181
details change, say immediately after a resume. */
182182
if (!dev->otherend ||
183-
strncmp(dev->otherend, vec[XS_WATCH_PATH],
184-
strlen(dev->otherend))) {
185-
dev_dbg(&dev->dev, "Ignoring watch at %s\n",
186-
vec[XS_WATCH_PATH]);
183+
strncmp(dev->otherend, path, strlen(dev->otherend))) {
184+
dev_dbg(&dev->dev, "Ignoring watch at %s\n", path);
187185
return;
188186
}
189187

190188
state = xenbus_read_driver_state(dev->otherend);
191189

192190
dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n",
193-
state, xenbus_strstate(state), dev->otherend_watch.node,
194-
vec[XS_WATCH_PATH]);
191+
state, xenbus_strstate(state), dev->otherend_watch.node, path);
195192

196193
/*
197194
* Ignore xenbus transitions during shutdown. This prevents us doing

0 commit comments

Comments
 (0)