Call update u-boot env once when a priority is changed
The recursive nature of calling the free priority function
would trigger setting the u-boot env multiple times.
Make a change so that the priorities are sorted and
updated once.
- Create a non-overriden priority setter function to be called
by the free priority function and by the function that creates
the dbus objects after a bmc reboot. There's no need to call
to free the priorities after reboot since the priorities are
preserved on the bmc, and if they're not they default to 0 or 255.
- When a dbus request is made to update the priority, update
the value, then call the free priority function, which will
sort the versions by priority and bump the priority of any
duplicate ones.
Resolves openbmc/openbmc#2535
Change-Id: Ib92cc0ca6c4d5f6e986f3cde7156d63b53844b46
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/activation.hpp b/activation.hpp
index d1d050a..a6e1111 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -49,11 +49,13 @@
* @param[in] path - The Dbus object path
* @param[in] parent - Parent object.
* @param[in] value - The redundancyPriority value
+ * @param[in] freePriority - Call freePriorioty, default to true
*/
RedundancyPriority(sdbusplus::bus::bus& bus,
const std::string& path,
Activation& parent,
- uint8_t value) :
+ uint8_t value,
+ bool freePriority=true) :
RedundancyPriorityInherit(bus,
path.c_str(), true),
parent(parent),
@@ -61,7 +63,15 @@
path(path)
{
// Set Property
- priority(value);
+ if (freePriority)
+ {
+ priority(value);
+ }
+ else
+ {
+ sdbusPriority(value);
+ }
+
std::vector<std::string> interfaces({interface});
bus.emit_interfaces_added(path.c_str(), interfaces);
}
@@ -72,7 +82,8 @@
bus.emit_interfaces_removed(path.c_str(), interfaces);
}
- /** @brief Overloaded Priority property set function
+ /** @brief Overriden Priority property set function, calls freePriority
+ * to bump the duplicated priority values.
*
* @param[in] value - uint8_t
*
@@ -80,6 +91,14 @@
*/
uint8_t priority(uint8_t value) override;
+ /** @brief Non-Overriden Priority property set function
+ *
+ * @param[in] value - uint8_t
+ *
+ * @return Success or exception thrown
+ */
+ uint8_t sdbusPriority(uint8_t value);
+
/** @brief Priority property get function
*
* @returns uint8_t - The Priority value
@@ -313,13 +332,6 @@
*/
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 Persistent sdbusplus DBus bus connection */
sdbusplus::bus::bus& bus;