diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2006-08-07 15:35:06 +0100 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2006-08-07 15:35:06 +0100 |
commit | 9ee1bd77bfc225d638c8df106238f875025b5e8f (patch) | |
tree | 1c3f2a8d2f3358fa195d43390e0d9f6cc41c3bb3 /xen/common/shutdown.c | |
parent | 3923c6638e50c51781fb5f6f29729c71336eb95a (diff) | |
download | xen-9ee1bd77bfc225d638c8df106238f875025b5e8f.tar.gz xen-9ee1bd77bfc225d638c8df106238f875025b5e8f.tar.bz2 xen-9ee1bd77bfc225d638c8df106238f875025b5e8f.zip |
[XEN] Clean up shutdown handling and ignore opt_noreboot if dom0
shuts down cleanly. The option is intended only to retain information
on the local console in case of a crash.
Based on a patch from Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/shutdown.c')
-rw-r--r-- | xen/common/shutdown.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c new file mode 100644 index 0000000000..1baea16205 --- /dev/null +++ b/xen/common/shutdown.c @@ -0,0 +1,66 @@ +#include <xen/config.h> +#include <xen/init.h> +#include <xen/lib.h> +#include <xen/sched.h> +#include <xen/domain.h> +#include <xen/delay.h> +#include <xen/shutdown.h> +#include <asm/debugger.h> +#include <public/sched.h> + +/* opt_noreboot: If true, machine will need manual reset on error. */ +int opt_noreboot; +boolean_param("noreboot", opt_noreboot); + +static void maybe_reboot(void) +{ + if ( opt_noreboot ) + { + printk("'noreboot' set - not rebooting.\n"); + machine_halt(); + } + else + { + printk("rebooting machine in 5 seconds.\n"); + watchdog_disable(); + mdelay(5000); + machine_restart(NULL); + } +} + +void dom0_shutdown(u8 reason) +{ + debugger_trap_immediate(); + + switch ( reason ) + { + case SHUTDOWN_poweroff: + { + printk("Domain 0 halted: halting machine.\n"); + machine_halt(); + break; /* not reached */ + } + + case SHUTDOWN_crash: + { + printk("Domain 0 crashed: "); + maybe_reboot(); + break; /* not reached */ + } + + case SHUTDOWN_reboot: + { + printk("Domain 0 shutdown: rebooting machine.\n"); + machine_restart(NULL); + break; /* not reached */ + } + + default: + { + printk("Domain 0 shutdown (unknown reason %u): ", reason); + maybe_reboot(); + break; /* not reached */ + } + } +} + |