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