Fix fru disappear after power off
Don't mark devices or buses failed if power is off,
as it is normal to lose some busses.
Tested: Rescan with power off, then power back on,
all devices remain
Change-Id: Ia21646a74d4c1ed19efb209ff0555a47766d4169
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index 7107a96..874bbb1 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -76,6 +76,8 @@
static BusMap busMap;
+static bool powerIsOn = false;
+
static boost::container::flat_map<
std::pair<size_t, size_t>, std::shared_ptr<sdbusplus::asio::dbus_interface>>
foundDevices;
@@ -586,7 +588,10 @@
{
std::cerr << "failed to read bus " << bus << " address " << ii
<< "\n";
- failedItems.insert(ii);
+ if (powerIsOn)
+ {
+ failedItems.insert(ii);
+ }
continue;
}
@@ -609,7 +614,10 @@
if (status == std::future_status::timeout)
{
std::cerr << "Error reading bus " << bus << "\n";
- busBlacklist.insert(bus);
+ if (powerIsOn)
+ {
+ busBlacklist.insert(bus);
+ }
close(file);
return -1;
}
@@ -1370,14 +1378,13 @@
values;
message.read(objectName, values);
auto findState = values.find("CurrentHostState");
- bool on = false;
if (findState != values.end())
{
- on = boost::ends_with(std::get<std::string>(findState->second),
- "Running");
+ powerIsOn = boost::ends_with(
+ std::get<std::string>(findState->second), "Running");
}
- if (on)
+ if (powerIsOn)
{
rescanBusses(busMap, dbusInterfaceMap);
}