doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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