aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-24 22:52:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-24 22:52:24 -0400
commitaa34e07e457ed13b44d680b5b605e3e5a585f611 (patch)
tree0c46cb911f52cb0f19082bf925758d7f1f4527c7 /drivers/xen
parent0d7317598214134d73da59990b846481a9527a00 (diff)
parentc251f15c7dbf2cb72e7b2b282020b41f4e4d3665 (diff)
Merge tag 'for-linus-4.9-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from David Vrabel: - advertise control feature flags in xenstore - fix x86 build when XEN_PVHVM is disabled * tag 'for-linus-4.9-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xenbus: check return value of xenbus_scanf() xenbus: prefer list_for_each() x86: xen: move cpu_up functions out of ifdef xenbus: advertise control feature flags
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/manage.c45
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c4
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c4
3 files changed, 34 insertions, 19 deletions
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index e12bd3635f83..26e5e8507f03 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -168,7 +168,9 @@ out:
168#endif /* CONFIG_HIBERNATE_CALLBACKS */ 168#endif /* CONFIG_HIBERNATE_CALLBACKS */
169 169
170struct shutdown_handler { 170struct shutdown_handler {
171 const char *command; 171#define SHUTDOWN_CMD_SIZE 11
172 const char command[SHUTDOWN_CMD_SIZE];
173 bool flag;
172 void (*cb)(void); 174 void (*cb)(void);
173}; 175};
174 176
@@ -206,22 +208,22 @@ static void do_reboot(void)
206 ctrl_alt_del(); 208 ctrl_alt_del();
207} 209}
208 210
211static struct shutdown_handler shutdown_handlers[] = {
212 { "poweroff", true, do_poweroff },
213 { "halt", false, do_poweroff },
214 { "reboot", true, do_reboot },
215#ifdef CONFIG_HIBERNATE_CALLBACKS
216 { "suspend", true, do_suspend },
217#endif
218};
219
209static void shutdown_handler(struct xenbus_watch *watch, 220static void shutdown_handler(struct xenbus_watch *watch,
210 const char **vec, unsigned int len) 221 const char **vec, unsigned int len)
211{ 222{
212 char *str; 223 char *str;
213 struct xenbus_transaction xbt; 224 struct xenbus_transaction xbt;
214 int err; 225 int err;
215 static struct shutdown_handler handlers[] = { 226 int idx;
216 { "poweroff", do_poweroff },
217 { "halt", do_poweroff },
218 { "reboot", do_reboot },
219#ifdef CONFIG_HIBERNATE_CALLBACKS
220 { "suspend", do_suspend },
221#endif
222 {NULL, NULL},
223 };
224 static struct shutdown_handler *handler;
225 227
226 if (shutting_down != SHUTDOWN_INVALID) 228 if (shutting_down != SHUTDOWN_INVALID)
227 return; 229 return;
@@ -238,13 +240,13 @@ static void shutdown_handler(struct xenbus_watch *watch,
238 return; 240 return;
239 } 241 }
240 242
241 for (handler = &handlers[0]; handler->command; handler++) { 243 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
242 if (strcmp(str, handler->command) == 0) 244 if (strcmp(str, shutdown_handlers[idx].command) == 0)
243 break; 245 break;
244 } 246 }
245 247
246 /* Only acknowledge commands which we are prepared to handle. */ 248 /* Only acknowledge commands which we are prepared to handle. */
247 if (handler->cb) 249 if (idx < ARRAY_SIZE(shutdown_handlers))
248 xenbus_write(xbt, "control", "shutdown", ""); 250 xenbus_write(xbt, "control", "shutdown", "");
249 251
250 err = xenbus_transaction_end(xbt, 0); 252 err = xenbus_transaction_end(xbt, 0);
@@ -253,8 +255,8 @@ static void shutdown_handler(struct xenbus_watch *watch,
253 goto again; 255 goto again;
254 } 256 }
255 257
256 if (handler->cb) { 258 if (idx < ARRAY_SIZE(shutdown_handlers)) {
257 handler->cb(); 259 shutdown_handlers[idx].cb();
258 } else { 260 } else {
259 pr_info("Ignoring shutdown request: %s\n", str); 261 pr_info("Ignoring shutdown request: %s\n", str);
260 shutting_down = SHUTDOWN_INVALID; 262 shutting_down = SHUTDOWN_INVALID;
@@ -310,6 +312,9 @@ static struct notifier_block xen_reboot_nb = {
310static int setup_shutdown_watcher(void) 312static int setup_shutdown_watcher(void)
311{ 313{
312 int err; 314 int err;
315 int idx;
316#define FEATURE_PATH_SIZE (SHUTDOWN_CMD_SIZE + sizeof("feature-"))
317 char node[FEATURE_PATH_SIZE];
313 318
314 err = register_xenbus_watch(&shutdown_watch); 319 err = register_xenbus_watch(&shutdown_watch);
315 if (err) { 320 if (err) {
@@ -326,6 +331,14 @@ static int setup_shutdown_watcher(void)
326 } 331 }
327#endif 332#endif
328 333
334 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
335 if (!shutdown_handlers[idx].flag)
336 continue;
337 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
338 shutdown_handlers[idx].command);
339 xenbus_printf(XBT_NIL, "control", node, "%u", 1);
340 }
341
329 return 0; 342 return 0;
330} 343}
331 344
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index c1010f018bd8..1e8be12ebb55 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -364,7 +364,7 @@ out:
364 364
365static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u) 365static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
366{ 366{
367 struct watch_adapter *watch, *tmp_watch; 367 struct watch_adapter *watch;
368 char *path, *token; 368 char *path, *token;
369 int err, rc; 369 int err, rc;
370 LIST_HEAD(staging_q); 370 LIST_HEAD(staging_q);
@@ -399,7 +399,7 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
399 } 399 }
400 list_add(&watch->list, &u->watches); 400 list_add(&watch->list, &u->watches);
401 } else { 401 } else {
402 list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) { 402 list_for_each_entry(watch, &u->watches, list) {
403 if (!strcmp(watch->token, token) && 403 if (!strcmp(watch->token, token) &&
404 !strcmp(watch->watch.node, path)) { 404 !strcmp(watch->watch.node, path)) {
405 unregister_xenbus_watch(&watch->watch); 405 unregister_xenbus_watch(&watch->watch);
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index 611a23119675..6d40a972ffb2 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -335,7 +335,9 @@ static int backend_state;
335static void xenbus_reset_backend_state_changed(struct xenbus_watch *w, 335static void xenbus_reset_backend_state_changed(struct xenbus_watch *w,
336 const char **v, unsigned int l) 336 const char **v, unsigned int l)
337{ 337{
338 xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", &backend_state); 338 if (xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i",
339 &backend_state) != 1)
340 backend_state = XenbusStateUnknown;
339 printk(KERN_DEBUG "XENBUS: backend %s %s\n", 341 printk(KERN_DEBUG "XENBUS: backend %s %s\n",
340 v[XS_WATCH_PATH], xenbus_strstate(backend_state)); 342 v[XS_WATCH_PATH], xenbus_strstate(backend_state));
341 wake_up(&backend_state_wq); 343 wake_up(&backend_state_wq);