Host reboot configuration support
Redfish API now supports a mechanism for the users of the system
to configure the number of times a BMC should restart the host
firmware when in an error path before giving up. Originally
the function "attemptsLeft(uint32_t)" ignored the passed in value
and and always set this number to a hardcoded 3(without the user
knowing). Changes made here allow for this property to be set by
an external user over D-bus for values other than 3.
To compliment this functionality and the new DBus property
"RetryAttempts" an override was created to ensure that when
"RetryAttempts" is set by an external user that the "AttemptsLeft"
property is updated accordingly.
Versioning was added to avoid a serialization error that
would occur if a system was loaded using the previous version that did
not include this new property.
Testing:
- Using the newly defined cereal version of '2' performed correctly.
- Removing the new property and reverting cereal class version back
to '1' behaved properly.
- built and ran with Docker along with the web changes.
- verified update of "AttemptsLeft" through a p10bmc running
on simics through busctl.
- verified that when the "RetryAttempts" policy value is changed by
either bmcweb or dbus set-property() that "AttemptsLeft" updates
accordingly.
busctl set-property xyz.openbmc_project.State.Host ... RetryAttempts u 1
busctl get-property xyz.openbmc_project.State.Host ... RetryAttempts
service@p10bmc: u 1
busctl get-property xyz.openbmc_project.State.Host ... AttemptsLeft
service@p10bmc: u 1
busctl set-property xyz.openbmc_project.State.Host ... RetryAttempts u 3
busctl set-property xyz.openbmc_project.State.Host ... AttemptLeft u 8
busctl get-property xyz.openbmc_project.State.Host ... AttemptLeft u 3
service@p10bmc: u 3
Signed-off-by: Corey Hardesty <corey.hardesty@icloud.com>
Change-Id: I70a8457c88fb76e118937d79e8dbe15518df7264
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index 3e0763e..6388308 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -80,7 +80,9 @@
// Will throw exception on fail
determineInitialState();
- attemptsLeft(BOOT_COUNT_MAX_ALLOWED);
+ // Sets auto-reboot attempts to max-allowed
+ attemptsLeft(sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::retryAttempts());
// We deferred this until we could get our property correct
this->emit_object_added();
@@ -99,27 +101,56 @@
HostState currentHostState(HostState value) override;
/**
+ * @brief Set value for allowable auto-reboot count
+ *
+ * This override is responsible for ensuring that when external users
+ * set the number of automatic retry attempts that the number of
+ * automatic reboot attempts left will update accordingly.
+ *
+ * @param[in] value - desired Reboot count value
+ *
+ * @return number of reboot attempts allowed.
+ */
+ uint32_t retryAttempts(uint32_t value) override
+ {
+ if (sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::attemptsLeft() != value)
+ {
+ info("Automatic reboot retry attempts set to: {VALUE} ", "VALUE",
+ value);
+ sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::attemptsLeft(value);
+ }
+
+ return (sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::retryAttempts(value));
+ }
+
+ /**
* @brief Set host reboot count to default
*
* OpenBMC software controls the number of allowed reboot attempts so
* any external set request of this property will be overridden by
- * this function and set to the default.
+ * this function and set to the number of the allowed auto-reboot
+ * retry attempts found on the system.
*
* The only code responsible for decrementing the boot count resides
* within this process and that will use the sub class interface
* directly
*
- * @param[in] value - Reboot count value, will be ignored
+ * @param[in] value - Reboot count value
*
- * @return Default number of reboot attempts left
+ * @return number of reboot attempts left(allowed by retry attempts
+ * property)
*/
uint32_t attemptsLeft(uint32_t value) override
{
- // value is ignored in this implementation
- (void)(value);
debug("External request to reset reboot count");
- return (sdbusplus::xyz::openbmc_project::Control::Boot::server::
- RebootAttempts::attemptsLeft(BOOT_COUNT_MAX_ALLOWED));
+ auto retryAttempts = sdbusplus::xyz::openbmc_project::Control::Boot::
+ server::RebootAttempts::retryAttempts();
+ return (
+ sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::attemptsLeft(std::min(value, retryAttempts)));
}
private:
@@ -221,7 +252,9 @@
{
// version is not used currently
(void)(version);
- archive(convertForMessage(sdbusplus::xyz::openbmc_project::State::
+ archive(sdbusplus::xyz::openbmc_project::Control::Boot::server::
+ RebootAttempts::retryAttempts(),
+ convertForMessage(sdbusplus::xyz::openbmc_project::State::
server::Host::requestedHostTransition()),
convertForMessage(sdbusplus::xyz::openbmc_project::State::Boot::
server::Progress::bootProgress()),
@@ -240,12 +273,21 @@
template <class Archive>
void load(Archive& archive, const std::uint32_t version)
{
- // version is not used currently
- (void)(version);
std::string reqTranState;
std::string bootProgress;
std::string osState;
- archive(reqTranState, bootProgress, osState);
+ // Older cereal archive without RetryAttempt may be implemented
+ // just set to (BOOT_COUNT_MAX_ALLOWED)
+ uint32_t retryAttempts = BOOT_COUNT_MAX_ALLOWED;
+ switch (version)
+ {
+ case 2:
+ archive(retryAttempts);
+ [[fallthrough]];
+ case 1:
+ archive(reqTranState, bootProgress, osState);
+ break;
+ }
auto reqTran = Host::convertTransitionFromString(reqTranState);
// When restoring, set the requested state with persistent value
// but don't call the override which would execute it
@@ -256,6 +298,8 @@
sdbusplus::xyz::openbmc_project::State::OperatingSystem::server::
Status::operatingSystemState(
Host::convertOSStatusFromString(osState));
+ sdbusplus::xyz::openbmc_project::Control::Boot::server::RebootAttempts::
+ retryAttempts(retryAttempts);
}
/** @brief Serialize and persist requested host state