Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 1 | #include "file_io_type_dump.hpp" |
| 2 | |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 3 | #include "common/utils.hpp" |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 4 | #include "utils.hpp" |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Common/error.hpp" |
| 6 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 7 | #include <libpldm/base.h> |
| 8 | #include <libpldm/file_io.h> |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | #include <systemd/sd-bus.h> |
| 11 | #include <unistd.h> |
| 12 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 13 | #include <phosphor-logging/lg2.hpp> |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 14 | #include <sdbusplus/server.hpp> |
| 15 | #include <xyz/openbmc_project/Dump/NewDump/server.hpp> |
| 16 | |
George Liu | 6492f52 | 2020-06-16 10:34:05 +0800 | [diff] [blame] | 17 | #include <exception> |
| 18 | #include <filesystem> |
| 19 | #include <iostream> |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 20 | #include <type_traits> |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 21 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 22 | PHOSPHOR_LOG2_USING; |
| 23 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 24 | using namespace pldm::responder::utils; |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 25 | using namespace pldm::utils; |
| 26 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 27 | namespace pldm |
| 28 | { |
| 29 | namespace responder |
| 30 | { |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 31 | static constexpr auto dumpEntry = "xyz.openbmc_project.Dump.Entry"; |
Deepak Kodihalli | 14b54a3 | 2020-09-29 05:20:02 -0500 | [diff] [blame] | 32 | static constexpr auto dumpObjPath = "/xyz/openbmc_project/dump/system"; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 33 | static constexpr auto systemDumpEntry = "xyz.openbmc_project.Dump.Entry.System"; |
| 34 | static constexpr auto resDumpObjPath = "/xyz/openbmc_project/dump/resource"; |
| 35 | static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource"; |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 36 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 37 | // Resource dump file path to be deleted once hyperviosr validates the input |
| 38 | // parameters. Need to re-look in to this name when we support multiple |
| 39 | // resource dumps. |
| 40 | static constexpr auto resDumpDirPath = "/var/lib/pldm/resourcedump/1"; |
| 41 | |
| 42 | int DumpHandler::fd = -1; |
| 43 | namespace fs = std::filesystem; |
| 44 | |
| 45 | std::string DumpHandler::findDumpObjPath(uint32_t fileHandle) |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 46 | { |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 47 | static constexpr auto DUMP_MANAGER_BUSNAME = |
| 48 | "xyz.openbmc_project.Dump.Manager"; |
| 49 | static constexpr auto DUMP_MANAGER_PATH = "/xyz/openbmc_project/dump"; |
| 50 | static constexpr auto OBJECT_MANAGER_INTERFACE = |
| 51 | "org.freedesktop.DBus.ObjectManager"; |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 52 | auto& bus = pldm::utils::DBusHandler::getBus(); |
| 53 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 54 | // Stores the current resource dump entry path |
| 55 | std::string curResDumpEntryPath{}; |
| 56 | |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 57 | dbus::ObjectValueTree objects; |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 58 | // Select the dump entry interface for system dump or resource dump |
| 59 | DumpEntryInterface dumpEntryIntf = systemDumpEntry; |
| 60 | if ((dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP) || |
| 61 | (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS)) |
| 62 | { |
| 63 | dumpEntryIntf = resDumpEntry; |
| 64 | } |
| 65 | |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 66 | try |
| 67 | { |
Archana Kakani | 040c618 | 2023-02-20 07:01:51 -0600 | [diff] [blame] | 68 | auto method = |
| 69 | bus.new_method_call(DUMP_MANAGER_BUSNAME, DUMP_MANAGER_PATH, |
| 70 | OBJECT_MANAGER_INTERFACE, "GetManagedObjects"); |
| 71 | |
vkaverap@in.ibm.com | 9138c20 | 2023-05-19 07:50:47 -0500 | [diff] [blame] | 72 | auto reply = bus.call( |
| 73 | method, |
| 74 | std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count()); |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 75 | reply.read(objects); |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 76 | } |
Archana Kakani | 040c618 | 2023-02-20 07:01:51 -0600 | [diff] [blame] | 77 | catch (const sdbusplus::exception_t& e) |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 78 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 79 | error( |
| 80 | "findDumpObjPath: Error {ERR_EXCEP} found with GetManagedObjects call in findDumpObjPath with objPath={OBJ_PATH} and intf={DUMP_INFT}", |
| 81 | "ERR_EXCEP", e.what(), "OBJ_PATH", DUMP_MANAGER_PATH, "DUMP_INFT", |
| 82 | dumpEntryIntf); |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 83 | return curResDumpEntryPath; |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 84 | } |
| 85 | |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 86 | for (const auto& object : objects) |
| 87 | { |
| 88 | for (const auto& interface : object.second) |
| 89 | { |
| 90 | if (interface.first != dumpEntryIntf) |
| 91 | { |
| 92 | continue; |
| 93 | } |
| 94 | |
| 95 | for (auto& propertyMap : interface.second) |
| 96 | { |
| 97 | if (propertyMap.first == "SourceDumpId") |
| 98 | { |
| 99 | auto dumpIdPtr = std::get_if<uint32_t>(&propertyMap.second); |
| 100 | if (dumpIdPtr != nullptr) |
| 101 | { |
| 102 | auto dumpId = *dumpIdPtr; |
| 103 | if (fileHandle == dumpId) |
| 104 | { |
| 105 | curResDumpEntryPath = object.first.str; |
| 106 | return curResDumpEntryPath; |
| 107 | } |
| 108 | } |
| 109 | else |
| 110 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 111 | error( |
| 112 | "Invalid SourceDumpId in curResDumpEntryPath {CUR_RES_DUMP_PATH} but continuing with next entry for a match...", |
| 113 | "CUR_RES_DUMP_PATH", curResDumpEntryPath); |
Jayashankar Padath | e7cc869 | 2022-09-06 13:26:22 -0500 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 119 | return curResDumpEntryPath; |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 120 | } |
| 121 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 122 | int DumpHandler::newFileAvailable(uint64_t length) |
| 123 | { |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 124 | static constexpr auto dumpInterface = "xyz.openbmc_project.Dump.NewDump"; |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 125 | auto& bus = pldm::utils::DBusHandler::getBus(); |
| 126 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 127 | auto notifyObjPath = dumpObjPath; |
| 128 | if (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP) |
| 129 | { |
| 130 | // Setting the Notify path for resource dump |
| 131 | notifyObjPath = resDumpObjPath; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 132 | } |
| 133 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 134 | try |
| 135 | { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 136 | auto service = pldm::utils::DBusHandler().getService(notifyObjPath, |
| 137 | dumpInterface); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 138 | using namespace sdbusplus::xyz::openbmc_project::Dump::server; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 139 | auto method = bus.new_method_call(service.c_str(), notifyObjPath, |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 140 | dumpInterface, "Notify"); |
Dhruvaraj Subhashchandran | 41989eb | 2020-11-27 00:22:42 -0600 | [diff] [blame] | 141 | method.append(fileHandle, length); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 142 | bus.call_noreply(method); |
| 143 | } |
| 144 | catch (const std::exception& e) |
| 145 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 146 | error( |
| 147 | "newFileAvailable: Error {ERR_EXCEP} found while notifying new dump to dump manager with objPath={OBJ_PATH} and intf={DUMP_INTF}", |
| 148 | "ERR_EXCEP", e.what(), "OBJ_PATH", notifyObjPath, "DUMP_INTF", |
| 149 | dumpInterface); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 150 | return PLDM_ERROR; |
| 151 | } |
| 152 | |
| 153 | return PLDM_SUCCESS; |
| 154 | } |
| 155 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 156 | std::string DumpHandler::getOffloadUri(uint32_t fileHandle) |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 157 | { |
| 158 | auto path = findDumpObjPath(fileHandle); |
| 159 | if (path.empty()) |
| 160 | { |
| 161 | return {}; |
| 162 | } |
| 163 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 164 | std::string socketInterface{}; |
| 165 | |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 166 | try |
| 167 | { |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 168 | socketInterface = |
| 169 | pldm::utils::DBusHandler().getDbusProperty<std::string>( |
| 170 | path.c_str(), "OffloadUri", dumpEntry); |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 171 | } |
| 172 | catch (const std::exception& e) |
| 173 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 174 | error( |
| 175 | "getOffloadUri: Error {ERR_EXCEP} found while fetching the dump offload URI with objPath={OBJ_PATH} and intf={SOCKET_INTF}", |
| 176 | "ERR_EXCEP", e.what(), "OBJ_PATH", path.c_str(), "SOCKET_INTF", |
| 177 | socketInterface); |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 178 | } |
| 179 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 180 | return socketInterface; |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 181 | } |
| 182 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 183 | int DumpHandler::writeFromMemory(uint32_t, uint32_t length, uint64_t address, |
Sampa Misra | 6950850 | 2020-09-08 00:08:21 -0500 | [diff] [blame] | 184 | oem_platform::Handler* /*oemPlatformHandler*/) |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 185 | { |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 186 | if (DumpHandler::fd == -1) |
| 187 | { |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 188 | auto socketInterface = getOffloadUri(fileHandle); |
| 189 | int sock = setupUnixSocket(socketInterface); |
| 190 | if (sock < 0) |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 191 | { |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 192 | sock = -errno; |
| 193 | close(DumpHandler::fd); |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 194 | error("DumpHandler::writeFromMemory: setupUnixSocket() failed"); |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 195 | std::remove(socketInterface.c_str()); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 196 | return PLDM_ERROR; |
| 197 | } |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 198 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 199 | DumpHandler::fd = sock; |
| 200 | } |
| 201 | return transferFileDataToSocket(DumpHandler::fd, length, address); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 202 | } |
| 203 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 204 | int DumpHandler::write(const char* buffer, uint32_t, uint32_t& length, |
Sampa Misra | 6950850 | 2020-09-08 00:08:21 -0500 | [diff] [blame] | 205 | oem_platform::Handler* /*oemPlatformHandler*/) |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 206 | { |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 207 | int rc = writeToUnixSocket(DumpHandler::fd, buffer, length); |
| 208 | if (rc < 0) |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 209 | { |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 210 | rc = -errno; |
| 211 | close(DumpHandler::fd); |
| 212 | auto socketInterface = getOffloadUri(fileHandle); |
| 213 | std::remove(socketInterface.c_str()); |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 214 | error("DumpHandler::write: writeToUnixSocket() failed"); |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 215 | return PLDM_ERROR; |
| 216 | } |
| 217 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 218 | return PLDM_SUCCESS; |
| 219 | } |
| 220 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 221 | int DumpHandler::fileAck(uint8_t fileStatus) |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 222 | { |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 223 | auto path = findDumpObjPath(fileHandle); |
| 224 | if (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS) |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 225 | { |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 226 | if (fileStatus != PLDM_SUCCESS) |
| 227 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 228 | error("Failue in resource dump file ack"); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 229 | pldm::utils::reportError( |
| 230 | "xyz.openbmc_project.bmc.pldm.InternalFailure"); |
| 231 | |
| 232 | PropertyValue value{ |
| 233 | "xyz.openbmc_project.Common.Progress.OperationStatus.Failed"}; |
| 234 | DBusMapping dbusMapping{path, "xyz.openbmc_project.Common.Progress", |
| 235 | "Status", "string"}; |
| 236 | try |
| 237 | { |
| 238 | pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value); |
| 239 | } |
| 240 | catch (const std::exception& e) |
| 241 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 242 | error( |
| 243 | "fileAck: Error {ERR_EXCEP} found while setting the dump progress status as Failed with objPath={OBJ_PATH} and intf=Common.Progress", |
| 244 | "ERR_EXCEP", e.what(), "OBJ_PATH", path.c_str()); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
| 248 | if (fs::exists(resDumpDirPath)) |
| 249 | { |
| 250 | fs::remove_all(resDumpDirPath); |
| 251 | } |
| 252 | return PLDM_SUCCESS; |
| 253 | } |
| 254 | |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 255 | if (!path.empty()) |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 256 | { |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 257 | if (fileStatus == PLDM_ERROR_FILE_DISCARDED) |
| 258 | { |
| 259 | uint32_t val = 0xFFFFFFFF; |
| 260 | PropertyValue value = static_cast<uint32_t>(val); |
| 261 | auto dumpIntf = resDumpEntry; |
| 262 | |
| 263 | if (dumpType == PLDM_FILE_TYPE_DUMP) |
| 264 | { |
| 265 | dumpIntf = systemDumpEntry; |
| 266 | } |
| 267 | |
| 268 | DBusMapping dbusMapping{path.c_str(), dumpIntf, "SourceDumpId", |
| 269 | "uint32_t"}; |
| 270 | try |
| 271 | { |
| 272 | pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value); |
| 273 | } |
| 274 | catch (const std::exception& e) |
| 275 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 276 | error( |
| 277 | "fileAck: Failed to make a d-bus call to DUMP manager to reset source dump id of {FILE_PATH}, with ERROR={ERR_EXCEP}", |
| 278 | "FILE_PATH", path.c_str(), "ERR_EXCEP", e.what()); |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 279 | pldm::utils::reportError( |
| 280 | "xyz.openbmc_project.bmc.PLDM.fileAck.SourceDumpIdResetFail"); |
| 281 | return PLDM_ERROR; |
| 282 | } |
| 283 | |
| 284 | auto& bus = pldm::utils::DBusHandler::getBus(); |
| 285 | try |
| 286 | { |
| 287 | auto method = bus.new_method_call( |
| 288 | "xyz.openbmc_project.Dump.Manager", path.c_str(), |
| 289 | "xyz.openbmc_project.Object.Delete", "Delete"); |
vkaverap@in.ibm.com | 9138c20 | 2023-05-19 07:50:47 -0500 | [diff] [blame] | 290 | bus.call(method, |
| 291 | std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)) |
| 292 | .count()); |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 293 | } |
| 294 | catch (const std::exception& e) |
| 295 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 296 | error( |
| 297 | "fileAck: Failed to make a d-bus method to delete the dump entry {FILE_PATH}, with ERROR={ERR_EXCEP}", |
| 298 | "FILE_PATH", path.c_str(), "ERR_EXCEP", e.what()); |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 299 | pldm::utils::reportError( |
| 300 | "xyz.openbmc_project.bmc.PLDM.fileAck.DumpEntryDeleteFail"); |
| 301 | return PLDM_ERROR; |
| 302 | } |
| 303 | return PLDM_SUCCESS; |
| 304 | } |
| 305 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 306 | if (dumpType == PLDM_FILE_TYPE_DUMP || |
| 307 | dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP) |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 308 | { |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 309 | PropertyValue value{true}; |
| 310 | DBusMapping dbusMapping{path, dumpEntry, "Offloaded", "bool"}; |
| 311 | try |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 312 | { |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 313 | pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value); |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 314 | } |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 315 | catch (const std::exception& e) |
| 316 | { |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 317 | error( |
| 318 | "fileAck: Failed to make a d-bus method to set the dump offloaded property to true with path={FILE_PATH} and with ERROR={ERR_EXCEP}", |
| 319 | "FILE_PATH", path.c_str(), "ERR_EXCEP", e.what()); |
Deepak Kodihalli | 8cd6068 | 2020-04-02 02:59:22 -0500 | [diff] [blame] | 320 | } |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 321 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 322 | auto socketInterface = getOffloadUri(fileHandle); |
| 323 | std::remove(socketInterface.c_str()); |
Jayashankar Padath | 6289ea1 | 2022-06-13 12:33:10 -0500 | [diff] [blame] | 324 | if (DumpHandler::fd >= 0) |
| 325 | { |
| 326 | close(DumpHandler::fd); |
| 327 | DumpHandler::fd = -1; |
| 328 | } |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 329 | } |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 330 | return PLDM_SUCCESS; |
Deepak Kodihalli | fd279e1 | 2020-02-02 05:20:43 -0600 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | return PLDM_ERROR; |
| 334 | } |
| 335 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 336 | int DumpHandler::readIntoMemory(uint32_t offset, uint32_t& length, |
| 337 | uint64_t address, |
| 338 | oem_platform::Handler* /*oemPlatformHandler*/) |
| 339 | { |
| 340 | if (dumpType != PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS) |
| 341 | { |
| 342 | return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; |
| 343 | } |
| 344 | return transferFileData(resDumpDirPath, true, offset, length, address); |
| 345 | } |
| 346 | |
| 347 | int DumpHandler::read(uint32_t offset, uint32_t& length, Response& response, |
| 348 | oem_platform::Handler* /*oemPlatformHandler*/) |
| 349 | { |
| 350 | if (dumpType != PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS) |
| 351 | { |
| 352 | return PLDM_ERROR_UNSUPPORTED_PLDM_CMD; |
| 353 | } |
| 354 | return readFile(resDumpDirPath, offset, length, response); |
| 355 | } |
| 356 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 357 | } // namespace responder |
| 358 | } // namespace pldm |