1 #include "system_dump_entry.hpp" 2 3 #include "dump_utils.hpp" 4 #include "host_transport_exts.hpp" 5 #include "op_dump_consts.hpp" 6 7 #include <phosphor-logging/elog-errors.hpp> 8 #include <phosphor-logging/lg2.hpp> 9 #include <xyz/openbmc_project/Common/error.hpp> 10 11 namespace openpower 12 { 13 namespace dump 14 { 15 namespace system 16 { 17 // TODO #ibm-openbmc/issues/2859 18 // Revisit host transport impelementation 19 // This value is used to identify the dump in the transport layer to host, 20 constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3; 21 using namespace phosphor::logging; 22 23 void Entry::initiateOffload(std::string uri) 24 { 25 lg2::info("System dump offload request id: {ID} uri: {URI} " 26 "source dumpid: {SOURCE_DUMP_ID}", 27 "ID", id, "URI", uri, "SOURCE_DUMP_ID", sourceDumpId()); 28 phosphor::dump::Entry::initiateOffload(uri); 29 phosphor::dump::host::requestOffload(sourceDumpId()); 30 } 31 32 void Entry::delete_() 33 { 34 auto srcDumpID = sourceDumpId(); 35 auto dumpId = id; 36 37 if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning())) 38 { 39 lg2::error("Dump offload is in progress id: {DUMP_ID} " 40 "srcdumpid: {SRC_DUMP_ID}", 41 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID); 42 elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>( 43 xyz::openbmc_project::Common::NotAllowed::REASON( 44 "Dump offload is in progress")); 45 } 46 47 lg2::info("System dump delete id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}", 48 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID); 49 50 // Remove host system dump when host is up by using source dump id 51 // which is present in system dump entry dbus object as a property. 52 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID)) 53 { 54 try 55 { 56 phosphor::dump::host::requestDelete(srcDumpID, 57 TRANSPORT_DUMP_TYPE_IDENTIFIER); 58 } 59 catch (const std::exception& e) 60 { 61 lg2::error("Error deleting dump from host id: {DUMP_ID} " 62 "host id: {SRC_DUMP_ID} error: {ERROR}", 63 "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID, "ERROR", e); 64 elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>(); 65 } 66 } 67 68 // Remove Dump entry D-bus object 69 phosphor::dump::Entry::delete_(); 70 } 71 } // namespace system 72 } // namespace dump 73 } // namespace openpower 74