Add two new tunables / sysctls to controll reboot after panic:

kern.poweroff_on_panic which, when enabled, instructs a system to
power off on a panic instead of a reboot.

kern.powercyle_on_panic which, when enabled, instructs a system to
power cycle, if possible, on a panic instead of a reboot.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13042
This commit is contained in:
Warner Losh 2017-11-14 00:29:14 +00:00
parent 3e21cbc802
commit 48f1a4921e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325785
2 changed files with 26 additions and 0 deletions

View File

@ -134,6 +134,14 @@ static int sync_on_panic = 0;
SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RWTUN,
&sync_on_panic, 0, "Do a sync before rebooting from a panic");
static bool poweroff_on_panic = 0;
SYSCTL_BOOL(_kern, OID_AUTO, poweroff_on_panic, CTLFLAG_RWTUN,
&poweroff_on_panic, 0, "Do a power off instead of a reboot on a panic");
static bool powercycle_on_panic = 0;
SYSCTL_BOOL(_kern, OID_AUTO, powercycle_on_panic, CTLFLAG_RWTUN,
&powercycle_on_panic, 0, "Do a power cycle instead of a reboot on a panic");
static SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0,
"Shutdown environment");
@ -797,6 +805,10 @@ vpanic(const char *fmt, va_list ap)
/* thread_unlock(td); */
if (!sync_on_panic)
bootopt |= RB_NOSYNC;
if (poweroff_on_panic)
bootopt |= RB_POWEROFF;
if (powercycle_on_panic)
bootopt |= RB_POWERCYCLE;
kern_reboot(bootopt);
}

View File

@ -1034,6 +1034,20 @@ that the system
is attempting to comply with.
This is a read-only variable.
---
kern.powercycle_on_panic
bool
In the event of a panic, this variable controls whether or not the
system should try to power cycle instead of rebooting.
---
kern.poweroff_on_panic
bool
In the event of a panic, this variable controls whether or not the
system should try to power off instead of rebooting.
---
kern.proc.all