File kdump-fallback-re-register-fadump-from-userspace.patch of Package kdump.21347

From 4084339bb6e7c605dab7a48a98b97510f555d343 Mon Sep 17 00:00:00 2001
From: Hari Bathini <hbathini@linux.ibm.com>
Date: Thu, 27 Sep 2018 17:11:58 +0200
Subject: Re-register FADUMP from userspace if the kernel cannot do it
Reference: bsc#1108170, LTC#171288, bsc#1094016, LTC#168050
Upstream: merged
Git-commit: 4084339bb6e7c605dab7a48a98b97510f555d343

If the kernel does not allow writing a "1" to fadump_registered,
unregister and register again from userspace.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 init/load.sh | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

--- a/init/load.sh
+++ b/init/load.sh
@@ -251,15 +251,20 @@ function load_kdump_fadump()
     if [ $? -eq 0 ] ; then
         msg="Registered fadump"
     else
-        # For backward compatibility on older kernel that
-        # returns -EEXIST/-EINVAL
+        msg="FAILED to register fadump: $output"
+        result=1
+
+        # For re-registering on an older kernel that returns -EEXIST/-EINVAL,
+        # if fadump was already registered.
         if [ "$(cat $FADUMP_REGISTERED)" == "1" ] ; then
-            # TODO: unregiser/register OR warn user to stop/start?
-            # Best bet is to update to latest kernel.
-            msg="fadump is already registered"
-        else
-            msg="FAILED to register fadump: $output"
-            result=1
+            echo 0 > "$FADUMP_REGISTERED"
+            output=$( (echo 1 > "$FADUMP_REGISTERED") 2>&1)
+            if [ $? -eq 0 ] ; then
+                msg="Registered fadump"
+                result=0
+            else
+                msg="FAILED to register fadump: $output"
+            fi
         fi
     fi
 
openSUSE Build Service is sponsored by