Populate MinimumVersion property

The Minimum Version is now an available D-Bus interface:
```
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/70110
```
Populate its value if it's being defined.

Tested: If the msl meson options are defined, the D-Bus property is
populated with the value of the defined minimum version:
```
root@witherspoon:~# busctl get-property xyz.openbmc_project.Software.BMC.Updater /xyz/openbmc_project/software xyz.openbmc_project.Software.MinimumVersion MinimumVersion
s "2.15.0"
```

Change-Id: I0f9df0cfd7c06794df836e161b3416094a8535de
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.hpp b/item_updater.hpp
index 316113a..d4c5bdb 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -2,6 +2,7 @@
 
 #include "activation.hpp"
 #include "item_updater_helper.hpp"
+#include "msl_verify.hpp"
 #include "version.hpp"
 #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
 
@@ -9,6 +10,7 @@
 #include <xyz/openbmc_project/Association/Definitions/server.hpp>
 #include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
 #include <xyz/openbmc_project/Control/FieldMode/server.hpp>
+#include <xyz/openbmc_project/Software/MinimumVersion/server.hpp>
 
 #include <string>
 #include <vector>
@@ -25,12 +27,32 @@
     sdbusplus::server::xyz::openbmc_project::control::FieldMode,
     sdbusplus::server::xyz::openbmc_project::association::Definitions,
     sdbusplus::server::xyz::openbmc_project::collection::DeleteAll>;
+using MinimumVersionInherit = sdbusplus::server::object_t<
+    sdbusplus::server::xyz::openbmc_project::software::MinimumVersion>;
 
 namespace MatchRules = sdbusplus::bus::match::rules;
 using VersionClass = phosphor::software::manager::Version;
 using AssociationList =
     std::vector<std::tuple<std::string, std::string, std::string>>;
 
+/** @class MinimumVersion
+ *  @brief OpenBMC MinimumVersion implementation.
+ *  @details A concrete implementation for
+ *  xyz.openbmc_project.Software.MinimumVersion DBus API.
+ */
+class MinimumVersion : public MinimumVersionInherit
+{
+  public:
+    /** @brief Constructs MinimumVersion
+     *
+     * @param[in] bus - The D-Bus bus object
+     * @param[in] path - The D-bus object path
+     */
+    MinimumVersion(sdbusplus::bus_t& bus, const std::string& path) :
+        MinimumVersionInherit(bus, path.c_str(), action::emit_interface_added)
+    {}
+};
+
 /** @class ItemUpdater
  *  @brief Manages the activation of the BMC version items.
  */
@@ -68,6 +90,14 @@
 #ifdef HOST_BIOS_UPGRADE
         createBIOSObject();
 #endif
+
+        if (minimum_ship_level::enabled())
+        {
+            minimumVersionObject = std::make_unique<MinimumVersion>(bus, path);
+            minimumVersionObject->minimumVersion(
+                minimum_ship_level::getMinimumVersion());
+        }
+
         emit_object_added();
     };
 
@@ -263,6 +293,9 @@
     bool checkImage(const std::string& filePath,
                     const std::vector<std::string>& imageList);
 
+    /** @brief Persistent MinimumVersion D-Bus object */
+    std::unique_ptr<MinimumVersion> minimumVersionObject;
+
 #ifdef HOST_BIOS_UPGRADE
     /** @brief Create the BIOS object without knowing the version.
      *
diff --git a/msl_verify.cpp b/msl_verify.cpp
index c9f8bce..8dd30a0 100644
--- a/msl_verify.cpp
+++ b/msl_verify.cpp
@@ -59,9 +59,7 @@
 bool minimum_ship_level::verify(const std::string& versionManifest)
 {
     //  If there is no msl or mslRegex return upgrade is needed.
-    std::string msl{BMC_MSL};
-    std::string mslRegex{REGEX_BMC_MSL};
-    if (msl.empty() || mslRegex.empty())
+    if (!enabled())
     {
         return true;
     }
@@ -69,6 +67,7 @@
     // Define mslVersion variable and populate in Version format
     // {major,minor,rev} using parse function.
 
+    std::string msl = getMinimumVersion();
     Version mslVersion = {0, 0, 0};
     parse(msl, mslVersion);
 
@@ -104,3 +103,19 @@
 
     return true;
 }
+
+bool minimum_ship_level::enabled()
+{
+    std::string msl = getMinimumVersion();
+    std::string mslRegex{REGEX_BMC_MSL};
+    if (!msl.empty() && !mslRegex.empty())
+    {
+        return true;
+    }
+    return false;
+}
+
+std::string minimum_ship_level::getMinimumVersion()
+{
+    return BMC_MSL;
+}
diff --git a/msl_verify.hpp b/msl_verify.hpp
index af0c2a2..086c999 100644
--- a/msl_verify.hpp
+++ b/msl_verify.hpp
@@ -38,4 +38,14 @@
  */
 int compare(const Version& a, const Version& b);
 
+/** @brief Check if the minimum ship level option is enabled
+ *  @return true if enabled, false otherwise
+ */
+bool enabled();
+
+/** @brief Get the minimum version
+ *  @return[out] msl - Minimum version string
+ */
+std::string getMinimumVersion();
+
 } // namespace minimum_ship_level