Coverage Report

Created: 2017-10-25 09:10

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