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
|
From 59287a8869b5253a1b4203e0cc8a92f063dcc7e6 Mon Sep 17 00:00:00 2001
From: Yong Li <yong.b.li@linux.intel.com>
Date: Tue, 25 Sep 2018 16:08:22 +0800
Subject: [PATCH] Fix "Unspecified error" on ipmi restart cause command
Needs to convert the dbus value(enum) into ipmi value(uint8)
Tested by:
ipmitool chassis restart_cause
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
---
chassishandler.cpp | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/chassishandler.cpp b/chassishandler.cpp
index 40eb4f5..c3d4931 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -106,7 +106,7 @@ static constexpr auto match = "chassis0";
const static constexpr char* stateHostInterface =
"xyz.openbmc_project.State.Host";
const static constexpr char* hostRestartCauseInterface =
- "xyz.openbmc_project.State.Host.HostRestartCause";
+ "xyz.openbmc_project.State.Host";
const static constexpr char* hostRestartCause = "HostRestartCause";
const static constexpr char chassisCapIntf[] =
"xyz.openbmc_project.Control.ChassisCapabilities";
@@ -1764,6 +1764,26 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
return rc;
}
+namespace restart_cause
+{
+
+using namespace sdbusplus::xyz::openbmc_project::State::server;
+
+std::map<Host::RestartCause, uint8_t> dbusToIpmi = {
+ {Host::RestartCause::Unknown, 0x0},
+ {Host::RestartCause::IpmiCommand, 0x1},
+ {Host::RestartCause::ResetButton, 0x2},
+ {Host::RestartCause::PowerButton, 0x3},
+ {Host::RestartCause::WatchdogTimer, 0x4},
+ {Host::RestartCause::OEM, 0x5},
+ {Host::RestartCause::PowerPolicyAlwaysOn, 0x6},
+ {Host::RestartCause::PowerPolicyPreviousState, 0x7},
+ {Host::RestartCause::PEFReset, 0x8},
+ {Host::RestartCause::PEFPowerCycle, 0x9},
+ {Host::RestartCause::SoftReset, 0xa},
+ {Host::RestartCause::RTCWakeup, 0xb}};
+} // namespace restart_cause
+
ipmi_ret_t ipmi_chassis_get_sys_restart_cause(
ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request,
ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context)
@@ -1787,7 +1807,11 @@ ipmi_ret_t ipmi_chassis_get_sys_restart_cause(
ipmi::Value variant =
ipmi::getDbusProperty(bus, hostObject.second, hostObject.first,
hostRestartCauseInterface, hostRestartCause);
- resp->restartCause = variant.get<uint8_t>();
+
+ std::string restartCause =
+ sdbusplus::message::variant_ns::get<std::string>(variant);
+ resp->restartCause = restart_cause::dbusToIpmi.at(
+ restart_cause::Host::convertRestartCauseFromString(restartCause));
}
catch (std::exception& e)
--
2.7.4
|