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 <fmt/core.h> 8 9 #include <phosphor-logging/elog-errors.hpp> 10 #include <xyz/openbmc_project/Common/error.hpp> 11 12 namespace openpower 13 { 14 namespace dump 15 { 16 namespace system 17 { 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; 22 using namespace phosphor::logging; 23 24 void Entry::initiateOffload(std::string uri) 25 { 26 log<level::INFO>( 27 fmt::format( 28 "System dump offload request id({}) uri({}) source dumpid()", id, 29 uri, sourceDumpId()) 30 .c_str()); 31 phosphor::dump::Entry::initiateOffload(uri); 32 phosphor::dump::host::requestOffload(sourceDumpId()); 33 } 34 35 void Entry::delete_() 36 { 37 auto srcDumpID = sourceDumpId(); 38 auto dumpId = id; 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 51 log<level::INFO>(fmt::format("System dump delete id({}) srcdumpid({})", 52 dumpId, srcDumpID) 53 .c_str()); 54 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. 57 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID)) 58 { 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 } 72 } 73 74 // Remove Dump entry D-bus object 75 phosphor::dump::Entry::delete_(); 76 } 77 } // namespace system 78 } // namespace dump 79 } // namespace openpower 80