Add support for recoveryoff and recoveron
During early stages of system bringup, it is beneficial to have the system in
fail state, so that the issue can be debugged faster, instead of getting into
recovery mode.
Disabling the automatic reboot from Quiesce state and not handling the boot
watchdog timeout would help with this.
When phosphor-watchdog times out, it starts obmc-host-timeout@0.target
to get the BMC through recovery process. This patchset adds mask and unmask
on that target to support recoveryoff and recoveryon respectively
Tested:
.......
Scenario-1: Disable recovery, start Watchdog and enable it:
/tmp# ./obmcutil recoveryoff
Created symlink /etc/systemd/system/obmc-host-timeout@0.target → /dev/null.
/lib/systemd/system/obmc-host-startmin@0.target.wants# obmcutil state
CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState : xyz.openbmc_project.State.Chassis.PowerState.Off
CurrentHostState : xyz.openbmc_project.State.Host.HostState.Off
phosphor-watchdog --continue --service=xyz.openbmc_project.Watchdog
--path=/xyz/openbmc_project/watchdog/host0 --target=obmc-host-timeout@0.target &
busctl call `mapper get-service /xyz/openbmc_project/watchdog/host0`
/xyz/openbmc_project/watchdog/host0 org.freedesktop.DBus.Properties Set ssv
xyz.openbmc_project.State.Watchdog Enabled b true
phosphor-watchdog[2050]: watchdog: enabled and started
phosphor-watchdog[2050]: watchdog: Timed out
phosphor-watchdog[2050]: watchdog: Failed to start unit
phosphor-watchdog[2050]: watchdog: disabled
CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState : xyz.openbmc_project.State.Chassis.PowerState.Off
CurrentHostState : xyz.openbmc_project.State.Host.HostState.Off
....................................
Scenario-2: Enable recovery and enable watchdog:
/tmp# ./obmcutil recoveryon
Removed /etc/systemd/system/obmc-host-timeout@0.target.
CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState : xyz.openbmc_project.State.Chassis.PowerState.Off
CurrentHostState : xyz.openbmc_project.State.Host.HostState.Off
busctl call `mapper get-service /xyz/openbmc_project/watchdog/host0`
/xyz/openbmc_project/watchdog/host0 org.freedesktop.DBus.Properties Set ssv
xyz.openbmc_project.State.Watchdog Enabled b true
Oct 31 10:50:45 phosphor-watchdog[2050]: watchdog: enabled and started
Oct 31 10:51:15 phosphor-watchdog[2050]: watchdog: Timed out
Oct 31 10:51:15 systemd[1]: unit_file_find_fragment: obmc-host-timeout@.target+0 →
obmc-host-timeout@0.target
Oct 31 10:51:15 phosphor-watchdog[2050]: watchdog: disabled
Oct 31 10:51:15 systemd[1]: Stopped target Power0 Host Off.
Oct 31 10:51:16 systemd[1]: Stopped target Chassis0 (Power Off).
Oct 31 10:51:16 watchdog_timeout[2249]: Host watchdog timed out
Oct 31 10:51:16 systemd[1]: Reached target Quiesce Target.
Oct 31 10:51:17 systemd[1]: Started Reboot host0.
-------------------------------------------------
Change-Id: I3ea030666c6198f9638efd7201805dcecf41b6a6
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/obmcutil b/obmcutil
index 6cfdee5..64945b6 100755
--- a/obmcutil
+++ b/obmcutil
@@ -3,7 +3,7 @@
set -euo pipefail
OPTS="bmcstate,bootprogress,chassiskill,chassisoff,chassison,chassisstate,hoststate,\
-osstate,power,poweroff,poweron,state,status,rebootoff,rebooton"
+osstate,power,poweroff,poweron,state,status,rebootoff,rebooton,recoveryoff,recoveryon"
USAGE="Usage: obmcutil [-h] [--wait] [--verbose]
{$OPTS}"
@@ -16,6 +16,8 @@
STATE_OBJECT=$OBJECT_ROOT/state
CONTROL_OBJECT=$OBJECT_ROOT/control
+HOST_TIMEOUT_TARGET=obmc-host-timeout@0.target
+
## NOTE: The following global variables are used only in the run_timeout cmd.
## By declaring these globally instead of passing them through the
## intermediary functions, which may not be "best practice", the readability
@@ -47,6 +49,11 @@
echo "obmcutil rebootoff Disable auto reboot from Quiesce state"
echo "obmcutil rebooton Enable auto reboot from Quiesce state"
echo ""
+ echo "obmcutil recoveryoff Disable boot watchdog timeout handling and"
+ echo " disable auto reboot from Quiesce state"
+ echo "obmcutil recoveryon Enable boot watchdog timeout handling and"
+ echo " enable auto reboot from Quiesce state"
+ echo ""
echo "optional arguments:"
echo " -h, --help show this help message and exit"
echo " -w, --wait block until state transition succeeds or fails"
@@ -132,6 +139,18 @@
exit 1
}
+mask_systemd_target ()
+{
+ target="$@"
+ systemctl mask $target
+}
+
+unmask_systemd_target ()
+{
+ target="$@"
+ systemctl unmask $target
+}
+
handle_cmd ()
{
case "$1" in
@@ -250,6 +269,14 @@
VALUE=true
set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE
;;
+ recoveryoff)
+ handle_cmd rebootoff
+ mask_systemd_target $HOST_TIMEOUT_TARGET
+ ;;
+ recoveryon)
+ handle_cmd rebooton
+ unmask_systemd_target $HOST_TIMEOUT_TARGET
+ ;;
*)
print_usage_err "Invalid command '$1'"
;;