kdump-lib: always specify version in is_squash_available
is_squash_available is only used in dracut-module-setup.sh and mkdumprd. Neither of the two scripts calls prepare_kdump_bootinfo which determines and sets KDUMP_KERNELVER. Thus KDUMP_KERNELVER is only non-zero if it explicitly specified by the user in /etc/sysconfig/kdump (and the file gets sourced, which is not the case for drachu-module-setup.sh). In theory this can even lead to bugs. For example consider the case when a debug kernel is running. In that case kdumpctl will try to use the non-debug version of the kernel while is_squash_available will make its decision based on the debug version. So in case the debug kernel has squash available but the non-debug kernel doesn't mkdumprd will try to add it nevertheless. Thus factor out the kernel version detection from prepare_kdump_bootinfo and make use of the new function when checking for the availability of those kernel modules. Signed-off-by: Philipp Rudo <prudo@redhat.com> Reviewed-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
parent
383cb62202
commit
88919b73f0
64
kdump-lib.sh
64
kdump-lib.sh
@ -24,12 +24,11 @@ is_fadump_capable()
|
||||
|
||||
is_squash_available()
|
||||
{
|
||||
local _version kmodule
|
||||
|
||||
_version=$(_get_kdump_kernel_version)
|
||||
for kmodule in squashfs overlay loop; do
|
||||
if [[ -z $KDUMP_KERNELVER ]]; then
|
||||
modprobe --dry-run $kmodule &> /dev/null || return 1
|
||||
else
|
||||
modprobe -S "$KDUMP_KERNELVER" --dry-run $kmodule &> /dev/null || return 1
|
||||
fi
|
||||
modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1
|
||||
done
|
||||
}
|
||||
|
||||
@ -687,6 +686,31 @@ prepare_kdump_kernel()
|
||||
echo "$kdump_kernel"
|
||||
}
|
||||
|
||||
_get_kdump_kernel_version()
|
||||
{
|
||||
local _version _version_nondebug
|
||||
|
||||
if [[ -n "$KDUMP_KERNELVER" ]]; then
|
||||
echo "$KDUMP_KERNELVER"
|
||||
return
|
||||
fi
|
||||
|
||||
_version=$(uname -r)
|
||||
if [[ ! "$_version" =~ \+debug$ ]]; then
|
||||
echo "$_version"
|
||||
return
|
||||
fi
|
||||
|
||||
_version_nondebug=${_version%+debug}
|
||||
if [[ -f "$(prepare_kdump_kernel "$_version_nondebug")" ]]; then
|
||||
dinfo "Use of debug kernel detected. Trying to use $_version_nondebug"
|
||||
echo "$_version_nondebug"
|
||||
else
|
||||
dinfo "Use of debug kernel detected but cannot find $_version_nondebug. Falling back to $_version"
|
||||
echo "$_version"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Detect initrd and kernel location, results are stored in global environmental variables:
|
||||
# KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD
|
||||
@ -696,37 +720,11 @@ prepare_kdump_kernel()
|
||||
#
|
||||
prepare_kdump_bootinfo()
|
||||
{
|
||||
local boot_initrdlist nondebug_kernelver debug_kernelver
|
||||
local default_initrd_base var_target_initrd_dir
|
||||
|
||||
if [[ -z $KDUMP_KERNELVER ]]; then
|
||||
KDUMP_KERNELVER=$(uname -r)
|
||||
|
||||
# Fadump uses the regular bootloader, unlike kdump. So, use the same version
|
||||
# for default kernel and capture kernel unless specified explicitly with
|
||||
# KDUMP_KERNELVER option.
|
||||
if ! is_fadump_capable; then
|
||||
nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER")
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use nondebug kernel if possible, because debug kernel will consume more memory and may oom.
|
||||
if [[ -n $nondebug_kernelver ]]; then
|
||||
dinfo "Trying to use $nondebug_kernelver."
|
||||
debug_kernelver=$KDUMP_KERNELVER
|
||||
KDUMP_KERNELVER=$nondebug_kernelver
|
||||
fi
|
||||
local boot_initrdlist default_initrd_base var_target_initrd_dir
|
||||
|
||||
KDUMP_KERNELVER=$(_get_kdump_kernel_version)
|
||||
KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER")
|
||||
|
||||
if ! [[ -e $KDUMP_KERNEL ]]; then
|
||||
if [[ -n $debug_kernelver ]]; then
|
||||
dinfo "Fallback to using debug kernel"
|
||||
KDUMP_KERNELVER=$debug_kernelver
|
||||
KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER")
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [[ -e $KDUMP_KERNEL ]]; then
|
||||
derror "Failed to detect kdump kernel location"
|
||||
return 1
|
||||
|
Loading…
Reference in New Issue
Block a user