Add elog dump type to common create
This commit modifies the Elog BMC dump creation process
to utilize the common BMC dump creation interface. Elog
BMC dumps are a special type of dumps triggered upon the
logging of certain predefined set of error logs. These
dumps incorporate data based on the type of the error log.
If no error log type is specified, a default elog dump
will be generated. In the existing process, upon occurrence
of a predefined error log, the error log manager would
inform the dump manager via an internal DBus interface. Now,
with this change, the error log manager will request the
dump manager to create an Elog BMC dump that includes the
relevant error data, error type, and the object path of the
error log entry via the common create DBus interface.
Test:
Create an InternalFailure and sure dump is created
>busctl call xyz.openbmc_project.Logging \
/xyz/openbmc_project/logging \
xyz.openbmc_project.Logging.Create Create ssa{ss} \
xyz.openbmc_project.Common.Error.InternalFailure \
xyz.openbmc_project.Logging.Entry.Level.Error 0
Trace:
phosphor-dump-manager[542]: Initiating new BMC dump \
with type: elog path: /xyz/openbmc_project/logging/entry/12
phosphor-dump-manager[2918]: Report is available in \
/var/lib/phosphor-debug-collector/dumps/6
Change-Id: I734b052fc24e7893a61755790be49e8a1e594be5
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/dump_manager_bmc.cpp b/dump_manager_bmc.cpp
index 6c99099..d41979a 100644
--- a/dump_manager_bmc.cpp
+++ b/dump_manager_bmc.cpp
@@ -69,6 +69,11 @@
{
dumpType = validateDumpType(type, BMC_DUMP);
}
+
+ if (dumpType == DumpTypes::ELOG)
+ {
+ dumpType = getErrorDumpType(params);
+ }
std::string path = extractParameter<std::string>(
convertCreateParametersToString(CreateParameters::FilePath), params);
diff --git a/dump_manager_main.cpp b/dump_manager_main.cpp
index 68b0bc0..bad1bad 100644
--- a/dump_manager_main.cpp
+++ b/dump_manager_main.cpp
@@ -71,6 +71,8 @@
phosphor::dump::bmc::internal::Manager mgr(bus, *bmcDumpMgr,
OBJ_INTERNAL);
+
+ phosphor::dump::elog::Watch eWatch(bus, *bmcDumpMgr);
dumpMgrList.push_back(std::move(bmcDumpMgr));
std::unique_ptr<phosphor::dump::faultlog::Manager> faultLogMgr =
@@ -87,7 +89,6 @@
dmpMgr->restore();
}
- phosphor::dump::elog::Watch eWatch(bus, mgr);
bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
// Daemon is all set up so claim the busname now.
diff --git a/dump_types.cpp b/dump_types.cpp
index d64664e..817f823 100644
--- a/dump_types.cpp
+++ b/dump_types.cpp
@@ -9,12 +9,15 @@
{"xyz.openbmc_project.Dump.Create.DumpType.ApplicationCored",
{DumpTypes::CORE, "BMC_DUMP"}},
{"xyz.openbmc_project.Dump.Create.DumpType.Ramoops",
- {DumpTypes::RAMOOPS, "BMC_DUMP"}}};
+ {DumpTypes::RAMOOPS, "BMC_DUMP"}},
+ {"xyz.openbmc_project.Dump.Create.DumpType.ErrorLog",
+ {DumpTypes::ELOG, "elog"}}};
DUMP_TYPE_TO_STRING_MAP dumpTypeToStringMap = {
{DumpTypes::USER, "user"},
{DumpTypes::CORE, "core"},
{DumpTypes::RAMOOPS, "ramoops"},
+ {DumpTypes::ELOG, "elog"},
};
} // namespace dump
} // namespace phosphor
diff --git a/dump_types.hpp b/dump_types.hpp
index 9a54b09..219b10d 100644
--- a/dump_types.hpp
+++ b/dump_types.hpp
@@ -24,6 +24,7 @@
USER,
CORE,
RAMOOPS,
+ ELOG,
};
// A table of dump types
diff --git a/dump_utils.hpp b/dump_utils.hpp
index c3d9d36..953022e 100644
--- a/dump_utils.hpp
+++ b/dump_utils.hpp
@@ -5,11 +5,13 @@
#include <systemd/sd-event.h>
#include <unistd.h>
+#include <errors_map.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Dump/Create/common.hpp>
#include <xyz/openbmc_project/Dump/Create/server.hpp>
#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
#include <xyz/openbmc_project/State/Host/server.hpp>
@@ -356,5 +358,35 @@
return T{};
}
+/**
+ * @brief This function fetches the dump type associated with a particular
+ * error.
+ *
+ * @param[in] params The map of parameters passed as input.
+ *
+ * @return The dump type associated with the error. If no additional error type
+ * is specified a generic elog type dump will be generated.
+ */
+inline DumpTypes getErrorDumpType(phosphor::dump::DumpCreateParams& params)
+{
+ using CreateParameters =
+ sdbusplus::xyz::openbmc_project::Dump::server::Create::CreateParameters;
+ using DumpIntr = sdbusplus::common::xyz::openbmc_project::dump::Create;
+ DumpTypes dumpType = DumpTypes::ELOG;
+ std::string errorType = extractParameter<std::string>(
+ DumpIntr::convertCreateParametersToString(CreateParameters::ErrorType),
+ params);
+ const auto elogIt = errorMap.find(errorType);
+ if (elogIt != errorMap.end())
+ {
+ auto type = stringToDumpType(errorType);
+ if (type.has_value())
+ {
+ dumpType = type.value();
+ }
+ }
+ return dumpType;
+}
+
} // namespace dump
} // namespace phosphor
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 84eaff8..d43ca48 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -32,8 +32,8 @@
using PropertyName = std::string;
using PropertyMap = std::map<PropertyName, AttributeMap>;
-Watch::Watch(sdbusplus::bus_t& bus, IMgr& iMgr) :
- iMgr(iMgr),
+Watch::Watch(sdbusplus::bus_t& bus, Mgr& mgr) :
+ mgr(mgr),
addMatch(bus,
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::path_namespace(OBJ_LOGGING),
@@ -126,9 +126,19 @@
return;
}
- std::vector<std::string> fullPaths;
- fullPaths.push_back(objectPath);
-
+ DumpCreateParams params;
+ using DumpIntr = sdbusplus::common::xyz::openbmc_project::dump::Create;
+ using CreateParameters =
+ sdbusplus::common::xyz::openbmc_project::dump::Create::CreateParameters;
+ using DumpType =
+ sdbusplus::common::xyz::openbmc_project::dump::Create::DumpType;
+ params[DumpIntr::convertCreateParametersToString(
+ CreateParameters::FilePath)] = objectPath;
+ params[DumpIntr::convertCreateParametersToString(
+ CreateParameters::DumpType)] =
+ DumpIntr::convertDumpTypeToString(DumpType::ErrorLog);
+ params[DumpIntr::convertCreateParametersToString(
+ CreateParameters::ErrorType)] = errorType;
try
{
// Save the elog information. This is to avoid dump requests
@@ -136,16 +146,7 @@
elogList.insert(eId);
phosphor::dump::elog::serialize(elogList);
-
- auto item = std::find_if(phosphor::dump::bmc::TypeMap.begin(),
- phosphor::dump::bmc::TypeMap.end(),
- [errorType](const auto& err) {
- return (err.second == errorType);
- });
- if (item != phosphor::dump::bmc::TypeMap.end())
- {
- iMgr.IMgr::create((*item).first, fullPaths);
- }
+ mgr.Mgr::createDump(params);
}
catch (const QuotaExceeded& e)
{
diff --git a/elog_watch.hpp b/elog_watch.hpp
index 3806ed8..9fa270a 100644
--- a/elog_watch.hpp
+++ b/elog_watch.hpp
@@ -7,6 +7,7 @@
#include <cereal/access.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/Dump/Create/server.hpp>
#include <filesystem>
#include <set>
@@ -18,7 +19,7 @@
namespace elog
{
-using IMgr = phosphor::dump::bmc::internal::Manager;
+using Mgr = phosphor::dump::bmc::Manager;
using EId = uint32_t;
using ElogList = std::set<EId>;
@@ -41,7 +42,7 @@
* @param[in] bus - The Dbus bus object
* @param[in] intMgr - Dump internal Manager object
*/
- Watch(sdbusplus::bus_t& bus, IMgr& iMgr);
+ Watch(sdbusplus::bus_t& bus, Mgr& mgr);
private:
friend class cereal::access;
@@ -84,8 +85,8 @@
return std::stoul(path.filename());
}
- /** @brief Dump internal Manager object. */
- IMgr& iMgr;
+ /** @brief BMC Dump Manager object. */
+ Mgr& mgr;
/** @brief sdbusplus signal match for elog add */
sdbusplus::bus::match_t addMatch;