Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "dump_manager.hpp" |
| 4 | |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 5 | #include <phosphor-logging/elog-errors.hpp> |
| 6 | #include <phosphor-logging/elog.hpp> |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame^] | 7 | #include <phosphor-logging/lg2.hpp> |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/server/object.hpp> |
| 10 | #include <xyz/openbmc_project/Dump/Create/server.hpp> |
| 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace dump |
| 15 | { |
| 16 | namespace faultlog |
| 17 | { |
| 18 | |
| 19 | using namespace phosphor::logging; |
| 20 | |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 21 | using CreateIface = sdbusplus::server::object_t< |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 22 | sdbusplus::xyz::openbmc_project::Dump::server::Create>; |
| 23 | |
| 24 | /** @class Manager |
| 25 | * @brief FaultLog Dump manager implementation. |
| 26 | */ |
| 27 | class Manager : |
| 28 | virtual public CreateIface, |
| 29 | virtual public phosphor::dump::Manager |
| 30 | { |
| 31 | public: |
| 32 | Manager() = delete; |
| 33 | Manager(const Manager&) = default; |
| 34 | Manager& operator=(const Manager&) = delete; |
| 35 | Manager(Manager&&) = delete; |
| 36 | Manager& operator=(Manager&&) = delete; |
| 37 | virtual ~Manager() = default; |
| 38 | |
| 39 | /** @brief Constructor to put object onto bus at a dbus path. |
| 40 | * @param[in] bus - Bus to attach to. |
| 41 | * @param[in] path - Path to attach at. |
| 42 | * @param[in] baseEntryPath - Base path for dump entry. |
| 43 | * @param[in] filePath - Path where the dumps are stored. |
| 44 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 45 | Manager(sdbusplus::bus_t& bus, const char* path, |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 46 | const std::string& baseEntryPath, const char* filePath) : |
| 47 | CreateIface(bus, path), |
| 48 | phosphor::dump::Manager(bus, path, baseEntryPath), dumpDir(filePath) |
| 49 | { |
| 50 | std::error_code ec; |
| 51 | |
| 52 | std::filesystem::create_directory(FAULTLOG_DUMP_PATH, ec); |
| 53 | |
| 54 | if (ec) |
| 55 | { |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame^] | 56 | auto dir = FAULTLOG_DUMP_PATH; |
| 57 | lg2::error( |
| 58 | "dump_manager_faultlog directory {DIRECTORY} not created. " |
| 59 | "error_code = {ERRNO} ({ERROR_MESSAGE})", |
| 60 | "DIRECTORY", dir, "ERRNO", ec.value(), "ERROR_MESSAGE", |
| 61 | ec.message()); |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
| 65 | void restore() override |
| 66 | { |
| 67 | // TODO phosphor-debug-collector/issues/21: Restore fault log entries |
| 68 | // after service restart |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame^] | 69 | lg2::info("dump_manager_faultlog restore not implemented"); |
Claire Weinan | 919f71c | 2022-03-01 19:02:07 -0800 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /** @brief Method to create a new fault log dump entry |
| 73 | * @param[in] params - Key-value pair input parameters |
| 74 | * |
| 75 | * @return object_path - The path to the new dump entry. |
| 76 | */ |
| 77 | sdbusplus::message::object_path |
| 78 | createDump(phosphor::dump::DumpCreateParams params) override; |
| 79 | |
| 80 | private: |
| 81 | /** @brief Path to the dump file*/ |
| 82 | std::string dumpDir; |
| 83 | }; |
| 84 | |
| 85 | } // namespace faultlog |
| 86 | } // namespace dump |
| 87 | } // namespace phosphor |