watchdog: Collect hostboot dump when watchdog times out
The hostboot dump collection to be initiated by watchdog_timeout
is disabled by default. When watchdog times out, only error
message corresponding to watchdog timeout is logged. To enable
hostboot dump collection whenever watchdog times out, the meson
option 'hostboot-dump-collection' must be enabled.
Testing - with meson option 'hostboot-dump-collection' enabled:
Ran watchdog_timeout:
case-1: CurrentHostState - off, AutoReboot - false
- Verified PEL object was not created
- Verified hostboot dump was not created
- Verified the Host State changed to Quiesce
case-2: CurrentHostState - off, AutoReboot - true
- Verified PEL object was created
- Verified hostboot dump was not created
- Verified the Host State changed to Running
case-3: CurrentHostState - Running, AutoBoot - false
- Verified PEL object was not created
- Verified hostboot dump was not created
- Verified the Host State changed to Quiesce
case-4: CurrentHostState - Running, AutoBoot - true, default timeout = 300s
- Verified PEL object was created
- Verified hostboot dump was created
- Observed Host state moving to either Running or Quiesce
case-5: CurrentHostState - Running, AutoBoot - true, specified timeout = 5s
- Verified PEL object was created
- Verified hostboot dump was created
- Observed Host state moving to either Running or Quiesce
Docker Unit test: passed
Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com>
Change-Id: Ib92d0c2f282816fb742cf07c1cb876b2cc093c12
diff --git a/watchdog_timeout.cpp b/watchdog_timeout.cpp
index 10361f2..ca22ba3 100644
--- a/watchdog_timeout.cpp
+++ b/watchdog_timeout.cpp
@@ -1,14 +1,38 @@
+#include <config.h>
+
+#include <CLI/CLI.hpp>
+
+#ifdef HOSTBOOT_DUMP_COLLECTION
+#include <watchdog/watchdog_main.hpp>
+#else
#include "org/open_power/Host/Boot/error.hpp"
#include "phosphor-logging/elog-errors.hpp"
#include <phosphor-logging/elog.hpp>
+#endif
-int main(int /*argc*/, char** /*argv*/)
+int main(int argc, char* argv[])
{
+ CLI::App app{"Hostboot dump collector for watchdog timeout"};
+
+#ifdef HOSTBOOT_DUMP_COLLECTION
+ uint32_t timeoutInterval = 1500; // in seconds
+ app.add_option("-t,--timeout", timeoutInterval,
+ "Set timeout interval for watchdog timeout in seconds");
+#endif
+
+ CLI11_PARSE(app, argc, argv);
+
+#ifdef HOSTBOOT_DUMP_COLLECTION
+ using namespace watchdog::dump;
+ // TODO: trigger SBE dump if in SBE window otherwise hostboot dump
+ triggerHostbootDump(timeoutInterval);
+#else
using namespace phosphor::logging;
using error =
sdbusplus::org::open_power::Host::Boot::Error::WatchdogTimedOut;
report<error>();
+#endif
return 0;
}