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