summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xMakefile.am11
-rw-r--r--configure.ac4
-rw-r--r--dump_manager.cpp8
-rw-r--r--dump_manager.hpp7
-rw-r--r--elog_watch.cpp30
-rw-r--r--errors_map.mako.hpp18
-rwxr-xr-xerrors_map_gen.py31
-rw-r--r--example_errors_watch.yaml2
-rwxr-xr-xtools/dreport.d/dreport9
-rw-r--r--tools/dreport.d/sample.conf1
-rw-r--r--xyz/openbmc_project/Dump/Internal/Create.interface.yaml3
11 files changed, 107 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am
index 30f0331..9279a1d 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -55,7 +55,8 @@ phosphor_dump_monitor_LDADD = \
# Be sure to build needed files before compiling
BUILT_SOURCES = \
xyz/openbmc_project/Dump/Internal/Create/server.cpp \
- xyz/openbmc_project/Dump/Internal/Create/server.hpp
+ xyz/openbmc_project/Dump/Internal/Create/server.hpp \
+ errors_map.hpp
CLEANFILES=${BUILT_SOURCES}
@@ -71,3 +72,11 @@ xyz/openbmc_project/Dump/Internal/Create.interface.yaml
@mkdir -p `dirname $@`
$(SDBUSPLUSPLUS) -r $(srcdir) interface server-header \
xyz.openbmc_project.Dump.Internal.Create > $@
+
+ERROR_TEMPLATE ?= ${abs_srcdir}/errors_map.mako.hpp
+ERROR_REQ_FILES_TO_GEN ?= ${abs_srcdir}/errors_map_gen.py \
+ ${ERROR_TEMPLATE}
+
+EXTRA_DIST = $(ERROR_REQ_FILES_TO_GEN)
+errors_map.hpp: $(ERROR_REQ_FILES_TO_GEN)
+ $(AM_V_at)$(PYTHON) ${abs_srcdir}/errors_map_gen.py -i ${ERROR_MAP_YAML}
diff --git a/configure.ac b/configure.ac
index e108087..114e722 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,5 +96,9 @@ AS_IF([test "x$enable_ubifs_workaround" != "xno"],
[Turn on ubi workaround for core file])]
)
+AC_ARG_VAR(ERROR_MAP_YAML, [YAML filepath containing error object paths])
+AS_IF([test "x$ERROR_MAP_YAML" == "x"], \
+ [ERROR_MAP_YAML="example_errors_watch.yaml"])
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/dump_manager.cpp b/dump_manager.cpp
index d9326e0..21fca8a 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -40,12 +40,6 @@ uint32_t Manager::createDump()
uint32_t Manager::captureDump(Type type,
const std::vector<std::string>& fullPaths)
{
- // Type to dreport type string map
- static const std::map<Type, std::string> typeMap = {
- {Type::ApplicationCored, "core"},
- {Type::UserRequested, "user"},
- {Type::InternalFailure, "elog"}};
-
// Get Dump size.
auto size = getAllowedSize();
@@ -58,7 +52,7 @@ uint32_t Manager::captureDump(Type type,
dumpPath /= id;
// get dreport type map entry
- auto tempType = typeMap.find(type);
+ auto tempType = TypeMap.find(type);
execl("/usr/bin/dreport", "dreport", "-d", dumpPath.c_str(), "-i",
id.c_str(), "-s", std::to_string(size).c_str(), "-q", "-v", "-p",
diff --git a/dump_manager.hpp b/dump_manager.hpp
index f414752..694cf7b 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -37,6 +37,13 @@ namespace fs = std::experimental::filesystem;
using Watch = phosphor::dump::inotify::Watch;
+// Type to dreport type string map
+static const std::map<Type, std::string> TypeMap = {
+ {Type::ApplicationCored, "core"},
+ {Type::UserRequested, "user"},
+ {Type::InternalFailure, "elog"},
+ {Type::Checkstop, "checkstop"}};
+
/** @class Manager
* @brief OpenBMC Dump manager implementation.
* @details A concrete implementation for the
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 7369783..0a7789c 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -4,9 +4,11 @@
#include "dump_internal.hpp"
#include "dump_serialize.hpp"
+#include "errors_map.hpp"
#include "xyz/openbmc_project/Dump/Create/error.hpp"
#include <cereal/cereal.hpp>
+#include <fstream>
#include <phosphor-logging/elog.hpp>
#include <sdbusplus/exception.hpp>
@@ -22,8 +24,6 @@ namespace elog
using namespace phosphor::logging;
constexpr auto LOG_PATH = "/xyz/openbmc_project/logging";
-constexpr auto INTERNAL_FAILURE =
- "xyz.openbmc_project.Common.Error.InternalFailure";
using Message = std::string;
using Attributes = sdbusplus::message::variant<Message>;
using AttributeName = std::string;
@@ -57,8 +57,6 @@ Watch::Watch(sdbusplus::bus::bus& bus, IMgr& iMgr) :
void Watch::addCallback(sdbusplus::message::message& msg)
{
- using Type =
- sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type;
using QuotaExceeded =
sdbusplus::xyz::openbmc_project::Dump::Create::Error::QuotaExceeded;
@@ -112,9 +110,20 @@ void Watch::addCallback(sdbusplus::message::message& msg)
return;
}
- if (data != INTERNAL_FAILURE)
+ EType errorType;
+ for (const auto& [type, errorList] : errorMap)
+ {
+ auto error = std::find(errorList.begin(), errorList.end(), data);
+ if (error != errorList.end())
+ {
+ errorType = type;
+ break;
+ }
+ }
+
+ // error not supported in the configuration
+ if (errorType.empty())
{
- // Not a InternalFailure, skip
return;
}
@@ -129,8 +138,13 @@ void Watch::addCallback(sdbusplus::message::message& msg)
phosphor::dump::elog::serialize(elogList);
- // Call internal create function to initiate dump
- iMgr.IMgr::create(Type::InternalFailure, fullPaths);
+ auto item = std::find_if(
+ TypeMap.begin(), TypeMap.end(),
+ [errorType](const auto& err) { return (err.second == errorType); });
+ if (item != TypeMap.end())
+ {
+ iMgr.IMgr::create((*item).first, fullPaths);
+ }
}
catch (QuotaExceeded& e)
{
diff --git a/errors_map.mako.hpp b/errors_map.mako.hpp
new file mode 100644
index 0000000..b04f00e
--- /dev/null
+++ b/errors_map.mako.hpp
@@ -0,0 +1,18 @@
+## This file is a template. The comment below is emitted
+## into the rendered file; feel free to edit this file.
+// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
+#include <map>
+using EType = std::string;
+using Error = std::string;
+using ErrorList = std::vector<Error>;
+using ErrorMap = std::map<EType, std::vector<Error>>;
+
+const ErrorMap errorMap = {
+% for key, errors in errDict.items():
+ {"${key}", {
+ % for error in errors:
+ "${error}",
+ % endfor
+ }},
+% endfor
+};
diff --git a/errors_map_gen.py b/errors_map_gen.py
new file mode 100755
index 0000000..6e60610
--- /dev/null
+++ b/errors_map_gen.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import os
+import yaml
+from mako.template import Template
+import argparse
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="OpenPOWER error map code generator")
+
+ parser.add_argument(
+ '-i', '--errors_map_yaml', dest='errors_map_yaml',
+ default='errors_watch.yaml', help='input errors watch yaml file to parse')
+ args = parser.parse_args()
+
+ with open(os.path.join(script_dir, args.errors_map_yaml), 'r') as fd:
+ yamlDict = yaml.safe_load(fd)
+
+ # Render the mako template
+ template = os.path.join(script_dir, 'errors_map.mako.hpp')
+ t = Template(filename=template)
+ with open('errors_map.hpp', 'w') as fd:
+ fd.write(
+ t.render(
+ errDict=yamlDict))
+
+
+if __name__ == '__main__':
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ main() \ No newline at end of file
diff --git a/example_errors_watch.yaml b/example_errors_watch.yaml
new file mode 100644
index 0000000..eb47ec6
--- /dev/null
+++ b/example_errors_watch.yaml
@@ -0,0 +1,2 @@
+elog:
+ - xyz.openbmc_project.Common.Error.InternalFailure
diff --git a/tools/dreport.d/dreport b/tools/dreport.d/dreport
index 7fc1c32..3b6dce3 100755
--- a/tools/dreport.d/dreport
+++ b/tools/dreport.d/dreport
@@ -43,6 +43,7 @@ declare -rx SUMMARY_DUMP="summary"
declare -rx TYPE_USER="user"
declare -rx TYPE_CORE="core"
declare -rx TYPE_ELOG="elog"
+declare -rx TYPE_CHECKSTOP="checkstop"
declare -rx SUMMARY_LOG="summary.log"
declare -rx DREPORT_LOG="dreport.log"
declare -rx TMP_DIR="/tmp"
@@ -94,6 +95,11 @@ function collect_data()
elog_id=$(basename "$optional_path")
set_elog_pid
;;
+ $TYPE_CHECKSTOP)
+ log_summary "CHECKSTOP: $optional_path"
+ elog_id=$(basename "$optional_path")
+ set_elog_pid
+ ;;
$SUMMARY_DUMP)
#No data collection is required.
@@ -190,7 +196,8 @@ function initialize()
#Type
if [[ !($dump_type = $TYPE_USER || \
$dump_type = $TYPE_CORE || \
- $dump_type = $TYPE_ELOG) ]]; then
+ $dump_type = $TYPE_ELOG || \
+ $dump_type = $TYPE_CHECKSTOP) ]]; then
log_error "Invalid -type, Only summary log is available"
dump_type=$SUMMARY_DUMP
fi
diff --git a/tools/dreport.d/sample.conf b/tools/dreport.d/sample.conf
index 8a0e24a..45f5e59 100644
--- a/tools/dreport.d/sample.conf
+++ b/tools/dreport.d/sample.conf
@@ -8,3 +8,4 @@
1: core
2: user
3: elog
+4: checkstop
diff --git a/xyz/openbmc_project/Dump/Internal/Create.interface.yaml b/xyz/openbmc_project/Dump/Internal/Create.interface.yaml
index bb4a74f..ddb405f 100644
--- a/xyz/openbmc_project/Dump/Internal/Create.interface.yaml
+++ b/xyz/openbmc_project/Dump/Internal/Create.interface.yaml
@@ -34,5 +34,8 @@ enumerations:
- name: InternalFailure
description: >
Dump triggered due to InternalFailure type error commit.
+ - name: Checkstop
+ description: >
+ Dump triggered due to Checkstop type error commit.
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud