Add support for user initiated BMC Dump
Added support for creating new dump entry d-bus objects for
user request dump.
Change-Id: I31d2f478418e312e0aa6cc321a885498cf6ec6d6
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/dump_manager.cpp b/dump_manager.cpp
index d0376a5..3b00119 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -1,4 +1,5 @@
#include <unistd.h>
+#include <sys/inotify.h>
#include <phosphor-logging/elog-errors.hpp>
@@ -112,5 +113,17 @@
entries.erase(entryId);
}
+void Manager::watchCallback(const UserMap& fileInfo)
+{
+ for (const auto& i : fileInfo)
+ {
+ // For any new dump file create dump entry object.
+ if (IN_CLOSE_WRITE == i.second)
+ {
+ createEntry(i.first);
+ }
+ }
+}
+
} //namespace dump
} //namespace phosphor
diff --git a/dump_manager.hpp b/dump_manager.hpp
index b4c09c1..55947b2 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -9,6 +9,8 @@
#include "xyz/openbmc_project/Dump/Internal/Create/server.hpp"
#include "dump_entry.hpp"
#include "dump_utils.hpp"
+#include "watch.hpp"
+#include "config.h"
namespace phosphor
{
@@ -21,6 +23,8 @@
} // namespace internal
+using UserMap = phosphor::dump::inotify::UserMap;
+
using Type =
sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type;
@@ -57,7 +61,16 @@
CreateIface(bus, path),
bus(bus),
eventLoop(event.get()),
- lastEntryId(0)
+ lastEntryId(0),
+ dumpWatch(eventLoop,
+ IN_NONBLOCK,
+ IN_CLOSE_WRITE,
+ EPOLLIN,
+ BMC_DUMP_FILE_DIR,
+ std::bind(
+ std::mem_fn(
+ &phosphor::dump::Manager::watchCallback),
+ this, std::placeholders::_1))
{}
/** @brief Implementation for CreateDump
@@ -67,6 +80,11 @@
*/
uint32_t createDump() override;
+ /** @brief Implementation of dump watch call back
+ * @param [in] fileInfo - map of file info path:event
+ */
+ void watchCallback(const UserMap& fileInfo);
+
private:
/** @brief Create Dump entry d-bus object
* @param[in] fullPath - Full path of the Dump file name
@@ -117,6 +135,9 @@
/** @brief Id of the last Dump entry */
uint32_t lastEntryId;
+
+ /** @brief Dump watch object */
+ phosphor::dump::inotify::Watch dumpWatch;
};
} // namespace dump
diff --git a/dump_manager_main.cpp b/dump_manager_main.cpp
index 6be9a29..2cb6d2b 100644
--- a/dump_manager_main.cpp
+++ b/dump_manager_main.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "dump_manager.hpp"
#include "dump_internal.hpp"
+#include "watch.hpp"
int main(int argc, char* argv[])
{
@@ -34,6 +35,7 @@
phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
phosphor::dump::internal::Manager mgr(bus, OBJ_INTERNAL);
bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
+
auto rc = sd_event_loop(eventP.get());
if (rc < 0)
{