Attn: Qualify MPIPL request with dump policy

Check the value of the dumpPolicyEnabled property and if it is true
(dumps enabled) then request MPIPL for PHYP TI cases, otherwise quiesce
the host.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: Iff9d89c18b37fff02b741c20b9f988238674a147
diff --git a/attn/ti_handler.cpp b/attn/ti_handler.cpp
index 7a227e6..5e9f7a4 100644
--- a/attn/ti_handler.cpp
+++ b/attn/ti_handler.cpp
@@ -99,14 +99,16 @@
 
     // We are finished creating the event log entries so transition host to
     // the required state.
-    if (true == util::dbus::autoRebootEnabled())
+    if (true == util::dbus::dumpPolicyEnabled())
     {
-        // If autoreboot is enabled we will start crash (mpipl) mode target
+        // MPIPL is considered a "dump" so we will qualify this transition with
+        // the dumpPolicyEnabled property. MPIPL is triggered by by starting
+        // the host "crash" target.
         util::dbus::transitionHost(util::dbus::HostState::Crash);
     }
     else
     {
-        // If autoreboot is disabled we will quiesce the host
+        // If dumpPolicyEnabled property is disabled we will quiesce the host
         util::dbus::transitionHost(util::dbus::HostState::Quiesce);
     }
 }
diff --git a/util/dbus.cpp b/util/dbus.cpp
index 635a73c..4f28154 100644
--- a/util/dbus.cpp
+++ b/util/dbus.cpp
@@ -198,15 +198,16 @@
     }
 }
 
-/** @brief Read state of autoreboot propertyi via dbus */
+/** @brief Read state of autoRebootEnabled property via dbus */
 bool autoRebootEnabled()
 {
-    bool autoReboot = false; // assume autoreboot attribute not available
+    // Assume true in case autoRebootEnbabled property is not available
+    bool autoReboot = true;
 
     constexpr auto interface = "xyz.openbmc_project.Control.Boot.RebootPolicy";
 
-    DBusService service;
-    DBusPath path;
+    DBusService service; // will find this
+    DBusPath path;       // will find this
 
     // find a dbus object and path that implements the interface
     if (0 == find(interface, path, service))
@@ -273,6 +274,35 @@
     return host;
 }
 
+/** @brief Read state of dumpPolicyEnabled property via dbus */
+bool dumpPolicyEnabled()
+{
+    // Assume true In case dumpPolicyEnabled property is not available
+    bool dumpPolicyEnabled = true;
+
+    constexpr auto interface = "xyz.openbmc_project.Object.Enable";
+    constexpr auto path      = "/xyz/openbmc_project/dump/system_dump_policy";
+
+    DBusService service; // will find this
+
+    // find a dbus object and path that implements the interface
+    if (0 == findService(interface, path, service))
+    {
+        DBusValue value;
+
+        // autoreboot policy is implemented as a property
+        constexpr auto property = "Enabled";
+
+        if (0 == getProperty(interface, path, service, property, value))
+        {
+            // return value is a variant, dump policy enabled is a boolean
+            dumpPolicyEnabled = std::get<bool>(value);
+        }
+    }
+
+    return dumpPolicyEnabled;
+}
+
 } // namespace dbus
 
 } // namespace util
diff --git a/util/dbus.hpp b/util/dbus.hpp
index aaf3cdc..ecc8d13 100644
--- a/util/dbus.hpp
+++ b/util/dbus.hpp
@@ -82,10 +82,9 @@
 void transitionHost(const HostState i_hostState);
 
 /**
- * @brief Read autoreboot property
+ * @brief Read autoRebootEnabled property
  *
- * Read the autoreboot property via dbus. This status will be used to
- * determine whether to either mpipl or quiesce the host on TI condition.
+ * @return false if autoRebootEnabled policy false, else true
  */
 bool autoRebootEnabled();
 
@@ -107,6 +106,13 @@
  */
 HostRunningState hostRunningState();
 
+/**
+ * @brief Read dumpPolicyEnabled property
+ *
+ * @return false if dumpPolicyEnabled property is false, else true
+ */
+bool dumpPolicyEnabled();
+
 } // namespace dbus
 
 } // namespace util