summaryrefslogtreecommitdiffstats
path: root/dump_manager.hpp
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2017-06-14 07:17:21 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-06-29 18:36:04 +0000
commita320c7cafcab3a967de9a1149a5e34e02699d382 (patch)
treec676d1b03407a0092d9b25256bbc04ab73a5f32b /dump_manager.hpp
parenta19440dc9e62ffc3f8f7d1f46f0801f2b25cd0cf (diff)
downloadphosphor-debug-collector-a320c7cafcab3a967de9a1149a5e34e02699d382.tar.gz
phosphor-debug-collector-a320c7cafcab3a967de9a1149a5e34e02699d382.zip
Implementation of create interface.
Both the external and internal Dump managers define "Create" interfaces. This commit implements these. Change-Id: If857ec6ea7267fd72e9b420e6b44fa68b6abab66 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Diffstat (limited to 'dump_manager.hpp')
-rw-r--r--dump_manager.hpp130
1 files changed, 130 insertions, 0 deletions
diff --git a/dump_manager.hpp b/dump_manager.hpp
new file mode 100644
index 0000000..3bbcf3e
--- /dev/null
+++ b/dump_manager.hpp
@@ -0,0 +1,130 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Dump/Create/server.hpp>
+#include <experimental/filesystem>
+
+#include "xyz/openbmc_project/Dump/Internal/Create/server.hpp"
+#include "dump_entry.hpp"
+
+namespace phosphor
+{
+namespace dump
+{
+namespace internal
+{
+
+class Manager;
+
+} // namespace internal
+
+namespace fs = std::experimental::filesystem;
+using Type =
+ sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type;
+
+using CreateIface = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Dump::server::Create>;
+
+/* Need a custom deleter for freeing up sd_event */
+struct EventDeleter
+{
+ void operator()(sd_event* event) const
+ {
+ event = sd_event_unref(event);
+ }
+};
+using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
+
+/** @class Manager
+ * @brief OpenBMC Dump manager implementation.
+ * @details A concrete implementation for the
+ * xyz.openbmc_project.Dump.Create DBus API.
+ */
+class Manager : public CreateIface
+{
+ friend class internal::Manager;
+ friend class Entry;
+
+ public:
+ Manager() = delete;
+ Manager(const Manager&) = default;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = delete;
+ Manager& operator=(Manager&&) = delete;
+ virtual ~Manager() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] event - Dump manager sd_event loop.
+ * @param[in] path - Path to attach at.
+ */
+ Manager(sdbusplus::bus::bus& bus,
+ const EventPtr& event, const char* path) :
+ CreateIface(bus, path),
+ bus(bus),
+ eventLoop(event.get()),
+ lastEntryId(0)
+ {}
+
+ /** @brief Implementation for CreateDump
+ * Method to create Dump.
+ *
+ * @return id - The Dump entry id number.
+ */
+ uint32_t createDump() override;
+
+ private:
+ /** @brief Create Dump entry d-bus object
+ * @param[in] fullPath - Full path of the Dump file name
+ */
+ void createEntry(const fs::path& fullPath);
+
+ /** @brief Capture BMC Dump based on the Dump type.
+ * @param[in] type - Type of the Dump.
+ * @param[in] fullPaths - List of absolute paths to the files
+ * to be included as part of Dump package.
+ * @return id - The Dump entry id number.
+ */
+ uint32_t captureDump(
+ Type type,
+ const std::vector<std::string>& fullPaths);
+
+ /** @brief Erase specified entry d-bus object
+ *
+ * @param[in] entryId - unique identifier of the entry
+ */
+ void erase(uint32_t entryId);
+
+ /** @brief sd_event_add_child callback
+ *
+ * @param[in] s - event source
+ * @param[in] si - signal info
+ * @param[in] userdata - pointer to Watch object
+ *
+ * @returns 0 on success, -1 on fail
+ */
+ static int callback(sd_event_source* s,
+ const siginfo_t* si,
+ void* userdata)
+ {
+ //No specific action required in
+ //the sd_event_add_child callback.
+ return 0;
+ }
+
+ /** @brief sdbusplus DBus bus connection. */
+ sdbusplus::bus::bus& bus;
+
+ /** @brief sdbusplus Dump event loop */
+ EventPtr eventLoop;
+
+ /** @brief Dump Entry dbus objects map based on entry id */
+ std::map<uint32_t, std::unique_ptr<Entry>> entries;
+
+ /** @brief Id of the last Dump entry */
+ uint32_t lastEntryId;
+};
+
+} // namespace dump
+} // namespace phosphor
OpenPOWER on IntegriCloud