The first time of running kdumpctl test-check involves remote fs mount and
file string grep, which will consume a lot of time. If user re-run test-check
multiple times with no kdump config change, there is no need to waste the
time. This patch introduce md5sum of the kdump config. If unchanged,
just return result immediately.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
kdumpctl | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 5e9d1e7..493aa04 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -17,6 +17,7 @@ TARGET_INITRD=""
#kdump shall be the default dump mode
DEFAULT_DUMP_MODE="kdump"
KDUMP_TEST_ENV="/var/kdump/.kdump_test"
+KDUMP_TEST_SUCCESS_CHECKSUM="/var/kdump/kdump_test_checksum"
KDUMP_TEST_PREFIX="kdump_test_"
standard_kexec_args="-d -p"
@@ -1708,15 +1709,25 @@ kdump_test_ssh_check_id()
kdump_test_check_target()
{
- local _test_id
+ local _conf_checksum _test_id
_test_id=$(sed -ne "s/.*\($KDUMP_TEST_PREFIX.*\)\"/\1/p"
"$KDUMP_TEST_ENV" 2>/dev/null)
+ _conf_checksum=$(get_all_kdump_conf checksum_conf)
if [[ ! -f "$KDUMP_TEST_ENV" || -z "$_test_id" ]]; then
- dinfo "Need kdump test, please run \"kdumpctl test\" first!"
+ # We are not running "kdumpctl test-check" the 1st time, so no
+ # need to recheck the test dmesg logs, just check if kdump conf
+ # is changed, it is much faster
+ if [[ -f "$KDUMP_TEST_SUCCESS_CHECKSUM" &&
"$_conf_checksum" == $(cat "$KDUMP_TEST_SUCCESS_CHECKSUM" | tr -s
' ' | cut -d ' ' -f 2) ]]; then
+ dinfo "kdump test successful!"
+ else
+ dinfo "Need kdump test, please run \"kdumpctl test\" first!"
+ fi
return
fi
+ # We are running "kdumpctl test-check" the 1st time, so check the test
+ # dmesg logs and refresh kdump conf checksum if the checking is successful
[[ ${#OPT[@]} -eq 0 ]] && { parse_config || return ;}
if is_fs_dump_target || is_nfs_dump_target; then
check_user_configured_target "${OPT[_target]}" "${OPT[_fstype]}"
kdump_test_check_id "$_test_id"
@@ -1730,6 +1741,7 @@ kdump_test_check_target()
fi
if [[ $? -eq 0 ]]; then
+ echo "$_test_id $_conf_checksum" >
"$KDUMP_TEST_SUCCESS_CHECKSUM"
dinfo "kdump test successful!"
else
dinfo "kdump test failed!"
@@ -1789,6 +1801,15 @@ output_conf()
printf -- '-%.0s' $(seq -s " " $((_line_width + 1))); echo
}
+checksum_conf()
+{
+ local -n conf=$1
+
+ for _key in "${!conf[@]}"; do
+ echo "$_key ${conf[$_key]} "
+ done | md5sum | cut -d' ' -f1
+}
+
get_all_kdump_conf()
{
local _max_width=0 _width _elem _line_width _key _func=$1
--
2.40.1