-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwatchdog_timeout.cpp
100 lines (82 loc) · 2.68 KB
/
watchdog_timeout.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <config.h>
#include <CLI/CLI.hpp>
#ifdef WATCHDOG_DUMP_COLLECTION
extern "C"
{
#include <libpdbg.h>
#include <libpdbg_sbe.h>
}
#include <libphal.H>
#include <phosphor-logging/lg2.hpp>
#include <watchdog/watchdog_common.hpp>
#include <watchdog/watchdog_dbus.hpp>
#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[])
{
CLI::App app{"Hostboot dump collector for watchdog timeout"};
#ifdef WATCHDOG_DUMP_COLLECTION
constexpr uint32_t dumpTimeout = 1500; // in seconds
uint32_t timeout = dumpTimeout;
app.add_option("-t,--timeout", timeout,
"Set timeout interval for watchdog timeout in seconds");
#endif
CLI11_PARSE(app, argc, argv);
#ifdef WATCHDOG_DUMP_COLLECTION
using namespace watchdog::dump;
lg2::info("Host did not respond within watchdog timeout interval");
try
{
using namespace openpower::phal;
// Initialize pdbg library, default parameters are used for init()
pdbg::init();
// Get Primary Proc
struct pdbg_target* procTarget = pdbg::getPrimaryProc();
// Check Primary IPL done
bool primaryIplDone = sbe::isPrimaryIplDone();
if (primaryIplDone)
{
// Collect hostboot dump only if the host is in 'Running' state
if (!isHostStateRunning())
{
lg2::info(
"CurrentHostState is not in 'Running' state. Dump maybe "
"already occurring, skipping this dump request...");
return EXIT_SUCCESS;
}
// SBE boot done, Need to collect hostboot dump
lg2::info("Handle Hostboot boot failure");
triggerHostbootDump(timeout);
}
else
{
// SBE boot window, handle SBE boot failure
lg2::info("Handle SBE boot failure");
handleSbeBootError(procTarget, timeout);
}
}
catch (const std::exception& e)
{
lg2::error("Exception {ERROR} occurred", "ERROR", e);
std::string eventType =
"org.open_power.Host.Boot.Error.WatchdogTimedOut";
auto ffdc = std::vector<FFDCTuple>{};
std::map<std::string, std::string> additionalData;
if (!createPel(eventType, additionalData, ffdc))
{
lg2::error("Failed to create PEL");
}
return EXIT_SUCCESS;
}
#else
using namespace phosphor::logging;
using error =
sdbusplus::org::open_power::Host::Boot::Error::WatchdogTimedOut;
report<error>();
#endif
return EXIT_SUCCESS;
}