From c86f483f58cc8e65030169965c2b4fe34911ef1d Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Thu, 16 Jan 2014 13:11:20 +0100
Subject: [ABRT PATCH 27/27] MCE: make oops and vmcore MCEs a bit more similar

For oops-MCEs, change abrt-action-check-oops-for-hw-error
to write MCE description to "backtrace" instead of "comment"
element.

Extend abrt-action-check-oops-for-hw-error to be able to
detect vmcore MCEs: it will create "not-reportable" element
for them too, as it was doing it for oops-MCEs.

Add post-create processing to vmcore_event.conf which
runs abrt-action-check-oops-for-hw-error on vmcores.
Since that needs dmesg, dmesg extraction also moved
to this event from analyze_VMcore.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>

Related to rhbz#1032077

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/plugins/abrt-action-check-oops-for-hw-error.in | 14 ++++++++++----
 src/plugins/vmcore_event.conf                      | 13 +++++++++----
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/plugins/abrt-action-check-oops-for-hw-error.in b/src/plugins/abrt-action-check-oops-for-hw-error.in
index ce13caf..2333fa1 100644
--- a/src/plugins/abrt-action-check-oops-for-hw-error.in
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
@@ -70,7 +70,9 @@ if __name__ == "__main__":
     #
 
     # See if MCEs were seen
-    if not file_has_string("dmesg", "Machine check events logged"):
+    oops_mce = file_has_string("dmesg", "Machine check events logged");
+    vmcore_mce = file_has_string("backtrace", "Machine Check Exception:");
+    if not oops_mce and not vmcore_mce:
         sys.exit(0)
     #
     # There was an MCE. IOW: it's not a bug, it's a HW error.
@@ -81,11 +83,15 @@ if __name__ == "__main__":
     ))
     f.close()
 
+    # vmcore MCEs already have good backtrace element, nothing more to do
+    if vmcore_mce:
+        sys.exit(0)
+
     #
     # Did mcelog logged it to /var/log/mcelog
     # (RHEL6 by default does this)?
     if os.path.exists("/var/log/mcelog"):
-        f = open_or_die("comment", "w")
+        f = open_or_die("backtrace", "w")
         f.write("The kernel log indicates that hardware errors were detected.\n")
         f.write("/var/log/mcelog file may have more information.\n")
         f.write("The last 20 lines of /var/log/mcelog are:\n")
@@ -100,7 +106,7 @@ if __name__ == "__main__":
     # On RHEL7, mcelog is run so that its output ends up in syslog.
     # Do we see that?
     if file_has_string("/var/log/messages", "mcelog: Hardware event"):
-        f = open_or_die("comment", "w")
+        f = open_or_die("backtrace", "w")
         f.write("The kernel log indicates that hardware errors were detected.\n")
         f.write("System log may have more information.\n")
         f.write("The last 20 mcelog lines of system log are:\n")
@@ -114,7 +120,7 @@ if __name__ == "__main__":
     #
     # Apparently, there is no running mcelog daemon!
     # Let user know that he needs one.
-    f = open_or_die("comment", "w")
+    f = open_or_die("backtrace", "w")
     f.write("The kernel log indicates that hardware errors were detected.\n")
     f.write("The data was saved by kernel for processing by the mcelog tool.\n")
     f.write("However, neither /var/log/mcelog nor system log contain mcelog messages.\n")
diff --git a/src/plugins/vmcore_event.conf b/src/plugins/vmcore_event.conf
index a525ec7..34608d9 100644
--- a/src/plugins/vmcore_event.conf
+++ b/src/plugins/vmcore_event.conf
@@ -1,7 +1,6 @@
-# analyze
-EVENT=analyze_VMcore analyzer=vmcore
-        # If kdump machinery already extracted dmesg...
+EVENT=post-create analyzer=vmcore
         (
+        # If kdump machinery already extracted dmesg...
         if test -f vmcore-dmesg.txt; then
             # ...use that
             abrt-dump-oops -o vmcore-dmesg.txt >backtrace || exit $?
@@ -26,7 +25,13 @@ EVENT=analyze_VMcore analyzer=vmcore
             k=`sed -n '/Linux version/ s/.*Linux version \([^ ]*\) .*/\1/p' dmesg_log | tail -n1`
             test "$k" != "" && printf "%s" "$k" >kernel
         fi
-        ) &&
+        )
+        # Do not fail the event (->do not delete problem dir)
+        # if check-oops-for-hw-error exits nonzero:
+        { abrt-action-check-oops-for-hw-error || true; }
+
+# analyze
+EVENT=analyze_VMcore analyzer=vmcore
         abrt-action-analyze-oops &&
         abrt-action-save-kernel-data
 
-- 
1.8.3.1

