File kdump-try-kexec-load-file.patch of Package kdump.openSUSE_Leap_42.3_Update
From: Lance Wang <lzwang@suse.com>
Date: Tue Jan 16 13:53:40 2018 +0100
Subject: Try both kexec_load(2) and kexec_file_load(2)
References: bsc#951144, bsc#1056497
Upstream: merged
Git-commit: ab9c22489ef7627e3f0ad67f46ea19e8d401d044
The logic in load.sh will use kexec_load first. If kexec_load fails
or is blocked by kernel, then it will try kexec_load_file on
x86_64.
Signed-off-by: Joey Lee <jlee@suse.com>
Signed-off-by: Lance Wang <lzwang@suse.com>
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
init/load.sh | 52 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 18 deletions(-)
--- a/init/load.sh
+++ b/init/load.sh
@@ -138,29 +138,17 @@ function build_kexec_options()
echo "$options"
}
-#
-# Load kdump using kexec
-function load_kdump_kexec()
+function run_kexec()
{
+ local kexec_call="$1"
local result
- if [ ! -f "$kdump_initrd" ] ; then
- echo "No kdump initial ramdisk found. Tried to locate $kdump_initrd."
- return 6
- fi
-
- local kdump_commandline=$(build_kdump_commandline "$kdump_kernel")
- local kexec_options=$(build_kexec_options "$kdump_kernel")
-
- KEXEC_CALL="$KEXEC -p $kdump_kernel --append=\"$kdump_commandline\""
- KEXEC_CALL="$KEXEC_CALL --initrd=$kdump_initrd $kexec_options"
-
if [ $((${KDUMP_VERBOSE:-0} & 4)) -gt 0 ] ; then
- echo "Loading kdump kernel: $KEXEC_CALL"
+ echo "Loading kdump kernel: $kexec_call"
fi
local output
- output=$(eval "$KEXEC_CALL" 2>&1)
+ output=$(eval "$kexec_call" 2>&1)
if [ $? -eq 0 ] ; then
result=0
else
@@ -174,14 +162,42 @@ function load_kdump_kexec()
if [ $((${KDUMP_VERBOSE:-0} & 1)) -gt 0 ] ; then
if [ $result -eq 0 ] ; then
logger -i -t kdump \
- "Loaded kdump kernel: $KEXEC_CALL, Result: $output"
+ "Loaded kdump kernel: $kexec_call, Result: $output"
else
logger -i -t kdump \
- "FAILED to load kdump kernel: $KEXEC_CALL, Result: $output"
+ "FAILED to load kdump kernel: $kexec_call, Result: $output"
fi
fi
return $result
+}
+
+#
+# Load kdump using kexec
+function load_kdump_kexec()
+{
+ local result
+
+ if [ ! -f "$kdump_initrd" ] ; then
+ echo "No kdump initial ramdisk found. Tried to locate $kdump_initrd."
+ return 6
+ fi
+
+ local kdump_commandline=$(build_kdump_commandline "$kdump_kernel")
+ local kexec_options=$(build_kexec_options "$kdump_kernel")
+
+ KEXEC_CALL="$KEXEC -p $kdump_kernel --append=\"$kdump_commandline\""
+ KEXEC_CALL="$KEXEC_CALL --initrd=$kdump_initrd $kexec_options"
+
+ run_kexec "$KEXEC_CALL"
+ result=$?
+ # try kexec_load_file
+ if [ $result -eq 1 ] && [ "$(uname -i)" = "x86_64" ] ; then
+ run_kexec "$KEXEC_CALL -s"
+ result=$?
+ fi
+
+ return $result
}
#