From 891cfc90e5c70073f9cbc7c71edb63874625372b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 20 Nov 2025 17:01:18 +0800 Subject: [PATCH 1/2] Don't let logger functions turn off xtrace Resolves: https://github.com/rhkdump/kdump-utils/issues/108 Functions like dwarn in kdump-logger.sh disable xtrace temporarily and only re-enable xtrace when debug is set. Automatically set debug environment variable to resolve this issue. Signed-off-by: Coiby Xu --- kdump-logger.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kdump-logger.sh b/kdump-logger.sh index c8e7f7d3..d00ab874 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -37,6 +37,14 @@ # The code in this file might be run in an environment without bash. # Any code added must be POSIX compliant. +# When xtrace is enabled, set debug to prevent logger functions from turning +# off xtrace +case "$-" in +*"x"*) + debug=1 + ;; +esac + # Define vairables for the log levels in this module. kdump_stdloglvl="" kdump_sysloglvl="" From 2f7929f0d98ed11e47ff5d901f18e9d77528fb02 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 20 Nov 2025 17:15:52 +0800 Subject: [PATCH 2/2] Enable xtrace in mkdumprd, mkfadumprd and dracut when kdumpctl enables xtrace Resolves: https://github.com/rhkdump/kdump-utils/issues/118 Since dracut commit 5042681("fix(dracut.sh): initialize variables that get exported"), debug=1 won't enable xtrace in dracut. Let's call dracut with --debug explicitly in mkdumprd and mkfadumprd. Also enable xtrace in mkdumprd and mkfadumprd by passing --debug argument when kdumpctl enables xtrace. Signed-off-by: Coiby Xu --- kdumpctl | 8 +++++++- mkdumprd | 11 +++++++++-- mkfadumprd | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index 265cd3a0..32e388cd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -4,8 +4,14 @@ KEXEC=/sbin/kexec KDUMP_KERNELVER="" KDUMP_KERNEL="" KEXEC_ARGS="" -MKDUMPRD="/sbin/mkdumprd -f" +MKDUMPRD="/sbin/mkdumprd" MKFADUMPRD="/sbin/mkfadumprd" +if shopt -q -o xtrace; then + MKDUMPRD+=" --debug" + MKFADUMPRD+=" --debug" +fi +MKDUMPRD+=" -f" + DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" # Path to the initrd used for normal boot. Used to determine the naming diff --git a/mkdumprd b/mkdumprd index f1116d16..00beda01 100644 --- a/mkdumprd +++ b/mkdumprd @@ -6,7 +6,10 @@ # Written by Cong Wang # -[[ -n $debug ]] && set -x +if [[ $1 == --debug ]]; then + set -x + shift +fi if [[ -f /etc/sysconfig/kdump ]]; then # shellcheck source=/dev/null @@ -32,7 +35,11 @@ SSH_KEY_LOCATION=$DEFAULT_SSHKEY SAVE_PATH=$(get_save_path) declare -a dracut_args -dracut_args+=(--quiet) +if [[ -n $debug ]]; then + dracut_args+=(--debug) +else + dracut_args+=(--quiet) +fi dracut_args+=(--hostonly) dracut_args+=(--hostonly-cmdline) dracut_args+=(--hostonly-i18n) diff --git a/mkfadumprd b/mkfadumprd index 948f1cf7..cf24f0ab 100755 --- a/mkfadumprd +++ b/mkfadumprd @@ -2,6 +2,17 @@ # Generate an initramfs image that isolates dump capture capability within # the default initramfs using zz-fadumpinit dracut module. +MKDUMPRD="/sbin/mkdumprd" +if [[ $1 == --debug ]]; then + set -x + shift + MKDUMPRD+=" --debug" + debug_dracut=--debug +else + debug_dracut=--quiet +fi +MKDUMPRD+=" -f" + if [[ -f /etc/sysconfig/kdump ]]; then # shellcheck source=/dev/null . /etc/sysconfig/kdump @@ -33,7 +44,6 @@ trap ' # clean up after ourselves no matter how we die. trap 'exit 1;' SIGINT -MKDUMPRD="/sbin/mkdumprd -f" # Default boot initramfs to be rebuilt REBUILD_INITRD="$1" && shift TARGET_INITRD="$1" && shift @@ -74,6 +84,6 @@ if ! have_compression_in_dracut_args; then fi fi -if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then +if ! dracut "$debug_dracut" --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability" fi