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

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