aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/manage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/manage.c')
-rw-r--r--drivers/xen/manage.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index fc6c94c0b436..32f9236c959f 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -198,10 +198,32 @@ struct shutdown_handler {
198 void (*cb)(void); 198 void (*cb)(void);
199}; 199};
200 200
201static int poweroff_nb(struct notifier_block *cb, unsigned long code, void *unused)
202{
203 switch (code) {
204 case SYS_DOWN:
205 case SYS_HALT:
206 case SYS_POWER_OFF:
207 shutting_down = SHUTDOWN_POWEROFF;
208 default:
209 break;
210 }
211 return NOTIFY_DONE;
212}
201static void do_poweroff(void) 213static void do_poweroff(void)
202{ 214{
203 shutting_down = SHUTDOWN_POWEROFF; 215 switch (system_state) {
204 orderly_poweroff(false); 216 case SYSTEM_BOOTING:
217 orderly_poweroff(true);
218 break;
219 case SYSTEM_RUNNING:
220 orderly_poweroff(false);
221 break;
222 default:
223 /* Don't do it when we are halting/rebooting. */
224 pr_info("Ignoring Xen toolstack shutdown.\n");
225 break;
226 }
205} 227}
206 228
207static void do_reboot(void) 229static void do_reboot(void)
@@ -307,6 +329,10 @@ static struct xenbus_watch shutdown_watch = {
307 .callback = shutdown_handler 329 .callback = shutdown_handler
308}; 330};
309 331
332static struct notifier_block xen_reboot_nb = {
333 .notifier_call = poweroff_nb,
334};
335
310static int setup_shutdown_watcher(void) 336static int setup_shutdown_watcher(void)
311{ 337{
312 int err; 338 int err;
@@ -317,6 +343,7 @@ static int setup_shutdown_watcher(void)
317 return err; 343 return err;
318 } 344 }
319 345
346
320#ifdef CONFIG_MAGIC_SYSRQ 347#ifdef CONFIG_MAGIC_SYSRQ
321 err = register_xenbus_watch(&sysrq_watch); 348 err = register_xenbus_watch(&sysrq_watch);
322 if (err) { 349 if (err) {
@@ -345,6 +372,7 @@ int xen_setup_shutdown_event(void)
345 if (!xen_domain()) 372 if (!xen_domain())
346 return -ENODEV; 373 return -ENODEV;
347 register_xenstore_notifier(&xenstore_notifier); 374 register_xenstore_notifier(&xenstore_notifier);
375 register_reboot_notifier(&xen_reboot_nb);
348 376
349 return 0; 377 return 0;
350} 378}