Blame 0026-MCE-cover-cases-where-kernel-version-isn-t-detected-.patch

69165ba
From e30c24a5572c33f9ca5157bfb4e504897b1bb7c9 Mon Sep 17 00:00:00 2001
69165ba
From: Denys Vlasenko <dvlasenk@redhat.com>
69165ba
Date: Mon, 6 Jan 2014 16:04:37 +0100
69165ba
Subject: [ABRT PATCH 26/27] MCE: cover cases where kernel version isn't
69165ba
 detected on Fedora 20.
69165ba
69165ba
With this change, both fata and non-fatal MCEs are caught on default
69165ba
Fedora 20 installation.
69165ba
69165ba
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
69165ba
69165ba
Related to rhbz#1032077
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 doc/MCE_readme.txt            |  9 ++++++++-
69165ba
 src/lib/kernel.c              |  2 +-
69165ba
 src/plugins/abrt-dump-oops.c  |  3 ++-
69165ba
 src/plugins/koops_event.conf  | 11 +++++++++++
69165ba
 src/plugins/vmcore_event.conf | 14 ++++++++++++--
69165ba
 5 files changed, 34 insertions(+), 5 deletions(-)
69165ba
69165ba
diff --git a/doc/MCE_readme.txt b/doc/MCE_readme.txt
69165ba
index ed5b627..5dff636 100644
69165ba
--- a/doc/MCE_readme.txt
69165ba
+++ b/doc/MCE_readme.txt
69165ba
@@ -70,7 +70,7 @@ echo "Exitcode:$?"
69165ba
 
69165ba
 It requires files which describe MCE to simulate. I grabbed a few examples
69165ba
 from mce-test.tar.gz (source tarball of mce-test project).
69165ba
-I used this this file to cause a non-fatal MCE:
69165ba
+I used this file to cause a non-fatal MCE:
69165ba
 
69165ba
 CPU 0 BANK 2
69165ba
 STATUS VAL OVER EN
69165ba
@@ -84,3 +84,10 @@ RIP 12343434
69165ba
 MISC 11
69165ba
 
69165ba
 (Not sure what failures exactly they imitate, maybe there are better examples).
69165ba
+
69165ba
+
69165ba
+For testing fatal MCEs you need to set up kdump. Mini-recipe:
69165ba
+(1) yum install --enablerepo='*debuginfo*' kexec-tools crash kernel-debuginfo
69165ba
+(2) add "crashkernel=128M" to the kernel's command line, reboot
69165ba
+(3) before injecting fatal MCE, start kdump service:
69165ba
+    systemctl start kdump.service
69165ba
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
69165ba
index 340ec39..ad20c65 100644
69165ba
--- a/src/lib/kernel.c
69165ba
+++ b/src/lib/kernel.c
69165ba
@@ -66,7 +66,7 @@ static void record_oops(GList **oops_list, struct line_info* lines_info, int oop
69165ba
         {
69165ba
             *oops_list = g_list_append(
69165ba
                         *oops_list,
69165ba
-                        xasprintf("%s\n%s", (version ? version : "undefined"), oops)
69165ba
+                        xasprintf("%s\n%s", (version ? version : ""), oops)
69165ba
             );
69165ba
         }
69165ba
         else
69165ba
diff --git a/src/plugins/abrt-dump-oops.c b/src/plugins/abrt-dump-oops.c
69165ba
index 5e33f0a..12291be 100644
69165ba
--- a/src/plugins/abrt-dump-oops.c
69165ba
+++ b/src/plugins/abrt-dump-oops.c
69165ba
@@ -115,7 +115,8 @@ static void save_oops_data_in_dump_dir(struct dump_dir *dd, char *oops, const ch
69165ba
     char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
69165ba
     *second_line++ = '\0';
69165ba
 
69165ba
-    dd_save_text(dd, FILENAME_KERNEL, first_line);
69165ba
+    if (first_line[0])
69165ba
+        dd_save_text(dd, FILENAME_KERNEL, first_line);
69165ba
     dd_save_text(dd, FILENAME_BACKTRACE, second_line);
69165ba
 
69165ba
     /* check if trace doesn't have line: 'Your BIOS is broken' */
69165ba
diff --git a/src/plugins/koops_event.conf b/src/plugins/koops_event.conf
69165ba
index 37a79a9..b1472ce 100644
69165ba
--- a/src/plugins/koops_event.conf
69165ba
+++ b/src/plugins/koops_event.conf
69165ba
@@ -3,6 +3,17 @@ 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
         # Do not fail the event (->do not delete problem dir)
69165ba
         # if check-oops-for-hw-error exits nonzero:
69165ba
diff --git a/src/plugins/vmcore_event.conf b/src/plugins/vmcore_event.conf
69165ba
index 655d842..a525ec7 100644
69165ba
--- a/src/plugins/vmcore_event.conf
69165ba
+++ b/src/plugins/vmcore_event.conf
69165ba
@@ -1,6 +1,7 @@
69165ba
 # analyze
69165ba
 EVENT=analyze_VMcore analyzer=vmcore
69165ba
         # If kdump machinery already extracted dmesg...
69165ba
+        (
69165ba
         if test -f vmcore-dmesg.txt; then
69165ba
             # ...use that
69165ba
             abrt-dump-oops -o vmcore-dmesg.txt >backtrace || exit $?
69165ba
@@ -15,8 +16,17 @@ EVENT=analyze_VMcore analyzer=vmcore
69165ba
             test "$k" != "" && printf "%s" "$k" >kernel
69165ba
         else
69165ba
             # No vmcore-dmesg.txt, do it the hard way:
69165ba
-            abrt-action-analyze-vmcore
69165ba
-        fi &&
69165ba
+            abrt-action-analyze-vmcore || exit $?
69165ba
+            #
69165ba
+            # Does "kernel" element exist?
69165ba
+            test -f kernel && exit 0
69165ba
+            #
69165ba
+            # Try creating it from dmesg_log (created by abrt-action-analyze-vmcore):
69165ba
+            test -f dmesg_log || exit 0
69165ba
+            k=`sed -n '/Linux version/ s/.*Linux version \([^ ]*\) .*/\1/p' dmesg_log | tail -n1`
69165ba
+            test "$k" != "" && printf "%s" "$k" >kernel
69165ba
+        fi
69165ba
+        ) &&
69165ba
         abrt-action-analyze-oops &&
69165ba
         abrt-action-save-kernel-data
69165ba
 
69165ba
-- 
69165ba
1.8.3.1
69165ba