diff options
Diffstat (limited to 'activation.cpp')
-rw-r--r-- | activation.cpp | 36 |
1 files changed, 35 insertions, 1 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() != |