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.
Signed-off-by: Dave Young dyoung@redhat.com --- kdumpctl | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
--- kexec-tools.orig/kdumpctl +++ kexec-tools/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 @@ -534,6 +530,10 @@ function check_kdump_feasibility() if is_secure_boot_enforced; then return 1; fi + + if [ ! -e /sys/kernel/kexec_crash_loaded ]; then + return 2 + fi }
function start() @@ -560,18 +560,15 @@ function start() if [ $rc == 1 ]; then echo "Secure boot is not supported in kdump yet. Please disable secure boot and retry. [WARNING]" return 1 - fi - - status - rc=$? - if [ $rc == 2 ]; then + elif [ $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 + fi + + check_current_kdump_status + if [ $? == 0 ]; then + echo "Kdump already running: [WARNING]" + return 0 fi
if check_ssh_config; then
On Tue, Feb 11, 2014 at 03:06:06PM +0800, Dave Young wrote:
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.
Signed-off-by: Dave Young dyoung@redhat.com
kdumpctl | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
--- kexec-tools.orig/kdumpctl +++ kexec-tools/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
@@ -534,6 +530,10 @@ function check_kdump_feasibility() if is_secure_boot_enforced; then return 1; fi
- if [ ! -e /sys/kernel/kexec_crash_loaded ]; then
return 2
- fi
We should be able to just return "1" here if we make changes as suggested in last function. Also it does not hurt to give a warning/error message here.
Thanks Vivek
On 02/11/14 at 08:34am, Vivek Goyal wrote:
On Tue, Feb 11, 2014 at 03:06:06PM +0800, Dave Young wrote:
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.
Signed-off-by: Dave Young dyoung@redhat.com
kdumpctl | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
--- kexec-tools.orig/kdumpctl +++ kexec-tools/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
@@ -534,6 +530,10 @@ function check_kdump_feasibility() if is_secure_boot_enforced; then return 1; fi
- if [ ! -e /sys/kernel/kexec_crash_loaded ]; then
return 2
- fi
We should be able to just return "1" here if we make changes as suggested in last function. Also it does not hurt to give a warning/error message here.
Will see if I can improve it in next version.
Thanks Dave