debuggers.hg

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