From a1c28126ef02976556c60a4bd59a41b7c75321cd Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 27 Feb 2020 11:18:20 -0500 Subject: [PATCH] mkdumprd: Use makedumpfile --check-params option 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 Acked-by: Kairui Song --- mkdumprd | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 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." - 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." - } + 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 ! 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 }