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 | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 15 | using namespace phosphor::logging; |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 16 | |
| 17 | void Entry::initiateOffload(std::string uri) |
| 18 | { |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 19 | using NotAllowed = |
| 20 | sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed; |
| 21 | using Reason = xyz::openbmc_project::Common::NotAllowed::REASON; |
| 22 | |
| 23 | // Allow offloading only when the host is up. |
| 24 | if (!phosphor::dump::isHostRunning()) |
| 25 | { |
| 26 | elog<NotAllowed>( |
| 27 | Reason("System dump can be offloaded only when the host is up")); |
| 28 | return; |
| 29 | } |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 30 | phosphor::dump::Entry::initiateOffload(uri); |
Dhruvaraj Subhashchandran | 59642e2 | 2020-03-19 03:37:44 -0500 | [diff] [blame] | 31 | phosphor::dump::host::requestOffload(sourceDumpId()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 32 | } |
| 33 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 34 | void Entry::delete_() |
| 35 | { |
| 36 | auto srcDumpID = sourceDumpId(); |
| 37 | |
| 38 | // Remove Dump entry D-bus object |
| 39 | phosphor::dump::Entry::delete_(); |
| 40 | |
| 41 | // Remove host system dump when host is up by using source dump id |
| 42 | // which is present in system dump entry dbus object as a property. |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 43 | if (phosphor::dump::isHostRunning()) |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 44 | { |
| 45 | phosphor::dump::host::requestDelete(srcDumpID); |
| 46 | } |
| 47 | } |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 48 | } // namespace system |
| 49 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 50 | } // namespace openpower |