blob: af7714d99975e9b15e07d912414fddb172721021 [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 Subhashchandran69e61522020-02-04 06:39:11 -06005
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -06006#include <phosphor-logging/elog-errors.hpp>
7#include <xyz/openbmc_project/Common/error.hpp>
8
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -06009namespace openpower
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060010{
11namespace dump
12{
13namespace system
14{
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060015// TODO #ibm-openbmc/issues/2859
16// Revisit host transport impelementation
17// This value is used to identify the dump in the transport layer to host,
18constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3;
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060019using namespace phosphor::logging;
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060020
21void Entry::initiateOffload(std::string uri)
22{
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060023 using NotAllowed =
24 sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
25 using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
26
27 // Allow offloading only when the host is up.
28 if (!phosphor::dump::isHostRunning())
29 {
30 elog<NotAllowed>(
31 Reason("System dump can be offloaded only when the host is up"));
32 return;
33 }
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060034 phosphor::dump::Entry::initiateOffload(uri);
Dhruvaraj Subhashchandran59642e22020-03-19 03:37:44 -050035 phosphor::dump::host::requestOffload(sourceDumpId());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060036}
37
Ramesh Iyyar22793862020-12-04 04:03:03 -060038void Entry::delete_()
39{
40 auto srcDumpID = sourceDumpId();
41
42 // Remove Dump entry D-bus object
43 phosphor::dump::Entry::delete_();
44
45 // Remove host system dump when host is up by using source dump id
46 // which is present in system dump entry dbus object as a property.
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060047 if (phosphor::dump::isHostRunning())
Ramesh Iyyar22793862020-12-04 04:03:03 -060048 {
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060049 phosphor::dump::host::requestDelete(srcDumpID,
50 TRANSPORT_DUMP_TYPE_IDENTIFIER);
Ramesh Iyyar22793862020-12-04 04:03:03 -060051 }
52}
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060053} // namespace system
54} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060055} // namespace openpower