arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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