spawn async task to clean used BIOS images

There is a missing remnant from software manager refactor where a task
needs to be spawned to clean the used/old BIOS firmware images. Add the
logic to spawn this task as part of onStateChangesBios.

Testing:
Tested and Verified by Kamalesh and T.Chau Ly as per discord comment
[1].

[1] https://discord.com/channels/775381525260664832/1395349728459231316/1399291253769637930

Change-Id: I4b86f75eb8300669c0801e0baf1be6c814250945
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/bmc/activation.cpp b/bmc/activation.cpp
index a09b580..67c2881 100644
--- a/bmc/activation.cpp
+++ b/bmc/activation.cpp
@@ -18,8 +18,6 @@
 #include "image_verify.hpp"
 #endif
 
-extern boost::asio::io_context& getIOContext();
-
 namespace phosphor
 {
 namespace software
@@ -448,9 +446,10 @@
                 parent.versions.find(versionId)->second->version());
 
             // Delete the uploaded activation
-            boost::asio::post(getIOContext(), [this]() {
-                this->parent.erase(this->versionId);
-            });
+            ctx.spawn([](auto self) -> sdbusplus::async::task<> {
+                self->parent.erase(self->versionId);
+                co_return;
+            }(this));
         }
         else if (newStateResult == "failed")
         {
diff --git a/bmc/activation.hpp b/bmc/activation.hpp
index 47da9b5..2386bd2 100644
--- a/bmc/activation.hpp
+++ b/bmc/activation.hpp
@@ -7,6 +7,7 @@
 #include "xyz/openbmc_project/Software/ActivationProgress/server.hpp"
 #include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp"
 
+#include <sdbusplus/async.hpp>
 #include <sdbusplus/server.hpp>
 #include <xyz/openbmc_project/Association/Definitions/server.hpp>
 #include <xyz/openbmc_project/Software/Activation/server.hpp>
@@ -193,14 +194,15 @@
      * @param[in] activationStatus - The status of Activation
      * @param[in] assocs - Association objects
      */
-    Activation(sdbusplus::bus_t& bus, const std::string& path,
+    Activation(sdbusplus::async::context& ctx, const std::string& path,
                ItemUpdater& parent, std::string& versionId,
                sdbusplus::server::xyz::openbmc_project::software::Activation::
                    Activations activationStatus,
                AssociationList& assocs) :
-        ActivationInherit(bus, path.c_str(),
+        ActivationInherit(ctx.get_bus(), path.c_str(),
                           ActivationInherit::action::defer_emit),
-        bus(bus), path(path), parent(parent), versionId(versionId),
+        ctx(ctx), bus(ctx.get_bus()), path(path), parent(parent),
+        versionId(versionId),
         systemdSignals(
             bus,
             sdbusRule::type::signal() + sdbusRule::member("JobRemoved") +
@@ -309,6 +311,9 @@
      **/
     void rebootBmc();
 
+    /** @brief D-Bus context */
+    sdbusplus::async::context& ctx;
+
     /** @brief Persistent sdbusplus DBus bus connection */
     sdbusplus::bus_t& bus;
 
diff --git a/bmc/item_updater.cpp b/bmc/item_updater.cpp
index 77c9a70..02c20c7 100644
--- a/bmc/item_updater.cpp
+++ b/bmc/item_updater.cpp
@@ -150,7 +150,7 @@
                         bmcInventoryPath));
     activations.insert(std::make_pair(
         id, std::make_unique<Activation>(
-                bus, path, *this, id, server::Activation::Activations::NotReady,
+                ctx, path, *this, id, server::Activation::Activations::NotReady,
                 associations)));
     activations[id]->applyTime = applyTime;
 }
@@ -195,7 +195,7 @@
     if (activation == activations.end())
     {
         activations.insert(std::make_pair(
-            id, std::make_unique<Activation>(bus, path, *this, id,
+            id, std::make_unique<Activation>(ctx, path, *this, id,
                                              activationState, associations)));
     }
     else
@@ -397,7 +397,7 @@
             // Create Activation instance for this version.
             activations.insert(std::make_pair(
                 id, std::make_unique<Activation>(
-                        bus, path, *this, id, activationState, associations)));
+                        ctx, path, *this, id, activationState, associations)));
 
 #ifdef BMC_STATIC_DUAL_IMAGE
             uint8_t priority;
@@ -964,7 +964,7 @@
     auto version = "null";
     AssociationList assocs;
     biosActivation = std::make_unique<Activation>(
-        bus, path, *this, versionId, server::Activation::Activations::Active,
+        ctx, path, *this, versionId, server::Activation::Activations::Active,
         assocs);
     auto dummyErase = [](const std::string& /*entryId*/) {
         // Do nothing;
diff --git a/bmc/software_utils.cpp b/bmc/software_utils.cpp
index aeeaeb7..0e15da1 100644
--- a/bmc/software_utils.cpp
+++ b/bmc/software_utils.cpp
@@ -56,9 +56,3 @@
 }
 
 } // namespace phosphor::software::utils
-
-boost::asio::io_context& getIOContext()
-{
-    static boost::asio::io_context io;
-    return io;
-}
diff --git a/bmc/software_utils.hpp b/bmc/software_utils.hpp
index 5cfbd54..1abef1f 100644
--- a/bmc/software_utils.hpp
+++ b/bmc/software_utils.hpp
@@ -38,5 +38,3 @@
 bool unTar(int imageFd, const std::string& extractDirPath);
 
 } // namespace phosphor::software::utils
-
-boost::asio::io_context& getIOContext();