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 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index f72020d..e624b91 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,18 @@ 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
+ 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.
@@ -384,6 +398,27 @@ function propagate_ssh_key()
}
+function is_fadump_capable()
+{
+ # Check if firmware-assisted dump is enabled
+ # if yes, check fadump status Otherwise fallback to kdump check
+ if [ -f $FADUMP_ENABLED_SYS_NODE ] && \
+ [ -f $FADUMP_REGISTER_SYS_NODE ]
+ then
+ rc=`cat $FADUMP_ENABLED_SYS_NODE`
+ [ $rc -eq 1 ] && return 0
+ fi
+ return 1
+}
+
+function 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`
@@ -394,6 +429,17 @@ function check_current_kdump_status()
fi
}
+function 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
@@ -555,13 +601,15 @@ function start()
return 1
fi
- check_kdump_feasibility
- if [ $? -ne 0 ]; then
- echo "Starting kdump: [FAILED]"
- return 1
+ if [ $dump_mode == "kdump" ]; then
+ check_kdump_feasibility
+ if [ $? -ne 0 ]; then
+ echo "Starting kdump: [FAILED]"
+ return 1
+ fi
fi
- check_current_kdump_status
+ check_current_status
if [ $? == 0 ]; then
echo "Kdump already running: [WARNING]"
return 0
@@ -623,7 +671,7 @@ main ()
;;
status)
EXIT_CODE=0
- check_current_kdump_status
+ check_current_status
case "$?" in
0)
echo "Kdump is operational"
@@ -654,6 +702,9 @@ main ()
# Other kdumpctl instances will block in queue, until this one exits
single_instance_lock
+# Determine if the dump mode is kdump or fadump
+determine_dump_mode
+
# To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main.
# So that fd isn't leaking when main is invoking a subshell.
(exec 9<&-; main $1)