Blame SOURCES/0067-koops-don-t-analyze-MCEs-like-standard-oopses.patch

a60cd7
From ac3121ac9b752d62d82b329b8bae520147ebe6a6 Mon Sep 17 00:00:00 2001
a60cd7
From: Jakub Filak <jfilak@redhat.com>
a60cd7
Date: Thu, 26 Jun 2014 11:29:17 +0200
a60cd7
Subject: [ABRT PATCH 67/68] koops: don't analyze MCEs like standard oopses
a60cd7
a60cd7
MCEs are not kernel oopses as we know them, MCEs do not have stacktrace
a60cd7
and ABRT drops oopses without meaningful stack trace frames for hashing.
a60cd7
The required files are generated by abrt-action-check-oops-for-hw-errror
a60cd7
because that executable understands the format of MCE data.
a60cd7
  - uuid    (sha1 of backtrace file)
a60cd7
  - duphash (sha1 of backtrace file)
a60cd7
  - kernel  (from dmesg)
a60cd7
a60cd7
Related to #1076820
a60cd7
a60cd7
Signed-off-by: Jakub Filak <jfilak@redhat.com>
a60cd7
---
a60cd7
 src/plugins/abrt-action-check-oops-for-hw-error.in | 19 ++++++++++++++
a60cd7
 src/plugins/koops_event.conf                       | 29 +++++++++++-----------
a60cd7
 2 files changed, 33 insertions(+), 15 deletions(-)
a60cd7
a60cd7
diff --git a/src/plugins/abrt-action-check-oops-for-hw-error.in b/src/plugins/abrt-action-check-oops-for-hw-error.in
a60cd7
index d74f89d..6bf37f5 100644
a60cd7
--- a/src/plugins/abrt-action-check-oops-for-hw-error.in
a60cd7
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
a60cd7
@@ -4,6 +4,8 @@ import sys
a60cd7
 import os
a60cd7
 import locale
a60cd7
 import gettext
a60cd7
+import hashlib
a60cd7
+import re
a60cd7
 
a60cd7
 GETTEXT_PROGNAME = "abrt"
a60cd7
 
a60cd7
@@ -83,6 +85,23 @@ if __name__ == "__main__":
a60cd7
     ))
a60cd7
     f.close()
a60cd7
 
a60cd7
+    oops_hash = hashlib.sha1()
a60cd7
+    with open("backtrace", "r") as btfile:
a60cd7
+        for line in btfile:
a60cd7
+            oops_hash.update(line)
a60cd7
+
a60cd7
+    with open_or_die("uuid", "w") as f:
a60cd7
+        f.write(oops_hash.hexdigest())
a60cd7
+
a60cd7
+    with open_or_die("duphash", "w") as f:
a60cd7
+        f.write(oops_hash.hexdigest())
a60cd7
+
a60cd7
+    res = tail_with_search("dmesg", "Linux version", 1)
a60cd7
+    if res:
a60cd7
+        kernel = re.sub(r"^.*Linux version ([^ ]+) .*$", r"\1", res[0]);
a60cd7
+        with open_or_die("kernel", "w") as krnlfile:
a60cd7
+            krnlfile.write(kernel)
a60cd7
+
a60cd7
     # vmcore MCEs already have good backtrace element, nothing more to do
a60cd7
     if vmcore_mce:
a60cd7
         sys.exit(0)
a60cd7
diff --git a/src/plugins/koops_event.conf b/src/plugins/koops_event.conf
a60cd7
index b1472ce..1604acf 100644
a60cd7
--- a/src/plugins/koops_event.conf
a60cd7
+++ b/src/plugins/koops_event.conf
a60cd7
@@ -1,23 +1,22 @@
a60cd7
 # Analyze
a60cd7
 EVENT=post-create analyzer=Kerneloops
a60cd7
         # >> instead of > is due to bugzilla.redhat.com/show_bug.cgi?id=854266
a60cd7
-        abrt-action-analyze-oops &&
a60cd7
-        dmesg >>dmesg &&
a60cd7
-        {
a60cd7
-        # action-analyze-oops tries to save kernel version,
a60cd7
-        # but for some oopses it can't do that (e.g. MCEs).
a60cd7
-        # If it failed, try to extract version from dmesg:
a60cd7
-        test -f kernel ||
a60cd7
-            {
a60cd7
-            k=`sed -n '/Linux version/ s/.*Linux version \([^ ]*\) .*/\1/p' dmesg | tail -n1`
a60cd7
-            test "$k" != "" && printf "%s" "$k" >kernel
a60cd7
-            true   # ignore possible failures in previous command
a60cd7
-            }
a60cd7
-        } &&
a60cd7
-        abrt-action-save-kernel-data &&
a60cd7
+        # 'dmesg' file is required by check-oops-for-hw-error
a60cd7
+        dmesg >>dmesg
a60cd7
         # Do not fail the event (->do not delete problem dir)
a60cd7
         # if check-oops-for-hw-error exits nonzero:
a60cd7
-        { abrt-action-check-oops-for-hw-error || true; }
a60cd7
+        {
a60cd7
+        abrt-action-check-oops-for-hw-error || true
a60cd7
+        } &&
a60cd7
+        {
a60cd7
+        # run abrt-action-analyze-oops only if check-hw-error didn't create the
a60cd7
+        # required files
a60cd7
+        if test ! -f uuid -a ! -f duphash; then
a60cd7
+             abrt-action-analyze-oops || exit 1
a60cd7
+        fi
a60cd7
+        } &&
a60cd7
+        abrt-action-save-kernel-data
a60cd7
+
a60cd7
 
a60cd7
 # If you want behavior similar to one provided by kerneloops daemon
a60cd7
 # distributed by kerneloops.org - that is, if you want
a60cd7
-- 
a60cd7
1.8.3.1
a60cd7