blob: 2f44d346fbd6ae424b519629aff98efe330e25cf [file] [log] [blame]
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -06001#include "system_dump_entry.hpp"
2
Ramesh Iyyar22793862020-12-04 04:03:03 -06003#include "dump_utils.hpp"
Ramesh Iyyar131994b2020-12-03 08:35:36 -06004#include "host_transport_exts.hpp"
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -06005#include "op_dump_consts.hpp"
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -06006
Dhruvaraj Subhashchandranc1778da2022-02-04 01:46:49 -06007#include <fmt/core.h>
8
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -06009#include <phosphor-logging/elog-errors.hpp>
10#include <xyz/openbmc_project/Common/error.hpp>
11
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060012namespace openpower
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060013{
14namespace dump
15{
16namespace system
17{
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060018// TODO #ibm-openbmc/issues/2859
19// Revisit host transport impelementation
20// This value is used to identify the dump in the transport layer to host,
21constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3;
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060022using namespace phosphor::logging;
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060023
24void Entry::initiateOffload(std::string uri)
25{
Dhruvaraj Subhashchandranc1778da2022-02-04 01:46:49 -060026 log<level::INFO>(
27 fmt::format(
28 "System dump offload request id({}) uri({}) source dumpid()", id,
29 uri, sourceDumpId())
30 .c_str());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060031 phosphor::dump::Entry::initiateOffload(uri);
Dhruvaraj Subhashchandran59642e22020-03-19 03:37:44 -050032 phosphor::dump::host::requestOffload(sourceDumpId());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060033}
34
Ramesh Iyyar22793862020-12-04 04:03:03 -060035void Entry::delete_()
36{
37 auto srcDumpID = sourceDumpId();
Dhruvaraj Subhashchandranc1778da2022-02-04 01:46:49 -060038 auto dumpId = id;
Dhruvaraj Subhashchandran1112bdf2022-03-23 04:38:02 -050039
40 if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning()))
41 {
42 log<level::ERR>(
43 fmt::format("Dump offload is in progress id({}) srcdumpid({})",
44 dumpId, srcDumpID)
45 .c_str());
46 elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>(
47 xyz::openbmc_project::Common::NotAllowed::REASON(
48 "Dump offload is in progress"));
49 }
50
Dhruvaraj Subhashchandranc1778da2022-02-04 01:46:49 -060051 log<level::INFO>(fmt::format("System dump delete id({}) srcdumpid({})",
52 dumpId, srcDumpID)
53 .c_str());
Ramesh Iyyar22793862020-12-04 04:03:03 -060054
55 // Remove Dump entry D-bus object
56 phosphor::dump::Entry::delete_();
57
58 // Remove host system dump when host is up by using source dump id
59 // which is present in system dump entry dbus object as a property.
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -060060 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
Ramesh Iyyar22793862020-12-04 04:03:03 -060061 {
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060062 phosphor::dump::host::requestDelete(srcDumpID,
63 TRANSPORT_DUMP_TYPE_IDENTIFIER);
Ramesh Iyyar22793862020-12-04 04:03:03 -060064 }
65}
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060066} // namespace system
67} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060068} // namespace openpower