dual-image: Set priority for primary and secondary flash
Set priority to 0 for primary and 1 for secondary, whatever the BMC is
running on which flash.
This is done by checking the running slot and the functional state,
where:
* If the image is functional and the running slot is 0, it's primary;
* If the image is not function and the running slot is 1, it's primary;
* Other cases, it's secondary.
Tested: Verify the above behavior when BMC is running in primary flash
and in secondary flash.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ifee67377c15f7f92772ccde34d8abffb986c5f1f
diff --git a/item_updater.cpp b/item_updater.cpp
index de79dd8..5d820d6 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -303,6 +303,22 @@
id, std::make_unique<Activation>(
bus, path, *this, id, activationState, associations)));
+#ifdef BMC_STATIC_DUAL_IMAGE
+ uint8_t priority;
+ if ((functional && (runningImageSlot == 0)) ||
+ (!functional && (runningImageSlot == 1)))
+ {
+ priority = 0;
+ }
+ else
+ {
+ priority = 1;
+ }
+ activations.find(id)->second->redundancyPriority =
+ std::make_unique<RedundancyPriority>(
+ bus, path, *(activations.find(id)->second), priority,
+ false);
+#else
// If Active, create RedundancyPriority instance for this
// version.
if (activationState == server::Activation::Activations::Active)
@@ -326,6 +342,7 @@
bus, path, *(activations.find(id)->second), priority,
false);
}
+#endif
}
}