summaryrefslogtreecommitdiffstats
path: root/watchdog.cpp
Commit message (Collapse)AuthorAgeFilesLines
* watchdog: Log timer use during expirationHEADmasterWilliam A. Kennington III2019-04-181-5/+9
| | | | | Change-Id: Ie6dd1da92ffc225a313db208455ad24f4787a990 Signed-off-by: William A. Kennington III <wak@google.com>
* Set expiredTimerUse when timer expiredYong Li2019-03-201-0/+2
| | | | | | | | | | | | | | | IPMI get watchdog command needs this expiredTImerUse property, For the Timer Use Expiration flags Tested: After timer expired, check this dbus property: busctl get-property "xyz.openbmc_project.Watchdog" \ "/xyz/openbmc_project/watchdog/host0" \ "xyz.openbmc_project.State.Watchdog" \ "ExpiredTimerUse" Signed-off-by: Yong Li <yong.b.li@linux.intel.com> Change-Id: I65f15cee5a436e9ffbf5e7094373386f4dfba6b3
* Convert to using sdeventplusWilliam A. Kennington III2018-10-051-34/+10
| | | | | | | | | | | | This gets rid of the ad-hoc timer class in favor of using the timer source built into sdeventplus. Tested: Unit tests pass and everything still builds. Manually verified the functionality is still in tact on a zaius machine. Change-Id: I90619f0fe5a9fdfcecd24a49de672c0c99dc95e9 Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Handle systemd StartUnit errorsWilliam A. Kennington III2018-10-041-6/+24
| | | | | | | | | | | | | | | | | | | | | | | Currently, if systemd returns an error upon trying to StartUnit in the timeout of the watchdog the entire daemon will crash. Sep 28 22:59:09 phosphor-watchdog[2462]: Timer Expired Sep 28 22:59:09 phosphor-watchdog[2462]: watchdog: Timed out Sep 28 22:59:09 phosphor-watchdog[2462]: terminate called after throwing an instance of 'sdbusplus::exception::SdBusError' Sep 28 22:59:09 phosphor-watchdog[2462]: what(): sd_bus_call noreply: org.freedesktop.DBus.Error.InvalidArgs: Unit ho st-watchdog-reset.service is not loaded properly: Invalid argument. This patch fixes the behavior so we get something more like: Oct 04 07:12:14 phosphor-watchdog[10897]: watchdog: Timed out Oct 04 07:12:14 phosphor-watchdog[10897]: watchdog: Failed to start unit Oct 04 07:12:16 phosphor-watchdog[10897]: watchdog: disabled Tested: Ran with a bogus systemd target which used to throw errors which are now correctly handled without crashing. Change-Id: I4cf6ffded789e49d2329439165927cc227e2e79e Signed-off-by: William A. Kennington III <wak@google.com>
* Standardize Action -> Target Map TypeWilliam A. Kennington III2018-09-171-2/+2
| | | | | | | | | | | | | | | This change refactors the watchdog header to export the type of watchdog action to systemd target map, so it can be directly used by other files. This makes enumerating the map type more trivial. Also convert to an unordered_map instead of map since we don't need the ordering guarantees. Tested: Builds and tests still pass Change-Id: I77d315210ec27fde295589479c50d46dc5d1b32a Signed-off-by: William A. Kennington III <wak@google.com>
* add .clang-formatPatrick Venture2018-09-111-23/+19
| | | | | Change-Id: I6d9ec8401dcd46781ea258bf8998faa2507fa91d Signed-off-by: Patrick Venture <venture@google.com>
* Implement ResetTimeRemaining MethodWilliam A. Kennington III2018-04-271-0/+9
| | | | | | | | | | A dbus method was recently added that supports performing the watchdog reset and enable in a single action to reduce the amount of the dbus congestion and improve reliability of watchdog resets. Support this method as the build would be broken otherwise. Change-Id: Iac00fc2cf15d4ba06fb67a98e2c29fc3c31b3272 Signed-off-by: William A. Kennington III <wak@google.com>
* Implement a flag to enable fallback alwaysWilliam A. Kennington III2018-03-071-1/+1
| | | | | | | | | On some machines we want our watchdog running as long as the phosphor-watchdog daemon is alive. This patch adds an option to enter fallback mode any time the watchdog expires or is set to be disabled. Change-Id: Ic96d2f15c761aeb4e25158c5bd861076cca6497d Signed-off-by: William A. Kennington III <wak@google.com>
* Implement a fallback watchdog optionWilliam A. Kennington III2018-03-071-7/+36
| | | | | | | | | | | | | | | | | | Sometimes our initial watchdog action is not enough to recover the host from the state it transitioned into. However, always using a more power form of power cycle is not desirable as we can lose useful CPU crash state. It is desirable in this case to have two levels of watchog timers. This patch implements the ability for the service to specify a fallback watchdog action and interval. After the initial watchdog timeout is encountered, the watchdog will be re-armed with the new parameters. Once the watchdog times out again it will execute the fallback action. Attempts to update the timeRemaining will reset the fallback just in case something is still alive. Change-Id: I69f4422c7e3963f02200815f3cef620af9e6cf8b Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Rewrite timeoutHandler() to make disabling part of the timeoutWilliam A. Kennington III2018-03-071-33/+51
| | | | | | | | This makes no functional changes to the user interface but make future code reworks shorter. Change-Id: Ibd57a5d1090588c8a7b2a67730660c3cf47c832e Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Add a function to tell us if the timer is runningWilliam A. Kennington III2018-03-071-2/+2
| | | | | | | | This helps us refactor some of our existing code and will be useful for future changes. Change-Id: Ifa1547f09997d6824f726fc5f46e15eed4c1e8c1 Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Refactor timeRemainingWilliam A. Kennington III2018-03-071-15/+9
| | | | | | | | | This function also depends only on the state of the timer. This patch introduces no functional changes but will make future changes shorter. Change-Id: Id9b5825faf6c4795ca5b862f140afe06ca51e1cf Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: timeRemaining doesn't need to check enabledWilliam A. Kennington III2018-03-071-17/+14
| | | | | | | | | | | The Timer is fully owned by the Watchdog and is only enabled when the watchdog is enabled. Therefore, we only need to check the state of the timer instead of the interface and timer before populating the timeRemaining value. This simplifies later patches and does not make any functional change. Change-Id: Ib11edd75eb1953360bf4eae7fc4b29b5251cf0c5 Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Support multiple timeout actionsWilliam A. Kennington III2018-02-151-10/+19
| | | | | | | | | | | | This change adds the infrastructure to support having different actions map to different systemd targets being started when the watchdog expires. Right now this maintains compatability with the current --target argument and populates all of the watchdog actions, except for None, with the same target. A follow up patch will implement setting independent targets for each action. Change-Id: I0f0601f9e94d488650f20a9cebfc7c967007d78c Signed-off-by: William A. Kennington III <wak@google.com>
* Revert "watchdog: Log watchdog updates for debug"William A. Kennington III2018-02-061-3/+0
| | | | | | | | | | | | Current users of this code like the witherspoon platform generate a lot of debug messages that they save to flash. While this seems like it should be solved by not persisting debug messages lets back off on this extra messaging for now. This reverts commit 539f56069b07f39413789fa9ae4c7085fbc092b4. Change-Id: If0e2161c15447df8d1a4804e9e061f1d9aa35c5c Signed-off-by: William A. Kennington III <wak@google.com>
* watchdog: Log watchdog updates for debugWilliam A. Kennington III2018-01-291-0/+3
| | | | | Change-Id: Ida0a2f58e128d037fdbb5d94259f1637be67d8ae Signed-off-by: William A. Kennington III <wak@google.com>
* Don't set Interval by setting TimeRemainingPatrick Venture2017-09-121-3/+0
| | | | | | | | | | | | | This change allows one to set the TimeRemaining as a one-time shot, and also allows more straightforward control. -Changing the Interval doesn't reset the watchdog or update the TimeRemaining. -Changing the TimeRemaining doesn't set the Interval for future cycles. Change-Id: I03a3cdb9cc9e5c4bc034dc86d2b4324a5a4b7243 Signed-off-by: Patrick Venture <venture@google.com>
* Add option for daemon to continue running after timeoutPatrick Venture2017-08-231-0/+1
| | | | | | | | | Added new command line option that lets someone disable the watchdog timer on timer expiration instead of the default action of it exiting. Change-Id: I1c3414d4378872860ac083836cda4809fa26237a Signed-off-by: Patrick Venture <venture@google.com>
* Remove logging Watchdog reset requestVishwanatha Subbanna2017-06-151-3/+0
| | | | | | | | Since watchdog reset comes in very often, it floods the journal and hence it does not add any value. Change-Id: If36374511f7993126244e7c06da4bfa2dfcd0991 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Update Interval when timeRemaining is updatedVishwanatha Subbanna2017-06-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | A typical watchdog implementation would give these 2 features: - Setting the interval - Resetting the timer which also means poke This watchdog implementation does not provide a poke function and the same can be achieved by clients making these dbus calls in that order. 1) Get the Last set Interval 2) Set TimeRemaining field to result from #1 To achieve #1, this commit adds the support. This would make sure that the new timer would expire after last updated user interval from that time. Fixes openbmc/openbmc#767 Change-Id: I7393eb32992d7a08518ef463fd0a442df0772392 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Add Gtest to test watchdogVishwanatha Subbanna2017-06-061-3/+3
| | | | | Change-Id: Ia0268b6b18999b6dd6cfd26bcadcff25734306f0 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Call systemd target on timer expirationVishwanatha Subbanna2017-06-051-3/+17
| | | | | | | | | | User can pass an optional command line argument stating which systemd target needs to be called on timer expiration. The timeout handler will make sure that the systemd target is started prior to exiting. Change-Id: I37213ab28ad4166a47920dcb3dc79769c7f2af1a Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Invoke optional callback function on timer expirationVishwanatha Subbanna2017-06-021-1/+8
| | | | | | | | | | | | When the timer expires, it calls into it's own timeout handler which matches with sd_event callback handler. However, it is beneficial if the users of timer register their own callback routine so that they can execute some operations on timeout. Change-Id: Ia88cb4e3c17f6dd8d4528fa193ec7927f083a92b Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Implement Watchdog interfaceVishwanatha Subbanna2017-06-021-0/+96
This commit gives concrete implementation of the interface. Change-Id: I3951c5811c8e6cff87c87842a1e3c538463bfde7 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud