diff options
author | Saqib Khan <khansa@us.ibm.com> | 2017-10-24 13:36:22 -0500 |
---|---|---|
committer | Saqib Khan <khansa@us.ibm.com> | 2017-10-24 15:10:34 -0500 |
commit | f0382c358826568de434756bd0b2e6e4fd785ded (patch) | |
tree | 290f4ba5de8ccc5a9657019f5b512dc9a7de6676 | |
parent | 49446ae9de3bfd7361162fc75ad0d86fe2944fb7 (diff) | |
download | phosphor-bmc-code-mgmt-f0382c358826568de434756bd0b2e6e4fd785ded.tar.gz phosphor-bmc-code-mgmt-f0382c358826568de434756bd0b2e6e4fd785ded.zip |
Update U-boot env variables
- If the new priority is the lowest then set the uboot to point
to that particular version
- Otherwise reset the Uboot environment variable to find the version
with the lowest priority and then set that in uboot.
Resolves openbmc/openbmc#2512
Change-Id: Id27e78a85662e0ff2e941515bb467a43c6076d96
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
-rw-r--r-- | activation.cpp | 36 | ||||
-rw-r--r-- | activation.hpp | 7 | ||||
-rw-r--r-- | item_updater.cpp | 20 |
3 files changed, 45 insertions, 18 deletions
diff --git a/activation.cpp b/activation.cpp index 73eb651..ae8ebe9 100644 --- a/activation.cpp +++ b/activation.cpp @@ -155,10 +155,44 @@ uint8_t RedundancyPriority::priority(uint8_t value) { parent.parent.freePriority(value, parent.versionId); storeToFile(parent.versionId, value); - parent.parent.resetUbootEnvVars(); + + // Update U-Boot env variable to point to this version if it has the + // lowest priority. Otherwise, reset the UbootEnvVars to find the lowest + // priority version and set that in U-Boot. + if (parent.parent.isLowestPriority(value)) + { + parent.updateUbootEnvVars(); + } + else + { + parent.parent.resetUbootEnvVars(); + } + return softwareServer::RedundancyPriority::priority(value); } +// TODO: openbmc/openbmc#2369 Add recovery policy to updateubootvars +// unit template. +void Activation::updateUbootEnvVars() +{ + auto method = bus.new_method_call( + SYSTEMD_BUSNAME, + SYSTEMD_PATH, + SYSTEMD_INTERFACE, + "StartUnit"); + auto updateEnvVarsFile = "obmc-flash-bmc-updateubootvars@" + versionId + + ".service"; + method.append(updateEnvVarsFile, "replace"); + auto result = bus.call(method); + + //Check that the bus call didn't result in an error + if (result.is_method_error()) + { + log<level::ERR>("Failed to update u-boot env variables", + entry("VERSIONID=%s", versionId)); + } +} + void Activation::unitStateChange(sdbusplus::message::message& msg) { if (softwareServer::Activation::activation() != diff --git a/activation.hpp b/activation.hpp index cf4b5c2..6c303db 100644 --- a/activation.hpp +++ b/activation.hpp @@ -266,6 +266,13 @@ class Activation : public ActivationInherit void unsubscribeFromSystemdSignals(); /** + * @brief Updates the U-Boot variables to point to this activation's + * versionId, so that the systems boots from this version on + * the next reboot. + */ + void updateUbootEnvVars(); + + /** * @brief delete the d-bus object. */ void delete_() override; diff --git a/item_updater.cpp b/item_updater.cpp index e2de36f..e7e3b36 100644 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -602,23 +602,9 @@ void ItemUpdater::resetUbootEnvVars() } } - // TODO: openbmc/openbmc#2369 Add recovery policy to updateubootvars - // unit template. - auto method = bus.new_method_call( - SYSTEMD_BUSNAME, - SYSTEMD_PATH, - SYSTEMD_INTERFACE, - "StartUnit"); - auto updateEnvVarsFile = "obmc-flash-bmc-updateubootvars@" + - lowestPriorityVersion + ".service"; - method.append(updateEnvVarsFile, "replace"); - auto result = bus.call(method); - - //Check that the bus call didn't result in an error - if (result.is_method_error()) - { - log<level::ERR>("Failed to update u-boot env variables"); - } + // Update the U-boot environment variable to point to the lowest priority + auto it = activations.find(lowestPriorityVersion); + it->second->updateUbootEnvVars(); } } // namespace updater |