Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 1 | #include "system_dump_entry.hpp" |
| 2 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 3 | #include "dump_utils.hpp" |
Ramesh Iyyar | 131994b | 2020-12-03 08:35:36 -0600 | [diff] [blame] | 4 | #include "host_transport_exts.hpp" |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 5 | |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 6 | #include <phosphor-logging/elog-errors.hpp> |
| 7 | #include <xyz/openbmc_project/Common/error.hpp> |
| 8 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 9 | namespace openpower |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 10 | { |
| 11 | namespace dump |
| 12 | { |
| 13 | namespace system |
| 14 | { |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 15 | // 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, |
| 18 | constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3; |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 19 | using namespace phosphor::logging; |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 20 | |
| 21 | void Entry::initiateOffload(std::string uri) |
| 22 | { |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 23 | 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 Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 34 | phosphor::dump::Entry::initiateOffload(uri); |
Dhruvaraj Subhashchandran | 59642e2 | 2020-03-19 03:37:44 -0500 | [diff] [blame] | 35 | phosphor::dump::host::requestOffload(sourceDumpId()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 36 | } |
| 37 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 38 | void 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 Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 47 | if (phosphor::dump::isHostRunning()) |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 48 | { |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 49 | phosphor::dump::host::requestDelete(srcDumpID, |
| 50 | TRANSPORT_DUMP_TYPE_IDENTIFIER); |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 51 | } |
| 52 | } |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 53 | } // namespace system |
| 54 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 55 | } // namespace openpower |