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 ?
Thanks
>
>
>Thanks,
>
> Pingfan
>> +}
>> +
>> if [[ ! -f $KDUMP_CONFIG_FILE ]]; then
>> derror "Error: No kdump config file found!"
>> exit 1
>> @@ -1522,6 +1542,9 @@ main()
>> reset-crashkernel)
>> reset_crashkernel "$2" "$3"
>> ;;
>> + fadump)
>> + toggle_fadump "$2" "$3" "$4"
>> + ;;
>> *)
>> dinfo $"Usage: $0
{estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
>> exit 1
>> diff --git a/kdumpctl.8 b/kdumpctl.8
>> index 19734aa..17b10cf 100644
>> --- a/kdumpctl.8
>> +++ b/kdumpctl.8
>> @@ -55,7 +55,9 @@ Reset crashkernel value to CRASHKERNEL or the value specified
in
>> /etc/kdump.conf. If no kernel is specified, will reset current running
>> kernel's crashkernel value. If CRASHKERNEL is given, the value would be
also
>> writeen to /etc/kdump.conf.
>> -
>> +.TP
>> +.I fadump on/off [[KERNELPATH[, CRASHKERNEL]], [CRASHKERNEL], [KERNELPATH]]
>> +Toggle fadump on or off and reset crashkernel.
>>
>> .SH "SEE ALSO"
>> .BR kdump.conf (5),
>> --
>> 2.31.1
>>
>
--
Best regards,
Coiby