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

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