1 #include <xen/init.h>
2 #include <xen/lib.h>
3 #include <xen/param.h>
4 #include <xen/sched.h>
5 #include <xen/domain.h>
6 #include <xen/delay.h>
7 #include <xen/watchdog.h>
8 #include <xen/shutdown.h>
9 #include <xen/console.h>
10 #include <xen/kexec.h>
11 #include <asm/debugger.h>
12 #include <public/sched.h>
13
14 /* opt_noreboot: If true, machine will need manual reset on error. */
15 bool_t __read_mostly opt_noreboot;
16 boolean_param("noreboot", opt_noreboot);
17
maybe_reboot(void)18 static void noreturn maybe_reboot(void)
19 {
20 if ( opt_noreboot )
21 {
22 printk("'noreboot' set - not rebooting.\n");
23 machine_halt();
24 }
25 else
26 {
27 printk("rebooting machine in 5 seconds.\n");
28 watchdog_disable();
29 machine_restart(5000);
30 }
31 }
32
hwdom_shutdown(u8 reason)33 void hwdom_shutdown(u8 reason)
34 {
35 switch ( reason )
36 {
37 case SHUTDOWN_poweroff:
38 printk("Hardware Dom%u halted: halting machine\n",
39 hardware_domain->domain_id);
40 machine_halt();
41 break; /* not reached */
42
43 case SHUTDOWN_crash:
44 debugger_trap_immediate();
45 printk("Hardware Dom%u crashed: ", hardware_domain->domain_id);
46 kexec_crash();
47 maybe_reboot();
48 break; /* not reached */
49
50 case SHUTDOWN_reboot:
51 printk("Hardware Dom%u shutdown: rebooting machine\n",
52 hardware_domain->domain_id);
53 machine_restart(0);
54 break; /* not reached */
55
56 case SHUTDOWN_watchdog:
57 printk("Hardware Dom%u shutdown: watchdog rebooting machine\n",
58 hardware_domain->domain_id);
59 kexec_crash();
60 machine_restart(0);
61 break; /* not reached */
62
63 case SHUTDOWN_soft_reset:
64 printk("Hardware domain %d did unsupported soft reset, rebooting.\n",
65 hardware_domain->domain_id);
66 machine_restart(0);
67 break; /* not reached */
68
69 default:
70 printk("Hardware Dom%u shutdown (unknown reason %u): ",
71 hardware_domain->domain_id, reason);
72 maybe_reboot();
73 break; /* not reached */
74 }
75 }
76
77