summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2018-07-17 15:47:34 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2018-07-19 08:08:50 -0500
commitbbcb7be18c21da6c5d82be7f744b777aea610f24 (patch)
treee08882fbc06b6a9f8a4896f3e3792019901b5a5a
parent56aaf454adef04bd4c1d45870cd86dc2de0a880a (diff)
downloadphosphor-bmc-code-mgmt-bbcb7be18c21da6c5d82be7f744b777aea610f24.tar.gz
phosphor-bmc-code-mgmt-bbcb7be18c21da6c5d82be7f744b777aea610f24.zip
Move setting the priority U-Boot variable to ubi
The service that sets the priority value is unique to the ubi layout because there is only one version at a time on the static layout. Move the calling of the service to the ubi implementation. Tested: - Witherspoon: Priorities are still set. - Romulus: The BMC.Updater app does not core dump with the latest sdbusplus changes due to calling a non-existent service. Change-Id: Ica1c68f00d5cb43c51ee09c5a3851613edf941d5 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--activation.cpp4
-rw-r--r--item_updater.cpp6
-rw-r--r--item_updater.hpp9
-rw-r--r--item_updater_helper.hpp7
-rw-r--r--serialize.cpp9
-rw-r--r--static/item_updater_helper.cpp5
-rw-r--r--ubi/item_updater_helper.cpp11
7 files changed, 40 insertions, 11 deletions
diff --git a/activation.cpp b/activation.cpp
index 863ea56..8fac93c 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -240,14 +240,14 @@ uint8_t RedundancyPriority::priority(uint8_t value)
// Set the priority value so that the freePriority() function can order
// the versions by priority.
auto newPriority = softwareServer::RedundancyPriority::priority(value);
- storeToFile(parent.versionId, value);
+ parent.parent.savePriority(parent.versionId, value);
parent.parent.freePriority(value, parent.versionId);
return newPriority;
}
uint8_t RedundancyPriority::sdbusPriority(uint8_t value)
{
- storeToFile(parent.versionId, value);
+ parent.parent.savePriority(parent.versionId, value);
return softwareServer::RedundancyPriority::priority(value);
}
diff --git a/item_updater.cpp b/item_updater.cpp
index 1bbf200..22734ef 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -356,6 +356,12 @@ ItemUpdater::ActivationStatus
return ItemUpdater::ActivationStatus::ready;
}
+void ItemUpdater::savePriority(const std::string& versionId, uint8_t value)
+{
+ storeToFile(versionId, value);
+ helper.setEntry(versionId, value);
+}
+
void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
{
std::map<std::string, uint8_t> priorityMap;
diff --git a/item_updater.hpp b/item_updater.hpp
index 330ec82..ec7aee0 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -61,6 +61,15 @@ class ItemUpdater : public ItemUpdaterInherit
emit_object_added();
};
+ /** @brief Save priority value to persistent storage (flash and optionally
+ * a U-Boot environment variable)
+ *
+ * @param[in] versionId - The Id of the version
+ * @param[in] value - The priority value
+ * @return None
+ */
+ void savePriority(const std::string& versionId, uint8_t value);
+
/** @brief Sets the given priority free by incrementing
* any existing priority with the same value by 1
*
diff --git a/item_updater_helper.hpp b/item_updater_helper.hpp
index 33b3cdb..a2d90b8 100644
--- a/item_updater_helper.hpp
+++ b/item_updater_helper.hpp
@@ -28,6 +28,13 @@ class Helper
// Empty
}
+ /** @brief Set an environment variable to the specified value
+ *
+ * @param[in] entryId - The variable name
+ * @param[in] value - The variable value
+ */
+ void setEntry(const std::string& entryId, uint8_t value);
+
/** @brief Clear an image with the entry id
*
* @param[in] entryId - The image entry id
diff --git a/serialize.cpp b/serialize.cpp
index b59ff46..722b71b 100644
--- a/serialize.cpp
+++ b/serialize.cpp
@@ -16,8 +16,6 @@ namespace fs = std::experimental::filesystem;
void storeToFile(std::string versionId, uint8_t priority)
{
- auto bus = sdbusplus::bus::new_default();
-
if (!fs::is_directory(PERSIST_DIR))
{
fs::create_directories(PERSIST_DIR);
@@ -27,13 +25,6 @@ void storeToFile(std::string versionId, uint8_t priority)
std::ofstream os(path.c_str());
cereal::JSONOutputArchive oarchive(os);
oarchive(cereal::make_nvp("priority", priority));
-
- std::string serviceFile = "obmc-flash-bmc-setenv@" + versionId + "\\x3d" +
- std::to_string(priority) + ".service";
- auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(serviceFile, "replace");
- bus.call_noreply(method);
}
bool restoreFromFile(std::string versionId, uint8_t& priority)
diff --git a/static/item_updater_helper.cpp b/static/item_updater_helper.cpp
index 5cd8b9e..e639e63 100644
--- a/static/item_updater_helper.cpp
+++ b/static/item_updater_helper.cpp
@@ -7,6 +7,11 @@ namespace software
namespace updater
{
+void Helper::setEntry(const std::string& entryId, uint8_t value)
+{
+ // Empty
+}
+
void Helper::clearEntry(const std::string& entryId)
{
// Empty
diff --git a/ubi/item_updater_helper.cpp b/ubi/item_updater_helper.cpp
index 6704c21..b05291e 100644
--- a/ubi/item_updater_helper.cpp
+++ b/ubi/item_updater_helper.cpp
@@ -11,6 +11,17 @@ namespace updater
{
using namespace phosphor::logging;
+
+void Helper::setEntry(const std::string& entryId, uint8_t value)
+{
+ std::string serviceFile = "obmc-flash-bmc-setenv@" + entryId + "\\x3d" +
+ std::to_string(value) + ".service";
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(serviceFile, "replace");
+ bus.call_noreply(method);
+}
+
void Helper::clearEntry(const std::string& entryId)
{
// Remove the priority environment variable.
OpenPOWER on IntegriCloud