diff options
author | Juergen Gross <jgross@suse.com> | 2017-02-09 08:39:57 -0500 |
---|---|---|
committer | Boris Ostrovsky <boris.ostrovsky@oracle.com> | 2017-02-09 11:26:49 -0500 |
commit | 5584ea250ae44f929feb4c7bd3877d1c5edbf813 (patch) | |
tree | d84dca574c46ec785098d13211d92ef74e3a74f2 | |
parent | 332f791dc98d98116f4473b726f67c9321b0f31e (diff) |
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: konrad.wilk@oracle.com
Cc: roger.pau@citrix.com
Cc: wei.liu2@citrix.com
Cc: paul.durrant@citrix.com
Cc: netdev@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r-- | drivers/block/xen-blkback/xenbus.c | 6 | ||||
-rw-r--r-- | drivers/net/xen-netback/xenbus.c | 8 | ||||
-rw-r--r-- | drivers/xen/cpu_hotplug.c | 5 | ||||
-rw-r--r-- | drivers/xen/manage.c | 6 | ||||
-rw-r--r-- | drivers/xen/xen-balloon.c | 2 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/xenbus.c | 2 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus.h | 6 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_client.c | 4 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_dev_frontend.c | 21 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe.c | 11 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_backend.c | 8 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_frontend.c | 14 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_xs.c | 29 | ||||
-rw-r--r-- | include/xen/xenbus.h | 6 |
14 files changed, 59 insertions, 69 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index 415e79b69d34..8fe61b5dc5a6 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c | |||
@@ -38,8 +38,8 @@ struct backend_info { | |||
38 | static struct kmem_cache *xen_blkif_cachep; | 38 | static struct kmem_cache *xen_blkif_cachep; |
39 | static void connect(struct backend_info *); | 39 | static void connect(struct backend_info *); |
40 | static int connect_ring(struct backend_info *); | 40 | static int connect_ring(struct backend_info *); |
41 | static void backend_changed(struct xenbus_watch *, const char **, | 41 | static void backend_changed(struct xenbus_watch *, const char *, |
42 | unsigned int); | 42 | const char *); |
43 | static void xen_blkif_free(struct xen_blkif *blkif); | 43 | static void xen_blkif_free(struct xen_blkif *blkif); |
44 | static void xen_vbd_free(struct xen_vbd *vbd); | 44 | static void xen_vbd_free(struct xen_vbd *vbd); |
45 | 45 | ||
@@ -661,7 +661,7 @@ fail: | |||
661 | * ready, connect. | 661 | * ready, connect. |
662 | */ | 662 | */ |
663 | static void backend_changed(struct xenbus_watch *watch, | 663 | static void backend_changed(struct xenbus_watch *watch, |
664 | const char **vec, unsigned int len) | 664 | const char *path, const char *token) |
665 | { | 665 | { |
666 | int err; | 666 | int err; |
667 | unsigned major; | 667 | unsigned major; |
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 85b742e1c42f..bb854f92f5a5 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c | |||
@@ -734,7 +734,7 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]) | |||
734 | } | 734 | } |
735 | 735 | ||
736 | static void xen_net_rate_changed(struct xenbus_watch *watch, | 736 | static void xen_net_rate_changed(struct xenbus_watch *watch, |
737 | const char **vec, unsigned int len) | 737 | const char *path, const char *token) |
738 | { | 738 | { |
739 | struct xenvif *vif = container_of(watch, struct xenvif, credit_watch); | 739 | struct xenvif *vif = container_of(watch, struct xenvif, credit_watch); |
740 | struct xenbus_device *dev = xenvif_to_xenbus_device(vif); | 740 | struct xenbus_device *dev = xenvif_to_xenbus_device(vif); |
@@ -791,7 +791,7 @@ static void xen_unregister_credit_watch(struct xenvif *vif) | |||
791 | } | 791 | } |
792 | 792 | ||
793 | static void xen_mcast_ctrl_changed(struct xenbus_watch *watch, | 793 | static void xen_mcast_ctrl_changed(struct xenbus_watch *watch, |
794 | const char **vec, unsigned int len) | 794 | const char *path, const char *token) |
795 | { | 795 | { |
796 | struct xenvif *vif = container_of(watch, struct xenvif, | 796 | struct xenvif *vif = container_of(watch, struct xenvif, |
797 | mcast_ctrl_watch); | 797 | mcast_ctrl_watch); |
@@ -866,8 +866,8 @@ static void unregister_hotplug_status_watch(struct backend_info *be) | |||
866 | } | 866 | } |
867 | 867 | ||
868 | static void hotplug_status_changed(struct xenbus_watch *watch, | 868 | static void hotplug_status_changed(struct xenbus_watch *watch, |
869 | const char **vec, | 869 | const char *path, |
870 | unsigned int vec_size) | 870 | const char *token) |
871 | { | 871 | { |
872 | struct backend_info *be = container_of(watch, | 872 | struct backend_info *be = container_of(watch, |
873 | struct backend_info, | 873 | struct backend_info, |
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c index 0bab60a37464..0003912a8111 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c | |||
@@ -68,13 +68,12 @@ static void vcpu_hotplug(unsigned int cpu) | |||
68 | } | 68 | } |
69 | 69 | ||
70 | static void handle_vcpu_hotplug_event(struct xenbus_watch *watch, | 70 | static void handle_vcpu_hotplug_event(struct xenbus_watch *watch, |
71 | const char **vec, unsigned int len) | 71 | const char *path, const char *token) |
72 | { | 72 | { |
73 | unsigned int cpu; | 73 | unsigned int cpu; |
74 | char *cpustr; | 74 | char *cpustr; |
75 | const char *node = vec[XS_WATCH_PATH]; | ||
76 | 75 | ||
77 | cpustr = strstr(node, "cpu/"); | 76 | cpustr = strstr(path, "cpu/"); |
78 | if (cpustr != NULL) { | 77 | if (cpustr != NULL) { |
79 | sscanf(cpustr, "cpu/%u", &cpu); | 78 | sscanf(cpustr, "cpu/%u", &cpu); |
80 | vcpu_hotplug(cpu); | 79 | vcpu_hotplug(cpu); |
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 357a8db859c9..c1ec8ee80924 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c | |||
@@ -218,7 +218,7 @@ static struct shutdown_handler shutdown_handlers[] = { | |||
218 | }; | 218 | }; |
219 | 219 | ||
220 | static void shutdown_handler(struct xenbus_watch *watch, | 220 | static void shutdown_handler(struct xenbus_watch *watch, |
221 | const char **vec, unsigned int len) | 221 | const char *path, const char *token) |
222 | { | 222 | { |
223 | char *str; | 223 | char *str; |
224 | struct xenbus_transaction xbt; | 224 | struct xenbus_transaction xbt; |
@@ -266,8 +266,8 @@ static void shutdown_handler(struct xenbus_watch *watch, | |||
266 | } | 266 | } |
267 | 267 | ||
268 | #ifdef CONFIG_MAGIC_SYSRQ | 268 | #ifdef CONFIG_MAGIC_SYSRQ |
269 | static void sysrq_handler(struct xenbus_watch *watch, const char **vec, | 269 | static void sysrq_handler(struct xenbus_watch *watch, const char *path, |
270 | unsigned int len) | 270 | const char *token) |
271 | { | 271 | { |
272 | char sysrq_key = '\0'; | 272 | char sysrq_key = '\0'; |
273 | struct xenbus_transaction xbt; | 273 | struct xenbus_transaction xbt; |
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 79865b8901ba..e7715cb62eef 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c | |||
@@ -55,7 +55,7 @@ static int register_balloon(struct device *dev); | |||
55 | 55 | ||
56 | /* React to a change in the target key */ | 56 | /* React to a change in the target key */ |
57 | static void watch_target(struct xenbus_watch *watch, | 57 | static void watch_target(struct xenbus_watch *watch, |
58 | const char **vec, unsigned int len) | 58 | const char *path, const char *token) |
59 | { | 59 | { |
60 | unsigned long long new_target; | 60 | unsigned long long new_target; |
61 | int err; | 61 | int err; |
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c index 3f0aee0a068b..3814b44bf1f7 100644 --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c | |||
@@ -652,7 +652,7 @@ out: | |||
652 | } | 652 | } |
653 | 653 | ||
654 | static void xen_pcibk_be_watch(struct xenbus_watch *watch, | 654 | static void xen_pcibk_be_watch(struct xenbus_watch *watch, |
655 | const char **vec, unsigned int len) | 655 | const char *path, const char *token) |
656 | { | 656 | { |
657 | struct xen_pcibk_device *pdev = | 657 | struct xen_pcibk_device *pdev = |
658 | container_of(watch, struct xen_pcibk_device, be_watch); | 658 | container_of(watch, struct xen_pcibk_device, be_watch); |
diff --git a/drivers/xen/xenbus/xenbus.h b/drivers/xen/xenbus/xenbus.h index a6b007dfdaa8..51995276f549 100644 --- a/drivers/xen/xenbus/xenbus.h +++ b/drivers/xen/xenbus/xenbus.h | |||
@@ -40,8 +40,8 @@ struct xen_bus_type { | |||
40 | int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename); | 40 | int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename); |
41 | int (*probe)(struct xen_bus_type *bus, const char *type, | 41 | int (*probe)(struct xen_bus_type *bus, const char *type, |
42 | const char *dir); | 42 | const char *dir); |
43 | void (*otherend_changed)(struct xenbus_watch *watch, const char **vec, | 43 | void (*otherend_changed)(struct xenbus_watch *watch, const char *path, |
44 | unsigned int len); | 44 | const char *token); |
45 | struct bus_type bus; | 45 | struct bus_type bus; |
46 | }; | 46 | }; |
47 | 47 | ||
@@ -84,7 +84,7 @@ int xenbus_dev_resume(struct device *dev); | |||
84 | int xenbus_dev_cancel(struct device *dev); | 84 | int xenbus_dev_cancel(struct device *dev); |
85 | 85 | ||
86 | void xenbus_otherend_changed(struct xenbus_watch *watch, | 86 | void xenbus_otherend_changed(struct xenbus_watch *watch, |
87 | const char **vec, unsigned int len, | 87 | const char *path, const char *token, |
88 | int ignore_on_shutdown); | 88 | int ignore_on_shutdown); |
89 | 89 | ||
90 | int xenbus_read_otherend_details(struct xenbus_device *xendev, | 90 | int xenbus_read_otherend_details(struct xenbus_device *xendev, |
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 29f82338ab75..82a8866758ee 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c | |||
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(xenbus_strstate); | |||
115 | int xenbus_watch_path(struct xenbus_device *dev, const char *path, | 115 | int xenbus_watch_path(struct xenbus_device *dev, const char *path, |
116 | struct xenbus_watch *watch, | 116 | struct xenbus_watch *watch, |
117 | void (*callback)(struct xenbus_watch *, | 117 | void (*callback)(struct xenbus_watch *, |
118 | const char **, unsigned int)) | 118 | const char *, const char *)) |
119 | { | 119 | { |
120 | int err; | 120 | int err; |
121 | 121 | ||
@@ -153,7 +153,7 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path); | |||
153 | int xenbus_watch_pathfmt(struct xenbus_device *dev, | 153 | int xenbus_watch_pathfmt(struct xenbus_device *dev, |
154 | struct xenbus_watch *watch, | 154 | struct xenbus_watch *watch, |
155 | void (*callback)(struct xenbus_watch *, | 155 | void (*callback)(struct xenbus_watch *, |
156 | const char **, unsigned int), | 156 | const char *, const char *), |
157 | const char *pathfmt, ...) | 157 | const char *pathfmt, ...) |
158 | { | 158 | { |
159 | int err; | 159 | int err; |
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index e2bc9b301494..e4b984777507 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c | |||
@@ -258,26 +258,23 @@ out_fail: | |||
258 | } | 258 | } |
259 | 259 | ||
260 | static void watch_fired(struct xenbus_watch *watch, | 260 | static void watch_fired(struct xenbus_watch *watch, |
261 | const char **vec, | 261 | const char *path, |
262 | unsigned int len) | 262 | const char *token) |
263 | { | 263 | { |
264 | struct watch_adapter *adap; | 264 | struct watch_adapter *adap; |
265 | struct xsd_sockmsg hdr; | 265 | struct xsd_sockmsg hdr; |
266 | const char *path, *token; | 266 | const char *token_caller; |
267 | int path_len, tok_len, body_len, data_len = 0; | 267 | int path_len, tok_len, body_len; |
268 | int ret; | 268 | int ret; |
269 | LIST_HEAD(staging_q); | 269 | LIST_HEAD(staging_q); |
270 | 270 | ||
271 | adap = container_of(watch, struct watch_adapter, watch); | 271 | adap = container_of(watch, struct watch_adapter, watch); |
272 | 272 | ||
273 | path = vec[XS_WATCH_PATH]; | 273 | token_caller = adap->token; |
274 | token = adap->token; | ||
275 | 274 | ||
276 | path_len = strlen(path) + 1; | 275 | path_len = strlen(path) + 1; |
277 | tok_len = strlen(token) + 1; | 276 | tok_len = strlen(token_caller) + 1; |
278 | if (len > 2) | 277 | body_len = path_len + tok_len; |
279 | data_len = vec[len] - vec[2] + 1; | ||
280 | body_len = path_len + tok_len + data_len; | ||
281 | 278 | ||
282 | hdr.type = XS_WATCH_EVENT; | 279 | hdr.type = XS_WATCH_EVENT; |
283 | hdr.len = body_len; | 280 | hdr.len = body_len; |
@@ -288,9 +285,7 @@ static void watch_fired(struct xenbus_watch *watch, | |||
288 | if (!ret) | 285 | if (!ret) |
289 | ret = queue_reply(&staging_q, path, path_len); | 286 | ret = queue_reply(&staging_q, path, path_len); |
290 | if (!ret) | 287 | if (!ret) |
291 | ret = queue_reply(&staging_q, token, tok_len); | 288 | ret = queue_reply(&staging_q, token_caller, tok_len); |
292 | if (!ret && len > 2) | ||
293 | ret = queue_reply(&staging_q, vec[2], data_len); | ||
294 | 289 | ||
295 | if (!ret) { | 290 | if (!ret) { |
296 | /* success: pass reply list onto watcher */ | 291 | /* success: pass reply list onto watcher */ |
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 6baffbb6acf9..74888cacd0b0 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c | |||
@@ -169,7 +169,7 @@ int xenbus_read_otherend_details(struct xenbus_device *xendev, | |||
169 | EXPORT_SYMBOL_GPL(xenbus_read_otherend_details); | 169 | EXPORT_SYMBOL_GPL(xenbus_read_otherend_details); |
170 | 170 | ||
171 | void xenbus_otherend_changed(struct xenbus_watch *watch, | 171 | void xenbus_otherend_changed(struct xenbus_watch *watch, |
172 | const char **vec, unsigned int len, | 172 | const char *path, const char *token, |
173 | int ignore_on_shutdown) | 173 | int ignore_on_shutdown) |
174 | { | 174 | { |
175 | struct xenbus_device *dev = | 175 | struct xenbus_device *dev = |
@@ -180,18 +180,15 @@ void xenbus_otherend_changed(struct xenbus_watch *watch, | |||
180 | /* Protect us against watches firing on old details when the otherend | 180 | /* Protect us against watches firing on old details when the otherend |
181 | details change, say immediately after a resume. */ | 181 | details change, say immediately after a resume. */ |
182 | if (!dev->otherend || | 182 | if (!dev->otherend || |
183 | strncmp(dev->otherend, vec[XS_WATCH_PATH], | 183 | strncmp(dev->otherend, path, strlen(dev->otherend))) { |
184 | strlen(dev->otherend))) { | 184 | dev_dbg(&dev->dev, "Ignoring watch at %s\n", path); |
185 | dev_dbg(&dev->dev, "Ignoring watch at %s\n", | ||
186 | vec[XS_WATCH_PATH]); | ||
187 | return; | 185 | return; |
188 | } | 186 | } |
189 | 187 | ||
190 | state = xenbus_read_driver_state(dev->otherend); | 188 | state = xenbus_read_driver_state(dev->otherend); |
191 | 189 | ||
192 | dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n", | 190 | dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n", |
193 | state, xenbus_strstate(state), dev->otherend_watch.node, | 191 | state, xenbus_strstate(state), dev->otherend_watch.node, path); |
194 | vec[XS_WATCH_PATH]); | ||
195 | 192 | ||
196 | /* | 193 | /* |
197 | * Ignore xenbus transitions during shutdown. This prevents us doing | 194 | * Ignore xenbus transitions during shutdown. This prevents us doing |
diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c index f46b4dc72c76..b0bed4faf44c 100644 --- a/drivers/xen/xenbus/xenbus_probe_backend.c +++ b/drivers/xen/xenbus/xenbus_probe_backend.c | |||
@@ -181,9 +181,9 @@ static int xenbus_probe_backend(struct xen_bus_type *bus, const char *type, | |||
181 | } | 181 | } |
182 | 182 | ||
183 | static void frontend_changed(struct xenbus_watch *watch, | 183 | static void frontend_changed(struct xenbus_watch *watch, |
184 | const char **vec, unsigned int len) | 184 | const char *path, const char *token) |
185 | { | 185 | { |
186 | xenbus_otherend_changed(watch, vec, len, 0); | 186 | xenbus_otherend_changed(watch, path, token, 0); |
187 | } | 187 | } |
188 | 188 | ||
189 | static struct xen_bus_type xenbus_backend = { | 189 | static struct xen_bus_type xenbus_backend = { |
@@ -204,11 +204,11 @@ static struct xen_bus_type xenbus_backend = { | |||
204 | }; | 204 | }; |
205 | 205 | ||
206 | static void backend_changed(struct xenbus_watch *watch, | 206 | static void backend_changed(struct xenbus_watch *watch, |
207 | const char **vec, unsigned int len) | 207 | const char *path, const char *token) |
208 | { | 208 | { |
209 | DPRINTK(""); | 209 | DPRINTK(""); |
210 | 210 | ||
211 | xenbus_dev_changed(vec[XS_WATCH_PATH], &xenbus_backend); | 211 | xenbus_dev_changed(path, &xenbus_backend); |
212 | } | 212 | } |
213 | 213 | ||
214 | static struct xenbus_watch be_watch = { | 214 | static struct xenbus_watch be_watch = { |
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c index d7b77a62e6e7..19e45ce21f89 100644 --- a/drivers/xen/xenbus/xenbus_probe_frontend.c +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c | |||
@@ -86,9 +86,9 @@ static int xenbus_uevent_frontend(struct device *_dev, | |||
86 | 86 | ||
87 | 87 | ||
88 | static void backend_changed(struct xenbus_watch *watch, | 88 | static void backend_changed(struct xenbus_watch *watch, |
89 | const char **vec, unsigned int len) | 89 | const char *path, const char *token) |
90 | { | 90 | { |
91 | xenbus_otherend_changed(watch, vec, len, 1); | 91 | xenbus_otherend_changed(watch, path, token, 1); |
92 | } | 92 | } |
93 | 93 | ||
94 | static void xenbus_frontend_delayed_resume(struct work_struct *w) | 94 | static void xenbus_frontend_delayed_resume(struct work_struct *w) |
@@ -153,11 +153,11 @@ static struct xen_bus_type xenbus_frontend = { | |||
153 | }; | 153 | }; |
154 | 154 | ||
155 | static void frontend_changed(struct xenbus_watch *watch, | 155 | static void frontend_changed(struct xenbus_watch *watch, |
156 | const char **vec, unsigned int len) | 156 | const char *path, const char *token) |
157 | { | 157 | { |
158 | DPRINTK(""); | 158 | DPRINTK(""); |
159 | 159 | ||
160 | xenbus_dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend); | 160 | xenbus_dev_changed(path, &xenbus_frontend); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
@@ -332,13 +332,13 @@ static DECLARE_WAIT_QUEUE_HEAD(backend_state_wq); | |||
332 | static int backend_state; | 332 | static int backend_state; |
333 | 333 | ||
334 | static void xenbus_reset_backend_state_changed(struct xenbus_watch *w, | 334 | static void xenbus_reset_backend_state_changed(struct xenbus_watch *w, |
335 | const char **v, unsigned int l) | 335 | const char *path, const char *token) |
336 | { | 336 | { |
337 | if (xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", | 337 | if (xenbus_scanf(XBT_NIL, path, "", "%i", |
338 | &backend_state) != 1) | 338 | &backend_state) != 1) |
339 | backend_state = XenbusStateUnknown; | 339 | backend_state = XenbusStateUnknown; |
340 | printk(KERN_DEBUG "XENBUS: backend %s %s\n", | 340 | printk(KERN_DEBUG "XENBUS: backend %s %s\n", |
341 | v[XS_WATCH_PATH], xenbus_strstate(backend_state)); | 341 | path, xenbus_strstate(backend_state)); |
342 | wake_up(&backend_state_wq); | 342 | wake_up(&backend_state_wq); |
343 | } | 343 | } |
344 | 344 | ||
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c index 4c49d8709765..ebc768f44abe 100644 --- a/drivers/xen/xenbus/xenbus_xs.c +++ b/drivers/xen/xenbus/xenbus_xs.c | |||
@@ -64,8 +64,8 @@ struct xs_stored_msg { | |||
64 | /* Queued watch events. */ | 64 | /* Queued watch events. */ |
65 | struct { | 65 | struct { |
66 | struct xenbus_watch *handle; | 66 | struct xenbus_watch *handle; |
67 | char **vec; | 67 | const char *path; |
68 | unsigned int vec_size; | 68 | const char *token; |
69 | } watch; | 69 | } watch; |
70 | } u; | 70 | } u; |
71 | }; | 71 | }; |
@@ -765,7 +765,7 @@ void unregister_xenbus_watch(struct xenbus_watch *watch) | |||
765 | if (msg->u.watch.handle != watch) | 765 | if (msg->u.watch.handle != watch) |
766 | continue; | 766 | continue; |
767 | list_del(&msg->list); | 767 | list_del(&msg->list); |
768 | kfree(msg->u.watch.vec); | 768 | kfree(msg->u.watch.path); |
769 | kfree(msg); | 769 | kfree(msg); |
770 | } | 770 | } |
771 | spin_unlock(&watch_events_lock); | 771 | spin_unlock(&watch_events_lock); |
@@ -833,11 +833,10 @@ static int xenwatch_thread(void *unused) | |||
833 | 833 | ||
834 | if (ent != &watch_events) { | 834 | if (ent != &watch_events) { |
835 | msg = list_entry(ent, struct xs_stored_msg, list); | 835 | msg = list_entry(ent, struct xs_stored_msg, list); |
836 | msg->u.watch.handle->callback( | 836 | msg->u.watch.handle->callback(msg->u.watch.handle, |
837 | msg->u.watch.handle, | 837 | msg->u.watch.path, |
838 | (const char **)msg->u.watch.vec, | 838 | msg->u.watch.token); |
839 | msg->u.watch.vec_size); | 839 | kfree(msg->u.watch.path); |
840 | kfree(msg->u.watch.vec); | ||
841 | kfree(msg); | 840 | kfree(msg); |
842 | } | 841 | } |
843 | 842 | ||
@@ -903,24 +902,24 @@ static int process_msg(void) | |||
903 | body[msg->hdr.len] = '\0'; | 902 | body[msg->hdr.len] = '\0'; |
904 | 903 | ||
905 | if (msg->hdr.type == XS_WATCH_EVENT) { | 904 | if (msg->hdr.type == XS_WATCH_EVENT) { |
906 | msg->u.watch.vec = split(body, msg->hdr.len, | 905 | if (count_strings(body, msg->hdr.len) != 2) { |
907 | &msg->u.watch.vec_size); | 906 | err = -EINVAL; |
908 | if (IS_ERR(msg->u.watch.vec)) { | ||
909 | err = PTR_ERR(msg->u.watch.vec); | ||
910 | kfree(msg); | 907 | kfree(msg); |
908 | kfree(body); | ||
911 | goto out; | 909 | goto out; |
912 | } | 910 | } |
911 | msg->u.watch.path = (const char *)body; | ||
912 | msg->u.watch.token = (const char *)strchr(body, '\0') + 1; | ||
913 | 913 | ||
914 | spin_lock(&watches_lock); | 914 | spin_lock(&watches_lock); |
915 | msg->u.watch.handle = find_watch( | 915 | msg->u.watch.handle = find_watch(msg->u.watch.token); |
916 | msg->u.watch.vec[XS_WATCH_TOKEN]); | ||
917 | if (msg->u.watch.handle != NULL) { | 916 | if (msg->u.watch.handle != NULL) { |
918 | spin_lock(&watch_events_lock); | 917 | spin_lock(&watch_events_lock); |
919 | list_add_tail(&msg->list, &watch_events); | 918 | list_add_tail(&msg->list, &watch_events); |
920 | wake_up(&watch_events_waitq); | 919 | wake_up(&watch_events_waitq); |
921 | spin_unlock(&watch_events_lock); | 920 | spin_unlock(&watch_events_lock); |
922 | } else { | 921 | } else { |
923 | kfree(msg->u.watch.vec); | 922 | kfree(body); |
924 | kfree(msg); | 923 | kfree(msg); |
925 | } | 924 | } |
926 | spin_unlock(&watches_lock); | 925 | spin_unlock(&watches_lock); |
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 98f73a20725c..869c816d5f8c 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h | |||
@@ -61,7 +61,7 @@ struct xenbus_watch | |||
61 | 61 | ||
62 | /* Callback (executed in a process context with no locks held). */ | 62 | /* Callback (executed in a process context with no locks held). */ |
63 | void (*callback)(struct xenbus_watch *, | 63 | void (*callback)(struct xenbus_watch *, |
64 | const char **vec, unsigned int len); | 64 | const char *path, const char *token); |
65 | }; | 65 | }; |
66 | 66 | ||
67 | 67 | ||
@@ -193,11 +193,11 @@ void xenbus_probe(struct work_struct *); | |||
193 | int xenbus_watch_path(struct xenbus_device *dev, const char *path, | 193 | int xenbus_watch_path(struct xenbus_device *dev, const char *path, |
194 | struct xenbus_watch *watch, | 194 | struct xenbus_watch *watch, |
195 | void (*callback)(struct xenbus_watch *, | 195 | void (*callback)(struct xenbus_watch *, |
196 | const char **, unsigned int)); | 196 | const char *, const char *)); |
197 | __printf(4, 5) | 197 | __printf(4, 5) |
198 | int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, | 198 | int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, |
199 | void (*callback)(struct xenbus_watch *, | 199 | void (*callback)(struct xenbus_watch *, |
200 | const char **, unsigned int), | 200 | const char *, const char *), |
201 | const char *pathfmt, ...); | 201 | const char *pathfmt, ...); |
202 | 202 | ||
203 | int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); | 203 | int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); |