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/watchdog_dbus.hpp b/watchdog/watchdog_dbus.hpp
new file mode 100644
index 0000000..5de5691
--- /dev/null
+++ b/watchdog/watchdog_dbus.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Logging/Create/server.hpp>
+
+#include <string>
+
+namespace watchdog
+{
+namespace dump
+{
+
+enum ReturnCodes
+{
+ RC_SUCCESS = 0,
+ RC_NOT_HANDLED = 1,
+ RC_DBUS_ERROR = 2
+};
+
+using FFDCFormat =
+ sdbusplus::xyz::openbmc_project::Logging::server::Create::FFDCFormat;
+
+using FFDCTuple =
+ std::tuple<FFDCFormat, uint8_t, uint8_t, sdbusplus::message::unix_fd>;
+
+/**
+ * @brief Create a dbus method
+ *
+ * Find the dbus service associated with the dbus object path and create
+ * a dbus method for calling the specified dbus interface and function.
+ *
+ * @param path - dbus object path
+ * @param interface - dbus method interface
+ * @param function - dbus interface function
+ * @param method - method that is created
+ * @param extended - optional for extended methods
+ * @return non-zero if error
+ *
+ **/
+int dbusMethod(const std::string& path, const std::string& interface,
+ const std::string& function, sdbusplus::message::message& method,
+ const std::string& extended = "");
+
+/**
+ * @brief Create a PEL for the specified event type
+ *
+ * The additional data provided in the map will be placed in a user data
+ * section of the PEL.
+ *
+ * @param eventType - the event type
+ * @param additional - map of additional data
+ * @param ffdc - vector of ffdc data
+ * @return Platform log id or 0 if error
+ */
+uint32_t createPel(const std::string& eventType,
+ std::map<std::string, std::string>& additional,
+ const std::vector<FFDCTuple>& ffdc);
+
+} // namespace dump
+} // namespace watchdog