-
Notifications
You must be signed in to change notification settings - Fork 21
/
dump_manager_bmc.hpp
141 lines (121 loc) · 4.78 KB
/
dump_manager_bmc.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#pragma once
#include "dump_manager_bmcstored.hpp"
#include "dump_utils.hpp"
#include "watch.hpp"
#include "xyz/openbmc_project/Dump/Internal/Create/server.hpp"
#include <sdeventplus/source/child.hpp>
#include <xyz/openbmc_project/Dump/Create/server.hpp>
#include <filesystem>
#include <map>
namespace phosphor
{
namespace dump
{
namespace bmc
{
namespace internal
{
class Manager;
} // namespace internal
using CreateIface = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Dump::server::Create>;
using Type =
sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type;
using ::sdeventplus::source::Child;
// Type to dreport type string map
static const std::map<Type, std::string> TypeMap = {
{Type::ApplicationCored, "core"},
{Type::UserRequested, "user"},
{Type::InternalFailure, "elog"},
{Type::Checkstop, "checkstop"},
{Type::Ramoops, "ramoops"}};
/** @class Manager
* @brief OpenBMC Dump manager implementation.
* @details A concrete implementation for the
* xyz.openbmc_project.Dump.Create DBus API
*/
class Manager :
virtual public CreateIface,
virtual public phosphor::dump::bmc_stored::Manager
{
friend class internal::Manager;
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.
* @param[in] baseEntryPath - Base path for dump entry.
* @param[in] filePath - Path where the dumps are stored.
*/
Manager(sdbusplus::bus::bus& bus, const EventPtr& event, const char* path,
const std::string& baseEntryPath, const char* filePath) :
CreateIface(bus, path),
phosphor::dump::bmc_stored::Manager(
bus, event, path, baseEntryPath, filePath, BMC_DUMP_FILENAME_REGEX,
BMC_DUMP_MAX_SIZE, BMC_DUMP_MIN_SPACE_REQD, BMC_DUMP_TOTAL_SIZE)
{}
/** @brief Implementation for CreateDump
* Method to create a BMC dump entry when user requests for a new BMC dump
*
* @return object_path - The object path of the new dump entry.
*/
sdbusplus::message::object_path
createDump(phosphor::dump::DumpCreateParams params) override;
/** @brief Create a Dump Entry Object
* @param[in] id - Id of the dump
* @param[in] objPath - Object path to attach to
* @param[in] timeStamp - Dump creation timestamp
* since the epoch.
* @param[in] fileSize - Dump file size in bytes.
* @param[in] file - Name of dump file.
* @param[in] generatorId - id of the user initiated the dump.
* @param[in] status - status of the dump.
* @param[in] parent - The dump entry's parent.
*/
void createEntry(const uint32_t id, const std::string objPath,
const uint64_t ms, uint64_t fileSize,
const std::filesystem::path& file,
const std::string& generatorId,
phosphor::dump::OperationStatus status);
/** @brief Create a Dump Entry Object
* @param[in] id - Id of the dump
* @param[in] objPath - Object path to attach to
* @param[in] timeStamp - Dump creation timestamp
* since the epoch.
* @param[in] fileSize - Dump file size in bytes.
* @param[in] file - Name of dump file.
* @param[in] status - status of the dump.
* @param[in] parent - The dump entry's parent.
*/
void createEntry(const uint32_t id, const std::string objPath,
const uint64_t ms, uint64_t fileSize,
const std::filesystem::path& file,
phosphor::dump::OperationStatus status) override;
/** @brief Perform any post restore operations after claiming
* the bus name. Any new D-Bus dump objects created will be
* notified to the subscribers.
*/
void checkAndInitialize() override;
private:
/** @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 Check if any core files present and create BMC core dump
*/
void checkAndCreateCoreDump();
/** @brief SDEventPlus child pointer added to event loop */
std::map<pid_t, std::unique_ptr<Child>> childPtrMap;
};
} // namespace bmc
} // namespace dump
} // namespace phosphor