clear temp reset file on chassis on
See the following for more information on this file:
https://github.com/openbmc/phosphor-state-manager#bmc-reset-with-host-andor-chassis-on
Currently this file is cleared via the op-wait-power-off service in the
power down path. Upon further review, it's best to just clear this once
it has served its purpose which is to allow the chassis object to
get back into the On state after the BMC has been reset when the
chassis power is still on.
The simplification allows us to avoid the different corner cases of warm
reboots and memory preserving reboots and how those interact with BMC
reboots with the chassis power on.
Once this change is in, we can remove the deletion of this file from
the op-wait-power-off service.
Tested:
- Verified on a witherspoon that a reboot of the BMC worked as expected
and the /run/openbmc/ files were deleted correctly
- Ran HW CI regression against witherspoon and verified no failures
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I88c4289bc6a9dc2a044eeb88e5d7281a390a40d1
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index d970e58..d9eb78c 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -15,7 +15,7 @@
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
-#include <experimental/filesystem>
+#include <filesystem>
#include <fstream>
namespace phosphor
@@ -54,6 +54,8 @@
constexpr auto SYSTEMD_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
constexpr auto SYSTEMD_INTERFACE_UNIT = "org.freedesktop.systemd1.Unit";
+constexpr auto CHASSIS_ON_FILE = "/run/openbmc/chassis@%d-on";
+
void Chassis::subscribeToSystemdSignals()
{
try
@@ -237,6 +239,20 @@
log<level::INFO>("Received signal that power ON is complete");
this->currentPowerState(server::Chassis::PowerState::On);
this->setStateChangeTime();
+
+ // Remove temporary file which is utilized for scenarios where the
+ // BMC is rebooted while the chassis power is still on.
+ // This file is used to indicate to chassis related systemd services
+ // that the chassis is already on and they should skip running.
+ // Once the chassis state is back to on we can clear this file.
+ auto size = std::snprintf(nullptr, 0, CHASSIS_ON_FILE, 0);
+ size++; // null
+ std::unique_ptr<char[]> chassisFile(new char[size]);
+ std::snprintf(chassisFile.get(), size, CHASSIS_ON_FILE, 0);
+ if (std::filesystem::exists(chassisFile.get()))
+ {
+ std::filesystem::remove(chassisFile.get());
+ }
}
return 0;