On Fri, Nov 19, 2021 at 2:42 PM Coiby Xu <coxu(a)redhat.com> wrote:
On Fri, Nov 19, 2021 at 02:20:44PM +0800, Pingfan Liu wrote:
>On Fri, Nov 19, 2021 at 1:52 PM Coiby Xu <coxu(a)redhat.com> wrote:
>>
>> On Fri, Nov 19, 2021 at 01:25:25PM +0800, Pingfan Liu wrote:
>> >On Fri, Nov 19, 2021 at 11:23:07AM +0800, Coiby Xu wrote:
>> >> "kdumpctl fadump on/off" would be used to toggle on/off
fadump and then
>> >> call reset-crashkernel.
>> >>
>> >> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
>> >> ---
>> >> kdumpctl | 23 +++++++++++++++++++++++
>> >> kdumpctl.8 | 4 +++-
>> >> 2 files changed, 26 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/kdumpctl b/kdumpctl
>> >> index 5149cfe..22ee48b 100755
>> >> --- a/kdumpctl
>> >> +++ b/kdumpctl
>> >> @@ -1458,6 +1458,26 @@ reset_crashkernel()
>> >> _update_crashkernel "$_grub_kernel_path"
"$_kernel_crashkernel"
>> >> }
>> >>
>> >> +toggle_fadump()
>> >> +{
>> >> +
>> >> + local _grub_kernel_path _crashkernel _tmp_str
>> >> + if [[ $1 != on && $1 != nocma && $1 != off ]];
then
>> >> + derror "$1 invalid, valid values are
on/off/nocma"
>> >> + exit 1
>> >> + fi
>> >> +
>> >> + if _tmp_str=$(_determine_kernel_path_and_crashkernel
"$2" "$3"); then
>> >> + _grub_kernel_path=$(cut -d ";" -f 1 <<<
"$_tmp_str")
>> >> + _crashkernel=$(cut -d ";" -f 2 <<<
"$_tmp_str")
>> >> + else
>> >> + exit 1
>> >> + fi
>> >> +
>> >> + grubby --args "fadump=$1" --update-kernel
"$_grub_kernel_path"
>> >> + reset_crashkernel "$_grub_kernel_path"
"$_crashkernel"
>> >
>> >The kdump_get_arch_recommend_size()->is_fadump_capable() only works if
>> >booting with fadump=on.
>>
>> This interface doesn't use kdump_get_arch_recommend_size. To determine
>> if fadump is enabled for a kernel, the only reliably way is to get it
>> from grubby. For example, a user enables fadump for a kernel by running
>> "kumpctl fadump on" but is_fadump_capable is false in this case
before
>> rebooting the system.
>>
>> >
>> >So here let us say fadump=off -> on, unless I misunderstand, it can get
>> >the correct "crashkernel="
>
>As the above question, could you enlighten me about how to get the
>correct "crashkernel=" in the series ?
For crashkernel=auto, there are three cases where we need to get
crashkernel value,
1. when installing OS
kdump-anaconda-addon will call "kdumpctl get-default-crashkernel" to get
the value. If the user chooses to enable fadump, the addon would call
"kdumpctl get-default-crashkernel fadump" instead.
2. when the user toggles fadump on
a) kdumpctl would add "fadump=on" to the specified kernel cmdline.
b) reset_crashkernel would call get_dump_mode_of_kernel which
would return fadump since fadump=on is found in the kernel cmdline.
c) Then kdump_get_arch_recommend_crashkernel "$_dump_mode" would
return the fadump default crashkernel.
This is what I was concerned about. And I think you can avoid to call
grubby twice by taking the "1" way, something like "kdumpctl
get-default-crashkernel fadump=on"
Thanks,
Pingfan