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 | ad50d42 | 2022-01-18 05:54:02 -0600 | [diff] [blame] | 5 | #include "op_dump_consts.hpp" |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 6 | |
Dhruvaraj Subhashchandran | c1778da | 2022-02-04 01:46:49 -0600 | [diff] [blame] | 7 | #include <fmt/core.h> |
| 8 | |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 9 | #include <phosphor-logging/elog-errors.hpp> |
| 10 | #include <xyz/openbmc_project/Common/error.hpp> |
| 11 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 12 | namespace openpower |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 13 | { |
| 14 | namespace dump |
| 15 | { |
| 16 | namespace system |
| 17 | { |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 18 | // 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, |
| 21 | constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3; |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 22 | using namespace phosphor::logging; |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 23 | |
| 24 | void Entry::initiateOffload(std::string uri) |
| 25 | { |
Dhruvaraj Subhashchandran | c1778da | 2022-02-04 01:46:49 -0600 | [diff] [blame] | 26 | log<level::INFO>( |
| 27 | fmt::format( |
| 28 | "System dump offload request id({}) uri({}) source dumpid()", id, |
| 29 | uri, sourceDumpId()) |
| 30 | .c_str()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 31 | phosphor::dump::Entry::initiateOffload(uri); |
Dhruvaraj Subhashchandran | 59642e2 | 2020-03-19 03:37:44 -0500 | [diff] [blame] | 32 | phosphor::dump::host::requestOffload(sourceDumpId()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 33 | } |
| 34 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 35 | void Entry::delete_() |
| 36 | { |
| 37 | auto srcDumpID = sourceDumpId(); |
Dhruvaraj Subhashchandran | c1778da | 2022-02-04 01:46:49 -0600 | [diff] [blame] | 38 | auto dumpId = id; |
Dhruvaraj Subhashchandran | 1112bdf | 2022-03-23 04:38:02 -0500 | [diff] [blame] | 39 | |
| 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 Subhashchandran | c1778da | 2022-02-04 01:46:49 -0600 | [diff] [blame] | 51 | log<level::INFO>(fmt::format("System dump delete id({}) srcdumpid({})", |
| 52 | dumpId, srcDumpID) |
| 53 | .c_str()); |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 54 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 55 | // 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 Subhashchandran | ad50d42 | 2022-01-18 05:54:02 -0600 | [diff] [blame] | 57 | if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID)) |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 58 | { |
Dhruvaraj Subhashchandran | 345e56b | 2022-05-17 01:53:19 -0500 | [diff] [blame] | 59 | 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 Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 72 | } |
Dhruvaraj Subhashchandran | 345e56b | 2022-05-17 01:53:19 -0500 | [diff] [blame] | 73 | |
| 74 | // Remove Dump entry D-bus object |
| 75 | phosphor::dump::Entry::delete_(); |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 76 | } |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 77 | } // namespace system |
| 78 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 79 | } // namespace openpower |