BMC: Block BMC reboots during Code Update
- Enable the service that blocks reboot within the constructor
of ActivationBlockTransition, so that the user can't reboot BMC
while code update is in progress.
- Once the code update is complete the destructor of
ActivationBlockTransition will disable any reboot guard that
prevents user from rebooting the BMC.
Tested: Verified that the user is unable to reboot during the activation
process and that journal logs are present to indicate why the user is
unable to reboot.
Resolves openbmc/openbmc#1944
Change-Id: Ia149a76bcf093b011fe243fc609ae83358a0f933
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 8f7d8a1..a102bf3 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -249,6 +249,31 @@
return;
}
+void ActivationBlocksTransition::enableRebootGuard()
+{
+ log<level::INFO>("BMC image activating - BMC reboots are disabled.");
+
+ auto method = bus.new_method_call(
+ SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
+ method.append("reboot-guard-enable.service", "replace");
+ bus.call_noreply(method);
+}
+
+void ActivationBlocksTransition::disableRebootGuard()
+{
+ log<level::INFO>("BMC activation has ended - BMC reboots are re-enabled.");
+
+ auto method = bus.new_method_call(
+ SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
+ method.append("reboot-guard-disable.service", "replace");
+ bus.call_noreply(method);
+}
} // namespace updater
} // namespace software