Only update host state based on CurrentHostState
There are new properties triggering PropertiesChanged events
that should not update the hostOff state, so check only fo
CurrentHostState property changes.
Tested:
Confirmed that hostOff is only updated when CurrentHostState
changes.
Change-Id: Ibfafb435858359f04048f8420803e33e18452fec
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/src/host_error_monitor.cpp b/src/host_error_monitor.cpp
index f8de2d3..f1cab3d 100644
--- a/src/host_error_monitor.cpp
+++ b/src/host_error_monitor.cpp
@@ -269,19 +269,30 @@
std::string interfaceName;
boost::container::flat_map<std::string, std::variant<std::string>>
propertiesChanged;
- std::string state;
try
{
msg.read(interfaceName, propertiesChanged);
- state =
- std::get<std::string>(propertiesChanged.begin()->second);
}
catch (std::exception& e)
{
std::cerr << "Unable to read host state\n";
return;
}
- hostOff = state == "xyz.openbmc_project.State.Host.HostState.Off";
+ // We only want to check for CurrentHostState
+ if (propertiesChanged.begin()->first != "CurrentHostState")
+ {
+ return;
+ }
+ std::string* state =
+ std::get_if<std::string>(&(propertiesChanged.begin()->second));
+ if (state == nullptr)
+ {
+ std::cerr << propertiesChanged.begin()->first
+ << " property invalid\n";
+ return;
+ }
+
+ hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off";
if (hostOff)
{