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

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