diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2017-09-26 15:16:06 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-10-03 17:25:14 +0000 |
commit | ee590c744d2bc28bbe0a3aaad1eb4c3568414f5b (patch) | |
tree | 5269d87106e50bd763b28467b75fa432d724b958 | |
parent | 021c365b73cd9d7d6ad437783821e6ea24bd648e (diff) | |
download | phosphor-bmc-code-mgmt-ee590c744d2bc28bbe0a3aaad1eb4c3568414f5b.tar.gz phosphor-bmc-code-mgmt-ee590c744d2bc28bbe0a3aaad1eb4c3568414f5b.zip |
Set Priority value of functional BMC version to 0
The priority values are saved on the BMC flash and in u-boot env
variables as backup, but in the case where both copies are missing
like when the BMC chip is reflashed using a programmer, set the
Priority value of the functional (currently running) BMC version
to 0 to indicate that's the image the BMC booted from.
Resolves openbmc/openbmc#2373
Change-Id: I7cc8a7ae5b1c676891109c71686d7f9b18fde1ca
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r-- | item_updater.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/item_updater.cpp b/item_updater.cpp index 85fc8ed..3dfa2bc 100644 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -200,6 +200,18 @@ void ItemUpdater::processBMCImage() createActiveAssociation(path); } + // Create Version instance for this version. + auto versionPtr = std::make_unique<VersionClass>( + bus, + path, + version, + purpose, + ""); + auto isVersionFunctional = versionPtr->isFunctional(); + versions.insert(std::make_pair( + id, + std::move(versionPtr))); + // Create Activation instance for this version. activations.insert(std::make_pair( id, @@ -217,8 +229,15 @@ void ItemUpdater::processBMCImage() uint8_t priority = std::numeric_limits<uint8_t>::max(); if (!restoreFromFile(id, priority)) { - log<level::ERR>("Unable to restore priority from file.", - entry("VERSIONID=%s", id)); + if (isVersionFunctional) + { + priority = 0; + } + else + { + log<level::ERR>("Unable to restore priority from file.", + entry("VERSIONID=%s", id)); + } } activations.find(id)->second->redundancyPriority = std::make_unique<RedundancyPriority>( @@ -227,17 +246,6 @@ void ItemUpdater::processBMCImage() *(activations.find(id)->second), priority); } - - // Create Version instance for this version. - versions.insert(std::make_pair( - id, - std::make_unique< - phosphor::software::manager::Version>( - bus, - path, - version, - purpose, - ""))); } } return; |