bmc-ready: don't allow power operations if not ready
Tested:
- Put BMC in NotReady state and verified error was returned when
requesting a chassis or host power on
- Verified that a power off was still possible in this state
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I8f17c681469c01c701e80cdb57ed623e04c8b921
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 71accee..aa5d178 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -16,6 +16,7 @@
#include <sdbusplus/exception.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
+#include <xyz/openbmc_project/State/Chassis/error.hpp>
#include <xyz/openbmc_project/State/Decorator/PowerSystemInputs/server.hpp>
#include <filesystem>
@@ -590,6 +591,14 @@
{
info("Change to Chassis Requested Power State: {REQ_POWER_TRAN}",
"REQ_POWER_TRAN", value);
+#if ONLY_ALLOW_BOOT_WHEN_BMC_READY
+ if ((value != Transition::Off) && (!utils::isBmcReady(this->bus)))
+ {
+ info("BMC State is not Ready so no chassis on operations allowed");
+ throw sdbusplus::xyz::openbmc_project::State::Chassis::Error::
+ BMCNotReady();
+ }
+#endif
startUnit(systemdTargetTable.find(value)->second);
return server::Chassis::requestedPowerTransition(value);
}