faultlog: Initial framework for Fault Log
Fault Log is a new type of dump. For details please see
https://github.com/openbmc/docs/blob/master/designs/hw-fault-monitor.md
This commit enables creation and deletion of fault log entries.
Tested: Created and deleted fault log entries by calling the
corresponding D-Bus methods via bmcweb (added extra code in bmcweb for
testing this). Also forced a fault log directory creation error by
changing the code to specify a nonexistent directory path "/abc/def/"
instead of FAULTLOG_DUMP_PATH, and forced a fault log file open error
by creating a directory (manually using mkdir) with the same name as
the file that the fault log manager tried to open.
Signed-off-by: Claire Weinan <cweinan@google.com>
Change-Id: I03d4c19a4c131f7224ac895e404c46b1f566617b
diff --git a/faultlog_dump_entry.hpp b/faultlog_dump_entry.hpp
new file mode 100644
index 0000000..50f97cd
--- /dev/null
+++ b/faultlog_dump_entry.hpp
@@ -0,0 +1,74 @@
+#pragma once
+
+#include "dump_entry.hpp"
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Object/Delete/server.hpp>
+#include <xyz/openbmc_project/Time/EpochTime/server.hpp>
+
+#include <filesystem>
+
+namespace phosphor
+{
+namespace dump
+{
+namespace faultlog
+{
+template <typename T>
+using ServerObject = typename sdbusplus::server::object::object<T>;
+
+using EntryIfaces = sdbusplus::server::object::object<>;
+
+class Manager;
+
+/** @class Entry
+ * @brief OpenBMC Fault Log Dump Entry implementation.
+ */
+class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
+{
+ public:
+ Entry() = delete;
+ Entry(const Entry&) = delete;
+ Entry& operator=(const Entry&) = delete;
+ Entry(Entry&&) = delete;
+ Entry& operator=(Entry&&) = delete;
+ ~Entry() = default;
+
+ /** @brief Constructor for the Dump Entry Object
+ * @param[in] bus - Bus to attach to.
+ * @param[in] objPath - Object path to attach to
+ * @param[in] dumpId - Dump id.
+ * @param[in] timeStamp - Dump creation timestamp
+ * in microseconds since the epoch.
+ * @param[in] fileSize - Dump file size in bytes.
+ * @param[in] file - Full path of dump file.
+ * @param[in] status - status of the dump.
+ * @param[in] parent - The dump entry's parent.
+ */
+ Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
+ uint64_t timeStamp, uint64_t fileSize,
+ const std::filesystem::path& file,
+ phosphor::dump::OperationStatus status,
+ phosphor::dump::Manager& parent) :
+ EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
+ phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize,
+ status, parent),
+ file(file)
+ {
+ // Emit deferred signal.
+ this->phosphor::dump::faultlog::EntryIfaces::emit_object_added();
+ }
+
+ /** @brief Delete this d-bus object.
+ */
+ void delete_() override;
+
+ private:
+ /** @Dump file path */
+ std::filesystem::path file;
+};
+
+} // namespace faultlog
+} // namespace dump
+} // namespace phosphor