Skip to content

Commit

Permalink
mmc: reset: Delete all BMC error logs
Browse files Browse the repository at this point in the history
During a bios factory reset, the partition where hostboot stores their
error logs is cleared. Need to clear the BMC error logs too to avoid
discrepancies.

Tested: Verified the /var/lib/phosphor-logging/extensions/pels/logs/
directory was cleared after a bios factory reset except for the
'archive' subdirectory.

Change-Id: I273d7953fda053823cea93dc57b751de74ddef43
Signed-off-by: Adriana Kobylak <[email protected]>
  • Loading branch information
anoo1 committed Feb 25, 2022
1 parent 56a4677 commit 267c413
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mmc/item_updater_mmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void ItemUpdaterMMC::reset()
}
}

// Delete all BMC error logs to avoid discrepancies with the host error logs
utils::deleteAllErrorLogs(bus);

// Remove files related to the Hardware Management Console / BMC web app

utils::clearHMCManaged(bus);
Expand Down
20 changes: 20 additions & 0 deletions utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,24 @@ void clearHMCManaged(sdbusplus::bus::bus& bus)
}
}

void deleteAllErrorLogs(sdbusplus::bus::bus& bus)
{
constexpr auto loggingPath = "/xyz/openbmc_project/logging";
constexpr auto deleteAllIntf = "xyz.openbmc_project.Collection.DeleteAll";

auto service = getService(bus, loggingPath, deleteAllIntf);
auto method = bus.new_method_call(service.c_str(), loggingPath,
deleteAllIntf, "DeleteAll");

try
{
bus.call_noreply(method);
}
catch (const sdbusplus::exception::exception& e)
{
log<level::ERR>("Error deleting all error logs",
entry("ERROR=%s", e.what()));
}
}

} // namespace utils
6 changes: 6 additions & 0 deletions utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ void hiomapdResume(sdbusplus::bus::bus& bus);
*/
void clearHMCManaged(sdbusplus::bus::bus& bus);

/** @brief DeleteAll error logs
*
* @param[in] bus - The D-Bus bus object.
*/
void deleteAllErrorLogs(sdbusplus::bus::bus& bus);

} // namespace utils

#endif // OPENSSL_VERSION_NUMBER < 0x10100000L

0 comments on commit 267c413

Please sign in to comment.