doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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