[kexec-tools] kdumpctl: status function cleanup

WANG Chao wangchao at fedoraproject.org
Mon Feb 17 04:53:54 UTC 2014


commit d802c3a1df92ff83778de6ed587a2df130f6fb2c
Author: Dave Young <dyoung at redhat.com>
Date:   Thu Feb 13 11:23:58 2014 +0800

    kdumpctl: status function cleanup
    
    Move the code to check /sys/kernel/kexec_crash_loaded to function
    check_kdump_feasibility(). And rename status() to check_current_kdump_status()
    so these two functions become clearer.
    
    cleanup kdumpctl status path as well.
    
    Tested with kernel without CONFIG_KEXEC
    Tested with run kdumpctl start two times.
    
    Signed-off-by: Dave Young <dyoung at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 kdumpctl |   31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)
---
diff --git a/kdumpctl b/kdumpctl
index aef3875..f72020d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -384,12 +384,8 @@ function propagate_ssh_key()
 		
 }
 
-function status()
+function check_current_kdump_status()
 {
-	if [ ! -e /sys/kernel/kexec_crash_loaded ]
-	then
-		return 2 
-	fi
 	rc=`cat /sys/kernel/kexec_crash_loaded`
 	if [ $rc == 1 ]; then
 		return 0
@@ -535,6 +531,11 @@ function check_kdump_feasibility()
 		echo "Secure Boot is Enabled. Kdump service can't be started. Disable Secure Boot and retry"
 		return 1;
 	fi
+
+	if [ ! -e /sys/kernel/kexec_crash_loaded ]; then
+		echo "Kdump is not supported on this kernel"
+		return 1
+	fi
 }
 
 function start()
@@ -560,16 +561,10 @@ function start()
 		return 1
 	fi
 
-	status 
-	rc=$?
-	if [ $rc == 2 ]; then
-		echo "Kdump is not supported on this kernel: [WARNING]"
-		return 1;
-	else
-		if [ $rc == 0 ]; then
-			echo "Kdump already running: [WARNING]"
-			return 0
-		fi
+	check_current_kdump_status
+	if [ $? == 0 ]; then
+		echo "Kdump already running: [WARNING]"
+		return 0
 	fi
 
 	if check_ssh_config; then
@@ -628,7 +623,7 @@ main ()
 		;;
 	  status)
 		EXIT_CODE=0
-		status
+		check_current_kdump_status
 		case "$?" in
 		  0)
 			echo "Kdump is operational"
@@ -638,10 +633,6 @@ main ()
 			echo "Kdump is not operational"
 			EXIT_CODE=3
 			;;
-		  2)
-			echo "Kdump is unsupported on this kernel"
-			EXIT_CODE=3
-			;;
 		esac
 		exit $EXIT_CODE
 		;;


More information about the scm-commits mailing list