dump-collect: Add application for SBE dump collection
This series of commits introduces the `dump-collect` application, a new
command-line tool designed to facilitate the collection of dumps from
the SBE. The tool is capable of asynchronous operation, allowing it
to initiate dump collection from different SBEs at the same time.
Key Highlights:
- The base implementation sets up the application to accept necessary
parameters for dump collection, including dump type, dump ID,
destination path for collected data, and the ID of the failing unit.
- An implementation of the dump collection class and the initiation
method enables the start of the dump collection process
asynchronously.
- The `dump-collect` application is designed to be invoked from scripts,
which collect various data in the case of system failures.
Tests:
Validated parameters passed
Starting dump collection method
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: If6f44075d33af20e09a442d7968d235dc6e8ea16
diff --git a/dump/dump_utils.hpp b/dump/dump_utils.hpp
new file mode 100644
index 0000000..8918024
--- /dev/null
+++ b/dump/dump_utils.hpp
@@ -0,0 +1,84 @@
+#pragma once
+
+#include <sdbusplus/server.hpp>
+
+#include <filesystem>
+#include <map>
+#include <string>
+#include <variant>
+namespace openpower::dump::util
+{
+
+using DumpCreateParams =
+ std::map<std::string, std::variant<std::string, uint64_t>>;
+
+/** @struct DumpPtr
+ * @brief a structure holding the data pointer
+ * @details This is a RAII container for the dump data
+ * returned by the SBE
+ */
+struct DumpDataPtr
+{
+ public:
+ /** @brief Destructor for the object, free the allocated memory.
+ */
+ ~DumpDataPtr()
+ {
+ // The memory is allocated using malloc
+ free(dataPtr);
+ }
+ /** @brief Returns the pointer to the data
+ */
+ uint8_t** getPtr()
+ {
+ return &dataPtr;
+ }
+ /** @brief Returns the stored data
+ */
+ uint8_t* getData()
+ {
+ return dataPtr;
+ }
+
+ private:
+ /** The pointer to the data */
+ uint8_t* dataPtr = nullptr;
+};
+
+/**
+ * @brief Get DBUS service for input interface via mapper call
+ *
+ * @param[in] bus - DBUS Bus Object
+ * @param[in] intf - DBUS Interface
+ * @param[in] path - DBUS Object Path
+ *
+ * @return distinct dbus name for input interface/path
+ **/
+std::string getService(sdbusplus::bus::bus& bus, const std::string& intf,
+ const std::string& path);
+
+/**
+ * @brief Set the property value based on the inputs
+ *
+ * @param[in] interface - the interface the property is on
+ * @param[in] propertName - the name of the property
+ * @param[in] path - the D-Bus path
+ * @param[in] service - the D-Bus service
+ * @param[in] bus - the D-Bus object
+ * @param[in] value - the value to set the property to
+ */
+template <typename T>
+void setProperty(const std::string& interface, const std::string& propertyName,
+ const std::string& path, sdbusplus::bus::bus& bus,
+ const T& value)
+{
+ constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
+
+ auto service = getService(bus, interface, path);
+ auto method = bus.new_method_call(service.c_str(), path.c_str(),
+ PROPERTY_INTF, "Set");
+ method.append(interface, propertyName, value);
+ auto reply = bus.call(method);
+}
+
+} // namespace openpower::dump::util