Implement user requested system dump.
Add method to set the diag mode target to start the creation of
user requested system dump.
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: Id4986b615133db575767956d435e6a14faa147b8
diff --git a/dump_manager_system.cpp b/dump_manager_system.cpp
index ab7ca72..865ed91 100644
--- a/dump_manager_system.cpp
+++ b/dump_manager_system.cpp
@@ -38,6 +38,21 @@
lastEntryId++;
}
+uint32_t Manager::createDump()
+{
+ constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
+ constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
+ constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
+ constexpr auto DIAG_MOD_TARGET = "obmc-host-diagnostic-mode@0.target";
+ auto b = sdbusplus::bus::new_default();
+ auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(DIAG_MOD_TARGET); // unit to activate
+ method.append("replace");
+ bus.call_noreply(method);
+ return ++lastEntryId;
+}
+
} // namespace system
} // namespace dump
} // namespace phosphor
diff --git a/dump_manager_system.hpp b/dump_manager_system.hpp
index 948dc3d..441611d 100644
--- a/dump_manager_system.hpp
+++ b/dump_manager_system.hpp
@@ -6,6 +6,7 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Dump/Create/server.hpp>
namespace phosphor
{
@@ -15,6 +16,7 @@
{
using NotifyIface = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Dump::server::Create,
sdbusplus::xyz::openbmc_project::Dump::server::NewDump>;
/** @class Manager
@@ -59,6 +61,13 @@
*/
void notify(NewDump::DumpType dumpType, uint32_t dumpId,
uint64_t size) override;
+
+ /** @brief Implementation for CreateDump
+ * Method to create Dump.
+ *
+ * @return id - The Dump entry id number.
+ */
+ uint32_t createDump() override;
};
} // namespace system