diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-08-06 18:46:27 +0530 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-09-12 15:39:46 +0000 |
commit | e59abfbade094966f45d3de796e7b15ea736732d (patch) | |
tree | 587eee1e0b94f176c0f411714ee703afd0795daa /storagehandler.cpp | |
parent | dd0459e027105e66de146f7be36d85aade93f302 (diff) | |
download | phosphor-host-ipmid-e59abfbade094966f45d3de796e7b15ea736732d.tar.gz phosphor-host-ipmid-e59abfbade094966f45d3de796e7b15ea736732d.zip |
Handle SdBusError exception in SEL commands
Change-Id: Ia79b3e2ea4ca8783c912c9864be32107d170d561
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'storagehandler.cpp')
-rw-r--r-- | storagehandler.cpp | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/storagehandler.cpp b/storagehandler.cpp index 72a0c08..871eae6 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -112,7 +112,18 @@ ipmi_ret_t getSELInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd, responseData->eraseTimeStamp = ipmi::sel::invalidTimeStamp; responseData->operationSupport = ipmi::sel::operationSupport; - ipmi::sel::readLoggingObjectPaths(cache::paths); + try + { + ipmi::sel::readLoggingObjectPaths(cache::paths); + } + catch (const sdbusplus::exception::SdBusError& e) + { + // No action if reading log objects have failed for this command. + // readLoggingObjectPaths will throw exception if there are no log + // entries. The command will be responded with number of SEL entries + // as 0. + } + responseData->entries = 0; responseData->addTimeStamp = ipmi::sel::invalidTimeStamp; @@ -267,7 +278,17 @@ ipmi_ret_t deleteSELEntry(ipmi_netfn_t netfn, ipmi_cmd_t cmd, return IPMI_CC_INVALID_RESERVATION_ID; } - ipmi::sel::readLoggingObjectPaths(cache::paths); + try + { + ipmi::sel::readLoggingObjectPaths(cache::paths); + } + catch (const sdbusplus::exception::SdBusError& e) + { + // readLoggingObjectPaths will throw exception if there are no error + // log entries. + *data_len = 0; + return IPMI_CC_SENSOR_INVALID; + } if (cache::paths.empty()) { @@ -371,6 +392,7 @@ ipmi_ret_t clearSEL(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, } sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; + ipmi::sel::ObjectPaths objectPaths; auto depth = 0; auto mapperCall = @@ -380,17 +402,25 @@ ipmi_ret_t clearSEL(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, mapperCall.append(depth); mapperCall.append(ipmi::sel::ObjectPaths({ipmi::sel::logEntryIntf})); - auto reply = bus.call(mapperCall); - if (reply.is_method_error()) + try { - memcpy(response, &eraseProgress, sizeof(eraseProgress)); - *data_len = sizeof(eraseProgress); - return IPMI_CC_OK; - } + auto reply = bus.call(mapperCall); + if (reply.is_method_error()) + { + memcpy(response, &eraseProgress, sizeof(eraseProgress)); + *data_len = sizeof(eraseProgress); + return IPMI_CC_OK; + } - ipmi::sel::ObjectPaths objectPaths; - reply.read(objectPaths); - if (objectPaths.empty()) + reply.read(objectPaths); + if (objectPaths.empty()) + { + memcpy(response, &eraseProgress, sizeof(eraseProgress)); + *data_len = sizeof(eraseProgress); + return IPMI_CC_OK; + } + } + catch (const sdbusplus::exception::SdBusError& e) { memcpy(response, &eraseProgress, sizeof(eraseProgress)); *data_len = sizeof(eraseProgress); |