debuggers.hg

annotate xen/common/shutdown.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents e8acb9753ff1
children
rev   line source
kaf24@10989 1 #include <xen/config.h>
kaf24@10989 2 #include <xen/init.h>
kaf24@10989 3 #include <xen/lib.h>
kaf24@10989 4 #include <xen/sched.h>
kaf24@10989 5 #include <xen/domain.h>
kaf24@10989 6 #include <xen/delay.h>
kaf24@10989 7 #include <xen/shutdown.h>
keir@21575 8 #include <xen/console.h>
keir@21654 9 #include <xen/kexec.h>
kaf24@10989 10 #include <asm/debugger.h>
kaf24@10989 11 #include <public/sched.h>
kaf24@10989 12
kaf24@10989 13 /* opt_noreboot: If true, machine will need manual reset on error. */
keir@22676 14 bool_t __read_mostly opt_noreboot;
kaf24@10989 15 boolean_param("noreboot", opt_noreboot);
kaf24@10989 16
kaf24@10989 17 static void maybe_reboot(void)
kaf24@10989 18 {
kaf24@10989 19 if ( opt_noreboot )
kaf24@10989 20 {
kaf24@10989 21 printk("'noreboot' set - not rebooting.\n");
kaf24@10989 22 machine_halt();
kaf24@10989 23 }
kaf24@10989 24 else
kaf24@10989 25 {
kaf24@10989 26 printk("rebooting machine in 5 seconds.\n");
kaf24@10989 27 watchdog_disable();
keir@18251 28 machine_restart(5000);
kaf24@10989 29 }
kaf24@10989 30 }
kaf24@10989 31
kaf24@10989 32 void dom0_shutdown(u8 reason)
kaf24@10989 33 {
kaf24@10989 34 switch ( reason )
kaf24@10989 35 {
kaf24@10989 36 case SHUTDOWN_poweroff:
kaf24@10989 37 {
kaf24@10989 38 printk("Domain 0 halted: halting machine.\n");
kaf24@10989 39 machine_halt();
kaf24@10989 40 break; /* not reached */
kaf24@10989 41 }
kaf24@10989 42
kaf24@10989 43 case SHUTDOWN_crash:
kaf24@10989 44 {
kaf24@11729 45 debugger_trap_immediate();
kaf24@10989 46 printk("Domain 0 crashed: ");
kaf24@10989 47 maybe_reboot();
kaf24@10989 48 break; /* not reached */
kaf24@10989 49 }
kaf24@10989 50
kaf24@10989 51 case SHUTDOWN_reboot:
kaf24@10989 52 {
kaf24@10989 53 printk("Domain 0 shutdown: rebooting machine.\n");
keir@18251 54 machine_restart(0);
kaf24@10989 55 break; /* not reached */
kaf24@10989 56 }
kaf24@10989 57
keir@21575 58 case SHUTDOWN_watchdog:
keir@21575 59 {
keir@21575 60 printk("Domain 0 shutdown: watchdog rebooting machine.\n");
keir@21575 61 kexec_crash();
keir@21575 62 machine_restart(0);
keir@21575 63 break; /* not reached */
keir@21575 64 }
keir@21575 65
kaf24@10989 66 default:
kaf24@10989 67 {
kaf24@10989 68 printk("Domain 0 shutdown (unknown reason %u): ", reason);
kaf24@10989 69 maybe_reboot();
kaf24@10989 70 break; /* not reached */
kaf24@10989 71 }
kaf24@10989 72 }
kaf24@10989 73 }
kaf24@10989 74