[kexec-tools] kdump: Modify status routine to check for firmware-assisted dump

WANG Chao wangchao at fedoraproject.org
Mon Jul 28 05:05:59 UTC 2014


commit e0e70085e1ed799ab5a7b5d3b4a526b54f1cbb1d
Author: Hari Bathini <hbathini at linux.vnet.ibm.com>
Date:   Fri Jul 25 00:08:36 2014 +0530

    kdump: Modify status routine to check for firmware-assisted dump
    
    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 at linux.vnet.ibm.com>
    Signed-off-by: Hari Bathini <hbathini at linux.vnet.ibm.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 kdumpctl |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 3 deletions(-)
---
diff --git a/kdumpctl b/kdumpctl
index 215bbd3..d281abb 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -9,6 +9,10 @@ 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"
+#kdump shall be the default dump mode
+DEFAULT_DUMP_MODE="kdump"
 
 . /lib/kdump/kdump-lib.sh
 
@@ -34,6 +38,16 @@ single_instance_lock()
 	done
 }
 
+determine_dump_mode()
+{
+	# Check if firmware-assisted dump is enabled
+	# if yes, set the dump mode as fadump
+	if is_fadump_capable; then
+		echo "Dump mode is fadump"
+		DEFAULT_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.
@@ -436,6 +450,25 @@ propagate_ssh_key()
 	fi
 }
 
+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
+}
+
 check_current_kdump_status()
 {
 	rc=`cat /sys/kernel/kexec_crash_loaded`
@@ -446,6 +479,17 @@ check_current_kdump_status()
 	fi
 }
 
+check_current_status()
+{
+	if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
+		check_current_fadump_status
+	else
+		check_current_kdump_status
+	fi
+
+	return $?
+}
+
 save_raw()
 {
 	local kdump_dir
@@ -608,6 +652,16 @@ check_fence_kdump_config()
 	return 0
 }
 
+check_dump_feasibility()
+{
+	if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
+		return 0
+	fi
+
+	check_kdump_feasibility
+	return $?
+}
+
 start()
 {
 	check_config
@@ -625,13 +679,13 @@ 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
@@ -679,6 +733,9 @@ fi
 
 main ()
 {
+	# Determine if the dump mode is kdump or fadump
+	determine_dump_mode
+
 	case "$1" in
 	  start)
 		if [ -s /proc/vmcore ]; then
@@ -693,7 +750,7 @@ main ()
 		;;
 	  status)
 		EXIT_CODE=0
-		check_current_kdump_status
+		check_current_status
 		case "$?" in
 		  0)
 			echo "Kdump is operational"


More information about the scm-commits mailing list