Add power fault check to checkstop handler
If a power fault is being reported during a
checkstop condition we will not call the
analyzer.
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I9813a55b80eb1b94c6ad2d5cddb2e56b1daa67f4
diff --git a/util/dbus.cpp b/util/dbus.cpp
index f9370d4..ca5ccc4 100644
--- a/util/dbus.cpp
+++ b/util/dbus.cpp
@@ -530,5 +530,34 @@
return true;
}
+/** @brief Determine if power fault was detected */
+bool powerFault()
+{
+ // power fault based on pgood property
+ int32_t pgood = 0; // assume fault or unknown
+
+ constexpr auto interface = "org.openbmc.control.Power";
+
+ DBusService service;
+ DBusPath path;
+
+ // find a dbus service and object path that implements the interface
+ if (0 == find(interface, path, service))
+ {
+ DBusValue value;
+
+ // chassis pgood is implemented as a property
+ constexpr auto property = "pgood";
+
+ if (0 == getProperty(interface, path, service, property, value))
+ {
+ // return value is a variant, int32 == 1 for pgood OK
+ pgood = std::get<int32_t>(value);
+ }
+ }
+
+ return pgood != 1 ? true : false; // if not pgood then power fault
+}
+
} // namespace dbus
} // namespace util
diff --git a/util/dbus.hpp b/util/dbus.hpp
index 39041e2..6c1a554 100644
--- a/util/dbus.hpp
+++ b/util/dbus.hpp
@@ -12,7 +12,7 @@
namespace dbus
{
using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>,
- std::vector<std::string>>;
+ std::vector<std::string>, int32_t>;
using DBusProperty = std::string;
using DBusInterface = std::string;
using DBusService = std::string;
@@ -179,5 +179,12 @@
*/
bool getMctpInstance(uint8_t& mctpInstance, uint8_t Eid);
+/**
+ * @brief Determine if power fault was detected
+ *
+ * @return true if power fault or unknown, false otherwise
+ */
+bool powerFault();
+
} // namespace dbus
} // namespace util