boot-block: check quiesce on error setting

An initial commit to check the new QuiesceOnHwError setting. Future
commits will act on this setting by creating the appropriate error
associations if needed.

Make public functions so code outside of log_manager (such as extension
code) can utilize these functions.

The design for this feature can be found here:
https://github.com/openbmc/docs/blob/master/designs/fail-boot-on-hw-error.md

Tested:
Verified code correctly read setting and took correct code path

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I2d113b5ca05afc39a5b81808eaafbc15da03bf8e
diff --git a/log_manager.cpp b/log_manager.cpp
index bdb2e2e..5be474f 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -30,6 +30,7 @@
 
 using namespace phosphor::logging;
 using namespace std::chrono;
+using sdbusplus::exception::SdBusError;
 extern const std::map<metadata::Metadata,
                       std::function<metadata::associations::Type>>
     meta;
@@ -230,6 +231,11 @@
                                      std::move(objects), fwVersion, *this);
     serialize(*e);
 
+    if (isQuiesceOnErrorEnabled())
+    {
+        checkQuiesceOnError(*e);
+    }
+
     doExtensionLogCreate(*e, ffdc);
 
     // Note: No need to close the file descriptors in the FFDC.
@@ -237,6 +243,36 @@
     entries.insert(std::make_pair(entryId, std::move(e)));
 }
 
+bool Manager::isQuiesceOnErrorEnabled()
+{
+    std::variant<bool> property;
+
+    auto method = this->busLog.new_method_call(
+        "xyz.openbmc_project.Settings", "/xyz/openbmc_project/logging/settings",
+        "org.freedesktop.DBus.Properties", "Get");
+
+    method.append("xyz.openbmc_project.Logging.Settings", "QuiesceOnHwError");
+
+    try
+    {
+        auto reply = this->busLog.call(method);
+        reply.read(property);
+    }
+    catch (const SdBusError& e)
+    {
+        log<level::ERR>("Error reading QuiesceOnHwError property",
+                        entry("ERROR=%s", e.what()));
+        throw;
+    }
+
+    return std::get<bool>(property);
+}
+
+void Manager::checkQuiesceOnError(const Entry& entry)
+{
+    // TODO in later commit in this series
+}
+
 void Manager::doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc)
 {
     // Make the association <endpointpath>/<endpointtype> paths
diff --git a/log_manager.hpp b/log_manager.hpp
index 74450cb..a57f1ab 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -171,6 +171,18 @@
         const std::map<std::string, std::string>& additionalData,
         const FFDCEntries& ffdc);
 
+    /** @brief Common wrapper for creating an Entry object
+     *
+     * @return true if quiesce on error setting is enabled, false otherwise
+     */
+    bool isQuiesceOnErrorEnabled();
+
+    /** @brief Check if error has callout and if so, block boot
+     *
+     * @param[in] entry - The error to check for callouts
+     */
+    void checkQuiesceOnError(const Entry& entry);
+
   private:
     /*
      * @fn _commit()