blob: 39b161d3f7adb49acb6ace2a67c1a33903b052b1 [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
Ramesh Iyyar22793862020-12-04 04:03:03 -060055 // Remove host system dump when host is up by using source dump id
56 // which is present in system dump entry dbus object as a property.
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -060057 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
Ramesh Iyyar22793862020-12-04 04:03:03 -060058 {
Dhruvaraj Subhashchandran345e56b2022-05-17 01:53:19 -050059 try
60 {
61 phosphor::dump::host::requestDelete(srcDumpID,
62 TRANSPORT_DUMP_TYPE_IDENTIFIER);
63 }
64 catch (const std::exception& e)
65 {
66 log<level::ERR>(fmt::format("Error deleting dump from host id({}) "
67 "host id({}) error({})",
68 dumpId, srcDumpID, e.what())
69 .c_str());
70 elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>();
71 }
Ramesh Iyyar22793862020-12-04 04:03:03 -060072 }
Dhruvaraj Subhashchandran345e56b2022-05-17 01:53:19 -050073
74 // Remove Dump entry D-bus object
75 phosphor::dump::Entry::delete_();
Ramesh Iyyar22793862020-12-04 04:03:03 -060076}
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060077} // namespace system
78} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060079} // namespace openpower