blob: 3d0fb51b619f3a135d45f174a25639b8b3022441 [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 Subhashchandran6a54d9a2020-12-17 22:24:37 -06007#include <phosphor-logging/elog-errors.hpp>
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -05008#include <phosphor-logging/lg2.hpp>
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -06009#include <xyz/openbmc_project/Common/error.hpp>
10
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060011namespace openpower
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060012{
13namespace dump
14{
15namespace system
16{
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060017// TODO #ibm-openbmc/issues/2859
18// Revisit host transport impelementation
19// This value is used to identify the dump in the transport layer to host,
20constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3;
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060021using namespace phosphor::logging;
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060022
23void Entry::initiateOffload(std::string uri)
24{
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050025 lg2::info("System dump offload request id: {ID} uri: {URI} "
26 "source dumpid: {SOURCE_DUMP_ID}",
27 "ID", id, "URI", uri, "SOURCE_DUMP_ID", sourceDumpId());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060028 phosphor::dump::Entry::initiateOffload(uri);
Dhruvaraj Subhashchandran59642e22020-03-19 03:37:44 -050029 phosphor::dump::host::requestOffload(sourceDumpId());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060030}
31
Ramesh Iyyar22793862020-12-04 04:03:03 -060032void Entry::delete_()
33{
34 auto srcDumpID = sourceDumpId();
Dhruvaraj Subhashchandranc1778da2022-02-04 01:46:49 -060035 auto dumpId = id;
Dhruvaraj Subhashchandran1112bdf2022-03-23 04:38:02 -050036
37 if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning()))
38 {
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050039 lg2::error("Dump offload is in progress id: {DUMP_ID} "
40 "srcdumpid: {SRC_DUMP_ID}",
41 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID);
Dhruvaraj Subhashchandran1112bdf2022-03-23 04:38:02 -050042 elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>(
43 xyz::openbmc_project::Common::NotAllowed::REASON(
44 "Dump offload is in progress"));
45 }
46
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050047 lg2::info("System dump delete id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}",
48 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID);
Ramesh Iyyar22793862020-12-04 04:03:03 -060049
Ramesh Iyyar22793862020-12-04 04:03:03 -060050 // Remove host system dump when host is up by using source dump id
51 // which is present in system dump entry dbus object as a property.
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -060052 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
Ramesh Iyyar22793862020-12-04 04:03:03 -060053 {
Dhruvaraj Subhashchandran345e56b2022-05-17 01:53:19 -050054 try
55 {
56 phosphor::dump::host::requestDelete(srcDumpID,
57 TRANSPORT_DUMP_TYPE_IDENTIFIER);
58 }
59 catch (const std::exception& e)
60 {
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050061 lg2::error("Error deleting dump from host id: {DUMP_ID} "
62 "host id: {SRC_DUMP_ID} error: {ERROR}",
63 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID, "ERROR", e);
Dhruvaraj Subhashchandran345e56b2022-05-17 01:53:19 -050064 elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>();
65 }
Ramesh Iyyar22793862020-12-04 04:03:03 -060066 }
Dhruvaraj Subhashchandran345e56b2022-05-17 01:53:19 -050067
68 // Remove Dump entry D-bus object
69 phosphor::dump::Entry::delete_();
Ramesh Iyyar22793862020-12-04 04:03:03 -060070}
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060071} // namespace system
72} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060073} // namespace openpower