On Tue, 9 May 2023 15:01:39 +0800
Coiby Xu <coxu(a)redhat.com> wrote:
> Currently, kexec-tools only updates the crashkernel to a new default
> value only when both two conditions are met,
> - auto_reset_crashkernel=yes in kdump.conf
> - existing kernels or current running kernel should use the old default
> value.
>
> To address seen corner cases, the logic to tell if the second condition
> is met becomes quite complex. Instead of making the logic more complex
> to support aarch64-64k, this patch drops the second condition to
> simplify the management of the crashkernel kernel parameter.
>
> Note this patch also stop trying to update /etc/default/grub because
> 1) it only affects the static file /boot/grub2/grub.cfg
> 2) grubby is recommended to change the kernel command-line parameters
> for both Fedora [1] and RHEL9 [2][3]
> 3) For the cases of aarch64 and POWER, different kernels could have
> different default crashkernel value.
>
> [1]
https://fedoraproject.org/wiki/GRUB_2
> [2]
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/...
> [3]
https://access.redhat.com/solutions/1136173
>
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> kdump.conf.5 | 5 ++-
> kdumpctl | 89 +++++++++++-------------------------------------
> kexec-tools.spec | 21 ------------
> 3 files changed, 21 insertions(+), 94 deletions(-)
>
> diff --git a/kdump.conf.5 b/kdump.conf.5
> index e3e9900b..ec285524 100644
> --- a/kdump.conf.5
> +++ b/kdump.conf.5
> @@ -28,9 +28,8 @@ understand how this configuration file affects the behavior of
kdump.
>
> .B auto_reset_crashkernel <yes|no>
> .RS
> -determine whether to reset kernel crashkernel to new default value
> -or not when kexec-tools updates the default crashkernel value and
> -existing kernels using the old default kernel crashkernel value
> +determine whether to reset kernel crashkernel parameter to the default value
> +or not when kexec-tools is updated or a new kernel is installed.
>
> .B raw <partition>
> .RS
> diff --git a/kdumpctl b/kdumpctl
> index edcf2caf..6e66e7bb 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -1585,72 +1585,36 @@ _is_bootloader_installed()
> fi
> }
>
> -# update the crashkernel value in GRUB_ETC_DEFAULT if necessary
> -#
> -# called by reset_crashkernel_after_update and inherit its array variable
> -# _crashkernel_vals
> -update_crashkernel_in_grub_etc_default_after_update()
> -{
> - local _crashkernel _fadump_val
> - local _dump_mode _old_default_crashkernel _new_default_crashkernel
> -
> - if [[ $(uname -m) == s390x ]]; then
> - return
> - fi
> -
> - _crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel)
I think with this patch there is no more user of
_read_kernel_arg_in_grub_etc_default. You can remove this as well.
> -
> - if [[ -z $_crashkernel ]]; then
> - return
> - fi
> -
> - _fadump_val=$(_read_kernel_arg_in_grub_etc_default fadump)
> - _dump_mode=$(get_dump_mode_by_fadump_val "$_fadump_val")
> -
> - _old_default_crashkernel=${_crashkernel_vals[old_${_dump_mode}]}
> - _new_default_crashkernel=${_crashkernel_vals[new_${_dump_mode}]}
> -
> - if [[ $_crashkernel == auto ]] ||
> - [[ $_crashkernel == "$_old_default_crashkernel" &&
> - $_new_default_crashkernel != "$_old_default_crashkernel" ]]; then
> - _update_kernel_arg_in_grub_etc_default crashkernel
"$_new_default_crashkernel"
> +_update_crashkernel()
> +{
> + local _kernel _dump_mode _old_default_crashkernel _new_default_crashkernel
_fadump_val
> +
> + _kernel=$1
> + _dump_mode=$(get_dump_mode_by_kernel "$_kernel")
> + _old_default_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel"
crashkernel)
> + _new_default_crashkernel=$(kdump_get_arch_recommend_crashkernel
"$_dump_mode")
> + if [[ $_old_default_crashkernel != "$_new_default_crashkernel" ]]; then
> + _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
> + if _update_kernel_cmdline "$_kernel"
"$_new_default_crashkernel" "$_dump_mode" "$_fadump_val";
then
> + echo -n "For kernel=$_kernel, crashkernel=$_new_default_crashkernel now.
Please reboot the system for the change to take effet."
> + echo " Note if you don't want kexec-tools to manage the crashkernel
kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf."
> + fi
> fi
> }
>
> +
> # shellcheck disable=SC2154 # false positive when dereferencing an array
^^^^^^^^^^^^^^^^^^^^^^^^^
Is this still needed with your change?