ia64/xen-unstable

changeset 10979:16aa4b417c6b

[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>
author kaf24@firebug.cl.cam.ac.uk
date Mon Aug 07 15:35:06 2006 +0100 (2006-08-07)
parents 353404fe850c
children 47af0e2ebb13
files xen/arch/ia64/linux-xen/setup.c xen/arch/powerpc/domain.c xen/arch/x86/genapic/es7000plat.c xen/arch/x86/shutdown.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/common/Makefile xen/common/domain.c xen/common/keyhandler.c xen/common/shutdown.c xen/drivers/char/console.c xen/drivers/char/serial.c xen/include/xen/shutdown.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/setup.c	Mon Aug 07 11:59:31 2006 +0100
     1.2 +++ b/xen/arch/ia64/linux-xen/setup.c	Mon Aug 07 15:35:06 2006 +0100
     1.3 @@ -31,7 +31,7 @@
     1.4  #include <linux/console.h>
     1.5  #include <linux/delay.h>
     1.6  #include <linux/kernel.h>
     1.7 -#include <linux/reboot.h>
     1.8 +#include <linux/shutdown.h>
     1.9  #include <linux/sched.h>
    1.10  #include <linux/seq_file.h>
    1.11  #include <linux/string.h>
     2.1 --- a/xen/arch/powerpc/domain.c	Mon Aug 07 11:59:31 2006 +0100
     2.2 +++ b/xen/arch/powerpc/domain.c	Mon Aug 07 15:35:06 2006 +0100
     2.3 @@ -26,7 +26,7 @@
     2.4  #include <xen/serial.h>
     2.5  #include <xen/domain.h>
     2.6  #include <xen/console.h>
     2.7 -#include <xen/reboot.h>
     2.8 +#include <xen/shutdown.h>
     2.9  #include <asm/htab.h>
    2.10  #include <asm/current.h>
    2.11  #include <asm/hcalls.h>
     3.1 --- a/xen/arch/x86/genapic/es7000plat.c	Mon Aug 07 11:59:31 2006 +0100
     3.2 +++ b/xen/arch/x86/genapic/es7000plat.c	Mon Aug 07 15:35:06 2006 +0100
     3.3 @@ -31,7 +31,6 @@
     3.4  #include <xen/string.h>
     3.5  #include <xen/spinlock.h>
     3.6  #include <xen/errno.h>
     3.7 -#include <xen/reboot.h>
     3.8  #include <xen/init.h>
     3.9  #include <xen/acpi.h>
    3.10  #include <asm/io.h>
     4.1 --- a/xen/arch/x86/shutdown.c	Mon Aug 07 11:59:31 2006 +0100
     4.2 +++ b/xen/arch/x86/shutdown.c	Mon Aug 07 15:35:06 2006 +0100
     4.3 @@ -11,19 +11,16 @@
     4.4  #include <xen/smp.h>
     4.5  #include <xen/delay.h>
     4.6  #include <xen/dmi.h>
     4.7 +#include <xen/irq.h>
     4.8 +#include <xen/console.h>
     4.9 +#include <xen/shutdown.h>
    4.10 +#include <asm/msr.h>
    4.11  #include <asm/regs.h>
    4.12  #include <asm/mc146818rtc.h>
    4.13  #include <asm/system.h>
    4.14  #include <asm/io.h>
    4.15  #include <asm/processor.h>
    4.16  #include <asm/mpspec.h>
    4.17 -#include <xen/irq.h>
    4.18 -#include <xen/console.h>
    4.19 -#include <asm/msr.h>
    4.20 -
    4.21 -/* opt_noreboot: If true, machine will need manual reset on error. */
    4.22 -static int opt_noreboot = 0;
    4.23 -boolean_param("noreboot", opt_noreboot);
    4.24  
    4.25  /* reboot_str: comma-separated list of reboot options. */
    4.26  static char __initdata reboot_str[10] = "";
    4.27 @@ -204,12 +201,6 @@ void machine_restart(char * __unused)
    4.28  {
    4.29      int i;
    4.30  
    4.31 -    if ( opt_noreboot )
    4.32 -    {
    4.33 -        printk("Reboot disabled on cmdline: require manual reset\n");
    4.34 -        machine_halt();
    4.35 -    }
    4.36 -
    4.37      watchdog_disable();
    4.38      console_start_sync();
    4.39  
     5.1 --- a/xen/arch/x86/traps.c	Mon Aug 07 11:59:31 2006 +0100
     5.2 +++ b/xen/arch/x86/traps.c	Mon Aug 07 15:35:06 2006 +0100
     5.3 @@ -32,7 +32,7 @@
     5.4  #include <xen/errno.h>
     5.5  #include <xen/mm.h>
     5.6  #include <xen/console.h>
     5.7 -#include <xen/reboot.h>
     5.8 +#include <xen/shutdown.h>
     5.9  #include <asm/regs.h>
    5.10  #include <xen/delay.h>
    5.11  #include <xen/event.h>
     6.1 --- a/xen/arch/x86/x86_32/traps.c	Mon Aug 07 11:59:31 2006 +0100
     6.2 +++ b/xen/arch/x86/x86_32/traps.c	Mon Aug 07 15:35:06 2006 +0100
     6.3 @@ -9,7 +9,7 @@
     6.4  #include <xen/mm.h>
     6.5  #include <xen/irq.h>
     6.6  #include <xen/symbols.h>
     6.7 -#include <xen/reboot.h>
     6.8 +#include <xen/shutdown.h>
     6.9  #include <xen/nmi.h>
    6.10  #include <asm/current.h>
    6.11  #include <asm/flushtlb.h>
     7.1 --- a/xen/arch/x86/x86_64/traps.c	Mon Aug 07 11:59:31 2006 +0100
     7.2 +++ b/xen/arch/x86/x86_64/traps.c	Mon Aug 07 15:35:06 2006 +0100
     7.3 @@ -10,7 +10,7 @@
     7.4  #include <xen/symbols.h>
     7.5  #include <xen/console.h>
     7.6  #include <xen/sched.h>
     7.7 -#include <xen/reboot.h>
     7.8 +#include <xen/shutdown.h>
     7.9  #include <xen/nmi.h>
    7.10  #include <asm/current.h>
    7.11  #include <asm/flushtlb.h>
     8.1 --- a/xen/common/Makefile	Mon Aug 07 11:59:31 2006 +0100
     8.2 +++ b/xen/common/Makefile	Mon Aug 07 15:35:06 2006 +0100
     8.3 @@ -16,6 +16,7 @@ obj-y += sched_bvt.o
     8.4  obj-y += sched_credit.o
     8.5  obj-y += sched_sedf.o
     8.6  obj-y += schedule.o
     8.7 +obj-y += shutdown.o
     8.8  obj-y += softirq.o
     8.9  obj-y += string.o
    8.10  obj-y += symbols.o
     9.1 --- a/xen/common/domain.c	Mon Aug 07 11:59:31 2006 +0100
     9.2 +++ b/xen/common/domain.c	Mon Aug 07 15:35:06 2006 +0100
     9.3 @@ -20,6 +20,7 @@
     9.4  #include <xen/guest_access.h>
     9.5  #include <xen/hypercall.h>
     9.6  #include <xen/delay.h>
     9.7 +#include <xen/shutdown.h>
     9.8  #include <asm/debugger.h>
     9.9  #include <public/dom0_ops.h>
    9.10  #include <public/sched.h>
    9.11 @@ -282,36 +283,12 @@ static __init int domain_shutdown_finali
    9.12  }
    9.13  __initcall(domain_shutdown_finaliser_init);
    9.14  
    9.15 -
    9.16  void domain_shutdown(struct domain *d, u8 reason)
    9.17  {
    9.18      struct vcpu *v;
    9.19  
    9.20      if ( d->domain_id == 0 )
    9.21 -    {
    9.22 -        extern void machine_restart(char *);
    9.23 -        extern void machine_halt(void);
    9.24 -
    9.25 -        debugger_trap_immediate();
    9.26 -
    9.27 -        if ( reason == SHUTDOWN_poweroff ) 
    9.28 -        {
    9.29 -            printk("Domain 0 halted: halting machine.\n");
    9.30 -            machine_halt();
    9.31 -        }
    9.32 -        else if ( reason == SHUTDOWN_crash )
    9.33 -        {
    9.34 -            printk("Domain 0 crashed: rebooting machine in 5 seconds.\n");
    9.35 -            watchdog_disable();
    9.36 -            mdelay(5000);
    9.37 -            machine_restart(0);
    9.38 -        }
    9.39 -        else
    9.40 -        {
    9.41 -            printk("Domain 0 shutdown: rebooting machine.\n");
    9.42 -            machine_restart(0);
    9.43 -        }
    9.44 -    }
    9.45 +        dom0_shutdown(reason);
    9.46  
    9.47      /* Mark the domain as shutting down. */
    9.48      d->shutdown_code = reason;
    10.1 --- a/xen/common/keyhandler.c	Mon Aug 07 11:59:31 2006 +0100
    10.2 +++ b/xen/common/keyhandler.c	Mon Aug 07 15:35:06 2006 +0100
    10.3 @@ -4,7 +4,7 @@
    10.4  
    10.5  #include <asm/regs.h>
    10.6  #include <xen/keyhandler.h> 
    10.7 -#include <xen/reboot.h>
    10.8 +#include <xen/shutdown.h>
    10.9  #include <xen/event.h>
   10.10  #include <xen/console.h>
   10.11  #include <xen/serial.h>
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/xen/common/shutdown.c	Mon Aug 07 15:35:06 2006 +0100
    11.3 @@ -0,0 +1,66 @@
    11.4 +#include <xen/config.h>
    11.5 +#include <xen/init.h>
    11.6 +#include <xen/lib.h>
    11.7 +#include <xen/sched.h>
    11.8 +#include <xen/domain.h>
    11.9 +#include <xen/delay.h>
   11.10 +#include <xen/shutdown.h>
   11.11 +#include <asm/debugger.h>
   11.12 +#include <public/sched.h>
   11.13 +
   11.14 +/* opt_noreboot: If true, machine will need manual reset on error. */
   11.15 +int opt_noreboot;
   11.16 +boolean_param("noreboot", opt_noreboot);
   11.17 +
   11.18 +static void maybe_reboot(void)
   11.19 +{
   11.20 +    if ( opt_noreboot )
   11.21 +    {
   11.22 +        printk("'noreboot' set - not rebooting.\n");
   11.23 +        machine_halt();
   11.24 +    }
   11.25 +    else
   11.26 +    {
   11.27 +        printk("rebooting machine in 5 seconds.\n");
   11.28 +        watchdog_disable();
   11.29 +        mdelay(5000);
   11.30 +        machine_restart(NULL);
   11.31 +    }
   11.32 +}
   11.33 +
   11.34 +void dom0_shutdown(u8 reason)
   11.35 +{
   11.36 +    debugger_trap_immediate();
   11.37 +
   11.38 +    switch ( reason )
   11.39 +    {
   11.40 +    case SHUTDOWN_poweroff:
   11.41 +    {
   11.42 +        printk("Domain 0 halted: halting machine.\n");
   11.43 +        machine_halt();
   11.44 +        break; /* not reached */
   11.45 +    }
   11.46 +
   11.47 +    case SHUTDOWN_crash:
   11.48 +    {
   11.49 +        printk("Domain 0 crashed: ");
   11.50 +        maybe_reboot();
   11.51 +        break; /* not reached */
   11.52 +    }
   11.53 +
   11.54 +    case SHUTDOWN_reboot:
   11.55 +    {
   11.56 +        printk("Domain 0 shutdown: rebooting machine.\n");
   11.57 +        machine_restart(NULL);
   11.58 +        break; /* not reached */
   11.59 +    }
   11.60 +
   11.61 +    default:
   11.62 +    {
   11.63 +        printk("Domain 0 shutdown (unknown reason %u): ", reason);
   11.64 +        maybe_reboot();
   11.65 +        break; /* not reached */
   11.66 +    }
   11.67 +    }
   11.68 +}  
   11.69 +
    12.1 --- a/xen/drivers/char/console.c	Mon Aug 07 11:59:31 2006 +0100
    12.2 +++ b/xen/drivers/char/console.c	Mon Aug 07 15:35:06 2006 +0100
    12.3 @@ -21,6 +21,7 @@
    12.4  #include <xen/mm.h>
    12.5  #include <xen/delay.h>
    12.6  #include <xen/guest_access.h>
    12.7 +#include <xen/shutdown.h>
    12.8  #include <asm/current.h>
    12.9  #include <asm/debugger.h>
   12.10  #include <asm/io.h>
   12.11 @@ -730,14 +731,24 @@ void panic(const char *fmt, ...)
   12.12      printk("Panic on CPU %d:\n", smp_processor_id());
   12.13      printk(buf);
   12.14      printk("****************************************\n\n");
   12.15 -    printk("Reboot in five seconds...\n");
   12.16 +    if ( opt_noreboot )
   12.17 +        printk("Manual reset required ('noreboot' specified)\n");
   12.18 +    else
   12.19 +        printk("Reboot in five seconds...\n");
   12.20      spin_unlock_irqrestore(&lock, flags);
   12.21  
   12.22      debugger_trap_immediate();
   12.23  
   12.24 -    watchdog_disable();
   12.25 -    mdelay(5000);
   12.26 -    machine_restart(0);
   12.27 +    if ( opt_noreboot )
   12.28 +    {
   12.29 +        machine_halt();
   12.30 +    }
   12.31 +    else
   12.32 +    {
   12.33 +        watchdog_disable();
   12.34 +        mdelay(5000);
   12.35 +        machine_restart(NULL);
   12.36 +    }
   12.37  }
   12.38  
   12.39  void __bug(char *file, int line)
    13.1 --- a/xen/drivers/char/serial.c	Mon Aug 07 11:59:31 2006 +0100
    13.2 +++ b/xen/drivers/char/serial.c	Mon Aug 07 15:35:06 2006 +0100
    13.3 @@ -11,7 +11,6 @@
    13.4  #include <xen/init.h>
    13.5  #include <xen/irq.h>
    13.6  #include <xen/keyhandler.h> 
    13.7 -#include <xen/reboot.h>
    13.8  #include <xen/sched.h>
    13.9  #include <xen/serial.h>
   13.10  
    14.1 --- a/xen/include/xen/reboot.h	Mon Aug 07 11:59:31 2006 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,8 +0,0 @@
    14.4 -#ifndef _LINUX_REBOOT_H
    14.5 -#define _LINUX_REBOOT_H
    14.6 -
    14.7 -extern void machine_restart(char *cmd);
    14.8 -extern void machine_halt(void);
    14.9 -extern void machine_power_off(void);
   14.10 -
   14.11 -#endif /* _LINUX_REBOOT_H */
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/xen/include/xen/shutdown.h	Mon Aug 07 15:35:06 2006 +0100
    15.3 @@ -0,0 +1,13 @@
    15.4 +#ifndef __XEN_SHUTDOWN_H__
    15.5 +#define __XEN_SHUTDOWN_H__
    15.6 +
    15.7 +/* opt_noreboot: If true, machine will need manual reset on error. */
    15.8 +extern int opt_noreboot;
    15.9 +
   15.10 +void dom0_shutdown(u8 reason);
   15.11 +
   15.12 +void machine_restart(char *cmd);
   15.13 +void machine_halt(void);
   15.14 +void machine_power_off(void);
   15.15 +
   15.16 +#endif /* __XEN_SHUTDOWN_H__ */