dbus-sdr:storagecommands: Add option to use Clear method
There is support in phosphor-sel-logger to clear the SEL files
through its Clear method from,
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-sel-logger/+/45438
The Clear method API was added through,
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/45402
The packageconfig option is added through,
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/49032
This change will create an option to configure the Clear SEL IPMI
command to call the Clear method, so the Record ID can be restarted
after a clear. If the clears-sel option from phosphor-sel-logger is
used while the IPMI SEL Clear clears the SEL log files, then the
Record ID will not restart at 1.
Tested:
- Enabled clears-sel in phosphor-sel-logger
- Enabled sel-logger-clears-sel through packageconfig, and after
a Clear SEL command, new SEL entries restarted at Record ID 1
as intended.
- With sel-logger-clears-sel disabled, the SEL entries continued
after the latest Record ID before the clear. This indicates that
the SEL files were cleared by the IPMI Clear SEL command.
Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I4461b4ba7449c12e276b1b0e0e7d54ace611643f
diff --git a/configure.ac b/configure.ac
index 2c05fdd..4902c2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,6 +320,24 @@
AC_MSG_WARN([Disabling sensors cache feature])
)
+# Clearing SEL through sel-logger is disabled by default; offer a way to enable it
+AC_ARG_ENABLE([sel_logger_clears_sel],
+ [ --enable-sel_logger_clears_sel Enable/disable sel-logger to Clear SEL],
+ [case "${enableval}" in
+ yes) sel_logger_clears_sel=true ;;
+ no) sel_logger_clears_sel=false ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-sel_logger_clears_sel]) ;;
+ esac],[sel_logger_clears_sel=false]
+ )
+AM_CONDITIONAL([FEATURE_SEL_LOGGER_CLEARS_SEL], [test x$sel_logger_clears_sel = xtrue])
+
+AS_IF([test x$sel_logger_clears_sel = xtrue],
+ AC_MSG_NOTICE([Enabling sel-logger to Clear SEL])
+ [cpp_flags="$cpp_flags -DFEATURE_SEL_LOGGER_CLEARS_SEL"]
+ AC_SUBST([CPPFLAGS], [$cpp_flags]),
+ AC_MSG_WARN([Disabling sel-logger to Clear SEL])
+)
+
# Create configured output
AC_CONFIG_FILES([
Makefile
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index b76aa5e..09d71d0 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -97,6 +97,8 @@
boost::container::flat_map<sdbusplus::message::object_path, ObjectType>;
using ManagedEntry = std::pair<sdbusplus::message::object_path, ObjectType>;
+constexpr static const char* selLoggerServiceName =
+ "xyz.openbmc_project.Logging.IPMI";
constexpr static const char* fruDeviceServiceName =
"xyz.openbmc_project.FruDevice";
constexpr static const char* entityManagerServiceName =
@@ -1128,6 +1130,7 @@
// cleared
cancelSELReservation();
+#ifndef FEATURE_SEL_LOGGER_CLEARS_SEL
// Save the erase time
dynamic_sensors::ipmi::sel::erase_time::save();
@@ -1156,7 +1159,20 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
}
+#else
+ boost::system::error_code ec;
+ ctx->bus->yield_method_call<>(ctx->yield, ec, selLoggerServiceName,
+ "/xyz/openbmc_project/Logging/IPMI",
+ "xyz.openbmc_project.Logging.IPMI", "Clear");
+ if (ec)
+ {
+ std::cerr << "error in clear SEL: " << ec << std::endl;
+ return ipmi::responseUnspecifiedError();
+ }
+ // Save the erase time
+ dynamic_sensors::ipmi::sel::erase_time::save();
+#endif
return ipmi::responseSuccess(ipmi::sel::eraseComplete);
}