Modify clearSEL
After clearing the log, adding the log does not start from 1,
use deleteAll method to clearSEL.
Tested :Run `ipmitool sel clear&&ipmitool sel list`:
1 | 05/23/21 | 09:01:11 UTC | Event Logging Disabled #0x8b | Log area reset/cleared | Asserted
Signed-off-by: Lotus Xu <xuxiaohan@bytedance.com>
Change-Id: Ic1e63c3334adf77f54f36bebfed459138a215f06
diff --git a/selutility.hpp b/selutility.hpp
index 91c4eaf..fa28fb1 100644
--- a/selutility.hpp
+++ b/selutility.hpp
@@ -22,6 +22,10 @@
static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry";
static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete";
+static constexpr auto logObj = "/xyz/openbmc_project/logging";
+static constexpr auto logIntf = "xyz.openbmc_project.Collection.DeleteAll";
+static constexpr auto logDeleteAllMethod = "DeleteAll";
+
static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
using ObjectPaths = std::vector<std::string>;
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 18a42e2..b225e30 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -510,63 +510,20 @@
cancelSELReservation();
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
- ipmi::sel::ObjectPaths objectPaths;
- auto depth = 0;
-
- auto mapperCall =
- bus.new_method_call(ipmi::sel::mapperBusName, ipmi::sel::mapperObjPath,
- ipmi::sel::mapperIntf, "GetSubTreePaths");
- mapperCall.append(ipmi::sel::logBasePath);
- mapperCall.append(depth);
- mapperCall.append(ipmi::sel::ObjectPaths({ipmi::sel::logEntryIntf}));
-
+ auto service = ipmi::getService(bus, ipmi::sel::logIntf, ipmi::sel::logObj);
+ auto method =
+ bus.new_method_call(service.c_str(), ipmi::sel::logObj,
+ ipmi::sel::logIntf, ipmi::sel::logDeleteAllMethod);
try
{
- auto reply = bus.call(mapperCall);
- if (reply.is_method_error())
- {
- return ipmi::responseSuccess(
- static_cast<uint8_t>(ipmi::sel::eraseComplete));
- }
-
- reply.read(objectPaths);
- if (objectPaths.empty())
- {
- return ipmi::responseSuccess(
- static_cast<uint8_t>(ipmi::sel::eraseComplete));
- }
+ bus.call_noreply(method);
}
catch (const sdbusplus::exception::exception& e)
{
- return ipmi::responseSuccess(
- static_cast<uint8_t>(ipmi::sel::eraseComplete));
- }
-
- std::string service;
-
- try
- {
- service = ipmi::getService(bus, ipmi::sel::logDeleteIntf,
- objectPaths.front());
- }
- catch (const std::runtime_error& e)
- {
- log<level::ERR>(e.what());
+ log<level::ERR>("Error eraseAll ", entry("ERROR=%s", e.what()));
return ipmi::responseUnspecifiedError();
}
- for (const auto& iter : objectPaths)
- {
- auto methodCall = bus.new_method_call(
- service.c_str(), iter.c_str(), ipmi::sel::logDeleteIntf, "Delete");
-
- auto reply = bus.call(methodCall);
- if (reply.is_method_error())
- {
- return ipmi::responseUnspecifiedError();
- }
- }
-
return ipmi::responseSuccess(
static_cast<uint8_t>(ipmi::sel::eraseComplete));
}