Ensure POR reset is logged
In situations where the last reboot cause is not changed to POR,
specifically after unexpected AC losses, bmc-state-manager fails to
update the property. Therefore after a power cycle the last reboot
cause property is set to unknown. Thankfully, chassis-state-manager
generates a file indicating an AC loss occurred and that can be used
to identify that the last reboot cause was a power-on-cycle. It was
necessary to add an "After xyz.openbmc_project.State.Chassis"
dependency to bmc-state-managers service file to ensure the AC loss
was generated prior to bmc-state-manager executing.
Tested:
- Ensured that when the system was power cycled that the last reboot
cause was set to "POR" when the chassis lost power file was present.
- Verified that when the file was not present the last reboot
cause was set accordingly (typically unknown)
Change-Id: Ifa6d5d6f89c221477ee2f2fa1ed15adade359e45
Signed-off-by: NodeMan97 <corey.hardesty@icloud.com>
diff --git a/utils.cpp b/utils.cpp
index ced4e90..9ef652f 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -1,9 +1,15 @@
+#include "config.h"
+
#include "utils.hpp"
+#include <fmt/format.h>
+#include <fmt/printf.h>
#include <gpiod.h>
#include <phosphor-logging/lg2.hpp>
+#include <filesystem>
+
namespace phosphor
{
namespace state
@@ -182,6 +188,20 @@
}
}
+bool checkACLoss(size_t& chassisId)
+{
+ std::string chassisLostPowerFileFmt =
+ fmt::sprintf(CHASSIS_LOST_POWER_FILE, chassisId);
+
+ std::filesystem::path chassisPowerLossFile{chassisLostPowerFileFmt};
+ if (std::filesystem::exists(chassisPowerLossFile))
+ {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace utils
} // namespace manager
} // namespace state