Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kdump-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
8 changes: 7 additions & 1 deletion kdumpctl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions mkdumprd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# Written by Cong Wang <amwang@redhat.com>
#

[[ -n $debug ]] && set -x
if [[ $1 == --debug ]]; then
set -x
shift
fi

if [[ -f /etc/sysconfig/kdump ]]; then
# shellcheck source=/dev/null
Expand All @@ -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
Comment on lines -35 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @coiby,

I had an other look and while the change is fine I'm a little bit worried about both dracut and kdumpctl using debug as a variable. In particular the fact that when we export debug in kdumpctl dracut will overwrite 'our' variable. So I'm wondering if it makes sense to also call dracut in a sub-shell in addition to the change proposed. With that we wouldn't need to worry about changes in dracut causing trouble in the future. What do you think?

Thanks
Philipp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising the concern! Although dracut won't overwrite our variable because we call it with --debug, it's better to avoid using this variable in our code. So I make mkdumprd and mkfadumprd accepts --debug argument to enable xtrace in new version.

dracut_args+=(--hostonly)
dracut_args+=(--hostonly-cmdline)
dracut_args+=(--hostonly-i18n)
Expand Down
14 changes: 12 additions & 2 deletions mkfadumprd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Comment on lines 86 to 89
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit, the call to dracut already contains --quiet. So $debug_dracut adds a second one or a conflicting (?) --debug

Loading