In order to check whether the specified makedumpfile parameters are valid or not when generating initramfs, use the --check-params option, which was recently added.
With the patch, kdumpctl can point out mistakes in core_collector option and failed. For example, if there is an practical mistake that dump_level is -1:
# cat /etc/kdump.conf core_collector makedumpfile -l --message-level 1 -d -1
# kdumpctl start Detected change(s) in the following file(s):
/etc/kdump.conf Rebuilding /boot/initramfs-5.4.19-200.fc31.x86_64kdump.img Dump_level(-1) is invalid. makedumpfile parameter check failed. mkdumprd: failed to make kdump initrd Starting kdump: [FAILED]
Signed-off-by: Kazuhito Hagio k-hagio-ab@nec.com --- mkdumprd | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 6c33fc5..b46fd32 100644 --- a/mkdumprd +++ b/mkdumprd @@ -199,15 +199,27 @@ check_size() {
# $1: core_collector config value verify_core_collector() { - if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then - echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." + local _cmd="${1%% *}" + local _params="${1#* }" + + if [ "$_cmd" != "makedumpfile" ]; then + if is_raw_dump_target; then + echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." + fi + return fi + if is_ssh_dump_target || is_raw_dump_target; then - if [ "${1%% *}" = "makedumpfile" ]; then - ! strstr "$1" "-F" && { - perror_exit "The specified dump target needs makedumpfile "-F" option." - } + if ! strstr "$_params" "-F"; then + perror_exit "The specified dump target needs makedumpfile "-F" option." fi + _params="$_params vmcore" + else + _params="$_params vmcore dumpfile" + fi + + if ! $_cmd --check-params $_params; then + perror_exit "makedumpfile parameter check failed." fi }