Log a PEL for communication, presence mismatch, and safe state errors
Add code to log a PEL in various error scenarios. Refactor some of the
error handling to get the return code out of the driver.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Change-Id: Ifd91cfc063718e484ec8886df8357d115c6b41e3
diff --git a/occ_errors.hpp b/occ_errors.hpp
index 6fe0983..ba4610e 100644
--- a/occ_errors.hpp
+++ b/occ_errors.hpp
@@ -15,6 +15,10 @@
namespace fs = std::filesystem;
+constexpr auto PRESENCE_ERROR_PATH =
+ "org.open_power.OCC.Firmware.PresenceMismatch";
+constexpr auto SAFE_ERROR_PATH = "org.open_power.OCC.Device.SafeState";
+
/** @class Error
* @brief Monitors for OCC device error condition
*/
@@ -34,7 +38,7 @@
* @param[in] callBack - Optional function callback on error condition
*/
Error(EventPtr& event, const fs::path& file,
- std::function<void(bool)> callBack = nullptr) :
+ std::function<void(int)> callBack = nullptr) :
event(event),
file(file), callBack(callBack)
{
@@ -49,6 +53,38 @@
}
}
+ /** @class Descriptor
+ * @brief Contains data relevant to an error that occurred.
+ */
+ class Descriptor
+ {
+ public:
+ Descriptor(const Descriptor&) = default;
+ Descriptor& operator=(const Descriptor&) = default;
+ Descriptor(Descriptor&&) = default;
+ Descriptor& operator=(Descriptor&&) = default;
+
+ Descriptor() : log(false), err(0), callout(nullptr), path(nullptr)
+ {}
+
+ /** @brief Constructs the Descriptor object
+ *
+ * @param[in] path - the DBus error path
+ * @param[in] err - Optional error return code
+ * @param[in] callout - Optional PEL callout path
+ */
+ Descriptor(const char* path, int err = 0,
+ const char* callout = nullptr) :
+ log(true),
+ err(err), callout(callout), path(path)
+ {}
+
+ bool log;
+ int err;
+ const char* callout;
+ const char* path;
+ };
+
/** @brief Starts to monitor for error conditions
*
* @param[in] poll - Indicates whether or not the error file should
@@ -109,7 +145,7 @@
fs::path file;
/** @brief Optional function to call on error scenario */
- std::function<void(bool)> callBack;
+ std::function<void(int)> callBack;
/** @brief Reads file data
*