mmc: reset: Add sleep before returning
Add a sleep call to the reset call to allow service files and reset
operations to complete, so that the user can safely reboot the BMC or
power on the system until after the reset call returns.
Tested: Verified the curl command returned after 5s. The BMC takes about
3s to start the service files.
$ date; curl -k -H "X-Auth-Token: $token" -X POST
https://${bmc}/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios -d
'{"data":[]}'; date
Mon 13 Jun 2022 03:50:08 PM UTC
Mon 13 Jun 2022 03:50:13 PM UTC
Jun 13 15:35:20 p10bmc phosphor-log-manager[343]: Deleting all log
entries
...
Jun 13 15:35:23 p10bmc systemd[1]: Started OpenPOWER Host
HardwareIsolation.
Change-Id: Ic36cd2f9de60d8f72dd75cd63d78189349210f05
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/mmc/item_updater_mmc.cpp b/mmc/item_updater_mmc.cpp
index 2b83305..c99a3c4 100644
--- a/mmc/item_updater_mmc.cpp
+++ b/mmc/item_updater_mmc.cpp
@@ -8,6 +8,7 @@
#include <filesystem>
#include <iostream>
+#include <thread>
namespace openpower
{
@@ -114,6 +115,11 @@
catch (const std::exception& e)
{}
}
+
+ // Wait a few seconds for the service files and reset operations to finish,
+ // otherwise the BMC may be rebooted and cause corruption.
+ constexpr auto resetWait = std::chrono::seconds(5);
+ std::this_thread::sleep_for(resetWait);
}
bool ItemUpdaterMMC::isVersionFunctional(const std::string& versionId)