bmc: add preparation step before data is received
Add a preparation systemd trigger event before data is received. On
systems under memory pressure, this'll trigger a service that can do
things like flush caches.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I175177f4a91b58d9f163098572a9d2614002b718
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
index de37e20..8c7cb04 100644
--- a/firmware_handler.hpp
+++ b/firmware_handler.hpp
@@ -104,6 +104,7 @@
CreateFirmwareBlobHandler(
const std::vector<HandlerPack>& firmwares,
const std::vector<DataHandlerPack>& transports,
+ std::unique_ptr<TriggerableActionInterface> preparation,
std::unique_ptr<TriggerableActionInterface> verification,
std::unique_ptr<TriggerableActionInterface> update);
@@ -121,13 +122,14 @@
const std::vector<HandlerPack>& firmwares,
const std::vector<std::string>& blobs,
const std::vector<DataHandlerPack>& transports, std::uint16_t bitmask,
+ std::unique_ptr<TriggerableActionInterface> preparation,
std::unique_ptr<TriggerableActionInterface> verification,
std::unique_ptr<TriggerableActionInterface> update) :
handlers(firmwares),
blobIDs(blobs), transports(transports), bitmask(bitmask),
activeImage(activeImageBlobId), activeHash(activeHashBlobId),
verifyImage(verifyBlobId), updateImage(updateBlobId), lookup(),
- state(UpdateState::notYetStarted),
+ state(UpdateState::notYetStarted), preparation(std::move(preparation)),
verification(std::move(verification)), update(std::move(update))
{
}
@@ -221,6 +223,12 @@
/** The firmware update state. */
UpdateState state;
+ /* preparation is triggered once we go into uploadInProgress(), but only
+ * once per full cycle, going back to notYetStarted resets this.
+ */
+ bool preparationTriggered = false;
+ std::unique_ptr<TriggerableActionInterface> preparation;
+
std::unique_ptr<TriggerableActionInterface> verification;
std::unique_ptr<TriggerableActionInterface> update;