oem-ibm: Dump entry delete support
This commit includes following changes:
1. Support to delete the resource or system dump entry after dump
was being offloaded to operating system in non-hmc managed
systems
2. Changed the bus call method for not to use noreply option
Signed-off-by: Jayashankar Padath <jayashankar.padath@in.ibm.com>
Change-Id: Ia2f7554ad45be05cdaa0c8aa8b78b1c11aa3a401
diff --git a/libpldm/oem/ibm/libpldm/file_io.h b/libpldm/oem/ibm/libpldm/file_io.h
index 5586b86..c78627f 100644
--- a/libpldm/oem/ibm/libpldm/file_io.h
+++ b/libpldm/oem/ibm/libpldm/file_io.h
@@ -36,6 +36,7 @@
PLDM_INVALID_FILE_HANDLE = 0x86,
PLDM_DATA_OUT_OF_RANGE = 0x87,
PLDM_INVALID_FILE_TYPE = 0x89,
+ PLDM_ERROR_FILE_DISCARDED = 0x8A,
};
/** @brief PLDM File I/O table types
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index 37cbb56..ffb1d88 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -237,8 +237,56 @@
return PLDM_SUCCESS;
}
- if (DumpHandler::fd >= 0 && !path.empty())
+ if (!path.empty())
{
+ if (fileStatus == PLDM_ERROR_FILE_DISCARDED)
+ {
+ uint32_t val = 0xFFFFFFFF;
+ PropertyValue value = static_cast<uint32_t>(val);
+ auto dumpIntf = resDumpEntry;
+
+ if (dumpType == PLDM_FILE_TYPE_DUMP)
+ {
+ dumpIntf = systemDumpEntry;
+ }
+
+ DBusMapping dbusMapping{path.c_str(), dumpIntf, "SourceDumpId",
+ "uint32_t"};
+ try
+ {
+ pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << "Failed to make a d-bus call to DUMP "
+ "manager to reset source dump id of "
+ << path.c_str() << ", with ERROR=" << e.what()
+ << "\n";
+ pldm::utils::reportError(
+ "xyz.openbmc_project.bmc.PLDM.fileAck.SourceDumpIdResetFail");
+ return PLDM_ERROR;
+ }
+
+ auto& bus = pldm::utils::DBusHandler::getBus();
+ try
+ {
+ auto method = bus.new_method_call(
+ "xyz.openbmc_project.Dump.Manager", path.c_str(),
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ bus.call(method);
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr
+ << "Failed to make a d-bus method to delete the dump entry "
+ << path.c_str() << ", with ERROR=" << e.what() << "\n";
+ pldm::utils::reportError(
+ "xyz.openbmc_project.bmc.PLDM.fileAck.DumpEntryDeleteFail");
+ return PLDM_ERROR;
+ }
+ return PLDM_SUCCESS;
+ }
+
if (dumpType == PLDM_FILE_TYPE_DUMP ||
dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP)
{
@@ -255,10 +303,13 @@
<< e.what() << "\n";
}
- close(DumpHandler::fd);
auto socketInterface = getOffloadUri(fileHandle);
std::remove(socketInterface.c_str());
- DumpHandler::fd = -1;
+ if (DumpHandler::fd >= 0)
+ {
+ close(DumpHandler::fd);
+ DumpHandler::fd = -1;
+ }
}
return PLDM_SUCCESS;
}