This patch enables kdump script to check if firmware-assisted dump is
enabled or not by reading value from '/sys/kernel/fadump_enabled'. The
determine_dump_mode() routine sets dump_mode to 'fadump', if fadump is
enabled. By default, dump_mode is set to 'kdump' mode.
Modify status routine to check if firmware assisted dump is registered
or not by reading value from '/sys/kernel/fadump_registered' file. If
it is set to '1' then return status=0 else return status=1.
0 <= Firmware assisted is enabled and running
1 <= Firmware assisted is enabled but not running
Signed-off-by: Mahesh Salgaonkar <mahesh(a)linux.vnet.ibm.com>
Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
---
kdumpctl | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 3 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 481ffed..0009031 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -9,6 +9,8 @@ MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
DUMP_TARGET=""
+FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled"
+FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered"
. /lib/kdump/kdump-lib.sh
@@ -24,6 +26,19 @@ single_instance_lock()
flock 9
}
+determine_dump_mode()
+{
+ # kdump shall be the default dump mode
+ dump_mode="kdump"
+
+ # Check if firmware-assisted dump is enabled
+ # if yes, set the dump mode as fadump
+ if is_fadump_capable; then
+ echo "Using dump mode fadump"
+ dump_mode="fadump"
+ fi
+}
+
# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ...
[<paramN>]
# Remove a list of kernel parameters from a given kernel cmdline and print the result.
# For each "arg" in the removing params list, "arg" and
"arg=xxx" will be removed if exists.
@@ -372,6 +387,25 @@ function propagate_ssh_key()
}
+is_fadump_capable()
+{
+ # Check if firmware-assisted dump is enabled
+ # if no, fallback to kdump check
+ if [ -f $FADUMP_ENABLED_SYS_NODE ]; then
+ rc=`cat $FADUMP_ENABLED_SYS_NODE`
+ [ $rc -eq 1 ] && return 0
+ fi
+ return 1
+}
+
+check_current_fadump_status()
+{
+ # Check if firmware-assisted dump has been registered.
+ rc=`cat $FADUMP_REGISTER_SYS_NODE`
+ [ $rc -eq 1 ] && return 0
+ return 1
+}
+
function check_current_kdump_status()
{
rc=`cat /sys/kernel/kexec_crash_loaded`
@@ -382,6 +416,17 @@ function check_current_kdump_status()
fi
}
+check_current_status()
+{
+ if [ $dump_mode == "fadump" ]; then
+ check_current_fadump_status
+ else
+ check_current_kdump_status
+ fi
+
+ return $?
+}
+
function save_raw()
{
local kdump_dir
@@ -526,6 +571,16 @@ function check_kdump_feasibility()
fi
}
+check_dump_feasibility()
+{
+ if [ $dump_mode != "kdump" ]; then
+ return 0
+ fi
+
+ check_kdump_feasibility
+ return $?
+}
+
function start()
{
check_config
@@ -543,13 +598,13 @@ function start()
return 1
fi
- check_kdump_feasibility
+ check_dump_feasibility
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
return 1
fi
- check_current_kdump_status
+ check_current_status
if [ $? == 0 ]; then
echo "Kdump already running: [WARNING]"
return 0
@@ -597,6 +652,9 @@ fi
main ()
{
+ # Determine if the dump mode is kdump or fadump
+ determine_dump_mode
+
case "$1" in
start)
if [ -s /proc/vmcore ]; then
@@ -611,7 +669,7 @@ main ()
;;
status)
EXIT_CODE=0
- check_current_kdump_status
+ check_current_status
case "$?" in
0)
echo "Kdump is operational"