make bmc dump creation a utility function
Other parts of the code have a need for this function so put it in utils
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I223d9142e7d6ffe12ec3d59d42e848c2c859e3ce
diff --git a/meson.build b/meson.build
index 87fd97b..7ea0f28 100644
--- a/meson.build
+++ b/meson.build
@@ -206,8 +206,10 @@
'systemd_target_monitor.cpp',
'systemd_target_parser.cpp',
'systemd_target_signal.cpp',
+ 'utils.cpp',
dependencies: [
CLI11,
+ libgpiod,
nlohmann_json,
phosphorlogging,
sdbusplus,
@@ -289,8 +291,10 @@
executable('test_systemd_signal',
'./test/systemd_signal.cpp',
'systemd_target_signal.cpp',
+ 'utils.cpp',
dependencies: [
gtest,
+ libgpiod,
nlohmann_json,
phosphorlogging,
sdbusplus,
diff --git a/systemd_target_signal.cpp b/systemd_target_signal.cpp
index 5bf40af..5f7036f 100644
--- a/systemd_target_signal.cpp
+++ b/systemd_target_signal.cpp
@@ -1,5 +1,7 @@
#include "systemd_target_signal.hpp"
+#include "utils.hpp"
+
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
@@ -19,26 +21,6 @@
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-void SystemdTargetLogging::createBmcDump()
-{
- auto method = this->bus.new_method_call(
- "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump/bmc",
- "xyz.openbmc_project.Dump.Create", "CreateDump");
- method.append(
- std::vector<
- std::pair<std::string, std::variant<std::string, uint64_t>>>());
- try
- {
- this->bus.call_noreply(method);
- }
- catch (const sdbusplus::exception::exception& e)
- {
- error("Failed to create BMC dump, exception:{ERROR}", "ERROR", e);
- // just continue, this is error path anyway so we're just collecting
- // what we can
- }
-}
-
void SystemdTargetLogging::startBmcQuiesceTarget()
{
auto method = this->bus.new_method_call(
@@ -104,7 +86,7 @@
"UNIT", unit, "RESULT", result);
// Generate a BMC dump when a monitored target fails
- createBmcDump();
+ utils::createBmcDump(this->bus);
return (targetEntry->second.errorToLog);
}
}
@@ -120,7 +102,7 @@
"UNIT", unit, "RESULT", result);
// Generate a BMC dump when a critical service fails
- createBmcDump();
+ utils::createBmcDump(this->bus);
// Enter BMC Quiesce when a critical service fails
startBmcQuiesceTarget();
return (std::string{
diff --git a/systemd_target_signal.hpp b/systemd_target_signal.hpp
index 755c817..61f3f06 100644
--- a/systemd_target_signal.hpp
+++ b/systemd_target_signal.hpp
@@ -72,9 +72,6 @@
const std::string& result);
private:
- /** @brief Call phosphor-dump-manager to create BMC dump */
- void createBmcDump();
-
/** @brief Start BMC Quiesce Target to indicate critical service failure */
void startBmcQuiesceTarget();
diff --git a/utils.cpp b/utils.cpp
index 1e5e9e2..d925d4c 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -164,6 +164,26 @@
}
}
+void createBmcDump(sdbusplus::bus::bus& bus)
+{
+ auto method = bus.new_method_call(
+ "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump/bmc",
+ "xyz.openbmc_project.Dump.Create", "CreateDump");
+ method.append(
+ std::vector<
+ std::pair<std::string, std::variant<std::string, uint64_t>>>());
+ try
+ {
+ bus.call_noreply(method);
+ }
+ catch (const sdbusplus::exception::exception& e)
+ {
+ error("Failed to create BMC dump, exception:{ERROR}", "ERROR", e);
+ // just continue, this is error path anyway so we're just collecting
+ // what we can
+ }
+}
+
} // namespace utils
} // namespace manager
} // namespace state
diff --git a/utils.hpp b/utils.hpp
index 410f972..e016d4f 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -66,6 +66,12 @@
sdbusplus::bus::bus& bus, const std::string& errorMsg,
sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level errLevel);
+/** @brief Call phosphor-dump-manager to create BMC user dump
+ *
+ * @param[in] bus - The Dbus bus object
+ */
+void createBmcDump(sdbusplus::bus::bus& bus);
+
} // namespace utils
} // namespace manager
} // namespace state