From 267c413f6d487341dbc674102dfea7eddc7d92c8 Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Fri, 25 Feb 2022 20:00:07 +0000 Subject: [PATCH] mmc: reset: Delete all BMC error logs 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 --- mmc/item_updater_mmc.cpp | 3 +++ utils.cpp | 20 ++++++++++++++++++++ utils.hpp | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/mmc/item_updater_mmc.cpp b/mmc/item_updater_mmc.cpp index 1a5b142..9541b08 100644 --- a/mmc/item_updater_mmc.cpp +++ b/mmc/item_updater_mmc.cpp @@ -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); diff --git a/utils.cpp b/utils.cpp index a994b33..a1ae101 100644 --- a/utils.cpp +++ b/utils.cpp @@ -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("Error deleting all error logs", + entry("ERROR=%s", e.what())); + } +} + } // namespace utils diff --git a/utils.hpp b/utils.hpp index 8ff2370..7588039 100644 --- a/utils.hpp +++ b/utils.hpp @@ -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