From cb3d1c1c3f8e6060467701d3f33f6e5c18d119a2 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Fri, 22 Sep 2017 16:30:05 +0530 Subject: [PATCH 001/806] kdumpctl: Error out in case there are white spaces before an option name Resolves: BZ1484945 https://bugzilla.redhat.com/show_bug.cgi?id=1484945 Currently the kdumpctl script doesn't handle whitespaces (including TABs) which might be there before an option name in the kdump.conf This patch addresses this issue, by ensuring that the kdumpctl errors out in case it finds any stray space(s) or tab(s) before a option name. Reported-by: Kenneth D'souza Signed-off-by: Bhupesh Sharma Acked-by: Pratyush Anand Acked-by: Dave Young --- kdumpctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kdumpctl b/kdumpctl index 7d06efe..d4e0050 100755 --- a/kdumpctl +++ b/kdumpctl @@ -364,6 +364,13 @@ check_config() return 1 } + # Check if we have any leading spaces (or tabs) before the + # variable name in the kdump conf file + if grep -E -q '^[[:blank:]]+[a-z]' $KDUMP_CONFIG_FILE; then + echo "No whitespaces are allowed before a kdump option name in $KDUMP_CONFIG_FILE" + return 1 + fi + while read config_opt config_val; do case "$config_opt" in \#* | "") From 823c962ff191f602a86d1840ae19de0b1d794b7b Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 11 Oct 2017 09:59:00 +0800 Subject: [PATCH 002/806] Release 2.0.15-14 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 292b689..2ffe7e5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist} +Release: 14%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Wed Oct 11 2017 Dave Young - 2.0.15-14 +- kdumpctl: Error out in case there are white spaces before an option name + * Wed Sep 6 2017 Dave Young - 2.0.15-13 - dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call - mkdumprd: use --quiet dracut argument to speedup initramfs build From 8e3b6475c9fcc4b55a5e704f588fa6df1c169e15 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:37:48 +0800 Subject: [PATCH 003/806] Use absolute path /usr/bin/dracut in mkdumprd Since we call dracut directly on current working directory "." so it is possible to trick root to call fake code. Thus move to use absolute path instead. Signed-off-by: Dave Young Acked-by: Bhupesh Sharma --- mkdumprd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 2f71f7b..d91be5d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,6 +17,7 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -457,7 +458,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -dracut "${dracut_args[@]}" "$@" +${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From a2d284eea835e3d0952b93c6391a63511c1df740 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:45:37 +0800 Subject: [PATCH 004/806] Release 2.0.15-15 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2ffe7e5..315a22b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 14%{?dist} +Release: 15%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Thu Nov 9 2017 Dave Young - 2.0.15-15 +- Use absolute path /usr/bin/dracut in mkdumprd + * Wed Oct 11 2017 Dave Young - 2.0.15-14 - kdumpctl: Error out in case there are white spaces before an option name From 36c1159249cc19866dd6404d4c15ea60cba76799 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:42:16 +0800 Subject: [PATCH 005/806] Use absolute path /usr/bin/dracut in mkdumprd Since we call dracut directly on current working directory "." so it is possible to trick root to call fake code. Thus move to use absolute path instead. Signed-off-by: Dave Young Acked-by: Bhupesh Sharma --- mkdumprd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 2f71f7b..d91be5d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,6 +17,7 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -457,7 +458,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -dracut "${dracut_args[@]}" "$@" +${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From cf2c8da395240e4533fe3bcee675b06ccd81d292 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:43:46 +0800 Subject: [PATCH 006/806] Release 2.0.15-13.1 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 292b689..dde98e1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist} +Release: 13%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Thu Nov 9 2017 Dave Young - 2.0.15-13.1 +- Use absolute path /usr/bin/dracut in mkdumprd + * Wed Sep 6 2017 Dave Young - 2.0.15-13 - dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call - mkdumprd: use --quiet dracut argument to speedup initramfs build From d3577e3394b92a1e9183d9a355a88c4d230bf9a7 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 15:28:54 +0800 Subject: [PATCH 007/806] Revert "Use absolute path /usr/bin/dracut in mkdumprd" This reverts commit 8e3b6475c9fcc4b55a5e704f588fa6df1c169e15. After reading the background of bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1510922 It is not a problem actually, sorry for the noise. Although root set different "PATH" can lead to wrong script, but it is different with what the bug described "current working dir" and it is not a problem worth an update --- mkdumprd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index d91be5d..2f71f7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,7 +17,6 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) -DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -458,7 +457,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" +dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From a4a1ee8267b72bde6b845faf8067d13c139d108a Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 15:30:54 +0800 Subject: [PATCH 008/806] Revert "Use absolute path /usr/bin/dracut in mkdumprd" This reverts commit 36c1159249cc19866dd6404d4c15ea60cba76799. After reading the background of bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1510922 It is not a problem actually, sorry for the noise. Although root set different "PATH" can lead to wrong script, but it is different with what the bug described "current working dir" and it is not a problem worth an update --- mkdumprd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index d91be5d..2f71f7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,7 +17,6 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) -DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -458,7 +457,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" +dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From 5b72833fbed3b4f95f5435ee266ea4e4a5993424 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 15:32:31 +0800 Subject: [PATCH 009/806] Release 2.0.15-13.2 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index dde98e1..dd37406 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist}.1 +Release: 13%{?dist}.2 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Thu Nov 9 2017 Dave Young - 2.0.15-13.2 +- Revert "Use absolute path /usr/bin/dracut in mkdumprd" + * Thu Nov 9 2017 Dave Young - 2.0.15-13.1 - Use absolute path /usr/bin/dracut in mkdumprd From bdd2ac6b93fdd3b7ebfa4994c44a958e9c646234 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 12:54:35 +0800 Subject: [PATCH 010/806] Release 2.0.16-1 Signed-off-by: Dave Young --- kexec-tools.spec | 7 +++++-- sources | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 315a22b..ffb8c65 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools -Version: 2.0.15 -Release: 15%{?dist} +Version: 2.0.16 +Release: 1%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Tue Nov 21 2017 Dave Young - 2.0.16-1 +- update to kexec-tools 2.0.16 + * Thu Nov 9 2017 Dave Young - 2.0.15-15 - Use absolute path /usr/bin/dracut in mkdumprd diff --git a/sources b/sources index 68abd0c..078a4e7 100644 --- a/sources +++ b/sources @@ -1,6 +1,4 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f -SHA512 (kexec-tools-2.0.14.tar.xz) = 8c1f9d1f4bb69a621961d45091f9c8349535ae69b80168423663685b44d89e1b9324d5cd11c83e86d805a3371f4f1600b0def551c52efb3c6cf020e9c11c273f SHA512 (kdump-anaconda-addon-005-25-g2a4398f.tar.gz) = 0ce8602607a8d781e1804973e6affef1ed3dce729bb1a5525b2a8129f28bcb88713f6e8be5e3f41151223518096f7eed33dd3ea0e63ac7dc338b21fb78664e7e -SHA512 (makedumpfile-1.6.1.tar.gz) = fd343e8117e38f9fd608f914297dfe54e0b677733db1871db5824d8ca549e6b8709ae5df6ec82362c100c6d8f35815c39c48e0c87395a30e6305aba7d11c8708 -SHA512 (kexec-tools-2.0.15.tar.xz) = 0bddf31b9bb0e203b813d820e1e248974c2d62cb388dfaf4f2f4971f764cc71e54edbaeaeb663c15d6fa06574beceb87d9ffd7d822ac6699d86c54645096e7e9 SHA512 (makedumpfile-1.6.2.tar.gz) = 436a787c9da7f0278289b22489936f0a06eb0cc558792245c513e4a5ad733057a9d0fb9c5e2e7ed887b1bdd128f9f016ce9c263f912dcc8636fd82637fc25658 +SHA512 (kexec-tools-2.0.16.tar.xz) = f2f06e7702fef20c8d7d6aabe1b264e2e2689e5c38cc00dbc2186dd7fa0479edb2dc9e307dd2ad7f03db47015e966e577f11576172604ef01c1bcca471fe2c24 From b316bfa8e1da6d0477e8de3b0abe80c91efcb143 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:27 +0800 Subject: [PATCH 011/806] Revert "Release 2.0.15-13.2" This reverts commit 5b72833fbed3b4f95f5435ee266ea4e4a5993424. --- kexec-tools.spec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index dd37406..dde98e1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist}.2 +Release: 13%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,9 +317,6 @@ done %doc %changelog -* Thu Nov 9 2017 Dave Young - 2.0.15-13.2 -- Revert "Use absolute path /usr/bin/dracut in mkdumprd" - * Thu Nov 9 2017 Dave Young - 2.0.15-13.1 - Use absolute path /usr/bin/dracut in mkdumprd From 35d31cea92b7bd0fa0aef2334e99bd875e0b4951 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:30 +0800 Subject: [PATCH 012/806] Revert "Revert "Use absolute path /usr/bin/dracut in mkdumprd"" This reverts commit a4a1ee8267b72bde6b845faf8067d13c139d108a. --- mkdumprd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 2f71f7b..d91be5d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,6 +17,7 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -457,7 +458,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -dracut "${dracut_args[@]}" "$@" +${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From 55388d1a2a0e1b93aecca0e962fdc81009c93dca Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:31 +0800 Subject: [PATCH 013/806] Revert "Release 2.0.15-13.1" This reverts commit cf2c8da395240e4533fe3bcee675b06ccd81d292. --- kexec-tools.spec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index dde98e1..292b689 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist}.1 +Release: 13%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,9 +317,6 @@ done %doc %changelog -* Thu Nov 9 2017 Dave Young - 2.0.15-13.1 -- Use absolute path /usr/bin/dracut in mkdumprd - * Wed Sep 6 2017 Dave Young - 2.0.15-13 - dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call - mkdumprd: use --quiet dracut argument to speedup initramfs build From 2f82313fa3cf1556c840c7de5cce9c5cb4d8fecc Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:32 +0800 Subject: [PATCH 014/806] Revert "Use absolute path /usr/bin/dracut in mkdumprd" This reverts commit 36c1159249cc19866dd6404d4c15ea60cba76799. --- mkdumprd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index d91be5d..2f71f7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,7 +17,6 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) -DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -458,7 +457,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" +dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From ed3e1c12488a53173478e96d377a9c0a2fc7fdae Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:33 +0800 Subject: [PATCH 015/806] Revert "Release 2.0.15-13" This reverts commit 4594c9830dc646a2838bb1c9ea35c2979f328496. --- kexec-tools.spec | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 292b689..f356e32 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 13%{?dist} +Release: 12%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,22 +317,6 @@ done %doc %changelog -* Wed Sep 6 2017 Dave Young - 2.0.15-13 -- dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call -- mkdumprd: use --quiet dracut argument to speedup initramfs build -- mkdumprd: fix patterns to modify mount options -- fadump: rebuild default initrd with dump capture capability -- module-setup: remove software iscsi cmdline generated by dracut -- kdumpctl: remove some cmdline inheritage from 1st kernel -- mkdumprd: apply dracut "--hostonly-cmdline" and "--no-hostonly-default-device" -- Change dump_to_rootfs to use "--mount" instead of "root=X" -- kdumpctl: move is_fadump_capable() to kdump-lib.sh -- Revert "kdumpctl: use generated rd.lvm.lv=X" -- Revert "mkdumprd: omit crypt when there is no crypt kdump target" -- Revert "mkdumprd: omit dracut modules in case of no dm target" -- Revert "mkdumprd: omit dracut modules in case of network dumping" -- update bogus date in rpm spec - * Thu Aug 17 2017 Dave Young - 2.0.15-12 - makedumpfile: fix 4.13 kernel larget vmcore bug - Revert "Improve 'cpu add' udev rules" @@ -361,7 +345,7 @@ done * Wed Jul 26 2017 Fedora Release Engineering - 2.0.15-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild -* Wed Jul 19 2017 Dave Young - 2.0.15-4 +* Thu Jul 19 2017 Dave Young - 2.0.15-4 - mkdumprd: remove useless "x-initrd.mount" - kdumpctl: use "apicid" other than "initial apicid" @@ -379,7 +363,7 @@ done * Wed Jun 28 2017 Dave Young - 2.0.15-2 - enable makedumpfile for arm64 -* Fri Jun 23 2017 Dave Young - 2.0.15-1 +* Thu Jun 23 2017 Dave Young - 2.0.15-1 - rebase kexec-tools-2.0.15 * Thu Jun 15 2017 Dave Young - 2.0.14-13 From 552d4d51a6b766fbaaa6916a3b6c2cffbc09368e Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:34 +0800 Subject: [PATCH 016/806] Revert "dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call" This reverts commit c05c8980629da24fa7fe19768476f4d622cf9a0b. --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 0c3609f..25bbbe7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -276,12 +276,12 @@ kdump_setup_znet() { kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2 local _static _proto _ip_conf _ip_opts _ifname_opts - local _netmac=$(kdump_get_mac_addr $_netdev) if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi + _netmac=$(kdump_get_mac_addr $_netdev) _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none @@ -310,7 +310,7 @@ kdump_setup_netdev() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" else - _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$_netmac" + _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$(kdump_get_mac_addr $_netdev)" echo "$_ifname_opts" >> $_ip_conf fi From 201fe8c4425c859547d23ff28b64a7a4b19d8354 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:35 +0800 Subject: [PATCH 017/806] Revert "mkdumprd: use --quiet dracut argument to speedup initramfs build" This reverts commit 69ba16a409b1260ac3a5451ec5f3f2eac244b73c. --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 2f71f7b..33d107f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -37,7 +37,7 @@ is_wdt_addition_needed [[ $? -eq 0 ]] && WDTCFG="-a watchdog" extra_modules="" -dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "-o" "plymouth dash resume ifcfg" $WDTCFG) +dracut_args=("--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "-o" "plymouth dash resume ifcfg" $WDTCFG) OVERRIDE_RESETTABLE=0 add_dracut_arg() { From b703267aa5665c8177afaf1908477b0f67c6b44b Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:36 +0800 Subject: [PATCH 018/806] Revert "mkdumprd: fix patterns to modify mount options" This reverts commit 75ab9ee26aa03ead904890b6c56ab032c26bdad5. --- mkdumprd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mkdumprd b/mkdumprd index 33d107f..6df144b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -101,9 +101,8 @@ to_mount() { [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here. - _options=$(echo $_options | sed 's/\bnoauto\b//') - #mount fs target as rw in 2nd kernel - _options=$(echo $_options | sed 's/\bro\b/rw/') + _options=$(echo $_options | sed 's/noauto//') + _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From 2ecbf6a9890867e60d1e39d2be8311607e91d833 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:37 +0800 Subject: [PATCH 019/806] Revert "fadump: rebuild default initrd with dump capture capability" This reverts commit 601766a3d9a74e2708578286e6a2afddd8f72b95. --- kdumpctl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7d06efe..1aceacf 100755 --- a/kdumpctl +++ b/kdumpctl @@ -6,7 +6,6 @@ KDUMP_COMMANDLINE="" KEXEC_ARGS="" KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" -DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" @@ -651,7 +650,6 @@ check_system_modified() check_rebuild() { local extra_modules - local capture_capable_initrd="1" local _force_rebuild force_rebuild="0" local _force_no_rebuild force_no_rebuild="0" local ret system_modified="0" @@ -706,12 +704,6 @@ check_rebuild() #since last build of the image file if [ -f $TARGET_INITRD ]; then image_time=`stat -c "%Y" $TARGET_INITRD 2>/dev/null` - - #in case of fadump mode, check whether the default/target - #initrd is already built with dump capture capability - if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then - capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l) - fi fi check_system_modified @@ -726,8 +718,6 @@ check_rebuild() if [ $image_time -eq 0 ]; then echo -n "No kdump initial ramdisk found."; echo - elif [ "$capture_capable_initrd" == "0" ]; then - echo -n "Rebuild $TARGET_INITRD with dump capture support"; echo elif [ "$force_rebuild" != "0" ]; then echo -n "Force rebuild $TARGET_INITRD"; echo elif [ "$system_modified" != "0" ]; then From 1be02523ade22cb98077bba7f5b08b84becdabdf Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:37 +0800 Subject: [PATCH 020/806] Revert "module-setup: remove software iscsi cmdline generated by dracut" This reverts commit 3172bc0ef3d5ca89145a0a23746438a93680da17. --- dracut-module-setup.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 25bbbe7..ae13337 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -555,10 +555,6 @@ kdump_setup_iscsi_device() { return fi - # Remove software iscsi cmdline generated by 95iscsi, - # and let kdump regenerate here. - rm -f ${initdir}/etc/cmdline.d/95iscsi.conf - tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name") tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address") From 371d599b0d12d606948ad5a7f0a4e140098ef7a0 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:38 +0800 Subject: [PATCH 021/806] Revert "kdumpctl: remove some cmdline inheritage from 1st kernel" This reverts commit 2c9a863fd3f9c89d4b933e5f9f096df886e28c22. --- kdumpctl | 3 --- 1 file changed, 3 deletions(-) diff --git a/kdumpctl b/kdumpctl index 1aceacf..188c000 100755 --- a/kdumpctl +++ b/kdumpctl @@ -199,9 +199,6 @@ prepare_cmdline() # KDUMP_COMMANDLINE_APPEND. cmdline=$(remove_cmdline_param "$cmdline" root) - # With the help of "--hostonly-cmdline", we can avoid some interitage. - cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) - cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" id=$(get_bootcpu_apicid) From cc319fa32262bda990688d52bcc54f84f62a38ef Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:39 +0800 Subject: [PATCH 022/806] Revert "mkdumprd: apply dracut "--hostonly-cmdline" and "--no-hostonly-default-device"" This reverts commit e067d77dfc4581e3126ebdb8b297088be9d59fb6. --- kdump-lib.sh | 8 ++++++++ kexec-tools.spec | 2 +- mkdumprd | 4 +--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d981c4f..19d749f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -186,6 +186,14 @@ get_kdump_targets() kdump_targets="$kdump_targets $_root" fi + # NOTE: + # dracut parses devices from "/etc/fstab" with the "x-initrd.mount" option, + # which will be added as host_devs, it also includes usually simple devices + # (say mounted to /boot, /boot/efi/, etc) plus the root device. Then kdump + # must wait for these devices if initramfs is built with "--hostonly-cmdline". + # + # We don't pass "--hostonly-cmdline" to dracut, so there's no problem. + echo "$kdump_targets" } diff --git a/kexec-tools.spec b/kexec-tools.spec index f356e32..1a37ef9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -47,7 +47,7 @@ Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units Requires(pre): coreutils sed zlib -Requires: dracut >= 046-7 +Requires: dracut >= 044-117 Requires: dracut-network >= 044-117 Requires: ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel diff --git a/mkdumprd b/mkdumprd index 6df144b..5342dac 100644 --- a/mkdumprd +++ b/mkdumprd @@ -37,7 +37,7 @@ is_wdt_addition_needed [[ $? -eq 0 ]] && WDTCFG="-a watchdog" extra_modules="" -dracut_args=("--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "-o" "plymouth dash resume ifcfg" $WDTCFG) +dracut_args=("--hostonly" "--hostonly-i18n" "-o" "plymouth dash resume ifcfg" $WDTCFG) OVERRIDE_RESETTABLE=0 add_dracut_arg() { @@ -452,8 +452,6 @@ if ! is_fadump_capable; then # The 2nd rootfs mount stays behind the normal dump target mount, # so it doesn't affect the logic of check_dump_fs_modified(). is_dump_to_rootfs && add_mount "$(to_dev_name $(get_root_fs_device))" - - add_dracut_arg "--no-hostonly-default-device" fi dracut "${dracut_args[@]}" "$@" From b060f9f6b0216077f85d40ba6fae52f68d81a41a Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:40 +0800 Subject: [PATCH 023/806] Revert "Change dump_to_rootfs to use "--mount" instead of "root=X"" This reverts commit 31dc60ad20abab2e8276678d0704a8f99875b294. --- kdumpctl | 17 ++++++++++------- mkdumprd | 6 ------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/kdumpctl b/kdumpctl index 188c000..51d586d 100755 --- a/kdumpctl +++ b/kdumpctl @@ -181,29 +181,32 @@ prepare_cmdline() local cmdline id if [ -z "$KDUMP_COMMANDLINE" ]; then - cmdline=$(cat /proc/cmdline) + cmdline=`cat /proc/cmdline` else cmdline=${KDUMP_COMMANDLINE} fi # These params should always be removed - cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) + cmdline=`remove_cmdline_param "$cmdline" crashkernel panic_on_warn` # These params can be removed configurably - cmdline=$(remove_cmdline_param "$cmdline" ${KDUMP_COMMANDLINE_REMOVE}) + cmdline=`remove_cmdline_param "$cmdline" ${KDUMP_COMMANDLINE_REMOVE}` # Always remove "root=X", as we now explicitly generate all kinds - # of dump target mount information including root fs. + # of dump target mount information including root fs. But we can + # not remove it in case of fadump or "default dump_to_rootfs". # # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares # about it(e.g. for debug purpose), then can pass "root=X" using # KDUMP_COMMANDLINE_APPEND. - cmdline=$(remove_cmdline_param "$cmdline" root) + if [ $DEFAULT_DUMP_MODE != "fadump" ] && ! is_dump_to_rootfs; then + cmdline=`remove_cmdline_param "$cmdline" root` + fi cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" - id=$(get_bootcpu_apicid) + id=`get_bootcpu_apicid` if [ ! -z ${id} ] ; then - cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) + cmdline=`append_cmdline "${cmdline}" disable_cpu_apicid ${id}` fi KDUMP_COMMANDLINE=$cmdline diff --git a/mkdumprd b/mkdumprd index 5342dac..9f375e0 100644 --- a/mkdumprd +++ b/mkdumprd @@ -448,12 +448,6 @@ then add_dracut_arg "--add-drivers" "$extra_modules" fi -if ! is_fadump_capable; then - # The 2nd rootfs mount stays behind the normal dump target mount, - # so it doesn't affect the logic of check_dump_fs_modified(). - is_dump_to_rootfs && add_mount "$(to_dev_name $(get_root_fs_device))" -fi - dracut "${dracut_args[@]}" "$@" _rc=$? sync From 9c5ac7478d6bb05ae18d8918a06385095268be13 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:41 +0800 Subject: [PATCH 024/806] Revert "kdumpctl: move is_fadump_capable() to kdump-lib.sh" This reverts commit d5fe9022d004318e441f2a4cd0b9e924af6292c3. --- kdump-lib.sh | 12 ------------ kdumpctl | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 19d749f..a33f172 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -6,18 +6,6 @@ DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" -FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" - -is_fadump_capable() -{ - # Check if firmware-assisted dump is enabled - # if no, fallback to kdump check - if [ -f $FADUMP_ENABLED_SYS_NODE ]; then - rc=`cat $FADUMP_ENABLED_SYS_NODE` - [ $rc -eq 1 ] && return 0 - fi - return 1 -} perror_exit() { echo $@ >&2 diff --git a/kdumpctl b/kdumpctl index 51d586d..f172058 100755 --- a/kdumpctl +++ b/kdumpctl @@ -13,6 +13,7 @@ DUMP_TARGET="" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" TARGET_INITRD="" +FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" @@ -892,6 +893,17 @@ handle_mode_switch() fi } +is_fadump_capable() +{ + # Check if firmware-assisted dump is enabled + # if no, fallback to kdump check + if [ -f $FADUMP_ENABLED_SYS_NODE ]; then + rc=`cat $FADUMP_ENABLED_SYS_NODE` + [ $rc -eq 1 ] && return 0 + fi + return 1 +} + check_current_fadump_status() { # Check if firmware-assisted dump has been registered. From 59a87a4011006002b249755b19dbe35b6c7d50c4 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:42 +0800 Subject: [PATCH 025/806] Revert "Revert "kdumpctl: use generated rd.lvm.lv=X"" This reverts commit 1bd757bc9642cac081c06b0d0b572a66a013d63a. --- kdumpctl | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index f172058..6a275e8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -175,6 +175,45 @@ check_kdump_cpus() echo " try nr_cpus=$nr_min or larger instead" } +# Generate rd.lvm.lv=X for the kdump targets if any. +generate_lvm_cmdlines() +{ + local lvm_cmdlines="" + + generate_lvm_cmdline() { + local majmin=$1 dev + + [ -d "/sys/dev/block/$majmin/dm" ] || return 0 + dev=/dev/mapper/$(< "/sys/dev/block/$majmin/dm/name") + + vg=$(lvm lvs --rows $dev -o vg_name --separator=* 2>/dev/null | cut -d "*" -f 2) + lv=$(lvm lvs --rows $dev -o lv_name --separator=* 2>/dev/null | cut -d "*" -f 2) + if [ -n "$vg" -a -n "$lv" ]; then + lvm_cmdlines="rd.lvm.lv=$vg/$lv $lvm_cmdlines" + fi + + return 0 + } + + for_each_block_target_all generate_lvm_cmdline + + echo "$lvm_cmdlines" +} + +# $1: function name +for_each_block_target_all() +{ + local dev majmin + + for dev in $(get_kdump_targets); do + [ -b "$dev" ] || continue + majmin=$(get_maj_min $dev) + check_block_and_slaves_all $1 $majmin + done + + return 0 +} + # This function performs a series of edits on the command line. # Store the final result in global $KDUMP_COMMANDLINE. prepare_cmdline() @@ -194,15 +233,19 @@ prepare_cmdline() # Always remove "root=X", as we now explicitly generate all kinds # of dump target mount information including root fs. But we can - # not remove it in case of fadump or "default dump_to_rootfs". + # not remove it in case of "default dump_to_rootfs". # # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares # about it(e.g. for debug purpose), then can pass "root=X" using # KDUMP_COMMANDLINE_APPEND. - if [ $DEFAULT_DUMP_MODE != "fadump" ] && ! is_dump_to_rootfs; then + if ! is_dump_to_rootfs; then cmdline=`remove_cmdline_param "$cmdline" root` fi + # Remove all the inherited rd.lvm.lv=X and generate those as needed. + cmdline=`remove_cmdline_param "$cmdline" rd.lvm.lv` + cmdline="${cmdline} $(generate_lvm_cmdlines)" + cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" id=`get_bootcpu_apicid` From fed96039e2fade4ba50959ef5df74d10756061df Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:43 +0800 Subject: [PATCH 026/806] Revert "Revert "mkdumprd: omit crypt when there is no crypt kdump target"" This reverts commit 8250f23c10639faedcd3f3d4015d293a844cd241. --- kdump-lib.sh | 12 ++++++++++++ kdumpctl | 12 ------------ mkdumprd | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index a33f172..3f0af91 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -6,6 +6,7 @@ DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" +FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" perror_exit() { echo $@ >&2 @@ -481,3 +482,14 @@ get_dracut_args_target() { echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 } + +is_fadump_capable() +{ + # Check if firmware-assisted dump is enabled + # if no, fallback to kdump check + if [ -f $FADUMP_ENABLED_SYS_NODE ]; then + rc=`cat $FADUMP_ENABLED_SYS_NODE` + [ $rc -eq 1 ] && return 0 + fi + return 1 +} diff --git a/kdumpctl b/kdumpctl index 6a275e8..b7a3105 100755 --- a/kdumpctl +++ b/kdumpctl @@ -13,7 +13,6 @@ DUMP_TARGET="" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" TARGET_INITRD="" -FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" @@ -936,17 +935,6 @@ handle_mode_switch() fi } -is_fadump_capable() -{ - # Check if firmware-assisted dump is enabled - # if no, fallback to kdump check - if [ -f $FADUMP_ENABLED_SYS_NODE ]; then - rc=`cat $FADUMP_ENABLED_SYS_NODE` - [ $rc -eq 1 ] && return 0 - fi - return 1 -} - check_current_fadump_status() { # Check if firmware-assisted dump has been registered. diff --git a/mkdumprd b/mkdumprd index 9f375e0..8a2fe74 100644 --- a/mkdumprd +++ b/mkdumprd @@ -359,11 +359,24 @@ check_crypt() return 1 } +crypt_exists=0 +omit_dracut_modules() +{ + # Skip fadump case + is_fadump_capable && return + + # Omit "crypt", BZ1451717 + if [ "$crypt_exists" == "0" ]; then + add_dracut_arg "--omit" "crypt" + fi +} + if ! check_resettable; then exit 1 fi if ! check_crypt; then + crypt_exists=1 echo "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot." fi @@ -448,6 +461,8 @@ then add_dracut_arg "--add-drivers" "$extra_modules" fi +omit_dracut_modules + dracut "${dracut_args[@]}" "$@" _rc=$? sync From 14251ce101b1cd7b27059521e4922833bda380b1 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:44 +0800 Subject: [PATCH 027/806] Revert "Revert "mkdumprd: omit dracut modules in case of no dm target"" This reverts commit dcffd4759e56169d5f8f1522c84f9fb0a0de7715. --- mkdumprd | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mkdumprd b/mkdumprd index 8a2fe74..68fe6e8 100644 --- a/mkdumprd +++ b/mkdumprd @@ -359,16 +359,44 @@ check_crypt() return 1 } +is_dm() +{ + if [ -d "/sys/dev/block/$1/dm" ]; then + return 0 + fi + + return 1 +} + crypt_exists=0 omit_dracut_modules() { + local target majmin + local dm_exists + # Skip fadump case is_fadump_capable && return + dm_exists=0 + + for target in $(get_kdump_targets); do + if [ -b "$target" ]; then + majmin=$(get_maj_min $target) + # Check "dm" + check_block_and_slaves is_dm $majmin && dm_exists=1 + fi + done + # Omit "crypt", BZ1451717 if [ "$crypt_exists" == "0" ]; then add_dracut_arg "--omit" "crypt" fi + + # Further omit more modules in case of no dm related target + if [ "$dm_exists" == "0" ]; then + # "dm_exists=0" implies "crypt_exists=0" + add_dracut_arg "--omit" "lvm dm multipath dmraid" + fi } if ! check_resettable; then From ea6bdc43219f296e0cbbd84c7568dc08804558d5 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:07:46 +0800 Subject: [PATCH 028/806] Revert "Revert "mkdumprd: omit dracut modules in case of network dumping"" This reverts commit 2c9128a9715ed012cdea9e2d7cf21d250574bbe6. --- mkdumprd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 68fe6e8..d3ecbd6 100644 --- a/mkdumprd +++ b/mkdumprd @@ -372,12 +372,13 @@ crypt_exists=0 omit_dracut_modules() { local target majmin - local dm_exists + local dm_exists network_only # Skip fadump case is_fadump_capable && return dm_exists=0 + network_only=1 for target in $(get_kdump_targets); do if [ -b "$target" ]; then @@ -385,6 +386,9 @@ omit_dracut_modules() # Check "dm" check_block_and_slaves is_dm $majmin && dm_exists=1 fi + + # Check nfs/ssh dumping + [[ "$target" != "nfs" && "$target" != "ssh" ]] && network_only=0 done # Omit "crypt", BZ1451717 @@ -397,6 +401,12 @@ omit_dracut_modules() # "dm_exists=0" implies "crypt_exists=0" add_dracut_arg "--omit" "lvm dm multipath dmraid" fi + + # Further omit more modules in case of nfs/ssh dumping + if [ "$network_only" == "1" ]; then + # "network_only=1" implies "dm_exists=0" + add_dracut_arg "--omit" "iscsi fcoe fcoe-uefi" + fi } if ! check_resettable; then From 666903c385ecc819ccedd902db391f04b0b1898f Mon Sep 17 00:00:00 2001 From: Dave Young Date: Tue, 21 Nov 2017 13:13:10 +0800 Subject: [PATCH 029/806] Release 2.0.15-12.1 Revert a series of patches for dracut new option "--no-hostonly-default-device" since dracut has not backported them to f27. Signed-off-by: Dave Young --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1a37ef9..a09a8dd 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 12%{?dist} +Release: 12%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,9 @@ done %doc %changelog +* Tue Nov 21 2017 Dave Young - 2.0.15-12.1 +- revert a series of patches to use --no-hostonly-default-device since dracut has not backport the support in f27 + * Thu Aug 17 2017 Dave Young - 2.0.15-12 - makedumpfile: fix 4.13 kernel larget vmcore bug - Revert "Improve 'cpu add' udev rules" From c755499fad6f48354017f7fbe577e92b4a2bd407 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 23 Nov 2017 10:17:54 +0800 Subject: [PATCH 030/806] dracut-module-setup.sh: check whether to include multipath-hostonly or not Due to the following commit in dracut, which splits out hostonly modules commit 5ce7cc7337a4c769b223152c083914f2052aa348 Author: Harald Hoyer Date: Mon Jul 10 13:28:40 2017 +0200 add 90multipath-hostonly module hardcoding the wwid of the drives in the initramfs causes problems when the drives are cloned to a system with the same hardware, but different disk wwid's https://bugzilla.redhat.com/show_bug.cgi?id=1457311 So kdump should decide whether to include the hostonly module. The multipath-hostonly can help kdump to include only the needed mpath device, in order to use less memory by 2nd kernel. ---- The performance ----- before this patch [root@localhost ~]# time kdumpctl start Detected change(s) in the following file(s): /etc/kdump.conf Rebuilding /boot/initramfs-4.13.9-300.fc27.x86_64kdump.img kexec: loaded kdump kernel Starting kdump: [OK] real 0m12.485s user 0m10.096s sys 0m1.887s after this patch root@localhost ~]# time kdumpctl start Detected change(s) in the following file(s): /etc/kdump.conf Rebuilding /boot/initramfs-4.13.9-300.fc27.x86_64kdump.img kexec: loaded kdump kernel Starting kdump: [OK] real 0m15.839s user 0m13.015s sys 0m1.853s Signed-off-by: Pingfan Liu Acked-by: Dave Young --- dracut-module-setup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 0c3609f..c0f1a88 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -7,6 +7,13 @@ if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" fi +is_mpath() { + local _dev=$1 + [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1 + [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0 + return 1 +} + check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly @@ -28,6 +35,7 @@ depends() { _dep="$_dep network" fi + for_each_host_dev_and_slaves is_mpath && _dep="$_dep multipath-hostonly" echo $_dep return 0 } From 85156bfc6685e51ae25a5b14024ccefa1bcc0ef6 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Tue, 28 Nov 2017 11:42:50 +0800 Subject: [PATCH 031/806] Revert "kdumpctl: sanity check of nr_cpus for x86_64 in case running out of vectors" This reverts commit 2040103bd7cef5501fc3bae05f39947b6733bc7f. Reason is it's based on the environment of 1st kernel where all present devices could be active and initialized during bootup. Then all pci devices will request irqs. While kdump only brings up those devices which are necessary for vmcore dumping. So this commit is not meaningful and helpless to very large extent. And it will print out 'Warning' when calculated result is larger than 1 cpu, actually it's a false positive report most of the time. So revert the commit, and can check the git history for later reference. [dyoung]: on some machine this warning message shows up but later we found the irq numbers with and without nr_cpus=1 is quite different so this need more investigation since the formula is not accurate. Signed-off-by: Baoquan He Acked-by: Dave Young --- kdumpctl | 67 -------------------------------------------------------- 1 file changed, 67 deletions(-) diff --git a/kdumpctl b/kdumpctl index d4e0050..2e73f31 100755 --- a/kdumpctl +++ b/kdumpctl @@ -110,71 +110,6 @@ append_cmdline() echo $cmdline } -# Check the number of cpus for kdump kernel to boot with. -# We met an issue on x86_64: kdump runs out of vectors with -# "nr_cpus=1" when requesting tons of irqs, so here we check -# "nr_cpus=1" and warn users if kdump probably can't work. -check_kdump_cpus() -{ - local nr_origin nr_min nr_max - local arch=$(uname -m) cmdline=$KDUMP_COMMANDLINE_APPEND - - if [ $arch != "x86_64" ]; then - return - fi - - # We only care about the default "nr_cpus=1". - echo $cmdline | grep -E -q "nr_cpus=1[[:space:]]*|nr_cpus=1$" - if [ $? -ne 0 ]; then - return - fi - - nr_origin=1 - - # Online cpus in first kernel. - nr_max=$(grep -c '^processor' /proc/cpuinfo) - - # To calculate the estimated minimal cpus required. - nr_min=$(ls -ld /proc/irq/*/ | wc -l) - - # Vectors for io device start from FIRST_EXTERNAL_VECTOR(32), - # some high-numbered ones starting from FIRST_EXTERNAL_VECTOR - # are reserved for system internal uses. - # - # We use a flexible variance and assume there are 32 reserved - # from FIRST_EXTERNAL_VECTOR. Then the total vectors for device - # interrupts percpu is: (256-32)-32=192. - # - # For "nr_cpus=1", irq and vector have the 1:1 mapping. - nr_min=$(($nr_min + 192 - 1)) - nr_min=$(($nr_min / 192)) - if [ $nr_min -gt 1 ]; then - # The system seems to have tons of interrupts. We need - # some further calculation of the number of cpus(>1). - # For "nr_cpus>1", irq and vector have the 1:M mapping, - # multiple-cpu affinity can consume multiple vectors. - # Luckily for x2apic which is commonly deployed on large - # modern machines, default case of boot, device bringup - # etc will use a single cpu to minimize vector pressure. - # - # For further safety, we add one more cpu and round it - # up to an even number. - nr_min=$(($nr_min + 1)) - nr_min=$(($nr_min + $nr_min % 2)) - fi - - if [ $nr_min -gt $nr_max ]; then - nr_min=$nr_max - fi - - if [ $nr_origin -ge $nr_min ]; then - return - fi - - echo -n "Warning: nr_cpus=1 may not be enough for kdump boot," - echo " try nr_cpus=$nr_min or larger instead" -} - # This function performs a series of edits on the command line. # Store the final result in global $KDUMP_COMMANDLINE. prepare_cmdline() @@ -211,8 +146,6 @@ prepare_cmdline() fi KDUMP_COMMANDLINE=$cmdline - - check_kdump_cpus } From cde5944f9359f88b9ab72677fa33884448aec7c8 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 4 Dec 2017 10:27:00 +0800 Subject: [PATCH 032/806] kdumpctl: skip selinux-relabel for dracut_args --mount dump target When using "dracut_args --mount" to specify dump target, e.g. nfs like: path / core_collector makedumpfile -d 31 dracut_args --mount "host:/path /var/crash nfs defaults" kdump service should neither guarantees the correctness, nor relabels it. For current code, since dracut_args dump targets are likely not mounted so kdump service mistakenly relabel the rootfs, which is meanless and takes very long time. Signed-off-by: Pingfan Liu --- kdumpctl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kdumpctl b/kdumpctl index 2e73f31..4280e7e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -946,6 +946,9 @@ path_to_be_relabeled() fi fi + if is_mount_in_dracut_args; then + return; + fi _path=$(get_save_path) # if $_path is masked by other mount, we will not relabel it. _rmnt=$(df $_mnt/$_path 2>/dev/null | tail -1 | awk '{ print $NF }') From 5604e2efb41aa6f8277fcdb9370ebe1ca7e37e33 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Mon, 4 Dec 2017 12:53:44 +0800 Subject: [PATCH 033/806] Release 2.0.16-2 Signed-off-by: Dave Young --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index ffb8c65..906a033 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.16 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -317,6 +317,11 @@ done %doc %changelog +* Mon Dec 4 2017 Dave Young - 2.0.16-2 +- dracut-module-setup.sh: check whether to include multipath-hostonly or not +- Revert "kdumpctl: sanity check of nr_cpus for x86_64 in case running out of vectors" +- kdumpctl: skip selinux-relabel for dracut_args --mount dump target + * Tue Nov 21 2017 Dave Young - 2.0.16-1 - update to kexec-tools 2.0.16 From 919a3299ee02c55763866f49f4cfed295b1e4ce6 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 8 Dec 2017 11:39:09 +0800 Subject: [PATCH 034/806] Workaround a koji build failure with below CFLAGS, kexec-tools can not build: --specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 segfault happened while strip the purgatory: gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -mcmodel=large -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector -mcmodel=large -Wl,--no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -Wl,-Map=purgatory/purgatory.map -o purgatory/purgatory.ro.sym purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/x86_64/entry64-32.o purgatory/arch/x86_64/entry64.o purgatory/arch/x86_64/setup-x86_64.o purgatory/arch/x86_64/stack.o purgatory/arch/x86_64/purgatory-x86_64.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/crashdump_backup.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/sha256.o strip --strip-debug -o purgatory/purgatory.ro purgatory/purgatory.ro.sym make: *** [purgatory/Makefile:69: purgatory/purgatory.ro] Segmentation fault (core dumped) koji build link: https://kojipkgs.fedoraproject.org//work/tasks/6067/23536067/build.log Reported rhbz1520805, a binutils bug is pending to be fixed, Will revert this once binutils bug is fixed and usable in koji build system. Signed-off-by: Dave Young --- kexec-tools-2.0.16-koji-build-fail-workaround.patch | 13 +++++++++++++ kexec-tools.spec | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 kexec-tools-2.0.16-koji-build-fail-workaround.patch diff --git a/kexec-tools-2.0.16-koji-build-fail-workaround.patch b/kexec-tools-2.0.16-koji-build-fail-workaround.patch new file mode 100644 index 0000000..c406063 --- /dev/null +++ b/kexec-tools-2.0.16-koji-build-fail-workaround.patch @@ -0,0 +1,13 @@ +diff --git a/purgatory/Makefile b/purgatory/Makefile +index 49ce80a..97b7a03 100644 +--- a/purgatory/Makefile ++++ b/purgatory/Makefile +@@ -67,7 +67,7 @@ $(PURGATORY): $(PURGATORY_OBJS) + $(MKDIR) -p $(@D) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@.sym $^ + # $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB) +- $(STRIP) --strip-debug -o $@ $@.sym ++ $(STRIP) --strip-debug --no-merge-notes -o $@ $@.sym + + echo:: + @echo "PURGATORY_SRCS $(PURGATORY_SRCS)" diff --git a/kexec-tools.spec b/kexec-tools.spec index 906a033..20fcd8b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -87,7 +87,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic Patch601: kexec-tools-2.0.3-disable-kexec-test.patch Patch602: kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch Patch603: kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch - +Patch604: kexec-tools-2.0.16-koji-build-fail-workaround.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -113,6 +113,7 @@ tar -z -x -v -f %{SOURCE23} %patch601 -p1 %patch602 -p1 %patch603 -p1 +%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc From 84311089a59a4abf8d5078c22ee37624a50f6299 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 8 Dec 2017 11:44:14 +0800 Subject: [PATCH 035/806] Release 2.0.16-3 Workaround a build failure (rhbz1520805) --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 20fcd8b..0183de4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.16 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -318,6 +318,9 @@ done %doc %changelog +* Fri Dec 8 2017 Dave Young - 2.0.16-3 +- workaround koji build failure (rhbz1520805) + * Mon Dec 4 2017 Dave Young - 2.0.16-2 - dracut-module-setup.sh: check whether to include multipath-hostonly or not - Revert "kdumpctl: sanity check of nr_cpus for x86_64 in case running out of vectors" From 0ee2dc96a51dcd8bd0164857a4af8ab8849fc97d Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 7 Feb 2018 11:29:16 +0800 Subject: [PATCH 036/806] Release 2.0.16-4 -update anaconda addon migrate with Anaconda changes. --- kexec-tools.spec | 7 +++++-- sources | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 0183de4..3dfccf6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.16 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -24,7 +24,7 @@ Source19: eppic_050615.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh -Source23: kdump-anaconda-addon-005-25-g2a4398f.tar.gz +Source23: kdump-anaconda-addon-005-31-g31ab4b7.tar.gz Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 @@ -318,6 +318,9 @@ done %doc %changelog +* Wed Feb 7 2017 Dave Young - 2.0.16-4 +- update anaconda addon migrate with Anaconda changes. + * Fri Dec 8 2017 Dave Young - 2.0.16-3 - workaround koji build failure (rhbz1520805) diff --git a/sources b/sources index 078a4e7..2c201f3 100644 --- a/sources +++ b/sources @@ -2,3 +2,4 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf3 SHA512 (kdump-anaconda-addon-005-25-g2a4398f.tar.gz) = 0ce8602607a8d781e1804973e6affef1ed3dce729bb1a5525b2a8129f28bcb88713f6e8be5e3f41151223518096f7eed33dd3ea0e63ac7dc338b21fb78664e7e SHA512 (makedumpfile-1.6.2.tar.gz) = 436a787c9da7f0278289b22489936f0a06eb0cc558792245c513e4a5ad733057a9d0fb9c5e2e7ed887b1bdd128f9f016ce9c263f912dcc8636fd82637fc25658 SHA512 (kexec-tools-2.0.16.tar.xz) = f2f06e7702fef20c8d7d6aabe1b264e2e2689e5c38cc00dbc2186dd7fa0479edb2dc9e307dd2ad7f03db47015e966e577f11576172604ef01c1bcca471fe2c24 +SHA512 (kdump-anaconda-addon-005-31-g31ab4b7.tar.gz) = d7d396c19ba9174ec64e72dfdf00e1c659143a849d5ce6aab73ae9f5270704e40914e11f2dd7650acc2d25c0ba41a0bbed75f2fe4a0746e9501f380eb98f3ea5 From 13107c8084539547049e517552d09507686abd44 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 7 Feb 2018 12:26:19 +0800 Subject: [PATCH 037/806] Fix wrong changelog date --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3dfccf6..8d7a511 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -318,7 +318,7 @@ done %doc %changelog -* Wed Feb 7 2017 Dave Young - 2.0.16-4 +* Wed Feb 7 2018 Dave Young - 2.0.16-4 - update anaconda addon migrate with Anaconda changes. * Fri Dec 8 2017 Dave Young - 2.0.16-3 From 4d1e8aadc8cbcc26c73a0c6946cd5b39b18da68d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 9 Feb 2018 09:04:52 +0100 Subject: [PATCH 038/806] Escape macros in %changelog Reference: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/Y2ZUKK2B7T2IKXPMODNF6HB2O5T5TS6H/ Signed-off-by: Igor Gnatenko --- kexec-tools.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8d7a511..f04527c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.16 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -318,6 +318,9 @@ done %doc %changelog +* Fri Feb 09 2018 Igor Gnatenko - 2.0.16-5 +- Escape macros in %%changelog + * Wed Feb 7 2018 Dave Young - 2.0.16-4 - update anaconda addon migrate with Anaconda changes. @@ -1593,7 +1596,7 @@ done - Misc spec cleanups and macro-ifications * Wed Aug 09 2006 Jarod Wilson - 1.101-42 -- Add %dir /var/crash, so default kdump setup works +- Add %%dir /var/crash, so default kdump setup works * Thu Aug 03 2006 Neil Horman - 1.101-41 - fix another silly makefile error for makedumpfile From 2f4149f2769f9c34358534d05de3b8b26ff3d36c Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 5 Mar 2018 15:09:09 +0800 Subject: [PATCH 039/806] dracut-module-setup.sh: pass correct ip= param for ipv6 Kdump always use _proto=dhcp for both ipv4 and ipv6. But for ipv6 the dhcp address assignment is not like ipv4, there are different ways for it, stateless and stateful, see below document: https://fedoraproject.org/wiki/IPv6Guide In case stateless, kernel can do the address assignment, dracut use _proto=auto6; for stateful case, dracut use _proto=dhcp6. We do not see bug reports before because for the most auto6 cases kernel assign ip address before dhclient, kdump just happened to work. Here we use auto6 if possible first. And we take the assumption that host use auto6 if /proc/sys/net/ipv6/conf/$netdev/autoconf is enabled Signed-off-by: Pingfan Liu --- dracut-module-setup.sh | 6 ++++++ kdump-lib.sh | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c0f1a88..d1dd673 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -293,6 +293,12 @@ kdump_setup_netdev() { _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none + elif is_ipv6_address $_srcaddr; then + if is_ipv6_auto $_netdev; then + _proto=auto6 + else + _proto=dhcp6 + fi else _proto=dhcp fi diff --git a/kdump-lib.sh b/kdump-lib.sh index d981c4f..ac4dc67 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -310,6 +310,18 @@ is_atomic() grep -q "ostree" /proc/cmdline } +# fixme, try the best to decide whether the ipv6 addr is allocated by slaac or dhcp6 +is_ipv6_auto() +{ + local _netdev=$1 + local _auto=$(cat /proc/sys/net/ipv6/conf/$_netdev/autoconf) + if [ $_auto -eq 1 ]; then + return 0 + else + return 1 + fi +} + is_ipv6_address() { echo $1 | grep -q ":" From dbe8214586cc685d19613bec970a75ee2f1087a0 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Feb 2018 19:35:47 +0800 Subject: [PATCH 040/806] kdumpctl: Check the modification time of core_collector When core_collector is changed, the kdump initramfs needs to be rebuilt before it is loaded. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- kdumpctl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 4280e7e..cebca36 100755 --- a/kdumpctl +++ b/kdumpctl @@ -400,10 +400,12 @@ check_files_modified() EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` + CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` + CORE_COLLECTOR=`type -P $CORE_COLLECTOR` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS" + files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" [[ -e /etc/fstab ]] && files="$files /etc/fstab" check_exist "$files" && check_executable "$EXTRA_BINS" From c14ebf2676094af50b492b22ee8cc3060fc8fd52 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 5 Dec 2017 14:42:19 +0800 Subject: [PATCH 041/806] kdump.sysconfig.ppc64(le): remove "root=" param from ppc64(le) 2nd kernel's command line For ppc64(le), the default behavior of kexec always copy "root=" param, but if dump target is ssh, there will no tools installed in kdump rd, which help to mount root. As a result, kdump service will fail to start. So explicitly disable the default behavior with --dt_no_old_root option. Signed-off-by: Pingfan Liu Acked-by: Dave Young --- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index be8e794..55a01cc 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_di # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="--dt-no-old-root" #Where to find the boot image #KDUMP_BOOTDIR="/boot" diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index be8e794..55a01cc 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_di # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="--dt-no-old-root" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 98cc66a34dfef4a90cb6115a7bd37f5c1da7f325 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Sun, 8 Apr 2018 17:03:04 +0800 Subject: [PATCH 042/806] Release 2.0.16-6 --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..3014cdf 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.16 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -318,6 +318,11 @@ done %doc %changelog +* Sun Apr 08 2018 Dave Young - 2.0.16-6 +- kdump.sysconfig.ppc64(le): remove "root=" param from ppc64(le) 2nd kernel +- kdumpctl: Check the modification time of core_collector +- dracut-module-setup.sh: pass correct ip= param for ipv6 + * Fri Feb 09 2018 Igor Gnatenko - 2.0.16-5 - Escape macros in %%changelog From 6e25286a97571a3609695fab710e38a10d7c685d Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 26 Apr 2018 13:19:12 +0800 Subject: [PATCH 043/806] Release 2.0.17-1 Pull upstream 2.0.17 --- kexec-tools.spec | 4 ++-- sources | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3014cdf..6a04fd1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools -Version: 2.0.16 -Release: 6%{?dist} +Version: 2.0.17 +Release: 1%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component diff --git a/sources b/sources index 2c201f3..7cd66ee 100644 --- a/sources +++ b/sources @@ -3,3 +3,4 @@ SHA512 (kdump-anaconda-addon-005-25-g2a4398f.tar.gz) = 0ce8602607a8d781e1804973e SHA512 (makedumpfile-1.6.2.tar.gz) = 436a787c9da7f0278289b22489936f0a06eb0cc558792245c513e4a5ad733057a9d0fb9c5e2e7ed887b1bdd128f9f016ce9c263f912dcc8636fd82637fc25658 SHA512 (kexec-tools-2.0.16.tar.xz) = f2f06e7702fef20c8d7d6aabe1b264e2e2689e5c38cc00dbc2186dd7fa0479edb2dc9e307dd2ad7f03db47015e966e577f11576172604ef01c1bcca471fe2c24 SHA512 (kdump-anaconda-addon-005-31-g31ab4b7.tar.gz) = d7d396c19ba9174ec64e72dfdf00e1c659143a849d5ce6aab73ae9f5270704e40914e11f2dd7650acc2d25c0ba41a0bbed75f2fe4a0746e9501f380eb98f3ea5 +SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 From 62999dab427193178807b49ec4863acd1acb1b09 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Sat, 28 Apr 2018 14:30:58 +0800 Subject: [PATCH 044/806] Add missing changelog in spec --- kexec-tools.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6a04fd1..8343e4d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -318,6 +318,9 @@ done %doc %changelog +* Sat Apr 28 2018 Dave Young - 2.0.17-1 +- pull in 2.0.17 + * Sun Apr 08 2018 Dave Young - 2.0.16-6 - kdump.sysconfig.ppc64(le): remove "root=" param from ppc64(le) 2nd kernel - kdumpctl: Check the modification time of core_collector From a95fcea412fe8c59d85751ff41925ded70af89cd Mon Sep 17 00:00:00 2001 From: Dave Young Date: Sat, 28 Apr 2018 14:34:23 +0800 Subject: [PATCH 045/806] Release 2.0.17-2 Pull in makedumpfile 1.6.3 --- ...MAP_MASK-for-kernel-bigger-than-4.13.patch | 66 ------------------- ...-of-init-level4-pgt-rename-in-kernel.patch | 43 ------------ kexec-tools.spec | 27 ++++---- sources | 1 + 4 files changed, 14 insertions(+), 123 deletions(-) delete mode 100644 kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch delete mode 100644 kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch diff --git a/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch b/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch deleted file mode 100644 index 7ff3902..0000000 --- a/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch +++ /dev/null @@ -1,66 +0,0 @@ -From: Pratyush Anand -To: ats-kumagai@wm.jp.nec.com -Subject: [Makedumpfile PATCH v2] Fix SECTION_MAP_MASK for kernel >= v.13 -Date: Thu, 17 Aug 2017 09:16:59 +0530 -Cc: Pratyush Anand , dyoung@redhat.com, - kexec@lists.infradead.org, bhe@redhat.com -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -Content-Type: text/plain; charset=utf-8 - -commit 2d070eab2e82 "mm: consider zone which is not fully populated to -have holes" added a new flag SECTION_IS_ONLINE and therefore -SECTION_MAP_MASK has been changed. We are not able to find correct -mem_map in makedumpfile for kernel version v4.13-rc1 and onward because -of the above kernel change. - -This patch fixes the MASK value keeping the code backward compatible - -Signed-off-by: Pratyush Anand ---- -v1->v2: Improved kernel_version comparison to take care of stable kernel -versions as well. - - makedumpfile.c | 5 ++++- - makedumpfile.h | 4 +++- - 2 files changed, 7 insertions(+), 2 deletions(-) - -diff --git kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.c kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.c -index 30230a15a2e7..c975651ca357 100644 ---- kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.c -+++ kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.c -@@ -3304,7 +3304,10 @@ section_mem_map_addr(unsigned long addr) - return NOT_KV_ADDR; - } - map = ULONG(mem_section + OFFSET(mem_section.section_mem_map)); -- map &= SECTION_MAP_MASK; -+ if (info->kernel_version < KERNEL_VERSION(4, 13, 0)) -+ map &= SECTION_MAP_MASK_4_12; -+ else -+ map &= SECTION_MAP_MASK; - free(mem_section); - - return map; -diff --git kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.h kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.h -index 8a05794843fb..322f28c632b0 100644 ---- kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.h -+++ kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.h -@@ -183,7 +183,9 @@ isAnon(unsigned long mapping) - #define SECTIONS_PER_ROOT() (info->sections_per_root) - #define SECTION_ROOT_MASK() (SECTIONS_PER_ROOT() - 1) - #define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT()) --#define SECTION_MAP_LAST_BIT (1UL<<2) -+#define SECTION_IS_ONLINE (1UL<<2) -+#define SECTION_MAP_LAST_BIT (1UL<<3) -+#define SECTION_MAP_MASK_4_12 (~(SECTION_IS_ONLINE-1)) - #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) - #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) - #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) --- -2.9.4 - - -_______________________________________________ -kexec mailing list -kexec@lists.infradead.org -http://lists.infradead.org/mailman/listinfo/kexec diff --git a/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch b/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch deleted file mode 100644 index 721f04a..0000000 --- a/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch +++ /dev/null @@ -1,43 +0,0 @@ -Following commit renamed init_level4_pgt to init_top_pgt in kernel. - -commit 65ade2f872b474fa8a04c2d397783350326634e6 -Author: Kirill A. Shutemov -Date: Tue Jun 6 14:31:27 2017 +0300 - - x86/boot/64: Rename init_level4_pgt and early_level4_pgt - -This patch takes care of above kernel modification in makedumpfile. - -Signed-off-by: Pratyush Anand ---- -v2 -> v1 -Removed redundant 'if condition' for WRITE_SYMBOL(). - - makedumpfile.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.c kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.c -index f85003a33551..30230a15a2e7 100644 ---- kexec-tools-2.0.15/makedumpfile-1.6.2/makedumpfile.c -+++ kexec-tools-2.0.15.new/makedumpfile-1.6.2/makedumpfile.c -@@ -1486,6 +1486,8 @@ get_symbol_info(void) - SYMBOL_INIT(_stext, "_stext"); - SYMBOL_INIT(swapper_pg_dir, "swapper_pg_dir"); - SYMBOL_INIT(init_level4_pgt, "init_level4_pgt"); -+ if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) -+ SYMBOL_INIT(init_level4_pgt, "init_top_pgt"); - SYMBOL_INIT(vmlist, "vmlist"); - SYMBOL_INIT(vmap_area_list, "vmap_area_list"); - SYMBOL_INIT(node_online_map, "node_online_map"); -@@ -2500,6 +2502,8 @@ read_vmcoreinfo(void) - READ_SYMBOL("_stext", _stext); - READ_SYMBOL("swapper_pg_dir", swapper_pg_dir); - READ_SYMBOL("init_level4_pgt", init_level4_pgt); -+ if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) -+ READ_SYMBOL("init_top_pgt", init_level4_pgt); - READ_SYMBOL("vmlist", vmlist); - READ_SYMBOL("vmap_area_list", vmap_area_list); - READ_SYMBOL("node_online_map", node_online_map); --- -2.9.4 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 8343e4d..2739039 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.2/makedumpfile-1.6.2.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.3/makedumpfile-1.6.3.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source14: 98-kexec.rules @@ -85,8 +85,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.3-disable-kexec-test.patch -Patch602: kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch -Patch603: kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch Patch604: kexec-tools-2.0.16-koji-build-fail-workaround.patch %description @@ -111,8 +109,6 @@ tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE23} %patch601 -p1 -%patch602 -p1 -%patch603 -p1 %patch604 -p1 %ifarch ppc @@ -140,8 +136,8 @@ cp %{SOURCE27} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.2 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.2 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.3 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.6.3 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif make -C kdump-anaconda-addon/po @@ -182,13 +178,13 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.2/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.6.2/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.2/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.2/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.2/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-1.6.3/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 644 makedumpfile-1.6.3/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.6.3/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.6.3/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.6.3/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.2/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.6.3/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon @@ -318,6 +314,9 @@ done %doc %changelog +* Sat Apr 28 2018 Dave Young - 2.0.17-1 +- pull in makedumpfile 1.6.3 + * Sat Apr 28 2018 Dave Young - 2.0.17-1 - pull in 2.0.17 diff --git a/sources b/sources index 7cd66ee..6a1e87d 100644 --- a/sources +++ b/sources @@ -4,3 +4,4 @@ SHA512 (makedumpfile-1.6.2.tar.gz) = 436a787c9da7f0278289b22489936f0a06eb0cc5587 SHA512 (kexec-tools-2.0.16.tar.xz) = f2f06e7702fef20c8d7d6aabe1b264e2e2689e5c38cc00dbc2186dd7fa0479edb2dc9e307dd2ad7f03db47015e966e577f11576172604ef01c1bcca471fe2c24 SHA512 (kdump-anaconda-addon-005-31-g31ab4b7.tar.gz) = d7d396c19ba9174ec64e72dfdf00e1c659143a849d5ce6aab73ae9f5270704e40914e11f2dd7650acc2d25c0ba41a0bbed75f2fe4a0746e9501f380eb98f3ea5 SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 +SHA512 (makedumpfile-1.6.3.tar.gz) = c213c944a2f578ecb37b234ef2354ee174a882d0eb354633d9941bd652704df1b111bab8bd94a31d7b045aade0f97962b1dfa5b0491217b4ab3896319ba291a4 From 2884fed616b53916162a7be2cdf397a7ddf86cd1 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 9 May 2018 14:21:51 +0800 Subject: [PATCH 046/806] Revert "dracut-module-setup.sh: pass correct ip= param for ipv6" This reverts commit 2f4149f2769f9c34358534d05de3b8b26ff3d36c. It is not proved to be right to get auto6 or dhcpv6 in 1st kernel, pingfan is working on a dracut fix to do some fallback in 2nd kernel initramfs. So revert this commit --- dracut-module-setup.sh | 6 ------ kdump-lib.sh | 12 ------------ 2 files changed, 18 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d1dd673..c0f1a88 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -293,12 +293,6 @@ kdump_setup_netdev() { _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none - elif is_ipv6_address $_srcaddr; then - if is_ipv6_auto $_netdev; then - _proto=auto6 - else - _proto=dhcp6 - fi else _proto=dhcp fi diff --git a/kdump-lib.sh b/kdump-lib.sh index ac4dc67..d981c4f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -310,18 +310,6 @@ is_atomic() grep -q "ostree" /proc/cmdline } -# fixme, try the best to decide whether the ipv6 addr is allocated by slaac or dhcp6 -is_ipv6_auto() -{ - local _netdev=$1 - local _auto=$(cat /proc/sys/net/ipv6/conf/$_netdev/autoconf) - if [ $_auto -eq 1 ]; then - return 0 - else - return 1 - fi -} - is_ipv6_address() { echo $1 | grep -q ":" From 1a6cb43a195be0a0ffcca69c40f04ffe6dbe0589 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 11 May 2018 10:02:39 +0800 Subject: [PATCH 047/806] kdumpctl: add showmem cmd port from rhel, original patch is contributed by Minfei Huang: Using /sys to determines crashkernel actual size is confusing since there is no unit of measure. Add a new command "kdumpctl showmem" to show the reserved memory kindly. Signed-off-by: Pingfan Liu Signed-off-by: Minfei Huang Acked-by: Bhupesh Sharma Acked-by: Dave Young --- kdumpctl | 13 ++++++++++++- kdumpctl.8 | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index cebca36..1279d72 100755 --- a/kdumpctl +++ b/kdumpctl @@ -830,6 +830,14 @@ propagate_ssh_key() fi } +show_reserved_mem() +{ + local mem=3D$(cat /sys/kernel/kexec_crash_size) + local mem_mb=3D$(expr $mem / 1024 / 1024) + + echo "Reserved "$mem_mb"MB memory for crash kernel" +} + handle_mode_switch() { if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then @@ -1246,8 +1254,11 @@ main () propagate) propagate_ssh_key ;; + showmem) + show_reserved_mem + ;; *) - echo $"Usage: $0 {start|stop|status|restart|propagate}" + echo $"Usage: $0 {start|stop|status|restart|propagate|showmem}" exit 1 esac } diff --git a/kdumpctl.8 b/kdumpctl.8 index b446b81..023562b 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -35,6 +35,9 @@ Is equal to .I propagate Helps to setup key authentication for ssh storage since it's impossible to use password authentication during kdump. +.TP +.I showmem +Prints the size of reserved memory for crash kernel in megabytes. .SH "SEE ALSO" .BR kdump.conf (5), From 5221d4b90cd90aa8319a32ec090a6c4ce94b3667 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 21 May 2018 10:31:46 +0530 Subject: [PATCH 048/806] kdumpctl: Remove 'netroot' and 'iscsi initiator' entries from kdump cmdline In a iSCSI multipath environment (which uses iSCSI software initiator and target environment) when the vmcore file is saved on the target, kdump always fails to establish a iSCSI session and also fails to collect dump due to duplicate entries for 'netroot' and 'iscsi initiator' in the kdump bootargs: # echo c > /proc/sysrq-trigger [83471.842707] SysRq : Trigger a crash [83471.843233] BUG: unable to handle kernel NULL pointer dereference at (null) [83471.844155] IP: [] sysrq_handle_crash+0x16/0x20 [83471.844931] PGD 800000023f710067 PUD 229fd6067 PMD 0 [83471.845655] Oops: 0002 [#1] SMP [83471.861889] Call Trace: [83471.862162] [] __handle_sysrq+0x10d/0x170 [83471.862771] [] write_sysrq_trigger+0x2f/0x40 [83471.863405] [] proc_reg_write+0x40/0x80 [83471.863984] [] vfs_write+0xc0/0x1f0 [83471.864536] [] SyS_write+0x7f/0xf0 [83471.865075] [] system_call_fastpath+0x1c/0x21 [83471.865714] Code: eb 9b 45 01 f4 45 39 65 34 75 e5 4c 89 ef e8 e2 f7 ff ff eb db 0f 1f 44 00 00 55 48 89 e5 c7 05 41 47 81 00 01 00 00 00 0f ae f8 04 25 00 00 00 00 01 5d c3 0f 1f 44 00 00 55 31 c0 c7 05 be [83471.868888] RIP [] sysrq_handle_crash+0x16/0x20 [83471.869700] RSP [83471.870074] CR2: 0000000000000000 Starting Login iSCSI Target iqn.2014-08.com.example:t1... [ OK ] Stopped Login iSCSI Target iqn.2014-08.com.example:t1. Starting Login iSCSI Target iqn.2014-08.com.example:t1... [ 6.607051] scsi host2: iSCSI Initiator over TCP/IP [FAILED] Failed to start Login iSCSI Target iqn.2014-08.com.example:t1. See 'systemctl status "iscsistart_\\x40...com.example:t1.service"' for details. [ 126.572911] dracut-initqueue[243]: Warning: dracut-initqueue timeout - starting timeout scripts Stopping Open-iSCSI... [ OK ] Stopped Open-iSCSI. Starting Open-iSCSI... [ OK ] Started Open-iSCSI. Starting Login iSCSI Target iqn.2014-08.com.example:t1... [ OK ] Stopped Login iSCSI Target iqn.2014-08.com.example:t1. Starting Login iSCSI Target iqn.2014-08.com.example:t1... [ 131.095897] scsi host3: iSCSI Initiator over TCP/IP [FAILED] Failed to start Login iSCSI Target iqn.2014-08.com.example:t1. See 'systemctl status "iscsistart_\\x40...com.example:t1.service"' for details. [ 251.085029] dracut-initqueue[243]: Warning: dracut-initqueue timeout - starting timeout scripts [ 251.594554] dracut-initqueue[243]: Warning: dracut-initqueue timeout - starting timeout scripts This patch fixes the same by removing the 'netroot', 'rd.iscsi.initiator' and 'iscsi_initiator' entries from the kdump boot cmdline. One reason why this is safe is our kdump target setup does not depend on 1st kernel inherited cmdline params now since the work we dropped root dependency. Signed-off-by: Bhupesh Sharma Acked-by: Dave Young --- kdumpctl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdumpctl b/kdumpctl index 1279d72..9a673c5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -138,6 +138,11 @@ prepare_cmdline() # With the help of "--hostonly-cmdline", we can avoid some interitage. cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) + # Remove netroot, rd.iscsi.initiator and iscsi_initiator since + # we get duplicate entries for the same in case iscsi code adds + # it as well. + cmdline=$(remove_cmdline_param "$cmdline" netroot rd.iscsi.initiator iscsi_initiator) + cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" id=$(get_bootcpu_apicid) From 3578c54ff2dd3efa3d74be9fe1dfe82bfc1105f6 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 24 May 2018 13:27:02 +0800 Subject: [PATCH 049/806] Fix kdumpctl showmem showmem function mistakenly added some noise character before the real code, it could be some copy-paste error. Fixes: 1a6cb43a195be0a0ffcca69c40f04ffe6dbe0589 --- kdumpctl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 9a673c5..44be90e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -837,8 +837,8 @@ propagate_ssh_key() show_reserved_mem() { - local mem=3D$(cat /sys/kernel/kexec_crash_size) - local mem_mb=3D$(expr $mem / 1024 / 1024) + local mem=$(cat /sys/kernel/kexec_crash_size) + local mem_mb=$(expr $mem / 1024 / 1024) echo "Reserved "$mem_mb"MB memory for crash kernel" } From b1fbeebd087b3b75fe1c2beca68d31ab25ce03c3 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 22 May 2018 18:15:07 +0800 Subject: [PATCH 050/806] move some common functions from kdumpctl to kdump-lib.sh we move some common functions from kdumpctl to kdump-lib.sh, the functions could be used in other modules, such as early kdump. It has no bad effect. Signed-off-by: Lianbo Jiang Reviewed-by: Kazuhito Hagio Acked-by: Dave Young --- kdump-lib.sh | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++ kdumpctl | 211 +----------------------------------------------- 2 files changed, 225 insertions(+), 208 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d981c4f..6acab8c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -485,3 +485,225 @@ get_dracut_args_target() { echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 } + +check_crash_mem_reserved() +{ + local mem_reserved + + mem_reserved=$(cat /sys/kernel/kexec_crash_size) + if [ $mem_reserved -eq 0 ]; then + echo "No memory reserved for crash kernel" + return 1 + fi + + return 0 +} + +check_kdump_feasibility() +{ + if [ ! -e /sys/kernel/kexec_crash_loaded ]; then + echo "Kdump is not supported on this kernel" + return 1 + fi + check_crash_mem_reserved + return $? +} + +check_current_kdump_status() +{ + if [ ! -f /sys/kernel/kexec_crash_loaded ];then + echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" + return 1 + fi + + rc=`cat /sys/kernel/kexec_crash_loaded` + if [ $rc == 1 ]; then + return 0 + else + return 1 + fi +} + +# remove_cmdline_param [] ... [] +# Remove a list of kernel parameters from a given kernel cmdline and print the result. +# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. +remove_cmdline_param() +{ + local cmdline=$1 + shift + + for arg in $@; do + cmdline=`echo $cmdline | \ + sed -e "s/\b$arg=[^ ]*//g" \ + -e "s/^$arg\b//g" \ + -e "s/[[:space:]]$arg\b//g" \ + -e "s/\s\+/ /g"` + done + echo $cmdline +} + +# +# This function returns the "apicid" of the boot +# cpu (cpu 0) if present. +# +get_bootcpu_apicid() +{ + awk ' \ + BEGIN { CPU = "-1"; } \ + $1=="processor" && $2==":" { CPU = $NF; } \ + CPU=="0" && /^apicid/ { print $NF; } \ + ' \ + /proc/cpuinfo +} + +# +# append_cmdline +# This function appends argument "$2=$3" to string ($1) if not already present. +# +append_cmdline() +{ + local cmdline=$1 + local newstr=${cmdline/$2/""} + + # unchanged str implies argument wasn't there + if [ "$cmdline" == "$newstr" ]; then + cmdline="${cmdline} ${2}=${3}" + fi + + echo $cmdline +} + +# This function check iomem and determines if we have more than +# 4GB of ram available. Returns 1 if we do, 0 if we dont +need_64bit_headers() +{ + return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ + print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` +} + +# Check if secure boot is being enforced. +# +# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and +# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four +# bytes are the attributes associated with the variable and can safely be +# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot +# is 1 and SetupMode is 0, then secure boot is being enforced. +# +# Assume efivars is mounted at /sys/firmware/efi/efivars. +is_secure_boot_enforced() +{ + local secure_boot_file setup_mode_file + local secure_boot_byte setup_mode_byte + + secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) + setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) + + if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then + secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) + setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) + + if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then + return 0 + fi + fi + + return 1 +} + +# +# prepare_kexec_args +# This function prepares kexec argument. +# +prepare_kexec_args() +{ + local kexec_args=$1 + local found_elf_args + + ARCH=`uname -m` + if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] + then + need_64bit_headers + if [ $? == 1 ] + then + found_elf_args=`echo $kexec_args | grep elf32-core-headers` + if [ -n "$found_elf_args" ] + then + echo -n "Warning: elf32-core-headers overrides correct elf64 setting" + echo + else + kexec_args="$kexec_args --elf64-core-headers" + fi + else + found_elf_args=`echo $kexec_args | grep elf64-core-headers` + if [ -z "$found_elf_args" ] + then + kexec_args="$kexec_args --elf32-core-headers" + fi + fi + fi + echo $kexec_args +} + +check_boot_dir() +{ + local kdump_bootdir=$1 + #If user specify a boot dir for kdump kernel, let's use it. Otherwise + #check whether it's a atomic host. If yes parse the subdirectory under + #/boot; If not just find it under /boot. + if [ -n "$kdump_bootdir" ]; then + echo "$kdump_bootdir" + return + fi + + if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then + kdump_bootdir="/boot" + else + eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) + kdump_bootdir="/boot"$(dirname $BOOT_IMAGE) + fi + echo $kdump_bootdir +} + +# +# prepare_cmdline +# This function performs a series of edits on the command line. +# Store the final result in global $KDUMP_COMMANDLINE. +prepare_cmdline() +{ + local cmdline id + + if [ -z "$1" ]; then + cmdline=$(cat /proc/cmdline) + else + cmdline="$1" + fi + + # These params should always be removed + cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) + # These params can be removed configurably + cmdline=$(remove_cmdline_param "$cmdline" "$2") + + # Always remove "root=X", as we now explicitly generate all kinds + # of dump target mount information including root fs. + # + # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares + # about it(e.g. for debug purpose), then can pass "root=X" using + # KDUMP_COMMANDLINE_APPEND. + cmdline=$(remove_cmdline_param "$cmdline" root) + + # With the help of "--hostonly-cmdline", we can avoid some interitage. + cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) + + # Remove netroot, rd.iscsi.initiator and iscsi_initiator since + # we get duplicate entries for the same in case iscsi code adds + # it as well. + cmdline=$(remove_cmdline_param "$cmdline" netroot rd.iscsi.initiator iscsi_initiator) + + cmdline="${cmdline} $3" + + id=$(get_bootcpu_apicid) + if [ ! -z ${id} ] ; then + cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) + fi + echo ${cmdline} +} diff --git a/kdumpctl b/kdumpctl index 44be90e..13b8209 100755 --- a/kdumpctl +++ b/kdumpctl @@ -62,98 +62,6 @@ determine_dump_mode() fi } -# remove_cmdline_param [] ... [] -# Remove a list of kernel parameters from a given kernel cmdline and print the result. -# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. -remove_cmdline_param() -{ - local cmdline=$1 - shift - - for arg in $@; do - cmdline=`echo $cmdline | \ - sed -e "s/\b$arg=[^ ]*//g" \ - -e "s/^$arg\b//g" \ - -e "s/[[:space:]]$arg\b//g" \ - -e "s/\s\+/ /g"` - done - echo $cmdline -} - -# -# This function returns the "apicid" of the boot -# cpu (cpu 0) if present. -# -get_bootcpu_apicid() -{ - awk ' \ - BEGIN { CPU = "-1"; } \ - $1=="processor" && $2==":" { CPU = $NF; } \ - CPU=="0" && /^apicid/ { print $NF; } \ - ' \ - /proc/cpuinfo -} - -# -# This function appends argument "$2=$3" to string ($1) if not already present. -# -append_cmdline() -{ - local cmdline=$1 - local newstr=${cmdline/$2/""} - - # unchanged str implies argument wasn't there - if [ "$cmdline" == "$newstr" ]; then - cmdline="${cmdline} ${2}=${3}" - fi - - echo $cmdline -} - -# This function performs a series of edits on the command line. -# Store the final result in global $KDUMP_COMMANDLINE. -prepare_cmdline() -{ - local cmdline id - - if [ -z "$KDUMP_COMMANDLINE" ]; then - cmdline=$(cat /proc/cmdline) - else - cmdline=${KDUMP_COMMANDLINE} - fi - - # These params should always be removed - cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) - # These params can be removed configurably - cmdline=$(remove_cmdline_param "$cmdline" ${KDUMP_COMMANDLINE_REMOVE}) - - # Always remove "root=X", as we now explicitly generate all kinds - # of dump target mount information including root fs. - # - # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares - # about it(e.g. for debug purpose), then can pass "root=X" using - # KDUMP_COMMANDLINE_APPEND. - cmdline=$(remove_cmdline_param "$cmdline" root) - - # With the help of "--hostonly-cmdline", we can avoid some interitage. - cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) - - # Remove netroot, rd.iscsi.initiator and iscsi_initiator since - # we get duplicate entries for the same in case iscsi code adds - # it as well. - cmdline=$(remove_cmdline_param "$cmdline" netroot rd.iscsi.initiator iscsi_initiator) - - cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" - - id=$(get_bootcpu_apicid) - if [ ! -z ${id} ] ; then - cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) - fi - - KDUMP_COMMANDLINE=$cmdline -} - - save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -366,21 +274,6 @@ get_pcs_cluster_modified_files() echo $modified_files } -check_boot_dir() -{ - #If user specify a boot dir for kdump kernel, let's use it. Otherwise - #check whether it's a atomic host. If yes parse the subdirectory under - #/boot; If not just find it under /boot. - [ -n "$KDUMP_BOOTDIR" ] && return - - if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then - KDUMP_BOOTDIR="/boot" - else - eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) - KDUMP_BOOTDIR="/boot"$(dirname $BOOT_IMAGE) - fi -} - setup_initrd() { DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img" @@ -603,7 +496,7 @@ check_rebuild() local _force_no_rebuild force_no_rebuild="0" local ret system_modified="0" - check_boot_dir + KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") if [ -z "$KDUMP_KERNELVER" ]; then kdump_kver=`uname -r` @@ -693,44 +586,13 @@ check_rebuild() return $? } -# This function check iomem and determines if we have more than -# 4GB of ram available. Returns 1 if we do, 0 if we dont -need_64bit_headers() -{ - return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ - print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` -} - # Load the kdump kernel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. load_kdump() { - ARCH=`uname -m` - if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] - then - - need_64bit_headers - if [ $? == 1 ] - then - FOUND_ELF_ARGS=`echo $KEXEC_ARGS | grep elf32-core-headers` - if [ -n "$FOUND_ELF_ARGS" ] - then - echo -n "Warning: elf32-core-headers overrides correct elf64 setting" - echo - else - KEXEC_ARGS="$KEXEC_ARGS --elf64-core-headers" - fi - else - FOUND_ELF_ARGS=`echo $KEXEC_ARGS | grep elf64-core-headers` - if [ -z "$FOUND_ELF_ARGS" ] - then - KEXEC_ARGS="$KEXEC_ARGS --elf32-core-headers" - fi - fi - fi - - prepare_cmdline + KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") + KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") # For secureboot enabled machines, use new kexec file based syscall. # Old syscall will always fail as it does not have capability to @@ -865,21 +727,6 @@ check_current_fadump_status() return 1 } -check_current_kdump_status() -{ - if [ ! -f /sys/kernel/kexec_crash_loaded ];then - echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" - return 1 - fi - - rc=`cat /sys/kernel/kexec_crash_loaded` - if [ $rc == 1 ]; then - return 0 - else - return 1 - fi -} - check_current_status() { if [ $DEFAULT_DUMP_MODE == "fadump" ]; then @@ -989,58 +836,6 @@ selinux_relabel() done } -# Check if secure boot is being enforced. -# -# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and -# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four -# bytes are the attributes associated with the variable and can safely be -# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot -# is 1 and SetupMode is 0, then secure boot is being enforced. -# -# Assume efivars is mounted at /sys/firmware/efi/efivars. -is_secure_boot_enforced() -{ - local secure_boot_file setup_mode_file - local secure_boot_byte setup_mode_byte - - secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) - - if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) - - if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then - return 0 - fi - fi - - return 1 -} - -check_crash_mem_reserved() -{ - local mem_reserved - - mem_reserved=$(cat /sys/kernel/kexec_crash_size) - if [ $mem_reserved -eq 0 ]; then - echo "No memory reserved for crash kernel" - return 1 - fi - - return 0 -} - -check_kdump_feasibility() -{ - if [ ! -e /sys/kernel/kexec_crash_loaded ]; then - echo "Kdump is not supported on this kernel" - return 1 - fi - check_crash_mem_reserved - return $? -} - check_fence_kdump_config() { local hostname=`hostname` From 17040648851ec76357e11d65c961d7ae7effd7f7 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 22 May 2018 18:15:08 +0800 Subject: [PATCH 051/806] Add early kdump support in initramfs. Kdump service starts too late, so early crashes will have no chance to get kdump kernel booting, this will cause crash information to be lost. It is necessary to add a dracut module in order to load crash kernel and initramfs as early as possible. You can provide "rd.early kdump" in grub commandline to enable, then the early kdump will load those files like the normal kdump, which is disabled by default. For the normal kdump service, it can check whether the early kdump has loaded the crash kernel and initramfs. It has no conflict with the early kdump. If you rebuild the new initramfs for early kdump, the new initramfs size will become large, because it will put the vmlinuz and kdump initramfs into the new initramfs. In addition, early kdump doesn't support fadump. Signed-off-by: Lianbo Jiang Reviewed-by: Kazuhito Hagio Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++ early-kdump-howto.txt | 54 +++++++++++++++++++ kexec-tools.spec | 11 ++++ 4 files changed, 193 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..7613fbc --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +. /etc/sysconfig/kdump +. /lib/kdump/kdump-lib.sh + +KDUMP_KERNEL="" +KDUMP_INITRD="" + +check() { + if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\ + || [ -n "${IN_KDUMP}" ] + then + return 1 + fi + return 255 +} + +depends() { + echo "base shutdown" + return 0 +} + +prepare_kernel_initrd() { + KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") + if [ -z "$KDUMP_KERNELVER" ]; then + kdump_kver=`uname -r` + else + kdump_kver=$KDUMP_KERNELVER + fi + KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" + KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" +} + +install() { + inst_multiple tail find cut dirname hexdump + inst_simple "/etc/sysconfig/kdump" + inst_binary "/usr/sbin/kexec" + inst_binary "/usr/bin/gawk" "/usr/bin/awk" + inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" + inst_hook cmdline 00 "$moddir/early-kdump.sh" + prepare_kernel_initrd + inst_binary "$KDUMP_KERNEL" + inst_binary "$KDUMP_INITRD" +} diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -0,0 +1,84 @@ +#! /bin/sh + +KEXEC=/sbin/kexec +standard_kexec_args="-p" + +EARLY_KDUMP_INITRD="" +EARLY_KDUMP_KERNEL="" +EARLY_KDUMP_CMDLINE="" +EARLY_KDUMP_KERNELVER="" +EARLY_KEXEC_ARGS="" + +. /etc/sysconfig/kdump +. /lib/dracut-lib.sh +. /lib/kdump-lib.sh + +prepare_parameters() +{ + EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") + KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") + + #make early-kdump kernel string + if [ -z "$KDUMP_KERNELVER" ]; then + EARLY_KDUMP_KERNELVER=`uname -r` + else + EARLY_KDUMP_KERNELVER=$KDUMP_KERNELVER + fi + + EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${EARLY_KDUMP_KERNELVER}${KDUMP_IMG_EXT}" + + #make early-kdump initrd string + EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${EARLY_KDUMP_KERNELVER}kdump.img" +} + +early_kdump_load() +{ + check_kdump_feasibility + if [ $? -ne 0 ]; then + return 1 + fi + + if is_fadump_capable; then + echo "WARNING: early kdump doesn't support fadump." + return 1 + fi + + check_current_kdump_status + if [ $? == 0 ]; then + return 1 + fi + + prepare_parameters + + EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") + + if is_secure_boot_enforced; then + echo "Secure Boot is enabled. Using kexec file based syscall." + EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" + fi + + $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ + --command-line="$EARLY_KDUMP_CMDLINE" \ + --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL + if [ $? == 0 ]; then + echo "kexec: loaded early-kdump kernel" + return 0 + else + echo "kexec: failed to load early-kdump kernel" + return 1 + fi +} + +set_early_kdump() +{ + if getargbool 0 rd.earlykdump; then + echo "early-kdump is enabled." + early_kdump_load + else + echo "early-kdump is disabled." + fi + + return 0 +} + +set_early_kdump diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..fe4f13f --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,54 @@ +Early Kdump HOWTO + +Introduction + +Kdump service starts too late, so early crashes will have no chance to get +kdump kernel booting, this will cause crash information to be lost. It is +necessary to add a dracut module in order to load crash kernel and initramfs +as early as possible. You can provide "rd.earlykdump" in grub commandline +to enable, then the early kdump will load those files like the normal kdump, +which is disabled by default. + +For the normal kdump service, it can check whether the early kdump has loaded +the crash kernel and initramfs. It has no conflict with the early kdump. + +How to configure early kdump: + +We assume if you're reading this document, you should already have kexec-tools +installed. + +You can rebuild the initramfs with earlykdump support with below steps: +1. start kdump service to make sure kdump initramfs is created. + # systemctl start kdump + +2. rebuild system initramfs with earlykdump support. + # dracut --add earlykdump + +3. add rd.earlykdump in grub kernel command line. + +Note: earlykdump initramfs size will be large because it includes vmlinuz and +kdump initramfs. And for step 2 if you are sure to overwrite system initramfs +you can backup the original initramfs and use "--force" option. + +After making said changes, reboot your system to take effect. Of course, if you +want to disable early kdump, you can simply remove "rd.earlykdump" from kernel +boot parameters in grub, and reboot system like above. + +Once the boot is completed, you can check the status of the early kdump support +on the command prompt: + + # journalctl -x|grep early-kdump + +Then, you will see some useful logs, for exapmle: + +1. if early kdump is successful. +Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: early-kdump is enabled. +Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: kexec: loaded early- +kdump kernel + +2. if early kdump is disabled. +Mar 09 10:02:47 localhost.localdomain dracut-cmdline[189]: early-kdump is disabled. + +Limitation + +At present, early kdump doesn't support fadump. diff --git a/kexec-tools.spec b/kexec-tools.spec index 2739039..60fafbc 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt ####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh Requires(post): systemd-units Requires(preun): systemd-units @@ -132,6 +135,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -190,6 +194,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') +%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g') # deal with dracut modules mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -203,6 +208,11 @@ cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} +mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump +cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} +cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} %define dracutlibdir %{_prefix}/lib/dracut @@ -301,6 +311,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 From 0dad02e4bb7529c10a2e3e2557d869d5999f3971 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 30 May 2018 10:50:36 +0800 Subject: [PATCH 052/806] Release 2.0.17-3 --- kexec-tools.spec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 60fafbc..5712acb 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,7 +325,15 @@ done %doc %changelog -* Sat Apr 28 2018 Dave Young - 2.0.17-1 +* Wed May 30 2018 Dave Young - 2.0.17-3 +- Add early kdump support in initramfs. +- move some common functions from kdumpctl to kdump-lib.sh +- Fix kdumpctl showmem +- kdumpctl: Remove 'netroot' and 'iscsi initiator' entries from kdump +- kdumpctl: add showmem cmd +- Revert "dracut-module-setup.sh: pass correct ip= param for ipv6" + +* Sat Apr 28 2018 Dave Young - 2.0.17-2 - pull in makedumpfile 1.6.3 * Sat Apr 28 2018 Dave Young - 2.0.17-1 From e4a27dde51e0c9a35dc0b06ab247ee0af2183ff8 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 27 Jun 2018 15:09:58 +0800 Subject: [PATCH 053/806] Resolves: bz1594827 Fix installation error for kdump anaconda addon. --- kexec-tools.spec | 7 +++++-- sources | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 5712acb..9c40b1c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -24,7 +24,7 @@ Source19: eppic_050615.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh -Source23: kdump-anaconda-addon-005-31-g31ab4b7.tar.gz +Source23: kdump-anaconda-addon-005-33-g8b243e3.tar.gz Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 @@ -325,6 +325,9 @@ done %doc %changelog +* Wed Jun 27 2018 Dave Young - 2.0.17-4 +- kdump anaconda addon fix for rhbz1594827 + * Wed May 30 2018 Dave Young - 2.0.17-3 - Add early kdump support in initramfs. - move some common functions from kdumpctl to kdump-lib.sh diff --git a/sources b/sources index 6a1e87d..e931d9a 100644 --- a/sources +++ b/sources @@ -1,7 +1,4 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f -SHA512 (kdump-anaconda-addon-005-25-g2a4398f.tar.gz) = 0ce8602607a8d781e1804973e6affef1ed3dce729bb1a5525b2a8129f28bcb88713f6e8be5e3f41151223518096f7eed33dd3ea0e63ac7dc338b21fb78664e7e -SHA512 (makedumpfile-1.6.2.tar.gz) = 436a787c9da7f0278289b22489936f0a06eb0cc558792245c513e4a5ad733057a9d0fb9c5e2e7ed887b1bdd128f9f016ce9c263f912dcc8636fd82637fc25658 -SHA512 (kexec-tools-2.0.16.tar.xz) = f2f06e7702fef20c8d7d6aabe1b264e2e2689e5c38cc00dbc2186dd7fa0479edb2dc9e307dd2ad7f03db47015e966e577f11576172604ef01c1bcca471fe2c24 -SHA512 (kdump-anaconda-addon-005-31-g31ab4b7.tar.gz) = d7d396c19ba9174ec64e72dfdf00e1c659143a849d5ce6aab73ae9f5270704e40914e11f2dd7650acc2d25c0ba41a0bbed75f2fe4a0746e9501f380eb98f3ea5 SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 SHA512 (makedumpfile-1.6.3.tar.gz) = c213c944a2f578ecb37b234ef2354ee174a882d0eb354633d9941bd652704df1b111bab8bd94a31d7b045aade0f97962b1dfa5b0491217b4ab3896319ba291a4 +SHA512 (kdump-anaconda-addon-005-33-g8b243e3.tar.gz) = 8ee5e5d314339502fa33a6afb5417ce71d9ae23018968dd982f2b53dd5efae9c7d7ae139a60657ca93e2dc7245a3ca2d4edc05e90c59fb5e56e3e16398bb2530 From 92db9cb9f2721370e3cb6d4177303513a4d8022d Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 22 Jun 2018 10:34:17 +0800 Subject: [PATCH 054/806] dracut-module-setup.sh: install /etc/hosts when using fence_kdump When using fence_kdump, module-setup will create a kdump.conf with fence_kdump_nodes. The node name comes from the cluster xml, which may use the hostname alias. Later in kdump stage, "fence_kdump_send alias_1 alias_2" sends out notification to peers. Hence it requires /etc/hosts and nsswitch.conf to make alias work. Signed-off-by: Pingfan Liu --- dracut-module-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c0f1a88..7505e81 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -703,6 +703,8 @@ kdump_configure_fence_kdump () { kdump_install_net $node done + dracut_install /etc/hosts + dracut_install /etc/nsswitch.conf dracut_install $FENCE_KDUMP_SEND } From 6832be14f2f3046b0886d90f9af703a502b360a2 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 22 Jun 2018 10:41:10 +0800 Subject: [PATCH 055/806] dracut-module-setup.sh: pass ip=either6 param for ipv6 Kdump always use _proto=dhcp for both ipv4 and ipv6. But for ipv6 the dhcp address assignment is not like ipv4, there are different ways for it, stateless and stateful, see below document: https://fedoraproject.org/wiki/IPv6Guide In case stateless, kernel can do the address assignment, dracut use _proto=auto6; for stateful case, dracut use _proto=dhcp6. But it is hard to decide whether stateless or stateful takes effect, hence, dracut introduces ip=either6 option, which can try both of these method automatically for us. For detail, refer to dracut: commit 67354ee 40network: introduce ip=either6 option We do not see bug reports before because for the most auto6 cases kernel assign ip address before dhclient, kdump just happened to work. Signed-off-by: Pingfan Liu --- dracut-module-setup.sh | 2 ++ kexec-tools.spec | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7505e81..f87617a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -293,6 +293,8 @@ kdump_setup_netdev() { _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none + elif is_ipv6_address $_srcaddr; then + _proto=either6 else _proto=dhcp fi diff --git a/kexec-tools.spec b/kexec-tools.spec index 9c40b1c..372b852 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -50,7 +50,7 @@ Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units Requires(pre): coreutils sed zlib -Requires: dracut >= 046-7 +Requires: dracut >= 047-34.git20180604 Requires: dracut-network >= 044-117 Requires: ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel From 9913d44d9e182b28052dcae29f63b290784d4800 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Mon, 9 Jul 2018 12:36:56 +0800 Subject: [PATCH 056/806] Update makedumpfile 1.6.4 --- kexec-tools.spec | 18 +++++++++--------- sources | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 372b852..f615045 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.3/makedumpfile-1.6.3.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.4/makedumpfile-1.6.4.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source14: 98-kexec.rules @@ -140,8 +140,8 @@ cp %{SOURCE28} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.3 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.3 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.4 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.6.4 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif make -C kdump-anaconda-addon/po @@ -182,13 +182,13 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.3/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.6.3/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.3/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.3/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.3/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-1.6.4/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 644 makedumpfile-1.6.4/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.6.4/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.6.4/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.6.4/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.3/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.6.4/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon diff --git a/sources b/sources index e931d9a..f58d1d3 100644 --- a/sources +++ b/sources @@ -1,4 +1,4 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f -SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 -SHA512 (makedumpfile-1.6.3.tar.gz) = c213c944a2f578ecb37b234ef2354ee174a882d0eb354633d9941bd652704df1b111bab8bd94a31d7b045aade0f97962b1dfa5b0491217b4ab3896319ba291a4 SHA512 (kdump-anaconda-addon-005-33-g8b243e3.tar.gz) = 8ee5e5d314339502fa33a6afb5417ce71d9ae23018968dd982f2b53dd5efae9c7d7ae139a60657ca93e2dc7245a3ca2d4edc05e90c59fb5e56e3e16398bb2530 +SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 +SHA512 (makedumpfile-1.6.4.tar.gz) = 0d564096a5400074f6154b751ee50c94b8f85a2e3ff478db69ddbb0a47852cbd895594030ca8a2e45a1ca1a641ce5d13f826922fa36054660c23380663f2c080 From 5350d31f56815fa262a443af2266735402fe1a92 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Mon, 9 Jul 2018 12:39:16 +0800 Subject: [PATCH 057/806] Release 2.0.17-5 --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f615045..1bde9a5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,6 +325,11 @@ done %doc %changelog +* Mon Jul 9 2018 Dave Young - 2.0.17-5 +- Update makedumpfile 1.6.4 +- dracut-module-setup.sh: pass ip=either6 param for ipv6 +- dracut-module-setup.sh: install /etc/hosts when using fence_kdump + * Wed Jun 27 2018 Dave Young - 2.0.17-4 - kdump anaconda addon fix for rhbz1594827 From 3de202cfdb6c77e23e0987faf53e235f95b312f2 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 13 Jul 2018 07:00:01 +0000 Subject: [PATCH 058/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1bde9a5..fb09c9e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,6 +325,9 @@ done %doc %changelog +* Fri Jul 13 2018 Fedora Release Engineering - 2.0.17-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Mon Jul 9 2018 Dave Young - 2.0.17-5 - Update makedumpfile 1.6.4 - dracut-module-setup.sh: pass ip=either6 param for ipv6 From 6b479b657266f130e6dc343817986e88883cabaf Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 25 Jul 2018 18:55:00 +0800 Subject: [PATCH 059/806] kdumpctl: Rebuild initramfs if loaded kernel modules changed Currently, we only rebuilt kdump initramfs on config file change, fs change, or watchdog related change. This will not cover the case that hardware changed but fs layout and other configurations still stays the same, and kdump may fail. To cover such case, we can detect and compare loaded kernel modules, if a hardware change requires the image to be rebuilt, loaded kernel modules must have changed. Starting from commit 7047294 dracut will record loaded kernel modules when the image is built if hostonly mode is enabled. With this patch, kdumpctl will compare the recorded value with currently loaded kernel modules, and rebuild the image on change. "kdumpctl start" will be a bit slower, as we have to call lsinitrd one more time to get the loaded kernel modules list. I measure the time consumption and we have an overall 0.2s increased loading time. Time consumption of command "kdumpctl restart": Before: real 0m0.587s user 0m0.481s sys 0m0.102s After: real 0m0.731s user 0m0.591s sys 0m0.133s Time comsumption of command "kdumpctl restart" with image rebuild: Before (force rebuild): real 0m10.972s user 0m8.966s sys 0m1.318s After (inserted ~100 new modules): real 0m11.220s user 0m9.387s sys 0m1.337s Signed-off-by: Kairui Song --- kdumpctl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kdumpctl b/kdumpctl index 13b8209..6a01c13 100755 --- a/kdumpctl +++ b/kdumpctl @@ -458,6 +458,31 @@ check_wdt_modified() return 1 } +check_kmodules_modified() +{ + # always sort again to avoid LANG/LC inconsistent problem + local _old_modules="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/loaded-kernel-modules.txt | sort)" + local _new_modules="$(get_loaded_kernel_modules | sort)" + + [[ -z $_old_modules ]] && echo "Warning: Previous loaded kernel module list is absent or empty" + + local _added_modules=$(comm -13 <(echo "$_old_modules") <(echo "$_new_modules")) + local _dropped_modules=$(comm -23 <(echo "$_old_modules") <(echo "$_new_modules")) + + if [ "$_old_modules" != "$_new_modules" ]; then + echo "Detected change(s) of loaded kernel modules list:" + [[ -n $_added_modules ]] && for _module in $_added_modules; do + echo " +$_module" + done + [[ -n $_dropped_modules ]] && for _module in $_dropped_modules; do + echo " -$_module" + done + return 1 + fi + + return 0 +} + # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -485,6 +510,11 @@ check_system_modified() return 1 fi + check_kmodules_modified + if [ $? -ne 0 ]; then + return 1 + fi + return 0 } From 4eedcae5e1540690a3761857fe2e692774c44960 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 26 Jul 2018 15:50:19 +0800 Subject: [PATCH 060/806] dracut-module-setup.sh: don't include multipath-hostonly This commit basically reverts commit c755499fad6f48354017f7fbe577e92b4a2bd407, and make use of new introduced tri-state hostonly mode. Following dracut commits merged multipath-hostonly into multipath module, and introduced a tri-state hostonly mode. commit 35e86ac117acbfd699f371f163cdda9db0ebc047 Author: Kairui Song Date: Thu Jul 5 16:20:04 2018 +0800 Merge 90-multipath-hostonly and 90-multipath commit a695250ec7db21359689e50733c6581a8d211215 Author: Kairui Song Date: Wed Jul 4 17:21:37 2018 +0800 Introduce tri-state hostonly mode multipath-hostonly module was introduced only for kdump, because kdump need a more strict hostonly policy for multipath device to save memory. Now multipath module will provide the behave we wanted by setting hostonly mode to strict. --- dracut-module-setup.sh | 8 -------- mkdumprd | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f87617a..d1f9f5f 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -7,13 +7,6 @@ if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" fi -is_mpath() { - local _dev=$1 - [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1 - [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0 - return 1 -} - check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly @@ -35,7 +28,6 @@ depends() { _dep="$_dep network" fi - for_each_host_dev_and_slaves is_mpath && _dep="$_dep multipath-hostonly" echo $_dep return 0 } diff --git a/mkdumprd b/mkdumprd index 2f71f7b..3d89a80 100644 --- a/mkdumprd +++ b/mkdumprd @@ -37,7 +37,7 @@ is_wdt_addition_needed [[ $? -eq 0 ]] && WDTCFG="-a watchdog" extra_modules="" -dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "-o" "plymouth dash resume ifcfg" $WDTCFG) +dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg" $WDTCFG) OVERRIDE_RESETTABLE=0 add_dracut_arg() { From 0b9095c11baaa6fc6bf0851290280f9cba67f5be Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Thu, 26 Jul 2018 16:03:33 +0530 Subject: [PATCH 061/806] Remove obsolete kdump tool Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441677 Testing: On x86_64 Fedora machine. After this patch kdump utility and related man page cannot be found on this machine: [root@tyan-gt24-09 ~]# which kdump /usr/bin/which: no kdump in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) [root@tyan-gt24-09 ~]# man kdump No manual entry for kdump Update the fedora 'kexec-tools.spec' to not install the obsolete kdump tool. I have submitted an upstream patch to obsolete the kdump tool from upstream kexec-tools (which has been accepted), but after an internal discussion we decided not to backport the upstream 'kexec-tools' patch (which does the same) for fedora, as we would prefer to manage the changes directly in the .spec file itself. Signed-off-by: Bhupesh Sharma --- kexec-tools.spec | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index fb09c9e..9468ab1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -146,7 +146,7 @@ make -C makedumpfile-1.6.4 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" epp make -C kdump-anaconda-addon/po %install -make install DESTDIR=$RPM_BUILD_ROOT +mkdir -p -m755 $RPM_BUILD_ROOT/sbin mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ @@ -160,6 +160,11 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl +install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/sbin/kexec +install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/sbin/vmcore-dmesg +install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ +install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ + SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_arch} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig @@ -289,7 +294,10 @@ do done %files -/sbin/* +/sbin/kexec +/sbin/makedumpfile +/sbin/mkdumprd +/sbin/vmcore-dmesg %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump @@ -303,7 +311,11 @@ done %endif %{dracutlibdir}/modules.d/* %dir %{_localstatedir}/crash -%{_mandir}/man8/* +%{_mandir}/man8/kdumpctl.8.gz +%{_mandir}/man8/kexec.8.gz +%{_mandir}/man8/makedumpfile.8.gz +%{_mandir}/man8/mkdumprd.8.gz +%{_mandir}/man8/vmcore-dmesg.8.gz %{_mandir}/man5/* %{_unitdir}/kdump.service %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh From bb6dd93d7a5e42143c182bcaed932894ae21f02a Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Thu, 26 Jul 2018 16:03:34 +0530 Subject: [PATCH 062/806] kexec-tools.spec: Drop kexec-tools-2.0.3-disable-kexec-test.patch kexec_test seems to be no longer used upstream, so we had introduced the 'kexec-tools-2.0.3-disable-kexec-test.patch' earlier to disable the same from fedora kexec-tools as well. However an earlier patch "Remove obsolete kdump tool" now explicitly installs needed files via appropriate logic in .spec file, so we can drop this patch now to reduce the maintenance burden. Signed-off-by: Bhupesh Sharma --- kexec-tools-2.0.3-disable-kexec-test.patch | 17 ----------------- kexec-tools.spec | 2 -- 2 files changed, 19 deletions(-) delete mode 100644 kexec-tools-2.0.3-disable-kexec-test.patch diff --git a/kexec-tools-2.0.3-disable-kexec-test.patch b/kexec-tools-2.0.3-disable-kexec-test.patch deleted file mode 100644 index 6fc73f2..0000000 --- a/kexec-tools-2.0.3-disable-kexec-test.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git kexec-tools-2.0.3/kexec_test/Makefile kexec-tools-2.0.3/kexec_test/Makefile -index fec6210..2ed4d51 100644 ---- kexec-tools-2.0.3/kexec_test/Makefile -+++ kexec-tools-2.0.3/kexec_test/Makefile -@@ -8,12 +8,6 @@ dist += kexec_test/Makefile $(KEXEC_TEST_SRCS) \ - kexec_test/x86-setup-legacy-pic.S - - BUILD_KEXEC_TEST = no --ifeq ($(ARCH),i386) --BUILD_KEXEC_TEST = yes --endif --ifeq ($(ARCH),x86_64) --BUILD_KEXEC_TEST = yes --endif - - ifeq ($(BUILD_KEXEC_TEST),yes) - diff --git a/kexec-tools.spec b/kexec-tools.spec index 9468ab1..857fad9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -87,7 +87,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.3-disable-kexec-test.patch Patch604: kexec-tools-2.0.16-koji-build-fail-workaround.patch %description @@ -111,7 +110,6 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE23} -%patch601 -p1 %patch604 -p1 %ifarch ppc From 3e065ac92e4f1ab6b669b334ad6aaf2f3dc8eb51 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 26 Jul 2018 19:26:04 +0800 Subject: [PATCH 063/806] Remove koji build workaround patch since koji build works without the patch now Signed-off-by: Dave Young --- kexec-tools.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 857fad9..9153f7f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -87,7 +87,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 601 onward are generic patches # -Patch604: kexec-tools-2.0.16-koji-build-fail-workaround.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -110,8 +109,6 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE23} -%patch604 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif From d319cbbb6de99e738f3890adcff7aaf76c602b95 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 26 Jul 2018 19:31:03 +0800 Subject: [PATCH 064/806] Release 2.0.17-7 Signed-off-by: Dave Young --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9153f7f..9ffe83f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -332,6 +332,13 @@ done %doc %changelog +* Thu Jul 26 2018 Dave Young - 2.0.17-7 +- Remove koji build workaround patch +- kexec-tools.spec: Drop kexec-tools-2.0.3-disable-kexec-test.patch +- Remove obsolete kdump tool +- dracut-module-setup.sh: don't include multipath-hostonly +- kdumpctl: Rebuild initramfs if loaded kernel modules changed + * Fri Jul 13 2018 Fedora Release Engineering - 2.0.17-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 9c7fea7ff76591274e60097175d3329e608f1eb1 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 26 Jul 2018 20:19:08 +0800 Subject: [PATCH 065/806] Fix armv7hl build failure armv7hl build failed because no makedumpfile* built but the latest commit tries to install them. Exclude armv7hl in the code chunk. Signed-off-by: Dave Young --- kexec-tools.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9ffe83f..260f2a0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -290,7 +290,9 @@ done %files /sbin/kexec +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 /sbin/makedumpfile +%endif /sbin/mkdumprd /sbin/vmcore-dmesg %{_bindir}/* @@ -308,7 +310,9 @@ done %dir %{_localstatedir}/crash %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_mandir}/man8/makedumpfile.8.gz +%endif %{_mandir}/man8/mkdumprd.8.gz %{_mandir}/man8/vmcore-dmesg.8.gz %{_mandir}/man5/* From 3b8642c280bf4636f11dace40a4ea2ab850eb1d3 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 26 Jul 2018 20:20:39 +0800 Subject: [PATCH 066/806] Release 2.0.17-8 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 260f2a0..f44aa03 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -336,6 +336,9 @@ done %doc %changelog +* Thu Jul 26 2018 Dave Young - 2.0.17-8 +- Fix armv7hl build failure + * Thu Jul 26 2018 Dave Young - 2.0.17-7 - Remove koji build workaround patch - kexec-tools.spec: Drop kexec-tools-2.0.3-disable-kexec-test.patch From 25b19d362722402209b04c03245ffa2948f41d6c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 Aug 2018 13:12:12 +0800 Subject: [PATCH 067/806] Remove kdump-anaconda subpackage Kdump anaconda has been included as a subpackage for a long time, which is not a good practice, as the anaconda plugin should be built as noarch and it does not belong to kexec-tools. We have created a new package 'kdump-anaconda-addon', so remove it here. The release version should be bumped later so that kdump-anaconda-addon could mark previous versions as obsoleted. Signed-off-by: Kairui Song --- kexec-tools.spec | 32 ++++++++------------------------ sources | 1 - 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f44aa03..e1b72ed 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -24,12 +24,11 @@ Source19: eppic_050615.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh -Source23: kdump-anaconda-addon-005-33-g8b243e3.tar.gz -Source24: kdump-lib-initramfs.sh -Source25: kdump.sysconfig.ppc64le -Source26: kdumpctl.8 -Source27: live-image-kdump-howto.txt -Source28: early-kdump-howto.txt +Source23: kdump-lib-initramfs.sh +Source24: kdump.sysconfig.ppc64le +Source25: kdumpctl.8 +Source26: live-image-kdump-howto.txt +Source27: early-kdump-howto.txt ####################################### # These are sources for mkdumpramfs @@ -95,19 +94,12 @@ normal or a panic reboot. This package contains the /sbin/kexec binary and ancillary utilities that together form the userspace component of the kernel's kexec feature. -%package anaconda-addon -Summary: Kdump configuration anaconda addon -Requires: anaconda >= 21.33 -%description anaconda-addon -Kdump anaconda addon - %prep %setup -q mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -tar -z -x -v -f %{SOURCE23} %ifarch ppc %define archdef ARCH=ppc @@ -129,8 +121,8 @@ rm -f kexec-tools.spec.in # setup the docs cp %{SOURCE10} . cp %{SOURCE21} . +cp %{SOURCE26} . cp %{SOURCE27} . -cp %{SOURCE28} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -138,7 +130,6 @@ make -C eppic/libeppic make -C makedumpfile-1.6.4 LINKTYPE=dynamic USELZO=on USESNAPPY=on make -C makedumpfile-1.6.4 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif -make -C kdump-anaconda-addon/po %install mkdir -p -m755 $RPM_BUILD_ROOT/sbin @@ -169,9 +160,9 @@ install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 -install -m 644 %{SOURCE26} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 +install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh -install -m 755 %{SOURCE24} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh +install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh %ifnarch s390x # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required @@ -190,8 +181,6 @@ install -m 755 makedumpfile-1.6.4/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdi mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ install -m 644 makedumpfile-1.6.4/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif -make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT -%find_lang kdump-anaconda-addon %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') %define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g') @@ -330,11 +319,6 @@ done /usr/share/makedumpfile/ %endif -%files anaconda-addon -f kdump-anaconda-addon.lang -%{_datadir}/anaconda/addons/com_redhat_kdump -%{_datadir}/icons/hicolor/scalable/apps/kdump.svg -%doc - %changelog * Thu Jul 26 2018 Dave Young - 2.0.17-8 - Fix armv7hl build failure diff --git a/sources b/sources index f58d1d3..6e846c8 100644 --- a/sources +++ b/sources @@ -1,4 +1,3 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f -SHA512 (kdump-anaconda-addon-005-33-g8b243e3.tar.gz) = 8ee5e5d314339502fa33a6afb5417ce71d9ae23018968dd982f2b53dd5efae9c7d7ae139a60657ca93e2dc7245a3ca2d4edc05e90c59fb5e56e3e16398bb2530 SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 SHA512 (makedumpfile-1.6.4.tar.gz) = 0d564096a5400074f6154b751ee50c94b8f85a2e3ff478db69ddbb0a47852cbd895594030ca8a2e45a1ca1a641ce5d13f826922fa36054660c23380663f2c080 From f6770b30c3bb49ff317a5987aba9a2a3ed149cf0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 Aug 2018 15:25:27 +0800 Subject: [PATCH 068/806] dracut-module-setup: Fix DRM module inclusion test for hyper-v We test if to include the drm module or not by testing if there are any drm entry in sysfs. But there is an exception for hyper-v, DRM module take care of hyperv's framebuffer driver as well but hyperv_fb will not create any drm entry. So currently we got black screen on hyperv guest. Fix by detect hyperv's special entry as well. Signed-off-by: Kairui Song --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d1f9f5f..a10244b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -20,7 +20,7 @@ check() { depends() { local _dep="base shutdown" - if [ -n "$( find /sys/devices -name drm )" ]; then + if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then _dep="$_dep drm" fi From f07d16814d600d7eb7e810c8049274826698a80d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 Aug 2018 17:23:45 +0800 Subject: [PATCH 069/806] Remove redundant kdump-anaconda-addon source codes Signed-off-by: Kairui Song --- anaconda-addon/Makefile | 79 ----- anaconda-addon/README | 29 -- anaconda-addon/com_redhat_kdump/__init__.py | 0 anaconda-addon/com_redhat_kdump/common.py | 88 ------ anaconda-addon/com_redhat_kdump/constants.py | 23 -- .../com_redhat_kdump/gui/__init__.py | 0 .../com_redhat_kdump/gui/spokes/RHEL.glade | 274 ------------------ .../com_redhat_kdump/gui/spokes/__init__.py | 0 .../com_redhat_kdump/gui/spokes/fedora.glade | 218 -------------- .../com_redhat_kdump/gui/spokes/kdump.py | 192 ------------ anaconda-addon/com_redhat_kdump/i18n.py | 27 -- .../com_redhat_kdump/ks/__init__.py | 0 anaconda-addon/com_redhat_kdump/ks/kdump.py | 128 -------- .../com_redhat_kdump/tui/__init__.py | 0 .../com_redhat_kdump/tui/spokes/__init__.py | 0 .../com_redhat_kdump/tui/spokes/kdump.py | 87 ------ anaconda-addon/po/Makefile | 75 ----- anaconda-addon/po/ar.po | 79 ----- anaconda-addon/po/as.po | 119 -------- anaconda-addon/po/bg.po | 118 -------- anaconda-addon/po/bn.po | 78 ----- anaconda-addon/po/bn_IN.po | 124 -------- anaconda-addon/po/bs.po | 79 ----- anaconda-addon/po/ca.po | 114 -------- anaconda-addon/po/cs.po | 114 -------- anaconda-addon/po/cy.po | 79 ----- anaconda-addon/po/da.po | 116 -------- anaconda-addon/po/de.po | 127 -------- anaconda-addon/po/el.po | 78 ----- anaconda-addon/po/en_GB.po | 78 ----- anaconda-addon/po/es.po | 129 --------- anaconda-addon/po/et.po | 78 ----- anaconda-addon/po/fa.po | 78 ----- anaconda-addon/po/fi.po | 115 -------- anaconda-addon/po/fr.po | 129 --------- anaconda-addon/po/gu.po | 120 -------- anaconda-addon/po/he.po | 78 ----- anaconda-addon/po/hi.po | 119 -------- anaconda-addon/po/hr.po | 121 -------- anaconda-addon/po/hu.po | 115 -------- anaconda-addon/po/hy.po | 78 ----- anaconda-addon/po/id.po | 114 -------- anaconda-addon/po/is.po | 115 -------- anaconda-addon/po/it.po | 125 -------- anaconda-addon/po/ja.po | 124 -------- anaconda-addon/po/ka.po | 78 ----- anaconda-addon/po/kdump-anaconda-addon.pot | 81 ------ anaconda-addon/po/kn.po | 124 -------- anaconda-addon/po/ko.po | 122 -------- anaconda-addon/po/ku.po | 78 ----- anaconda-addon/po/lo.po | 78 ----- anaconda-addon/po/lv.po | 79 ----- anaconda-addon/po/mk.po | 78 ----- anaconda-addon/po/ml.po | 119 -------- anaconda-addon/po/mr.po | 120 -------- anaconda-addon/po/ms.po | 115 -------- anaconda-addon/po/my.po | 78 ----- anaconda-addon/po/nb.po | 113 -------- anaconda-addon/po/nl.po | 78 ----- anaconda-addon/po/or.po | 122 -------- anaconda-addon/po/pa.po | 118 -------- anaconda-addon/po/pl.po | 114 -------- anaconda-addon/po/pom.xml | 19 -- anaconda-addon/po/pt.po | 113 -------- anaconda-addon/po/pt_BR.po | 129 --------- anaconda-addon/po/ru.po | 122 -------- anaconda-addon/po/si.po | 115 -------- anaconda-addon/po/sk.po | 78 ----- anaconda-addon/po/sl.po | 116 -------- anaconda-addon/po/sq.po | 78 ----- anaconda-addon/po/sr.po | 113 -------- anaconda-addon/po/sr@Latn.po | 116 -------- anaconda-addon/po/sv.po | 115 -------- anaconda-addon/po/ta.po | 119 -------- anaconda-addon/po/ta_IN.po | 113 -------- anaconda-addon/po/te.po | 116 -------- anaconda-addon/po/tr.po | 78 ----- anaconda-addon/po/uk.po | 115 -------- anaconda-addon/po/ur.po | 78 ----- anaconda-addon/po/vi.po | 78 ----- anaconda-addon/po/zanata.xml | 94 ------ anaconda-addon/po/zh_CN.po | 120 -------- anaconda-addon/po/zh_TW.po | 118 -------- 83 files changed, 7999 deletions(-) delete mode 100644 anaconda-addon/Makefile delete mode 100644 anaconda-addon/README delete mode 100644 anaconda-addon/com_redhat_kdump/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/common.py delete mode 100644 anaconda-addon/com_redhat_kdump/constants.py delete mode 100644 anaconda-addon/com_redhat_kdump/gui/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/gui/spokes/RHEL.glade delete mode 100644 anaconda-addon/com_redhat_kdump/gui/spokes/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/gui/spokes/fedora.glade delete mode 100644 anaconda-addon/com_redhat_kdump/gui/spokes/kdump.py delete mode 100644 anaconda-addon/com_redhat_kdump/i18n.py delete mode 100644 anaconda-addon/com_redhat_kdump/ks/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/ks/kdump.py delete mode 100644 anaconda-addon/com_redhat_kdump/tui/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/tui/spokes/__init__.py delete mode 100644 anaconda-addon/com_redhat_kdump/tui/spokes/kdump.py delete mode 100644 anaconda-addon/po/Makefile delete mode 100644 anaconda-addon/po/ar.po delete mode 100644 anaconda-addon/po/as.po delete mode 100644 anaconda-addon/po/bg.po delete mode 100644 anaconda-addon/po/bn.po delete mode 100644 anaconda-addon/po/bn_IN.po delete mode 100644 anaconda-addon/po/bs.po delete mode 100644 anaconda-addon/po/ca.po delete mode 100644 anaconda-addon/po/cs.po delete mode 100644 anaconda-addon/po/cy.po delete mode 100644 anaconda-addon/po/da.po delete mode 100644 anaconda-addon/po/de.po delete mode 100644 anaconda-addon/po/el.po delete mode 100644 anaconda-addon/po/en_GB.po delete mode 100644 anaconda-addon/po/es.po delete mode 100644 anaconda-addon/po/et.po delete mode 100644 anaconda-addon/po/fa.po delete mode 100644 anaconda-addon/po/fi.po delete mode 100644 anaconda-addon/po/fr.po delete mode 100644 anaconda-addon/po/gu.po delete mode 100644 anaconda-addon/po/he.po delete mode 100644 anaconda-addon/po/hi.po delete mode 100644 anaconda-addon/po/hr.po delete mode 100644 anaconda-addon/po/hu.po delete mode 100644 anaconda-addon/po/hy.po delete mode 100644 anaconda-addon/po/id.po delete mode 100644 anaconda-addon/po/is.po delete mode 100644 anaconda-addon/po/it.po delete mode 100644 anaconda-addon/po/ja.po delete mode 100644 anaconda-addon/po/ka.po delete mode 100644 anaconda-addon/po/kdump-anaconda-addon.pot delete mode 100644 anaconda-addon/po/kn.po delete mode 100644 anaconda-addon/po/ko.po delete mode 100644 anaconda-addon/po/ku.po delete mode 100644 anaconda-addon/po/lo.po delete mode 100644 anaconda-addon/po/lv.po delete mode 100644 anaconda-addon/po/mk.po delete mode 100644 anaconda-addon/po/ml.po delete mode 100644 anaconda-addon/po/mr.po delete mode 100644 anaconda-addon/po/ms.po delete mode 100644 anaconda-addon/po/my.po delete mode 100644 anaconda-addon/po/nb.po delete mode 100644 anaconda-addon/po/nl.po delete mode 100644 anaconda-addon/po/or.po delete mode 100644 anaconda-addon/po/pa.po delete mode 100644 anaconda-addon/po/pl.po delete mode 100644 anaconda-addon/po/pom.xml delete mode 100644 anaconda-addon/po/pt.po delete mode 100644 anaconda-addon/po/pt_BR.po delete mode 100644 anaconda-addon/po/ru.po delete mode 100644 anaconda-addon/po/si.po delete mode 100644 anaconda-addon/po/sk.po delete mode 100644 anaconda-addon/po/sl.po delete mode 100644 anaconda-addon/po/sq.po delete mode 100644 anaconda-addon/po/sr.po delete mode 100644 anaconda-addon/po/sr@Latn.po delete mode 100644 anaconda-addon/po/sv.po delete mode 100644 anaconda-addon/po/ta.po delete mode 100644 anaconda-addon/po/ta_IN.po delete mode 100644 anaconda-addon/po/te.po delete mode 100644 anaconda-addon/po/tr.po delete mode 100644 anaconda-addon/po/uk.po delete mode 100644 anaconda-addon/po/ur.po delete mode 100644 anaconda-addon/po/vi.po delete mode 100644 anaconda-addon/po/zanata.xml delete mode 100644 anaconda-addon/po/zh_CN.po delete mode 100644 anaconda-addon/po/zh_TW.po diff --git a/anaconda-addon/Makefile b/anaconda-addon/Makefile deleted file mode 100644 index 1b30e44..0000000 --- a/anaconda-addon/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -NAME = kdump-anaconda-addon - -ADDON = com_redhat_kdump -TESTS = test - -FILES = $(ADDON) \ - po \ - Makefile \ - README - -EXCLUDES = \ - *~ \ - *.pyc - -all: - @echo "usage: make dist" - @echo " make test" - @echo " make install" - @echo " make uninstall" - -DISTNAME = $(NAME)-$(shell date +%Y%m%d) -ADDONDIR = /usr/share/anaconda/addons/ -DISTBALL = $(DISTNAME).tar.gz -NUM_PROCS = $$(getconf _NPROCESSORS_ONLN) - -install: - mkdir -p $(DESTDIR)$(ADDONDIR) - cp -rv $(ADDON) $(DESTDIR)$(ADDONDIR) - make install-po-files - -uninstall: - rm -rfv $(DESTDIR)$(ADDONDIR) - -dist: - rm -rf $(NAME) - mkdir -p $(NAME) - @if test -d ".git"; \ - then \ - echo Creating ChangeLog && \ - ( cd "$(top_srcdir)" && \ - echo '# Generate automatically. Do not edit.'; echo; \ - git log --stat --date=short ) > ChangeLog.tmp \ - && mv -f ChangeLog.tmp $(NAME)/ChangeLog \ - || ( rm -f ChangeLog.tmp ; \ - echo Failed to generate ChangeLog >&2 ); \ - else \ - echo A git clone is required to generate a ChangeLog >&2; \ - fi - for file in $(FILES); do \ - cp -rpv $$file $(NAME)/$$file; \ - done - for excl in $(EXCLUDES); do \ - find $(NAME) -name "$$excl" -delete; \ - done - tar -czvf ../$(DISTBALL) $(NAME) - rm -rf $(NAME) - -potfile: - $(MAKE) DESTDIR=$(DESTDIR) -C po potfile - -po-pull: - tx pull -a --disable-overwrite - -install-po-files: - $(MAKE) -C po install - -test: - @echo "***Running pylint checks***" - @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null - @echo "[ OK ]" - @echo "***Running unittests checks***" - @PYTHONPATH=. nosetests --processes=-1 -vw tests/ - -runpylint: - @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null - @echo "[ OK ]" - -unittest: - PYTHONPATH=. nosetests --processes=-1 -vw tests/ diff --git a/anaconda-addon/README b/anaconda-addon/README deleted file mode 100644 index 50a7c97..0000000 --- a/anaconda-addon/README +++ /dev/null @@ -1,29 +0,0 @@ -This is an anaconda addon for configuring kdump. To use, copy the -com_redhat_kdump directory into /usr/share/anaconda/addons on your -installation media. - -The syntax of the addon's kickstart section is: - -%addon com_redhat_kdump (--enable|--disable) --reserve-mb=("auto"|) -%end - -Note that support for arguments on the %addon line was added in -anaconda-21.23. See anaconda commit 3a512e4f9e15977f0ce2d0bbe39e841b881398f3, -https://bugzilla.redhat.com/show_bug.cgi?id=1065674 - -How to test the kdump-anaconda-addon? -You can provide an updates image in the kernel boot arguments as updates=, -and the contents will be added to the stage2 filesystem. -https://fedoraproject.org/wiki/Anaconda/Updates has more details, but usually -the easiest is to make it available via HTTP or FTP and provide a url to updates=. - -The file is a gzip-compressed cpio archive, and the files need to be put into -stage2 in /usr/share/anaconda/addons, so something like this will work to create -an updates.img: - -mkdir -p updates/usr/share/anaconda/addons -cp -r com_redhat_kdump updates/usr/share/anaconda/addons/ -( cd updates; find . | cpio -oc | gzip -c9 ) > updates.img - -then you can upload the updates.img to some http or ftp server so the anaconda -can get it by boot parameter as updates=http://some.website.com/path/to/updates.img. diff --git a/anaconda-addon/com_redhat_kdump/__init__.py b/anaconda-addon/com_redhat_kdump/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/common.py b/anaconda-addon/com_redhat_kdump/common.py deleted file mode 100644 index cd37131..0000000 --- a/anaconda-addon/com_redhat_kdump/common.py +++ /dev/null @@ -1,88 +0,0 @@ -# Kdump configuration common methods -# -# Copyright (C) 2014 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# -import os -__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds", "getOS"] - -from pyanaconda.isys import total_memory -from pyanaconda.flags import flags -from com_redhat_kdump.constants import OS_RELEASE - -_reservedMemory = None -def getReservedMemory(): - """Return the amount of memory currently reserved for kdump in MB.""" - global _reservedMemory - - # Check if the value has already been read - if _reservedMemory is not None: - return _reservedMemory - - try: - with open("/sys/kernel/kexec_crash_size", "r") as fobj: - _reservedMemory = int(fobj.read()) / (1024*1024) - return _reservedMemory - except (ValueError, IOError): - return 0 - -def getTotalMemory(): - """Return the total amount of system memory in MB - - This is the amount reported by /proc/meminfo plus the aount - currently reserved for kdump. - """ - - # total_memory return memory in KB, convert to MB - availMem = total_memory() / 1024 - - return availMem + getReservedMemory() - -def getMemoryBounds(): - """Return a tuple of (lower, upper, step) for kdump reservation limits. - - If there is not enough memory available to use kdump, both lower and - upper will be 0. - """ - - totalMemory = getTotalMemory() - - if flags.targetarch == 'ppc64': - lowerBound = 256 - minUsable = 1024 - step = 1 - else: - lowerBound = 128 - minUsable = 256 - step = 1 - - upperBound = (totalMemory - minUsable) - (totalMemory % step) - - if upperBound < lowerBound: - upperBound = lowerBound = 0 - - return (lowerBound, upperBound, step) - -def getOS(): - with open(os.path.normpath(OS_RELEASE), "r") as fobj: - line = fobj.readline() - - if not "Fedora" in line: - return "redhat" - else: - return "fedora" diff --git a/anaconda-addon/com_redhat_kdump/constants.py b/anaconda-addon/com_redhat_kdump/constants.py deleted file mode 100644 index aab9537..0000000 --- a/anaconda-addon/com_redhat_kdump/constants.py +++ /dev/null @@ -1,23 +0,0 @@ -# Kdump configuration constants -# -# Copyright (C) 2014 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# - -# The location of the kdump config file -OS_RELEASE = "/etc/os-release" diff --git a/anaconda-addon/com_redhat_kdump/gui/__init__.py b/anaconda-addon/com_redhat_kdump/gui/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/gui/spokes/RHEL.glade b/anaconda-addon/com_redhat_kdump/gui/spokes/RHEL.glade deleted file mode 100644 index 272f745..0000000 --- a/anaconda-addon/com_redhat_kdump/gui/spokes/RHEL.glade +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - filler - False - filler - KDUMP - - - - False - vertical - 6 - - - True - False - - - False - 6 - 6 - 6 - - - - - False - False - 0 - - - - - False - 0 - - - False - vertical - 6 - - - True - False - 10 - vertical - 10 - - - True - False - 0 - Kdump is a kernel crash dumping mechanism. In the event of a system crash, kdump will capture information from your system that can be invaluable in determining the cause of the crash. Note that kdump does require reserving a portion of system memory that will be unavailable for other uses. - True - - - False - True - 0 - - - - - True - False - - - _Enable kdump? - True - True - False - True - 0 - 0 - True - - - - 0 - 0 - 3 - 1 - - - - - True - False - 0 - Kdump Memory Reservation: - - - 0 - 1 - 1 - 1 - - - - - _Automatic - True - True - False - True - 0 - True - True - - - - 1 - 1 - 1 - 1 - - - - - _Manual - True - True - False - True - 0 - True - True - autoButton - - - - 2 - 1 - 1 - 1 - - - - - True - False - 0 - Memory To Be _Reserved (MB): - True - toBeReservedSpin - - - 0 - 3 - 1 - 1 - - - - - True - True - digits - if-valid - - - - 1 - 3 - 1 - 1 - - - - - True - False - 0 - Total System Memory (MB): - - - 0 - 4 - 1 - 1 - - - - - True - False - 0 - - - 1 - 4 - 1 - 1 - - - - - True - False - 0 - Usable System Memory (MB): - - - 0 - 5 - 1 - 1 - - - - - True - False - 0 - - - 1 - 5 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - - - True - True - 1 - - - - - - - - - diff --git a/anaconda-addon/com_redhat_kdump/gui/spokes/__init__.py b/anaconda-addon/com_redhat_kdump/gui/spokes/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/gui/spokes/fedora.glade b/anaconda-addon/com_redhat_kdump/gui/spokes/fedora.glade deleted file mode 100644 index 55442a8..0000000 --- a/anaconda-addon/com_redhat_kdump/gui/spokes/fedora.glade +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - filler - False - filler - KDUMP - - - - False - vertical - 6 - - - True - False - - - False - 6 - 6 - 6 - - - - - False - False - 0 - - - - - False - 0 - - - False - vertical - 6 - - - True - False - 10 - vertical - 10 - - - True - False - 0 - Kdump is a kernel crash dumping mechanism. In the event of a system crash, kdump will capture information from your system that can be invaluable in determining the cause of the crash. Note that kdump does require reserving a portion of system memory that will be unavailable for other uses. - True - - - False - True - 0 - - - - - True - False - - - True - False - 0 - Memory To Be _Reserved (MB): - True - toBeReservedSpin - - - 0 - 3 - 1 - 1 - - - - - True - True - digits - if-valid - - - - 1 - 3 - 1 - 1 - - - - - True - False - 0 - Total System Memory (MB): - - - 0 - 4 - 1 - 1 - - - - - True - False - 0 - - - 1 - 4 - 1 - 1 - - - - - True - False - 0 - Usable System Memory (MB): - - - 0 - 5 - 1 - 1 - - - - - True - False - 0 - - - 1 - 5 - 1 - 1 - - - - - _Enable kdump? - True - True - False - True - 0 - 0 - True - - - - 0 - 0 - 1 - 1 - - - - - - - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - - - True - True - 1 - - - - - - - - - diff --git a/anaconda-addon/com_redhat_kdump/gui/spokes/kdump.py b/anaconda-addon/com_redhat_kdump/gui/spokes/kdump.py deleted file mode 100644 index cec6b06..0000000 --- a/anaconda-addon/com_redhat_kdump/gui/spokes/kdump.py +++ /dev/null @@ -1,192 +0,0 @@ -# Kdump anaconda configuration -# -# Copyright (C) 2014 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# - -"""Kdump anaconda GUI configuration""" - -from gi.repository import Gtk - -from pyanaconda.ui.gui.categories.system import SystemCategory -from pyanaconda.ui.gui.spokes import NormalSpoke -from pyanaconda.ui.gui.utils import fancy_set_sensitive - -from com_redhat_kdump.i18n import _, N_ -from com_redhat_kdump.common import getReservedMemory, getTotalMemory, getMemoryBounds, getOS - -__all__ = ["KdumpSpoke"] - -class KdumpSpoke(NormalSpoke): - """Kdump configuration spoke""" - - builderObjects = ["KdumpWindow", "advancedConfigBuffer"] - mainWidgetName = "KdumpWindow" - uiFile = "RHEL.glade" - translationDomain = "kdump-anaconda-addon" - - icon = "computer-fail-symbolic" - title = N_("KDUMP") - category = SystemCategory - OS = "redhat" - def __init__(self, data, storage, payload, instclass): - KdumpSpoke.OS = getOS() - if KdumpSpoke.OS == "fedora": - KdumpSpoke.uiFile = "fedora.glade" - NormalSpoke.__init__(self, data, storage, payload, instclass) - self._reserveMem = 0 - - def initialize(self): - NormalSpoke.initialize(self) - self._enableButton = self.builder.get_object("enableKdumpCheck") - KdumpSpoke.OS = getOS() - if KdumpSpoke.OS == "redhat": - self._reservationTypeLabel = self.builder.get_object("reservationTypeLabel") - self._autoButton = self.builder.get_object("autoButton") - self._manualButton = self.builder.get_object("manualButton") - - self._toBeReservedLabel = self.builder.get_object("toBeReservedLabel") - self._toBeReservedSpin = self.builder.get_object("toBeReservedSpin") - self._totalMemLabel = self.builder.get_object("totalMemLabel") - self._totalMemMB = self.builder.get_object("totalMemMB") - self._usableMemLabel = self.builder.get_object("usableMemLabel") - self._usableMemMB = self.builder.get_object("usableMemMB") - - # Set an initial value and adjustment on the spin button - lower, upper, step = getMemoryBounds() - adjustment = Gtk.Adjustment(lower, lower, upper, step, step, 0) - self._toBeReservedSpin.set_adjustment(adjustment) - self._toBeReservedSpin.set_value(lower) - - def refresh(self): - # If a reserve amount is requested, set it in the spin button - if self.data.addons.com_redhat_kdump.reserveMB != "auto": - # Strip the trailing 'M' - reserveMB = self.data.addons.com_redhat_kdump.reserveMB - if reserveMB and reserveMB[-1] == 'M': - reserveMB = reserveMB[:-1] - if reserveMB: - self._toBeReservedSpin.set_value(int(reserveMB)) - - # Set the various labels. Use the spin button signal handler to set the - # usable memory label once the other two have been set. - self._totalMemMB.set_text("%d" % getTotalMemory()) - self._toBeReservedSpin.emit("value-changed") - - # Set the states on the toggle buttons and let the signal handlers set - # the sensitivities on the related widgets. Set the radio button first, - # since the radio buttons' bailiwick is a subset of that of the - # enable/disable checkbox. - if KdumpSpoke.OS == "redhat": - if self.data.addons.com_redhat_kdump.reserveMB == "auto": - self._autoButton.set_active(True) - self._manualButton.set_active(False) - else: - self._autoButton.set_active(False) - self._manualButton.set_active(True) - - if self.data.addons.com_redhat_kdump.enabled: - self._enableButton.set_active(True) - else: - self._enableButton.set_active(False) - - # Force a toggled signal on the button in case it's state has not changed - self._enableButton.emit("toggled") - - def apply(self): - # Copy the GUI state into the AddonData object - self.data.addons.com_redhat_kdump.enabled = self._enableButton.get_active() - - if KdumpSpoke.OS == "redhat" and self._autoButton.get_active(): - reserveMem = "auto" - else: - reserveMem = "%dM" % self._toBeReservedSpin.get_value_as_int() - - self.data.addons.com_redhat_kdump.reserveMB = reserveMem - - - @property - def ready(self): - return True - - @property - def completed(self): - # Always treat as completed - return True - - @property - def mandatory(self): - return False - - @property - def status(self): - if self.data.addons.com_redhat_kdump.enabled: - state = _("Kdump is enabled") - else: - state = _("Kdump is disabled") - - return state - - # SIGNAL HANDLERS - - def on_enable_kdump_toggled(self, checkbutton, user_data=None): - status = checkbutton.get_active() - - # If disabling, set everything to insensitve. Otherwise, only set the radio - # button and currently reserved widgets to sensitive and then fake a - # toggle event on the radio button to set the state on the reserve - # amount spin button and total/usable mem display. - if KdumpSpoke.OS == "redhat": - self._autoButton.set_sensitive(status) - self._manualButton.set_sensitive(status) - self._reservationTypeLabel.set_sensitive(status) - - if not status: - fancy_set_sensitive(self._toBeReservedSpin, status) - self._totalMemLabel.set_sensitive(status) - self._totalMemMB.set_sensitive(status) - self._usableMemLabel.set_sensitive(status) - self._usableMemMB.set_sensitive(status) - elif KdumpSpoke.OS == "redhat": - self._autoButton.emit("toggled") - else: - fancy_set_sensitive(self._toBeReservedSpin, True) - self._totalMemLabel.set_sensitive(True) - self._totalMemMB.set_sensitive(True) - self._usableMemLabel.set_sensitive(True) - self._usableMemMB.set_sensitive(True) - - def on_reservation_toggled(self, radiobutton, user_data=None): - status = self._manualButton.get_active() - - # If setting to auto, disable the manual config spinner and - # the total/usable memory labels - fancy_set_sensitive(self._toBeReservedSpin, status) - self._totalMemLabel.set_sensitive(status) - self._totalMemMB.set_sensitive(status) - self._usableMemLabel.set_sensitive(status) - self._usableMemMB.set_sensitive(status) - - def on_reserved_value_changed(self, spinbutton, user_data=None): - reserveMem = spinbutton.get_value_as_int() - totalMemText = self._totalMemMB.get_text() - - # If no total memory is available yet, do nothing - if totalMemText: - totalMem = int(self._totalMemMB.get_text()) - self._usableMemMB.set_text("%d" % (totalMem - reserveMem)) diff --git a/anaconda-addon/com_redhat_kdump/i18n.py b/anaconda-addon/com_redhat_kdump/i18n.py deleted file mode 100644 index a8cd27a..0000000 --- a/anaconda-addon/com_redhat_kdump/i18n.py +++ /dev/null @@ -1,27 +0,0 @@ -# Kdump configuration translation functions -# -# Copyright (C) 2014 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# - -__all__ = ["_", "N_"] - -import gettext - -_ = lambda x: gettext.ldgettext("kdump-anaconda-addon", x) -N_ = lambda x: x diff --git a/anaconda-addon/com_redhat_kdump/ks/__init__.py b/anaconda-addon/com_redhat_kdump/ks/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/ks/kdump.py b/anaconda-addon/com_redhat_kdump/ks/kdump.py deleted file mode 100644 index b4b346c..0000000 --- a/anaconda-addon/com_redhat_kdump/ks/kdump.py +++ /dev/null @@ -1,128 +0,0 @@ -# Kdump anaconda configuration -# -# Copyright (C) 2014 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# - -import os - -from pyanaconda.addons import AddonData -from pyanaconda.constants import ROOT_PATH -from pyanaconda import iutil - -from pykickstart.options import KSOptionParser -from pykickstart.errors import KickstartParseError, formatErrorMsg -from com_redhat_kdump.common import getOS, getMemoryBounds -from com_redhat_kdump.i18n import _ - -__all__ = ["KdumpData"] - -class KdumpData(AddonData): - """Addon data for the kdump configuration""" - - def __init__(self, name): - AddonData.__init__(self, name) - - self.enabled = True - self.reserveMB = "auto" - if getOS() == "fedora": - self.enabled = False - lower, upper, step = getMemoryBounds() - self.reserveMB = "%d" % lower - - def __str__(self): - addon_str = "%%addon %s" % self.name - - if self.enabled: - addon_str += " --enable" - else: - addon_str += " --disable" - - if self.reserveMB: - addon_str += " --reserve-mb='%s'" % self.reserveMB - - addon_str += "\n%s\n%%end\n" % self.content.strip() - - return addon_str - - def setup(self, storage, ksdata, instClass): - # Clear any existing crashkernel bootloader arguments - if ksdata.bootloader.appendLine: - ksdata.bootloader.appendLine = ' '.join( - (arg for arg in ksdata.bootloader.appendLine.split() \ - if not arg.startswith('crashkernel='))) - - # Copy our reserved amount to the bootloader arguments - if self.enabled: - # Ensure that the amount is "auto" or an amount in MB - if self.reserveMB != "auto" and self.reserveMB[-1] != 'M': - self.reserveMB += 'M' - ksdata.bootloader.appendLine += ' crashkernel=%s' % self.reserveMB - - # Do the same thing with the storage.bootloader.boot_args set - if storage.bootloader.boot_args: - crashargs = [arg for arg in storage.bootloader.boot_args \ - if arg.startswith('crashkernel=')] - storage.bootloader.boot_args -= set(crashargs) - - if self.enabled: - storage.bootloader.boot_args.add('crashkernel=%s' % self.reserveMB) - ksdata.packages.packageList.append("kexec-tools") - - def handle_header(self, lineno, args): - op = KSOptionParser() - op.add_option("--enable", action="store_true", default=True, - dest="enabled", help="Enable kdump") - op.add_option("--disable", action="store_false", - dest="enabled", help="Disable kdump") - op.add_option("--reserve-mb", type="string", dest="reserveMB", - default="auto", help="Amount of memory in MB to reserve for kdump, or auto") - - (opts, extra) = op.parse_args(args=args, lineno=lineno) - - # Reject any additional arguments - if extra: - AddonData.handle_header(self, lineno, extra) - - # Validate the reserve-mb argument - if opts.reserveMB != "auto": - # Allow a final 'M' for consistency with the crashkernel kernel - # parameter. Strip it if found. - if opts.reserveMB and opts.reserveMB[-1] == 'M': - opts.reserveMB = opts.reserveMB[:-1] - - try: - _test = int(opts.reserveMB) - except ValueError: - msg = _("Invalid value %s for --reserve-mb") % opts.reserveMB - if lineno != None: - raise KickstartParseError(formatErrorMsg(lineno, msg=msg)) - else: - raise KickstartParseError(msg) - - # Store the parsed arguments - self.enabled = opts.enabled - self.reserveMB =opts.reserveMB - - def execute(self, storage, ksdata, instClass, users): - if self.enabled: - action = "enable" - else: - action = "disable" - - iutil.execWithRedirect("systemctl", [action, "kdump.service"], root=ROOT_PATH) diff --git a/anaconda-addon/com_redhat_kdump/tui/__init__.py b/anaconda-addon/com_redhat_kdump/tui/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/tui/spokes/__init__.py b/anaconda-addon/com_redhat_kdump/tui/spokes/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/anaconda-addon/com_redhat_kdump/tui/spokes/kdump.py b/anaconda-addon/com_redhat_kdump/tui/spokes/kdump.py deleted file mode 100644 index 23e8040..0000000 --- a/anaconda-addon/com_redhat_kdump/tui/spokes/kdump.py +++ /dev/null @@ -1,87 +0,0 @@ -# Kdump anaconda configuration -# -# Copyright (C) 2013 Red Hat, Inc. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# the GNU General Public License v.2, or (at your option) any later version. -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY expressed or implied, including the implied warranties of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. You should have received a copy of the -# GNU General Public License along with this program; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the -# source code or documentation are not subject to the GNU General Public -# License and may only be used or replicated with the express permission of -# Red Hat, Inc. -# -# Red Hat Author(s): David Shea -# - -"""Kdump anaconda TUI configuration""" - -import re - -from pyanaconda.ui.tui.spokes import EditTUISpoke -from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry -from com_redhat_kdump.common import getOS, getMemoryBounds -from com_redhat_kdump.i18n import N_, _ - -__all__ = ["KdumpSpoke"] - -class _re: - def __init__(self, patten, low, up): - self.re = re.compile(patten) - self.low = low - self.up = up - - def match(self, key): - if self.re.match(key): - if key == "auto": - return True - if key[-1] == 'M': - key = key[:-1] - key = int(key) - if key <= self.up and key >= self.low : - return True - return False - -lower, upper ,step = getMemoryBounds() -# Allow either "auto" or a string of digits optionally followed by 'M' -RESERVE_VALID = _re(r'^((auto)|(\d+M?))$', lower, upper) -FEDORA_RESERVE_VALID = _re(r'^(\d+M?)$', lower, upper) - -class KdumpSpoke(EditTUISpoke): - title = N_("Kdump") - category = "system" - - edit_fields = [ - Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True), - Entry("Reserve amount", "reserveMB", RESERVE_VALID, lambda self,args: args.enabled) - ] - - def __init__(self, app, data, storage, payload, instclass): - if getOS() == "fedora": - KdumpSpoke.edit_fields = [ - Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True), - Entry("Reserve amount", "reserveMB", FEDORA_RESERVE_VALID, lambda self,args: args.enabled) - ] - - EditTUISpoke.__init__(self, app, data, storage, payload, instclass) - self.args = self.data.addons.com_redhat_kdump - - def apply(self): - pass - - @property - def completed(self): - return True - - @property - def status(self): - if self.args.enabled: - state = _("Kdump is enabled") - else: - state = _("Kdump is disabled") - return state diff --git a/anaconda-addon/po/Makefile b/anaconda-addon/po/Makefile deleted file mode 100644 index b82cca4..0000000 --- a/anaconda-addon/po/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# -# Makefile for the PO files (translation) catalog -# -# $Id$ - -TOP = ../.. - -# What is this package? -NLSPACKAGE = kdump-anaconda-addon -POTFILE = $(NLSPACKAGE).pot -INSTALL = /usr/bin/install -c -INSTALL_DATA = $(INSTALL) -m 644 -INSTALL_DIR = /usr/bin/install -d - -# destination directory -INSTALL_NLS_DIR = $(DESTDIR)/usr/share/locale -# PO catalog handling -MSGMERGE = msgmerge -v -XGETTEXT = xgettext --default-domain=$(NLSPACKAGE) \ - --add-comments -MSGFMT = msgfmt --statistics --verbose - -# What do we need to do -POFILES = $(wildcard ./*.po) -MOFILES = $(patsubst %.po,%.mo,$(POFILES)) -PYSRC = $(wildcard ../com_redhat_kdump/*.py ../com_redhat_kdump/*/*.py ../com_redhat_kdump/*/*/*.py) -GLADEFILES = $(wildcard ../com_redhat_kdump/gui/spokes/*.glade) - -all:: update-po $(MOFILES) - -potfile: $(PYSRC) glade-po - $(XGETTEXT) -L Python --keyword=_ --keyword=N_ $(PYSRC) tmp/*.h - @if cmp -s $(NLSPACKAGE).po $(POTFILE); then \ - rm -f $(NLSPACKAGE).po; \ - else \ - mv -f $(NLSPACKAGE).po $(POTFILE); \ - fi; \ - rm -rf tmp/ - -glade-po: $(GLADEFILES) - rm -rf tmp/ - for f in $(GLADEFILES); do \ - intltool-extract --type=gettext/glade -l $$f ;\ - done - -update-po: Makefile refresh-po potfile - -refresh-po: Makefile - for cat in $(POFILES); do \ - if $(MSGMERGE) $$cat $(POTFILE) --out=$$cat ; then \ - echo "$(MSGMERGE) of $$cat succeeded" ; \ - else \ - echo "$(MSGMERGE) of $$cat failed" ; \ - fi \ - done - -clean: - @rm -fv *mo *~ .depend - @rm -rf tmp - -install: $(MOFILES) - @for n in $(MOFILES); do \ - l=`basename $$n .mo`; \ - $(INSTALL_DIR) $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \ - $(INSTALL_DATA) --verbose $$n $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \ - done - -uninstall: - rm -rfv $(INSTALL_NLS_DIR)/*/LC_MESSAGES/$(NLSPACKAGE).mo - -%.mo: %.po - $(MSGFMT) -o $@ $< - -.PHONY: missing depend - diff --git a/anaconda-addon/po/ar.po b/anaconda-addon/po/ar.po deleted file mode 100644 index 9792ce1..0000000 --- a/anaconda-addon/po/ar.po +++ /dev/null @@ -1,79 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: ar\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=6; plural= n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " -"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/as.po b/anaconda-addon/po/as.po deleted file mode 100644 index f69ff39..0000000 --- a/anaconda-addon/po/as.po +++ /dev/null @@ -1,119 +0,0 @@ -# translation of as.po to Assamese -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Amitakhya Phukan , 2007. -# ngoswami , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-11 03:18-0500\n" -"Last-Translator: ngoswami \n" -"Language-Team: Assamese\n" -"Language: as\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump এটা কাৰনেলৰ বিজুতি জমা কৰাৰ যন্ত্ৰকৌশল। চিস্টেমৰ বিজুতিৰ ঘটনাত, kdump এ " -"আপোনাৰ চিস্টেমৰ পৰা তথ্য গ্ৰহণ কৰিব যি বিজুতিৰ কাৰণ গম পোৱাত অমূল্য হ'ব। মন কৰিব " -"যে kdump ক চিস্টেমৰ মেমৰি এটা অংশ সংৰক্ষণ কৰিব যি অন্য কাৰ্য্যৰ বাবে পোৱা নাযাব।" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "সংৰক্ষণ কৰিবলে মেমৰি (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "চিস্টেমৰ মুঠ মেমৰি (MB) :" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ব্যৱহাৰযোগ্য চিস্টেমৰ মেমৰি (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump সামৰ্থবান কৰিব নে (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump ৰ মেমৰি সংৰক্ষণ:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "স্বচালিত (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "হস্তচালিত (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "বৰ্তমানে সংৰক্ষিত মেমৰি (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "উন্নত kdump সংৰূপ" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "ক্ষমা কৰিব, kdump ফলপ্ৰসু হোৱাৰ বাবে আপোনাৰ চিস্টেমৰ পৰ্যাপ্ত মেমৰি নাই!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "ক্ষমা কৰিব, Xen কাৰ্ণেলসমূহে এই সময়ত kdump সমৰ্থন নকৰে!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "ক্ষমা কৰিব, %s স্থাপত্যই এই সময়ত kdump ৰ সমৰ্থন নকৰে!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump ৰ পছন্দৰ সলনি কৰিলে চিস্টেম পুনাৰম্ভ কৰাৰ প্ৰয়োজন যাতে মেমৰি আবন্টন কৰিব " -#~ "পাৰি। আপুনি এই সলনিৰ সৈতে আগবাঢ়ি firstboot সম্পূৰ্ণ হোৱাৰ পিছত চিস্টেম পুনাৰম্ভ " -#~ "কৰিব খোজে নে?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "ত্ৰুটি! বুটল'ডাৰৰ কোনো বিন্যাস ফাইল পোৱা নগ'ল, বিন্যাস কৰা বাতিল কৰা হৈছে!" diff --git a/anaconda-addon/po/bg.po b/anaconda-addon/po/bg.po deleted file mode 100644 index d0878d4..0000000 --- a/anaconda-addon/po/bg.po +++ /dev/null @@ -1,118 +0,0 @@ -# translation of bg.pot to Bulgarian -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Doncho N. Gunchev , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-12 12:47-0400\n" -"Last-Translator: Doncho N. Gunchev \n" -"Language-Team: Bulgarian >\n" -"Language: bg\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump механизъм за стоварване (запис) на ядрото при блокиране. В случай на " -"блокиране, kdump ще прихване информация от вашата система, която може да " -"бъде незаменима при откриване причината за това. Забележете, че kdump " -"изисква резервиране на част от системната памет, която няма да бъде достъпна " -"за други цели." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Общо системна памет (МБ):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Използваема системна памет (МБ):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump памет (МБ):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "За съжаление вашата система няма достатъчно памет за да бъде kdump " -#~ "приложим!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Съжаляваме, Xen ядрата не поддържат kdump за момента!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Съжаляваме, архитектурата %s не поддържа kdump за момента!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Промяната на настройките на Kdump изисква рестартиране на системата за " -#~ "заделяне на съответстваща памет. %sЖелаете ли да продължите с тази " -#~ "промяна и рестарт на системата след приключване на firstboot?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Грешка! Не е намерен конфигурационния файл за начално зареждане, " -#~ "конфигурацията няма да продължи!" diff --git a/anaconda-addon/po/bn.po b/anaconda-addon/po/bn.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/bn.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/bn_IN.po b/anaconda-addon/po/bn_IN.po deleted file mode 100644 index e2dc241..0000000 --- a/anaconda-addon/po/bn_IN.po +++ /dev/null @@ -1,124 +0,0 @@ -# translation of bn_IN.po to Bengali (India) -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# Runa Bhattacharjee , 2007. -# translation of bn_IN.po to Bengali INDIA -# Runa Bhattacharjee , 2007, 2010. -# sray , 2013. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2013-12-03 12:14-0500\n" -"Last-Translator: sray \n" -"Language-Team: Bengali INDIA \n" -"Language: bn-IN\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 3.1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump মূলত কার্নেল বিপর্যের সময়কার ডাম্পিং ব্যবস্থা। সিস্টেম বিপর্যস্ত হলে kdump " -"আপনার সিস্টেমের তথ্য সংগ্রহ করবে। বিপর্যয়ের কারণ নির্ণয়ের সময় এই তথ্য অত্যন্ত সহায়ক " -"প্রমাণিত হতে পারে। উল্লেখ্য, kdump-র ক্ষেত্রে সিস্টেম মেমরির একাংশ বরাদ্দ করা " -"আবশ্যক। এই অংশটি অন্যান্য ব্যবহারকারীদের নাগালের বাইরে থাকবে।" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "যত মেমরি সংরক্ষণ করতে হবে (_R) (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "সিস্টেমে উপস্থিত সর্বমোট মেমরি(মেগাবাইট):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "সিস্টেমের ব্যবহারযোগ্য মেমরি (মেগাবাইট):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump সক্রিয় করা হবে কি?(_E)" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump মেমরি সংরক্ষণ:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "স্বয়ংক্রিয় (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "ম্যানুয়াল (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "বর্তমানে সংরক্ষিত মেমরি (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "উন্নত kdump কনফিগারেশন" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "দুঃখিত, kdump-র সুষ্টু ব্যবহারের জন্য আপনার সিস্টেমে পর্যাপ্ত মেমরি উপস্থিত নেই!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "দুঃখিত, Xen কার্নেল দ্বারা বর্তমানে kdump সমর্থিত হয় না!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "দুঃখিত, %s আর্কিটেকচারে বর্তমানে kdump সমর্থিত হয় না!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump-র বৈশিষ্ট্য পরিবর্তনের ফলে মেমরি পুনরায় বরাদ্দ করার জন্য সিস্টেম রি-বুট করা " -#~ "আবশ্যক। চিহ্নিত পরিবর্তনগুলি গ্রহণ করে firstboot-র কর্ম সমাপ্তির পরে আপনি সিস্টেম " -#~ "পুনরায় বুট করতে ইচ্ছুক কি?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "ত্রুটি! bootloader কনফিগ ফাইল পাওয়া যায়নি, কনফিগারেশন প্রক্রিয়া পরিত্যাগ করা " -#~ "হবে!" diff --git a/anaconda-addon/po/bs.po b/anaconda-addon/po/bs.po deleted file mode 100644 index be80936..0000000 --- a/anaconda-addon/po/bs.po +++ /dev/null @@ -1,79 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: bs\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/ca.po b/anaconda-addon/po/ca.po deleted file mode 100644 index d915e0f..0000000 --- a/anaconda-addon/po/ca.po +++ /dev/null @@ -1,114 +0,0 @@ -# Catalan translations for Kdump. -# Copyright © 2007 The Free Software Foundation, Inc. -# This file is distributed under the same license as the Kdump package. -# Josep Puigdemont , 2007 -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-10 10:56-0500\n" -"Last-Translator: Josep Puigdemont \n" -"Language-Team: Catalan \n" -"Language: ca\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"El kdump és un mecanisme de bolcat per al nucli. Si el sistema es penja, el " -"kdump en capturarà informació que pot ser molt valuosa per a determinar la " -"causa de la fallada. El kdump requereix que es reservi una porció de la " -"memòria del sistema, que altres aplicacions no podran emprar." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Mmemòria _total del sistema (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "Memòria _usable del sistema (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Memòria del _kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "El sistema no té prou memòria per al kdump." - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "De moment els nuclis Xen no són compatibles amb el kdump." - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "De moment l'arquitectura %s no és compatible amb el kdump." - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Per canviar els paràmetres del Kdump cal que es reiniciï el sistema, i " -#~ "poder ubicar la memòria que li calgui.%s Voleu continuar amb aquest canvi " -#~ "i reiniciar el sistema després que s'hagi completat la primera arrencada?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "S'ha produït un error, no s'ha trobat cap fitxer de configuració del " -#~ "carregador de l'arrencada; S'interromprà la configuració." diff --git a/anaconda-addon/po/cs.po b/anaconda-addon/po/cs.po deleted file mode 100644 index ebef8cb..0000000 --- a/anaconda-addon/po/cs.po +++ /dev/null @@ -1,114 +0,0 @@ -# Czech translation of kexec-tools. -# Copyright (C) 2007 FSF -# This file is distributed under the same license as the kexec-tools package. -# Milan Kerslager , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-08 07:29-0500\n" -"Last-Translator: Milan Kerslager \n" -"Language-Team: Czech \n" -"Language: cs\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump je nástroj pro zaznamenání stavu systému při havárii (pádu systému). " -"Dojde-li k havárii, kdump zaznamená stav systému, což může mít " -"nepostradatelný význam při zjišťování její příčiny. Upozorňujeme, že kdump " -"vyžaduje pro svoji činnost vyhrazení části systémové paměti, kterou pak " -"nelze při normálním běhu systému využít." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Celkem paměťi (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "Paměť pro _systém (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Paměť pro _kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Pro kdump není dostatek paměti!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Xen jádro zatím kdump nepodporuje!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Architektura %s zatím kdump nepodporuje!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Změna nastavení Kdump vyžaduje restart systému, aby mohla být alokována " -#~ "potřebná paměť %s. Chcete systém po dokončení nastavení restartovat a " -#~ "aktivovat tak provedené změny?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Chyba! Nenalezena konfigurace zavaděče systému, konfigurace přerušena!" diff --git a/anaconda-addon/po/cy.po b/anaconda-addon/po/cy.po deleted file mode 100644 index 0d9a180..0000000 --- a/anaconda-addon/po/cy.po +++ /dev/null @@ -1,79 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: cy\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=4; plural= (n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != " -"11) ? 2 : 3\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/da.po b/anaconda-addon/po/da.po deleted file mode 100644 index f22ab8c..0000000 --- a/anaconda-addon/po/da.po +++ /dev/null @@ -1,116 +0,0 @@ -# translation of da.po to -# Copyright (C) 2006, 2007 Free Software Foundation, Inc. -# Magnus Larsson , 2007. -# Keld Simonsen , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-14 06:14-0400\n" -"Last-Translator: Keld Simonsen \n" -"Language-Team: \n" -"Language: da\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump er en ny mekanisme for dumpning vedn kernenedbrud. I tilfælde af et " -"systemnedbrud kan en core-fil blive opfanget ved hjælp af kdump, som kan " -"være uvurderligt til at bestemme årsagen til et systemnedbrud. Bemærk at " -"kdump kræver reservering af en del af systemhukommelsen som vil være " -"utilgængelig for anden brug." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Total systemhukommelse (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Total brugelig systemhukommelse (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump-hukommelse (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Desværre har dette system ikke nok hukommelse for at kdump er brugbart!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Desværre understøtter Xen-kerner ikke kdump for nærværende!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Desværre understøtter %s-arkitekturen ikke kdump for nærværende!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Ændring af indstillinger for Kdump kræver genstart af systemet for at " -#~ "gentildele hukommelse. %s Vil du fortsætte med denne ændring og genstarte " -#~ "systemet efter firstboot er klar?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Fejl! Ingen konfigurationsfil for opstartsprogrammet blev fundet, " -#~ "afbryder konfigurering!" diff --git a/anaconda-addon/po/de.po b/anaconda-addon/po/de.po deleted file mode 100644 index c70bee7..0000000 --- a/anaconda-addon/po/de.po +++ /dev/null @@ -1,127 +0,0 @@ -# translation of de.po to -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# PGP-KeyID: 0x037FD3CF , 2007. -# hedda , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 11:45-0500\n" -"Last-Translator: hedda \n" -"Language-Team: \n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump ist ein Mechanismus zur Aufzeichnung (dumping) eines Kernel-Absturzes. " -"Bei einem Systemabsturz sammelt kdump Informationen Ihres Systems, die " -"außerordentlich wertvoll bei der Ursachenforschung sein können. Beachten Sie " -"bitte, dass kdump eine bestimmte Menge an Systemspeicher beansprucht, der " -"für andere Zwecke nicht zur Verfügung steht." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Zu _reservierender Speicher (MB)" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "Gesamter Systemspeicher (MB)" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "Verwendbarer Systemspeicher (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "Kdump aktivi_eren?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump-Speicherreservierung:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Automatisch" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_Manuell" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Derzeit reservierter Speicher (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Erweiterte kdump-Konfiguration" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Leider steht Ihrem System nicht genügend Speicher zur Verfügung, um kdump " -#~ "einzusetzen!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Leider unterstützen Xen-Kernel kdump derzeit noch nicht." - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "" -#~ "Leider wird kdump zu diesem Zeitpunkt noch nicht von der %s-Architektur " -#~ "unterstützt!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Änderungen der Kdump-Einstellungen erfordern einen Neustart des Systems, " -#~ "damit entsprechend Speicher neu zugewiesen wird. Möchten Sie mit dieser " -#~ "Änderung fortfahren und das System nach der Fertigstellung von firstboot " -#~ "neu starten?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Es trat ein Fehler auf! Es wurde keine Bootloader-Konfigurationsdatei " -#~ "gefunden. Die Konfiguration wird jetzt abgebrochen!" diff --git a/anaconda-addon/po/el.po b/anaconda-addon/po/el.po deleted file mode 100644 index e5d23f2..0000000 --- a/anaconda-addon/po/el.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: el\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/en_GB.po b/anaconda-addon/po/en_GB.po deleted file mode 100644 index a931099..0000000 --- a/anaconda-addon/po/en_GB.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: en-GB\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/es.po b/anaconda-addon/po/es.po deleted file mode 100644 index 70acb11..0000000 --- a/anaconda-addon/po/es.po +++ /dev/null @@ -1,129 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# translation of es.po to Spanish -# -# Gladys Guerrero , 2010. -# gguerrer , 2013. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2013-12-01 07:35-0500\n" -"Last-Translator: gguerrer \n" -"Language-Team: Spanish \n" -"Language: es\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Language: Spanish\n" -"X-Generator: Zanata 3.1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump es un mecanismo de volcado de fallos del kernel. En el evento de una " -"falla del sistema, kdump capturará la información de su sistema que puede " -"ser invaluable para la determinación de la causa del fallo. Observe que " -"kdump no requiere reservar una porción de memoria del sistema que no estará " -"disponible para otros usos." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Memoria que va a ser _Reservada (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "Memoria _Total del Sistema (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "Memoria del sistema utilizable (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Habilitar kdump?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Reserva de memoria de Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Automática" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_Manual" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Memoria reservada actualmente (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Configuración avanzada de Kdump " - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Lamentablemente su sistema no tiene memoria suficiente para usar kdump." - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "" -#~ "¡Lo siento, los kernel Xen no ofrecen soporte a kdump en este momento!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "" -#~ "Lamentablemente la arquitectura %s no tiene soporte para kdump en este " -#~ "momento." - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "El cambio de la configuración de Kdump requiere reiniciar el sistema para " -#~ "reasignar memoria de forma apropiada. ¿Desea continuar con este cambio y " -#~ "reiniciar el sistema cuando se complete el primer arranque ?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "¡Error! No se encontró el archivo de configuración del cargador de " -#~ "arranque, ¡abortando la configuración!" diff --git a/anaconda-addon/po/et.po b/anaconda-addon/po/et.po deleted file mode 100644 index 39512cb..0000000 --- a/anaconda-addon/po/et.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: et\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/fa.po b/anaconda-addon/po/fa.po deleted file mode 100644 index 81919d0..0000000 --- a/anaconda-addon/po/fa.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: fa\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/fi.po b/anaconda-addon/po/fi.po deleted file mode 100644 index 7db83e5..0000000 --- a/anaconda-addon/po/fi.po +++ /dev/null @@ -1,115 +0,0 @@ -# Finnish translation of firstboot_kdump -# This file is distributed under the same license as the firstboot_kdump package. -# -# Ville-Pekka Vainio , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-09 05:37-0500\n" -"Last-Translator: Ville-Pekka Vainio \n" -"Language-Team: Finnish \n" -"Language: fi\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump on järjestelmä, jolla ytimen kaatumisesta saa vedoksen. Järjestelmän " -"kaatuessa kdump hankkii järjestelmästä tietoja, jotka voivat olla tärkeitä " -"kaatumisen syytä selvitettäessä. Huomaa, että kdumpille on varattava " -"järjestelmän muistista osa, jota ei voi käyttää muuhun." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Järjestelmän muistin kokonaismäärä (Mt):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Käytettävänä oleva järjestelmän muisti (Mt):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump-muisti (Mt):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Järjestelmässä ei ole riittävästi muistia kdumpin toimintaan!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Xen-ytimet eivät tue Kdumpia tällä hetkellä!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "%s-arkkitehtuuri ei tue kdumpia tällä hetkellä!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdumpin asetusten muuttaminen vaatii järjestelmän uudelleenkäynnistyksen, " -#~ "jotta muistia voidaan varata. %s. Jatketaanko tätä muutosta ja " -#~ "käynnistetäänkö järjestelmä uudelleen sen jälkeen, kun firstboot on " -#~ "valmis?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Virhe! Käynnistyslataimen asetustiedostoa ei löydy, keskeytetään " -#~ "asetusten teko!" diff --git a/anaconda-addon/po/fr.po b/anaconda-addon/po/fr.po deleted file mode 100644 index 9d38eeb..0000000 --- a/anaconda-addon/po/fr.po +++ /dev/null @@ -1,129 +0,0 @@ -# translation of fr.po to French -# translation of fr.po to -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# Decroux Fabien , 2007. -# Gauthier Ancelin , 2007. -# Sam Friedmann , 2010. -# samfreemanz , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 01:40-0500\n" -"Last-Translator: samfreemanz \n" -"Language-Team: French \n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n > 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump est un mécanisme de capture lors du plantage d'un noyau. Kdump capture " -"les informations de votre système qui peuvent être cruciales pour aider à " -"déterminer la cause de l'échec. Notez que kdump requiert une partie de la " -"mémoire système qui sera indisponible pour d'autres utilisations." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Mémoire à _réserver (en Mo) :" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "Mémoire totale du système (en Mo) :" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "Mémoire utilisable du système (en Mo) :" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Activer kdump ?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Réservation de la mémoire Kdump (en Mo) :" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Automatique" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_Manuel" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Mémoire actuellement réservée (en Mo) :" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Configuration Kdump avancée" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Désolé, votre système n'a pas assez de mémoire pour que kdump puisse être " -#~ "viable !" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "" -#~ "Désolé, les noyaux Xen ne prennent pas en charge kdump pour le moment !" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "" -#~ "Désolé l'architecture %s ne supporte pas kdump pour le moment !" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Modifier les paramètres de kdump nécessite un redémarrage du système afin " -#~ "de réallouer convenablement la mémoire. Désirez-vous continuer avec ces " -#~ "modifications et redémarrer le système une fois que firstboot aura " -#~ "terminé ?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Erreur ! Aucun fichier de configuration du chargeur de démarrage n'a " -#~ "été trouvé, abandon de la configuration !" diff --git a/anaconda-addon/po/gu.po b/anaconda-addon/po/gu.po deleted file mode 100644 index 06cf525..0000000 --- a/anaconda-addon/po/gu.po +++ /dev/null @@ -1,120 +0,0 @@ -# translation of gu.po to Gujarati -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# Ankit Patel , 2007. -# Sweta Kothari , 2010. -# Ankit Patel , 2013. #zanata -# swkothar , 2013. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2013-11-29 04:47-0500\n" -"Last-Translator: swkothar \n" -"Language-Team: Gujarati\n" -"Language: gu\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 3.1.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump એ કર્નલ ક્રેશ ડમ્પીંગ પદ્ધતિ છે. સિસ્ટમ ભંગાણની ઘટનામાં, kdump તમારી સિસ્ટમમાંથી " -"જાણકારી પ્રાપ્ત કરશે કે જે ભંગાણનું કારણ નક્કી કરવા માટે અમૂલ્ય હોઈ શકે. નોંધ લો કે kdump " -"સિસ્ટમ મેમરીના ભાગને આરક્ષિત રાખવા માટે જરૂરી છે કે જે અન્ય વપરાશો માટે ઉપલબ્ધ રહેશે નહિં." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "સુરક્ષિત માપ રાખવા માટે મેમરી (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "કુલ સિસ્ટમ મેમરી (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ઉપયોગી સિસ્ટમ મેમરી (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "શું kdump સક્રિય કરવું છે (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump મેમરી આરક્ષણ:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "આપોઆપ (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "જાતે જ (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "મેમરીનું હાલમાં સુરક્ષિત માપ (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "અદ્યતન kdump રૂપરેખાંકન" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "માફ કરજો, તમારી સિસ્ટમ પાસે kdump ને વ્યાજબી બનાવવા માટે પૂરતી મેમરી નથી!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "માફ કરજો, Xen કર્નલો kdump ને આ વખતે આધાર આપતી નથી!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "માફ કરજો, %s આર્કીટેક્ચર આ સમયે kdump ને આધાર આપતું નથી!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump સુયોજનો બદલવા માટે સિસ્ટમને મેમરી અનુક્રમે પુનઃફાળવવા માટે સિસ્ટમ રીબુટ કરવાની " -#~ "જરૂર છે. શું તમે આ ફેરફાર સાથે ચાલુ રાખવા ઈચ્છો છો અને firstboot સમાપ્ત થાય પછી " -#~ "સિસ્ટમ રીબુટ કરવા માંગો છો?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "ભૂલ! કોઈ બુટલોડર રૂપરેખા ફાઈલ મળી નહિં, અડધેથી રૂપરેખાંકન બંધ કરી રહ્યા છીએ!" diff --git a/anaconda-addon/po/he.po b/anaconda-addon/po/he.po deleted file mode 100644 index 915895b..0000000 --- a/anaconda-addon/po/he.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: he\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/hi.po b/anaconda-addon/po/hi.po deleted file mode 100644 index 7b07efd..0000000 --- a/anaconda-addon/po/hi.po +++ /dev/null @@ -1,119 +0,0 @@ -# translation of hi.po to Hindi -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# hi , 2007. -# Rajesh Ranjan , 2007, 2010. -# rajesh , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-13 06:42-0500\n" -"Last-Translator: rajesh \n" -"Language-Team: Hindi \n" -"Language: hi\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump एक कर्नेल क्रैश डंपिंग यांत्रिकी है. तंत्र क्रैश की स्थिति में, kdump सूचना लेगा आपके तंत्र " -"से जो कि क्रैश निर्धारण में मूल्यवान होगा. नोट करें कि kdump के लिये तंत्र स्मृति का आरक्षित " -"हिस्सा जरूरी है जो कि अन्य प्रयोग के लिये अनुपलब्ध रहेगा." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "स्मृति वापस करने के लिए (_R) (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "कुल तंत्र स्मृति (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "प्रयोज्य तंत्र स्मृति (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump सक्रिय करें? (_E)" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump स्मृति आरक्षण:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "स्वचालित (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "दस्ती (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "स्मृति अभी वापस (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "उन्नत kdump विन्यास" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "क्षमा करें, आपके तंत्र के पास kdump के अर्थक्षम होने के लिये पर्याप्त स्मृति नहीं है!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "क्षमा करें, Xen कर्नेल इस समय kdump का समर्थन नहीं करता है!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "क्षमा करें, %s ऑर्किटेक्चर kdump को इस समय समर्थन नहीं देता है!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump सेटिंग बदलने के लिये तंत्र रिबूटिंग जरूरी है ताकि स्मृति को उसी तरह फिर आबंटित " -#~ "किया जा सके. क्या आप इस बदलाव के साथ जारी रखना चाहेंगे और तंत्र को फर्स्ट बूट के पूरा " -#~ "होने पर रिबूट करें?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "त्रुटि! कोई बूटलोडर विन्यास फाइल नहीं मिला, विन्यास छोड़ रहा है!" diff --git a/anaconda-addon/po/hr.po b/anaconda-addon/po/hr.po deleted file mode 100644 index ed9139d..0000000 --- a/anaconda-addon/po/hr.po +++ /dev/null @@ -1,121 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-07-02 02:20-0400\n" -"Last-Translator: Renato Pavicic translator-shop.org>\n" -"Language-Team: LANGUAGE \n" -"Language: hr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump je mehanizam ispisivanja pada kernela. U slučaju pada sustava, Kdump " -"će snimiti podatke vašeg sustava koji bi mogli biti od neprocjenjive " -"važnosti za određivanje uzroka pada. Napomena: Kdump ne zahtjeva " -"rezerviranje dijela memorije sustava koja bi u tom slučaju bila nedostupna " -"ostalim potrebama." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Ukupna _memorija sustava (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Upotrebljiva memorija sustava (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Omogućiti kdump?" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump memorija (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Nažalost, vaš sustav ne raspolaže s dovoljno memorije radi omogućavanja " -#~ "rada modula Kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "" -#~ "Nažalost, ia64 Xen kerneli u ovom trenutku ne pružaju podršku za kdump." - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Nažalost, arhitektura %s u ovom trenutku ne pruža podršku za kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Promjena postavki modula Kdump potražuje ponovno pokretanje sustava radi " -#~ "odgovarajućeg dodjeljivanja memorije %s \n" -#~ "\n" -#~ "Želite li nastaviti s postojećim postavkama i sustav ponovno pokrenuti " -#~ "nakon što dovršenja postupka firstboot?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Pogreška! Konfiguracijska datoteka pokretača nije pronađena. " -#~ "Konfiguriranje se prekida!" diff --git a/anaconda-addon/po/hu.po b/anaconda-addon/po/hu.po deleted file mode 100644 index efe4d2a..0000000 --- a/anaconda-addon/po/hu.po +++ /dev/null @@ -1,115 +0,0 @@ -# Hungarian translations for firstboot-kdump package. -# Copyright (C) 2006 Red Hat, Inc. -# This file is distributed under the same license as the firstboot-kdump package. -# Automatically generated, 2006. -# Péter Sulyok , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-13 04:23-0400\n" -"Last-Translator: Péter Sulyok \n" -"Language-Team: Hungarian \n" -"Language: hu\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Zanata 2.0.2\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump egy kernelösszeomlási lerakó mechanizmus. Renszerösszeomlás esetén " -"kdump információkat gyűjt a rendszerről, ami nagyon értékes lehet az " -"összeomlás okának felderítésekor. Vegye észre, hogy kdump igényli a tár egy " -"részének fenntartását, ami más célra elérhetetlen." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Teljes rendszertár (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Használható rendszertár (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump tár (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Sajnos, ez a rendszer nem rendelkezik elég memóriával kdump " -#~ "működtetéséhez!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Sajnos, Xen kernelek jelenleg nem támogatják kdumpot!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Sajnos, a %s architektúra jelenleg nem támogatja kdumpot!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump beállításának megváltoztatása a rendszer újraindítását igényli a " -#~ "tár megfelelő újrafoglalásához. %s Szeretné folytatni e változtatással, " -#~ "és újraindítani a rendszert, miután firstboot végzett?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "Hiba! Nincs bootloader konfigfájl, konfigurálás abbahagyva!" diff --git a/anaconda-addon/po/hy.po b/anaconda-addon/po/hy.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/hy.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/id.po b/anaconda-addon/po/id.po deleted file mode 100644 index 779083d..0000000 --- a/anaconda-addon/po/id.po +++ /dev/null @@ -1,114 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-20 04:08-0400\n" -"Last-Translator: Erwien Samantha Y \n" -"Language-Team: LANGUAGE \n" -"Language: id\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump adalah mekasih untuk dumping kernel yang crash. Kejadian dalam sistem " -"yang gagak, kdump akan mengambil informasi yang bisa berguna untuk " -"mendetermasi penyebab dari kegagalan sistem anda. Dengan catatan bahwa kdump " -"memerlukan alokasi memory yang cukup yang menyebabkan kegiatan lain tidak " -"bisa dilakukan dulu." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Total Memory Sistem (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Usable Memory Sistem (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump Memory (MB(:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Maaf, sistem anda tidak mempunyai cukup memory untuk menjalakan kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Maaf, Kernel Xen tidak didukung Kdump saat ini!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Maaf, Arsitektur %s tidak mendukung kdump saat ini!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Perubahan dari konfigurasi Kdump memerlukan boot ulang sistem anda untuk " -#~ "pengalokasian memori secara benar. %s Apa anda ingin melanjutkan dengan " -#~ "konfigurasi yang baru dan boot lagi sustem setelah fisrboot selesai?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "Error! No bootloader config file found, aborting configuration!" diff --git a/anaconda-addon/po/is.po b/anaconda-addon/po/is.po deleted file mode 100644 index e48bd5d..0000000 --- a/anaconda-addon/po/is.po +++ /dev/null @@ -1,115 +0,0 @@ -# Íslensk þýðing kexec-tools -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# Richard Allen , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-24 10:50-0400\n" -"Last-Translator: Richard Allen \n" -"Language-Team: is \n" -"Language: is\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n%10!=1 || n%100==11)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump grípur kjarnahrun. Ef svo illa fer að kjarninn hrynur mun kdump grípa " -"upplýsingar frá vélinni þinni sem geta reynst ómetanlegar til að elta uppi " -"skýringar á hruninu. Athugaðu að kdump þarf að taka frá hluta vinnsluminnis " -"vélarinnar sem verður þá ónothæft fyrir aðra hluti á vélinni." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Heildar_minni (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Nothæft minni (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump minni (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Því miður hefur vélin þín ekki nóg minni til að raunhæft sé að nota kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Því miður eru Xen kjarnar ekki studdir af kdump þessa stundina!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Því miður er %s vélbúnaðurinn ekki studdur af kdump þessa stundina!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Ef þú breytir stillingum kdump þarftu að endurræsa til að taka frá minni " -#~ "samkvæmt nýju stillingunum. %sViltu halda áfram og breyta þessu og " -#~ "endurræsa svo vélinni þegar firstboot hefur lokið keyrslu?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Villa! Engin stillingaskrá fyrir ræsistjórann fannst. Hætti við " -#~ "stillingar!" diff --git a/anaconda-addon/po/it.po b/anaconda-addon/po/it.po deleted file mode 100644 index bdadb8a..0000000 --- a/anaconda-addon/po/it.po +++ /dev/null @@ -1,125 +0,0 @@ -# translation of it.po to -# translation of it.po to -# translation of it.po to -# translation of it.po to italiano -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# Francesco Tombolini , 2007. -# fvalen , 2013. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2013-12-01 07:00-0500\n" -"Last-Translator: fvalen \n" -"Language-Team: \n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 3.1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump è un meccanismo di crash dumping del kernel. In caso di crash del " -"sistema, kdump catturerà le informazioni dal sistema, utili per determinare " -"la causa del crash. Da notare che kdump necessita di un utilizzo di una " -"porzione della memoria del sistema, la quale a sua volta non sarà " -"disponibile per altri usi." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Memoria da _Riservare (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "Memoria del sistema totale (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "Memoria del Sistema Utilizzabile (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Abilita kdump?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Prenotazione Memoria di Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Automatico" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_Manuale" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Memoria attualmente riservata (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Configurazioni avanzate di kdump" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Spiacente, il sistema non ha abbastanza memoria per far funzionare kdump!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Spiacente, i kernel Xen non supportano kdump in questo momento!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Spiacente, l'architettura %s non supporta kdump in questo momento!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Cambiare le impostazioni di Kdump richiederà il riavvio del sistema per " -#~ "poter riassegnare la memoria. Desideri continuare con il cambiamento e " -#~ "riavviare il sistema dopo che firstboot è stato completato?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Errore! Non è stato trovato alcun file di configurazione del bootloader, " -#~ "configurazione annullata!" diff --git a/anaconda-addon/po/ja.po b/anaconda-addon/po/ja.po deleted file mode 100644 index db898ff..0000000 --- a/anaconda-addon/po/ja.po +++ /dev/null @@ -1,124 +0,0 @@ -# translation of ja.po to Japanese -# translation of ja.po to -# translation of ja.po to -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# kiyoto james hashida , 2007. -# Kiyoto Hashida , 2007, 2010. -# noriko , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 09:59-0500\n" -"Last-Translator: noriko \n" -"Language-Team: Japanese \n" -"Language: ja\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump はカーネルクラッシュダンプのメカニズムです。システムがクラッシュした場" -"合、 Kdump はシステムからそのクラッシュの原因を判定するために重要となる可能性" -"のある情報をキャプチャします。kdump には kdump 以外では使用できない部分をシス" -"テムメモリー内に予約しておく必要があるため注意して下さい。" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "予約されるメモリー (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "合計システムメモリー (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "使用可能なシステムメモリー (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump を有効にしますか (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump メモリー予約:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "自動 (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "手動 (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "現在予約されているメモリー (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "高度な kdump の設定" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "すみません。システムには kdump を運営できるだけの充分なメモリーがありませ" -#~ "ん!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "すみません。Xen カーネルは、今回は kdump をサポートしていません. " - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "すみません。%s アーキテクチャは、今回は kdump サポートしていません!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump 設定を変更するとメモリーを再割り当てするためのシステムの再起動が必要" -#~ "になります。この変更を加え続行し、 初期起動 (firstboot) が完了した後にシス" -#~ "テムの再起動を行いますか?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "エラー! ブートローダ設定ファイルが見つかりません。設定を中止します!" diff --git a/anaconda-addon/po/ka.po b/anaconda-addon/po/ka.po deleted file mode 100644 index e7f6be6..0000000 --- a/anaconda-addon/po/ka.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: ka\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/kdump-anaconda-addon.pot b/anaconda-addon/po/kdump-anaconda-addon.pot deleted file mode 100644 index 3b9b641..0000000 --- a/anaconda-addon/po/kdump-anaconda-addon.pot +++ /dev/null @@ -1,81 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-09 15:07+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:138 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:140 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:43 -msgid "_KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:1 tmp/kdump.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/kdump.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/kdump.glade.h:7 -msgid "Memory To Be Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/kdump.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/kdump.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/kdump.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/kdump.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/kdump.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/kdump.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/kn.po b/anaconda-addon/po/kn.po deleted file mode 100644 index f837ae6..0000000 --- a/anaconda-addon/po/kn.po +++ /dev/null @@ -1,124 +0,0 @@ -# translation of kn.po to Kannada -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Shankar Prasad , 2007, 2010. -# shanky , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 07:26-0500\n" -"Last-Translator: shanky \n" -"Language-Team: kn_IN \n" -"Language: kn\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump ಎನ್ನುವುದು ಕರ್ನಲ್ಲಿನ ಕುಸಿತವನ್ನು ಬಿಸುಡುವ ಒಂದು ಯಾಂತ್ರಿಕ ವ್ಯವಸ್ಥೆ. ಗಣಕವು " -"ಕುಸಿತಕ್ಕೊಳಗಾದ ಸಂದರ್ಭದಲ್ಲಿ, kdump ಕುಸಿತದ ಕಾರಣವನ್ನು ನಿರ್ಧರಿಸುವ ಅಮೂಲ್ಯ ಮಾಹಿತಿಯನ್ನು " -"ನಿಮ್ಮ ಗಣಕದಿಂದ ಹಿಡಿದಿಟ್ಟುಕೊಳ್ಳುತ್ತದೆ. ಇಲ್ಲಿ ನೆನಪಿನಲ್ಲಿಡಬೇಕಾದ ಅಂಶವೆಂದರೆ, kdump ಗಾಗಿ " -"ಗಣಕದ ಮೆಮೊರಿಯಲ್ಲಿನ ಒಂದಂಶವನ್ನು ಕಾದಿರಿಸುವುದು ಅಗತ್ಯವಾಗುತ್ತದೆ ಹಾಗು ಈ ಮೆಮೊರಿಯು " -"ಬೇರಾವುದೇ ಬಳಕೆಗೆ ಬರುವುದಿಲ್ಲ." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "ಕಾದಿರಿಸಬೇಕಿರುವ ಮೆಮೊರಿ (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "ಗಣಕದ ಒಟ್ಟಾರೆ ಮೆಮೊರಿ (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ಗಣಕದ ಬಳಸಬಹುದಾದಂತಹ ಮೆಮೊರಿ (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump ಅನ್ನು ಶಕ್ತಗೊಳಿಸಬೇಕೆ (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump ಮೆಮೊರಿ ಕಾದಿರಿಸುವಿಕೆ:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "ಸ್ವಯಂಚಾಲಿತ (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "ಕೈಪಿಡಿ (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "ಪ್ರಸಕ್ತ ಕಾದಿರಿಸಲಾದ ಮೆಮೊರಿ (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "ಸುಧಾರಿತ kdump ಸಂರಚನೆ" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "ಕ್ಷಮಿಸಿ, kdump ಅನ್ನು ಕಾರ್ಯಸಾಧ್ಯ ಮಾಡಲು ನಿಮ್ಮ ಗಣಕದಲ್ಲಿ ಸಾಕಷ್ಟು ಮೆಮೊರಿಯು ಲಭ್ಯವಿಲ್ಲ!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "ಕ್ಷಮಿಸಿ, Xen ಕರ್ನಲ್ಲುಗಳು ಈ ಸಮಯದಲ್ಲಿ kdump ಅನ್ನು ಬೆಂಬಲಿಸುತ್ತಿಲ್ಲ." - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "ಕ್ಷಮಿಸಿ, %s ಆರ್ಕಿಟೆಕ್ಚರ್ ಈ ಸಮಯದಲ್ಲಿ kdump ಅನ್ನು ಬೆಂಬಲಿಸುತ್ತಿಲ್ಲ!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "ಮೆಮೊರಿಯನ್ನು ಅನುಗುಣವಾಗಿ ಪುನರ್ ಹಂಚಿಕೆ ಮಾಡಲು ಅನುವಾಗುವಂತೆ Kdump ಸಿದ್ಧತೆಗಳನ್ನು " -#~ "ಬದಲಾಯಿಸಲು ಗಣಕವನ್ನು ಪುನಃ ಬೂಟ್‌ ಮಾಡುವುದು ಅಗತ್ಯವಾಗುತ್ತದೆ. ನೀವು ಈ ಬದಲಾವಣೆಯೊಂದಿಗೆ " -#~ "ಮುಂದುವರೆಯಲು ಹಾಗು ಪ್ರಥಮ ಬೂಟ್ ಸಂಪೂರ್ಣಗೊಂಡ ನಂತರ ಗಣಕವನ್ನು ಮರಳಿ ಬೂಟ್‌ ಮಾಡಲು " -#~ "ಬಯಸುತ್ತೀರೆ?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "ದೋಷ! ಯಾವುದೇ ಬೂಟ್-ಲೋಡರ್ config ಕಡತವು ಕಂಡುಬಂದಿಲ್ಲ, ಸಂರಚನೆಯನ್ನು " -#~ "ಸ್ಥಗಿತಗೊಳಿಸಲಾಗುತ್ತಿದೆ!" diff --git a/anaconda-addon/po/ko.po b/anaconda-addon/po/ko.po deleted file mode 100644 index e940e49..0000000 --- a/anaconda-addon/po/ko.po +++ /dev/null @@ -1,122 +0,0 @@ -# translation of ko.po to Korean -# translation of ko.po to -# translation of ko.po to -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER, 2007. -# -# Eunju Kim , 2007. -# Hyunsok Oh , 2010. -# eukim , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 08:25-0500\n" -"Last-Translator: eukim \n" -"Language-Team: Korean \n" -"Language: ko\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0;\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"kdump는 커널 충돌 덤프 기술입니다. 시스템 충돌 시, kdump는 충돌의 원인을 파악" -"하는데 유용한 시스템 정보를 캡쳐합니다.kdump는 시스템 메모리의 한 부분을 차지" -"하며, 이 부분은 다른 목적으로 사용할 수 없음을 알려드립니다." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "예약 메모리 (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "전체 시스템 메모리 (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "사용 가능한 시스템 메모리 (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump를 활성화하겠습니까?(_E)" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump 메모리 예약:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "자동 (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "수동(_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "현재 예약된 메모리 (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "고급 kdump 설정 " - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "죄송합니다. 시스템에 kdump를 실행할 만한 충분한 메모리 공간이 없습니다!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "죄송합니다. Xen 커널은 현재 kdump를 지원하지 않습니다!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "죄송합니다. %s 구조는 현재 kdump를 지원하지 않습니다!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "kdump 설정을 변경하면 그에 맞게 메모리를 재할당하기 위해 시스템을 다시 시" -#~ "작해야 합니다. firstboot가 완료된 다음에 시스템을 다시 시작하여 이 변경 사" -#~ "항을 적용하시겠습니까?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "오류! 부트로더 구성 파일을 찾을 수 없습니다. 설정을 종료합니다!" diff --git a/anaconda-addon/po/ku.po b/anaconda-addon/po/ku.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/ku.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/lo.po b/anaconda-addon/po/lo.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/lo.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/lv.po b/anaconda-addon/po/lv.po deleted file mode 100644 index 47efd09..0000000 --- a/anaconda-addon/po/lv.po +++ /dev/null @@ -1,79 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: lv\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : " -"2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/mk.po b/anaconda-addon/po/mk.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/mk.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/ml.po b/anaconda-addon/po/ml.po deleted file mode 100644 index fd121de..0000000 --- a/anaconda-addon/po/ml.po +++ /dev/null @@ -1,119 +0,0 @@ -# translation of ml.po to Malayalam -# translation of ml.po to -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Ani Peter , 2007, 2010. -# anipeter , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-13 03:50-0500\n" -"Last-Translator: anipeter \n" -"Language-Team: Malayalam \n" -"Language: ml\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"ഒരു കേര്‍ണല്‍ ക്രാഷ് ഡംപിങ് സംവിധാനമാണു് Kdump . സിസ്റ്റത്തില്‍ ഒരു തകരാറു സംഭവിച്ചാല്‍, അതിനുളള " -"കാരണം എന്തെന്ന് കണ്ടുപിടിക്കുന്നതിനുളള കാര്യവിവരങ്ങള്‍ kdump-നു് ലഭ്യമാകുന്നു. കുറിപ്പ്: മറ്റു് " -"ഉപയോക്താക്കള്‍ക്കു് ലഭ്യമല്ലാത്ത സിസ്റ്റത്തിന്റെ ഒരു ഭാഗം മെമ്മറി kdump-നു് ആവശ്യമുണ്ട്." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "കരുതിവയ്ക്കേണ്ട മെമ്മറി (MB) :" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "സിസ്റ്റത്തിന്റെ പൂര്‍ണ്ണ മെമ്മറി (MB) :" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "സിസ്റ്റത്തില്‍ ഉപയോഗപ്രദമായ മെമ്മറി (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump പ്രവര്‍ത്തന സജ്ജമാക്കണമോ (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump മെമ്മറി കരുതല്‍:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_ഓട്ടോമാറ്റിക്ക്" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_മാനുവല്‍" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "നിലവില്‍ സൂക്ഷിച്ചിട്ടുള്ള മെമ്മറി (MB) :" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "മെച്ചപ്പെട്ട kdump ക്രമീകരണം" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "ക്ഷമിക്കണം, നിങ്ങളുടെ സിസ്റ്റത്തില്‍ kdump-നു് ആവശ്യമുളള മെമ്മറി നിലവിലില്ല!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "ക്ഷമിക്കണം, Xen കേര്‍ണലുകള്‍ നിലവില്‍ kdump പിന്തുണയ്ക്കുന്നില്ല!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "ക്ഷമിക്കണം, %s ആര്‍ക്കിടക്ചര്‍ നിലവില്‍ kdump പിന്തുണയ്ക്കുന്നില്ല!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump ക്രമീകരണങ്ങളില്‍ മാറ്റം വരുത്തുന്നതിനായി നിങ്ങളുടെ സിസ്റ്റം റീബൂട്ട് ചെയ്തു് മെമ്മറി " -#~ "സജ്ജീകരണങ്ങള്‍ വീണ്ടും ക്രമപ്പെടുത്തേണ്ടതാകുന്നു. നിങ്ങള്‍ക്ക് ഈ മാറ്റവുമായി മുമ്പോട്ട് പോയി, " -#~ "ഫസ്റ്റ്ബൂട്ട് പൂര്‍ത്തിയാക്കിയ ശേഷം സിസ്റ്റം വീണ്ടും റീബൂട്ട് ചെയ്യണമോ?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "പിഴവ്! ബൂട്ട്ലോഡര്‍ ക്രമീകരണ ഫയല്‍ ലഭ്യമായില്ല, ക്രമീകരണം നിര്‍ത്തുന്നു!" diff --git a/anaconda-addon/po/mr.po b/anaconda-addon/po/mr.po deleted file mode 100644 index c2028fc..0000000 --- a/anaconda-addon/po/mr.po +++ /dev/null @@ -1,120 +0,0 @@ -# translation of mr.po to Marathi -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# sandeep shedmake , 2007. -# Sandeep Shedmake , 2010. -# sandeeps , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-10 02:52-0500\n" -"Last-Translator: sandeeps \n" -"Language-Team: Marathi \n" -"Language: mr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "केडम्प" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"केडम्प कर्नल आणीबाणी निर्मुलन पद्धती आहे. प्रणाली आणीबाणी घटनाक्रमास, kdump आपल्या " -"प्रणालीतील अतीमहत्वाची माहिती ज्यामुऴे आणीबाणी चे कारण शोधण्यास मदत मिळते. लक्षात घ्या " -"kdump ला प्रणाली स्मृत्तीचे आरक्षण हवे असते जे इतर वापरकर्त्यांना अनुपलब्ध राहतील." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "आरक्षित करणेजोगी मेमरी (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "एकूण प्रणालीची मेमरी (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "वापरतायेण्याजोगी प्रणाली मेमरी (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "केडम्प सुरू करा (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "केडम्प मेमरी आरक्षण (MB) (_K):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "स्वयंचलित (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "व्यक्तिचलित (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "सध्या आरक्षित मेमरी(MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "प्रगत केडम्प संरचना" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "माफ करा, आपल्या प्रणालीस केडम्प यशस्वीरीत्या चालण्याजोगी अतिरीक्त स्मृत्ती नाही!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "माफ करा, xen कर्नल्स् याक्षणी kdump करीता समर्थन पुरवत नाही!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "माफ करा, %s आर्किटेक्चर kdump करीता समर्थन पुरवत नाही!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "केडम्प सेटिंग्ज बदलण्याकरीता प्रणालीस मेमरीचे परस्पररीत्या वाटप करण्याकरीता प्रणाली " -#~ "पुन्हा सुरू करा. तुम्हाला हे बदल लागू करायचे व फर्स्टबूट पूर्ण झाल्यावर प्रणालीला पुन्हा सुरू " -#~ "करायचे?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "त्रूटी! बूटलोडर config फाइल सापडली नाही, संरचना रद्द करीत आहे!" diff --git a/anaconda-addon/po/ms.po b/anaconda-addon/po/ms.po deleted file mode 100644 index 39b2f84..0000000 --- a/anaconda-addon/po/ms.po +++ /dev/null @@ -1,115 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-13 11:22-0400\n" -"Last-Translator: Sharuzzaman Ahmat Raslan \n" -"Language-Team: LANGUAGE \n" -"Language: ms\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump adalah mekanisme longgokan kerosakan kernel. Dalam kejadian kerosakan " -"sistem, kdump akan mendapatkan maklumat dari sistem anda yang mungkin " -"berharga dalam menentukan sebab kerosakan tersebut. Diingatkan bahawa kdump " -"perlu mengkhaskan sebahagian memori sistem yang tidak boleh digunakan untuk " -"kegunaan lain." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Jumlah Memori Sis_tem (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Memori Sistem Bolehguna (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Memori _Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Maaf, sistem anda tidak mempunyai memori yang cukup untuk kdump menjadi " -#~ "berguna!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Maaf, kernel Xen tidak menyokong kdump pada ketika ini!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Maaf, rekabentuk %s tidak menyokong kdump pada ketika ini!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Menukar tetapan Kdump memerlukan ulangboot sistem untuk mengumpukkan " -#~ "semula memori. %s Adakah anda hendak meneruskan dengan perubahan ini dan " -#~ "ulangboot sistem selepas firstboot selesai?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "Ralat! Tiada fail tetapan pemuat but dijumpai, membatalkan tetapan!" diff --git a/anaconda-addon/po/my.po b/anaconda-addon/po/my.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/my.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/nb.po b/anaconda-addon/po/nb.po deleted file mode 100644 index 9607113..0000000 --- a/anaconda-addon/po/nb.po +++ /dev/null @@ -1,113 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-26 07:42-0400\n" -"Last-Translator: Espen A. Stefansen \n" -"Language-Team: Norwegian/Bokmaal \n" -"Language: nb\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump er en mekanisme for logging av kjernekrasjer. Om et systemkrasj " -"inntreffer, vil kdump samle informasjonen fra ditt system som kan væra " -"verdifullt for å bestemma grunnene til krasjet. Legg merke til at kdump " -"reserverer en del av systemminnet som ikke kan brukes til noe annet." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Totalt systemminne (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Brukbart systemminne (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump-minne (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Dessverre, ditt system har ikke nok minne for at kdump kan brukes!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Dessverre, Xen-kjerner støtter ikke kdump for øyeblikket!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Dessverre, %s-arkitekturen støtter ikke kdump for øyeblikket!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Endringer av Kdump-innstillinger krever omstart av systemet for å " -#~ "omallokere minnet. %sVil du fortsette med denne endringen og starte " -#~ "systemet på nytt etter at firstboot er ferdig?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Feil! Ingen konfigurasjonsfil ble funnet for startprogrammet, avbryter " -#~ "konfigurasjonen!" diff --git a/anaconda-addon/po/nl.po b/anaconda-addon/po/nl.po deleted file mode 100644 index eb0edda..0000000 --- a/anaconda-addon/po/nl.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: nl\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/or.po b/anaconda-addon/po/or.po deleted file mode 100644 index 808b34d..0000000 --- a/anaconda-addon/po/or.po +++ /dev/null @@ -1,122 +0,0 @@ -# translation of or.po to Oriya -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Subhransu Behera , 2007. -# Subhransu Behera , 2007. -# Manoj Kumar Giri , 2010. -# mgiri , 2012. #zanata -# yangrr , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-20 10:06-0500\n" -"Last-Translator: yangrr \n" -"Language-Team: Oriya \n" -"Language: or\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump କର୍ଣ୍ଣଲ ଅକାମି ହେବା ସମୟରେ ତଥ୍ଯ ରଖିବାର ଗୋଟିଏ କୌଶଳ ଅଟେ। ଗୋଟିଏ ତନ୍ତ୍ର ଅକାମି ହେବା " -"ସମୟରେ, kdump ଆପଣଙ୍କ ତନ୍ତ୍ରରୁ ସୂଚନା ଗ୍ରହଣ କରିବ ଯାହାକି ଅକାମି ହେବାର କାରଣ ଖୋଜିବାରେ ଅମୂଲ୍ଯ " -"ଅଟେ। ଏହା ମନେ ରଖନ୍ତୁ ଯେ kdump ତନ୍ତ୍ର ସ୍ମୃତିର ଗୋଟିଏ ଅଂଶର ସଂରକ୍ଷଣ ଆବଶ୍ଯକ କରି ନ ଥାଏ ଯାହାକି " -"ଅନ୍ଯାନ୍ଯ ଚାଳକ ମାନଙ୍କ ପାଇଁ ଅନୁପଲବ୍ଧ ହେବ।" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "ସଂରକ୍ଷଣ କରିବାକୁ ଥିବା ସ୍ମୃତିସ୍ଥାନ (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "ସମୁଦାୟ ତନ୍ତ୍ର ସ୍ମୃତି (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ବ୍ଯବହାର ଯୋଗ୍ଯ ତନ୍ତ୍ର ସ୍ମୃତି (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdump କୁ ସକ୍ରିୟ କରାଯିବ କି (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump ସ୍ମୃତି ସଂରକ୍ଷଣ:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "ସ୍ୱୟଂଚାଳିତ (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "ହସ୍ତକୃତ (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "ବର୍ତ୍ତମାନ ସଂରକ୍ଷିତ ସ୍ମୃତିସ୍ଥାନ (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "ଉନ୍ନତ kdump ସଂରଚନା" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "କ୍ଷମା କରିବେ, kdump କୁ କାର୍ଯ୍ଯକାରୀ କରିବା ପାଇଁ ଆପଣଙ୍କ ତନ୍ତ୍ରରେ ଯଥେଷ୍ଟ ସ୍ମୃତି ନାହିଁ!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "କ୍ଷମା କରିବେ, Xen କର୍ଣ୍ଣଲ ଗୁଡିକ ବର୍ତ୍ତମାନ kdump କୁ ସମର୍ଥନ କରେନାହିଁ।" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "କ୍ଷମା କରିବେ, %s ସ୍ଥାପତ୍ଯ ବର୍ତ୍ତମାନ kdump କୁ ସମର୍ଥନ କରେ ନାହିଁ!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Kdump ର ବିନ୍ଯାସ ପରିବର୍ତ୍ତନ କରିବା ପାଇଁ ସେହି ଅନୁଯାୟୀ ସ୍ମୃତି ବଣ୍ଟନ କରିବାକୁ ତନ୍ତ୍ରକୁ ପୁନର୍ଚାଳନ " -#~ "କରିବା ଆବଶ୍ଯକ। ଆପଣ ଏହି ପରିବର୍ତ୍ତନ ସହିତ ଜାରି ରଖିବା ପାଇଁ ଏବଂ firstboot ସମାପ୍ତ ହେବା ପରେ " -#~ "ତନ୍ତ୍ରକୁ ପୁନର୍ଚାଳନ କରିବା ପାଇଁ ଚାହାଁନ୍ତି?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "ତୃଟି! କୌଣସି ବୁଟ ଲୋଡର config ଫାଇଲ ମିଳିଲା ନାହିଁ, ବିନ୍ଯାସ ପ୍ରକ୍ରିୟାକୁ ପରିତ୍ଯାଗ କରୁଅଛି!" diff --git a/anaconda-addon/po/pa.po b/anaconda-addon/po/pa.po deleted file mode 100644 index c71c3de..0000000 --- a/anaconda-addon/po/pa.po +++ /dev/null @@ -1,118 +0,0 @@ -# translation of pa.po to Punjabi -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# A S Alam , 2007. -# Jaswinder Singh , 2007, 2010, 2012. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-13 05:01-0500\n" -"Last-Translator: Jaswinder Singh \n" -"Language-Team: Punjabi/Panjabi \n" -"Language: pa\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "ਕੇ-ਡੰਪ" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"ਕੇ-ਡੰਪ ਕਰਨਲ ਕਰੈਸ਼ ਡੰਪ ਬਣਾਉਣ ਦਾ ਢੰਗ ਹੈ। ਇੱਕ ਸਿਸਟਮ ਕਰੈਸ਼ ਹੋਣ ਸਮੇਂ, ਕੇ-ਡੰਪ ਤੁਹਾਡੇ ਸਿਸਟਮ ਤੋਂ " -"ਜਾਣਕਾਰੀ ਇੱਕਤਰ ਕਰਦਾ ਹੈ, ਜੋ ਕਿ ਕਰੈਸ਼ ਦਾ ਕਾਰਨ ਜਾਣਨ ਲਈ ਸਹਾਇਕ ਹੋ ਸਕਦੀ ਹੈ। ਯਾਦ ਰੱਖੋ ਕਿ ਕੇ-ਡੰਪ " -"ਨੂੰ ਸਿਸਟਮ ਮੈਮੋਰੀ ਦਾ ਕੁਝ ਭਾਗ ਰਾਖਵਾਂ ਰੱਖਣਾ ਪੈਂਦਾ ਹੈ ਜੋ ਕਿ ਹੋਰ ਵਰਤੋਂ ਲਈ ਉਪਲੱਬਧ ਨਹੀਂ ਹੋਵੇਗਾ" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "ਰਾਖਵੀਂ ਮੈਮੋਰੀ(_R) (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "ਕੁੱਲ ਸਿਸਟਮ ਮੈਮੋਰੀ (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ਵਰਤੋਂ-ਯੋਗ ਸਿਸਟਮ ਮੈਮੋਰੀ (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "ਕੇ-ਡੰਪ ਯੋਗ ਕਰੋ(_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "ਕੇ-ਡੰਪ ਮੈਮੋਰੀ (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "ਆਟੋਮੈਟਿਕ(_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "ਦਸਤੀ(_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "ਮੌਜੂਦਾ ਰਾਖਵੀਂ ਮੈਮੋਰੀ (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "ਤਕਨੀਕੀ ਕੇ-ਡੰਪ ਸੰਰਚਨਾ" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "ਅਫਸੋਸ, ਕਿ ਤੁਹਾਡੇ ਸਿਸਟਮ ਉੱਤੇ ਕੇ-ਡੰਪ ਲਈ ਲੋੜੀਦੀ ਮੈਮੋਰੀ ਉਪਲੱਬਧ ਨਹੀਂ ਹੈ!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "ਮੁਆਫ਼ੀ, Xen ਕਰਨਲ ਹਾਲੇ ਕੇ-ਡੰਪ ਲਈ ਸਹਿਯੋਗੀ ਨਹੀਂ ਹਨ!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "ਮੁਆਫੀ, ਕਿ %s ਢਾਂਚਾ ਹਾਲੇ ਕੇ-ਡੰਪ ਲਈ ਸਹਿਯੋਗੀ ਨਹੀਂ ਹੈ!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "ਕੇ-ਡੰਪ ਦੀ ਸੈਟਿੰਗ ਬਦਲਣ ਨਾਲ ਸਿਸਟਮ ਨੂੰ ਮੁੜ-ਚਾਲ ਕਰਨਾ ਪਵੇਗਾ ਤਾਂ ਕਿ ਮੈਮੋਰੀ ਮੁੜ-ਜਾਰੀ ਕੀਤੀ ਜਾ " -#~ "ਸਕੇ। %sਕੀ ਤੁਸੀਂ ਇਹ ਤਬਦੀਲੀ ਕਰਨੀ ਚਾਹੁੰਦੇ ਹੋ ਅਤੇ ਸਿਸਟਮ ਫਸਟ-ਬੂਟ ਪੂਰਾ ਹੋਣ ਬਾਅਦ ਮੁੜ-ਚਾਲੂ " -#~ "ਹੋਵੇਗਾ?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "ਗਲਤੀ! ਬੂਟ-ਲੋਡਰ ਸੰਰਚਨਾ ਨਹੀਂ ਮਿਲੀ ਹੈ, ਸੰਰਚਨਾ ਅਧੂਰੀ ਛੱਡੀ ਜਾਂਦੀ ਹੈ!" diff --git a/anaconda-addon/po/pl.po b/anaconda-addon/po/pl.po deleted file mode 100644 index 75717b9..0000000 --- a/anaconda-addon/po/pl.po +++ /dev/null @@ -1,114 +0,0 @@ -# translation of pl.po to Polish -# Piotr Drąg , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-08 09:18-0500\n" -"Last-Translator: Piotr Drąg \n" -"Language-Team: Polish \n" -"Language: pl\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " -"|| n%100>=20) ? 1 : 2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump jest mechanizmem zrzucania błędów jądra. W wypadku zawieszenia się " -"systemu, kdump przechwyci informację systemu, która może być bezcenna w " -"ustaleniu powodu zawieszenia. Zauważ, że kdump wymaga zarezerwowania części " -"pamięci systemu, która będzie niedostępna dla innych użytkowników." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Całkowi_ta pamięć systemu (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Używalna pamięć systemu (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Pamięć _kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Przepraszam, system nie posiada wystarczającej ilości pamięci dla kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Przepraszam, jądra Xen nie obsługują teraz kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Przepraszam, architektura %s nie obsługuje teraz kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Zmienianie ustawień kdump wymaga ponownego uruchomienia systemu, aby " -#~ "ponownie przydzielić pamięć. %sCzy chcesz kontynuować z tą zmianą i " -#~ "uruchomić ponownie system po zakończeniu pierwszego uruchomienia?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Błąd! Nie znaleziono pliku konfiguracyjnego programu startowego, " -#~ "przerywanie konfiguracji!" diff --git a/anaconda-addon/po/pom.xml b/anaconda-addon/po/pom.xml deleted file mode 100644 index fb230ba..0000000 --- a/anaconda-addon/po/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - 4.0.0 - null - null - 0 - - - - - org.zanata - zanata-maven-plugin - 2.0.0 - - . - - - - - diff --git a/anaconda-addon/po/pt.po b/anaconda-addon/po/pt.po deleted file mode 100644 index bd3b3c8..0000000 --- a/anaconda-addon/po/pt.po +++ /dev/null @@ -1,113 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: firstboot_kdump\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-05-09 02:24+0100\n" -"Last-Translator: José Nuno Coelho Pires \n" -"Language-Team: pt \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-POFile-SpellExtra: kdump Xen firstboot Kdump kernels\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"O Kdump é um mecanismo de gravação dos estoiros do 'kernel'. No caso de " -"ocorrer um estoiro do sistema, o 'kdump' irá capturar a informação do seu " -"sistema, valiosa para determinar a causa do estoiro. Lembre-se que o 'kdump' " -"necessita de reservar uma parte da memória do sistema que estará " -"indisponível para outros usos." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "Memória _Total do Sistema (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "Memória Ú_til do Sistema (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Memória do _Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Infelizmente, o seu sistema não tem memória suficiente para o kdump ser " -#~ "viável!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "" -#~ "Infelizmente, os 'kernels' do Xen não suportam o 'kdump' nesta altura!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Infelizmente, a arquitectura %s não suporta o kdump nesta altura!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "A alteração da configuração do Kdump necessita de reiniciar o sistema " -#~ "para reservar de novo a memória de forma adequada.%s Deseja continuar com " -#~ "esta alteração e reiniciar o sistema depois de o 'firstboot' terminar?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Erro! Não foi encontrado o ficheiro de configuração do gestor de " -#~ "arranque, a abortar a configuração!" diff --git a/anaconda-addon/po/pt_BR.po b/anaconda-addon/po/pt_BR.po deleted file mode 100644 index ddc6303..0000000 --- a/anaconda-addon/po/pt_BR.po +++ /dev/null @@ -1,129 +0,0 @@ -# translation of pt_BR.po to Portuguese -# This file is distributed under the same license as the kexec-tools package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# Valnir Ferreira Jr., 2007. -# Igor Pires Soares , 2007. -# Glaucia Cintra , 2010. -# gcintra , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 07:44-0500\n" -"Last-Translator: gcintra \n" -"Language-Team: Portuguese \n" -"Language: pt-BR\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Poedit-Language: Portuguese\n" -"X-Poedit-Country: BRAZIL\n" -"X-Generator: Zanata 2.0.2\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"O kdump é um mecanismo de despejo de falhas do kernel. Em casos de falhas do " -"sistema, o kdump capturará informações sobre o seu sistema que podem ser " -"muito úteis para determinar a causa da falha. Note que o kdump não requer a " -"alocação exclusiva de uma porção da memória do sistema que estará " -"indisponível para outros usuários." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Memória a ser_Reservada (MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "Memória Total do Sistema (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "Memória Utilizável do Sistema (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Habilitar kdump?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Memória do Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Automático" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "_Manual" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Memória Reservada Atualmente (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Configuração avançada do kdump" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Infelizmente, o seu sistema não tem memória suficiente para viabilizar o " -#~ "uso do kdump." - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Infelizmente, kernels do xen não suportam o kdump desta vez!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Infelizmente, a arquitetura %s ainda não suporta o kdump!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "A mudança da configuração do kdump requer a reinicialização do sistema " -#~ "para a realocação apropriada de memória. \n" -#~ "Gostaria de prosseguir com esta mudança e reinicializar o sistema após o " -#~ "término do firstboot?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Erro! Nenhum arquivo de configuração do gerenciador de inicialização foi " -#~ "encontrado, abortando a configuração!" diff --git a/anaconda-addon/po/ru.po b/anaconda-addon/po/ru.po deleted file mode 100644 index 541c160..0000000 --- a/anaconda-addon/po/ru.po +++ /dev/null @@ -1,122 +0,0 @@ -# translation of ru.po to -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Yulia Poyarkova , 2007. -# Yulia , 2010. -# ypoyarko , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 05:21-0500\n" -"Last-Translator: ypoyarko \n" -"Language-Team: Russian\n" -"Language: ru\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump предоставляет новый механизм сбора статистики о сбоях ядра. В случае " -"сбоя kdump осуществляет сбор статистики для последующего определения причины " -"сбоя. Нужно иметь в виду, что kdump требует резервирования части системной " -"памяти, что делает её недоступной для использования." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "Будет зарезервировано (МБ):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "_Общий объем памяти (МБ):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "_Доступно памяти (МБ):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "_Включить Kdump?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Резервирование памяти Kdump:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "_Автоматически" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "В_ручную" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "Зарезервировано памяти (МБ):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "Дополнительные настройки kdump" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Извините, ваша система не имеет достаточно памяти для работы kdump!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "К сожалению, в настоящее время ядро Xen не поддерживает kdump." - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Извините, архитектура %s в настоящее время не поддерживает kdump!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Изменение настроек Kdump требует перезагрузки системы для " -#~ "перераспределения памяти. Продолжить и перезагрузить систему по " -#~ "завершению firstboot? " - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Ошибка! Не найден конфигурационный файл загрузчика, настройка прервана." diff --git a/anaconda-addon/po/si.po b/anaconda-addon/po/si.po deleted file mode 100644 index ad22ccc..0000000 --- a/anaconda-addon/po/si.po +++ /dev/null @@ -1,115 +0,0 @@ -# translation of si.po to Sinhala -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Danishka Navin , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-07-03 05:52-0400\n" -"Last-Translator: Danishka Navin \n" -"Language-Team: Sinhala \n" -"Language: si\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "කේඩම්ප්" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"කේඩම්ප් යනු න්‍යෂ්ඨි අනතුරු සිදුවු විට තොරතුරු ගන්නා ක්‍රමවේදයකි. පද්ධතිය අනතුරට පත්වු විට කේඩම්ප් මඟින් " -"ඔබගේ පද්ධතියේ තොරතුරු ලබාගන්නා අතර ඒවා අනතුරට ඒතුව සොයාගැනිම සඳහා මහෝපකාරි වනු ඇත. " -"කේඩම්ප් සඳහා වෙනම පද්ධති මතක කොටසක් වෙන්කර තැබීම අවශ්‍යවනු ඇත එය අනෙකුත් පරිශීලකයන් හට " -"භාවිතා කළ නොහැක." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "සම්පූර්‍ණ පද්ධති මතකය (මෙගා බයිට්) (_T):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "භාවිතා කළ හැකි මතකය (මෙගා බයිට්) (_U):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "කේඩම්ප් ක්‍රීය කරන්නද? (_E)" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "කේඩම්ප් මතකය (මෙගා බයිට්) (_K):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "සමාවන්න, කේඩම්ප් ජීව්‍ය වීම සඳහා ඔබගේ පද්ධතිය තුළ ප්‍රමාණවත් මතකයක් නැත!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "සමාවන්න, ia64 xen න්‍යෂ්ඨිය කේඩම්ප් සඳහා මෙම අවස්ථාවේ සහාය නොදක්වයි!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "සමාවන්න, %s ශෛලිය කේඩම්ප් සඳහා මෙම අවස්ථාවේ සහාය නොදක්වයි!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "කේඩම්ප් සැකසුම් වෙනස් කිරිමෙ ක්‍රියාවලියේදි මතකය නිසියාකාරව යෙදවීම සඳහා පද්ධතිය නැවත ඇරඹුම " -#~ "අවශ්‍යවේ. %s \n" -#~ "\n" -#~ "මෙම වෙනස්කම් සහිතව ඉදිරි කටයුතු කරමින් සහ පළමු ඇරඹුම සම්පූර්ණ වු පසු පද්ධතිය නැවත ඇරඹීමට ඔබ " -#~ "කැමතිද? " - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "දෝෂය!ආරමිභකය සුසර කිරීමේ ගොනුව හමු නොවීය, මානකරණය විනාශ වෙමින්!" diff --git a/anaconda-addon/po/sk.po b/anaconda-addon/po/sk.po deleted file mode 100644 index f955aae..0000000 --- a/anaconda-addon/po/sk.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: sk\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/sl.po b/anaconda-addon/po/sl.po deleted file mode 100644 index 1fbd12a..0000000 --- a/anaconda-addon/po/sl.po +++ /dev/null @@ -1,116 +0,0 @@ -# translation of sl.po to Slovenian -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Rok Papez , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-04-09 01:38-0400\n" -"Last-Translator: Rok Papez \n" -"Language-Team: Slovenian \n" -"Language: sl\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n" -"%100==4 ? 3 : 0)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump je mehanizem za posmrtne ostanke ob zrušitvi jedra. V primeru zrušitve " -"sistema, kdump shrani informacije o sistemu, ki so lahko zelo uporabne pri " -"iskanju vzroka zrušitve. Kdump za svoje delovanje rezervira kos sistemskega " -"pomnilnika, ki je nedostopen za drugo uporabo." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Skupno sistemskega pomnilnika (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Uporabnega sistemskega pomnilnika (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Pomnilnika Kdump (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Vaš sistem ne vsebuje dovolj pomnilnika za delovanje kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Jedro Xen še ne podpira kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "%s arhitektura še ne podpira kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Spreminjanje nastavitev Kdump zahteva ponovni zagon sistema zaradi " -#~ "prestavljanja pomnilnika. %sŽelite nadaljevati s spremembami in sistem " -#~ "znova zagnati, ko končate z nastavitvami po namestitvi?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Napaka! Ni bilo moč najti nastavitvene datoteke za zagon, spremembe " -#~ "nastavitev so preklicane!" diff --git a/anaconda-addon/po/sq.po b/anaconda-addon/po/sq.po deleted file mode 100644 index 1288948..0000000 --- a/anaconda-addon/po/sq.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: sq\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/sr.po b/anaconda-addon/po/sr.po deleted file mode 100644 index 96f33ed..0000000 --- a/anaconda-addon/po/sr.po +++ /dev/null @@ -1,113 +0,0 @@ -# Serbian translations for kexec-tools -# Copyright (C) 2007 Red Hat, Inc. -# This file is distributed under the same license as the kexec-tools package. -# Miloš Komarčević , 2007. -# -msgid "" -msgstr "" -"Project-Id-Version: kexec-tools\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-11 01:02-0000\n" -"Last-Translator: Miloš Komarčević \n" -"Language-Team: Serbian (sr) \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump је механизам за избачај краха језгра. У случају краха система, kdump " -"ће сакупити податке од система који могу бити од непроцењиве помоћи у " -"одређивању узрока краха. Приметите да kdump захтева заузимање дела системске " -"меморије који неће бити доступан за другу употребу." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Укупна меморија система (МБ):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Употребљива меморија система (МБ):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump меморија (МБ):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "Жалим, систем не поседује довољно меморије како би kdump био могућ!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Жалим, Xen језгра тренутно не подржавају kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Жалим, %s архитектура тренутно не подржава kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Измена Kdump подешавања захтева поновно покретање система како би се " -#~ "сходно заузела меморија. %sДа ли желите да наставите са овом изменом и " -#~ "поново покренете систем након што се firstboot заврши?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Грешка! Није пронађена датотека подешавања покретачког програма, " -#~ "обустављам подешавање!" diff --git a/anaconda-addon/po/sr@Latn.po b/anaconda-addon/po/sr@Latn.po deleted file mode 100644 index aa691ca..0000000 --- a/anaconda-addon/po/sr@Latn.po +++ /dev/null @@ -1,116 +0,0 @@ -# Serbian(Latin) translations for kexec-tools -# Copyright (C) 2007 Red Hat, Inc. -# This file is distributed under the same license as the kexec-tools package. -# Miloš Komarčević , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-10 08:02-0500\n" -"Last-Translator: Miloš Komarčević \n" -"Language-Team: Serbian (sr) \n" -"Language: sr-Latn\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump je mehanizam za izbačaj kraha jezgra. U slučaju kraha sistema, kdump " -"će sakupiti podatke od sistema koji mogu biti od neprocenjive pomoći u " -"određivanju uzroka kraha. Primetite da kdump zahteva zauzimanje dela " -"sistemske memorije koji neće biti dostupan za drugu upotrebu." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Ukupna memorija sistema (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Upotrebljiva memorija sistema (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump memorija (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Žalim, sistem ne poseduje dovoljno memorije kako bi kdump bio moguć!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Žalim, Xen jezgra trenutno ne podržavaju kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Žalim, %s arhitektura trenutno ne podržava kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Izmena Kdump podešavanja zahteva ponovno pokretanje sistema kako bi se " -#~ "shodno zauzela memorija. %sDa li želite da nastavite sa ovom izmenom i " -#~ "ponovo pokrenete sistem nakon što se firstboot završi?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Greška! Nije pronađena datoteka podešavanja pokretačkog programa, " -#~ "obustavljam podešavanje!" diff --git a/anaconda-addon/po/sv.po b/anaconda-addon/po/sv.po deleted file mode 100644 index 085874b..0000000 --- a/anaconda-addon/po/sv.po +++ /dev/null @@ -1,115 +0,0 @@ -# Svenska translation of kexec-tools. -# Copyright (C) 2006 Free Software Foundation, Inc. -# Magnus Larsson , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-03-09 07:35-0500\n" -"Last-Translator: Magnus Larsson \n" -"Language-Team: Swedish \n" -"Language: sv\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump är en mekanism för loggning av kärnkrascher. Om en " -"systemkraschinträffar, kommer kdump spara information om ditt system som kan " -"vara ovärderligt för att bestämma orsaken till kraschen. Notera att kdump " -"reserverar en del av systemminnet som inte kan användas för annat." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Totalt systemminne (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Totalt användbart systemminne (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "_Kdump-minne (MB):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Tyvärr har ditt system inte tillräckligt med minne för att kdump ska vara " -#~ "användbart!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Tyvärr stöder inte Xen-kärnor kdump för tillfället!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Tyvärr stöder inte %s-arkitekturen inte kdump för tillfället!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Ändring av inställningar för Kdump kräver omstart av systemet för att " -#~ "omallokera minne. %sVill du fortsätta med denna ändring och starta " -#~ "omsystemet efter firstboot är klar?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Fel! Ingen konfigurationsfil för startprogrammet hittades, avbryter " -#~ "konfigurering!" diff --git a/anaconda-addon/po/ta.po b/anaconda-addon/po/ta.po deleted file mode 100644 index 8df3a06..0000000 --- a/anaconda-addon/po/ta.po +++ /dev/null @@ -1,119 +0,0 @@ -# translation of ta.po to -# This file is distributed under the same license as the PACKAGE package. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER. -# -# Felix , 2007. -# I Felix , 2010. -# Shantha kumar , 2012. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 06:34-0500\n" -"Last-Translator: Shantha kumar \n" -"Language-Team: Tamil <>\n" -"Language: ta\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump என்பது ஒரு கர்னல் அழிவு டம்பிங்க்கிங் தொழில்நுட்பம். கணினி சேதமடையும் போது, kdump " -"உங்கள் கணினி சேதமடைய காரணமான மதிப்பில்லாத தகவல்களை எடுக்கிறது.kdumpக்கு வேறு " -"பயன்களுக்கு இல்லாத கணினி நினைவகத்தின் ஒரு பகுதி தேவைப்படும் என்பதை குறித்து கொள்ளவும்." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "ஒதுக்கி வைக்கப்பட வேண்டிய நினைவகம் (MB): (_R)" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "மொத்த கணினி நினைவகம் (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "பயன்படுத்தும் கணினி நினைவகம் (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdumpஐ செயல்படுத்த வேண்டுமா? (_E)" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump நினைவக ஒதுக்கீடு:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "தானியங்கி (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "கைமுறை (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "தற்போது ஒதுக்கிவைக்கப்பட்டுள்ள நினைவகம் (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "மேம்பட்ட kdump அமைவாக்கம்" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "உங்கள் கணினியில் kdump கொண்டிருக்க போதிய நினைவகம் இல்லை!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "இந்த நேரத்தில் Xen கர்னல்களை kdump துணை புரியவில்லை!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "இந்த நேரத்தில் %s கணினி kdump க்கு துணைப்புரிவதில்லை!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "நினைவகத்தை மறு ஒதுக்கீடு செய்வதற்கேற்ப Kdump அமைவுகளை மாற்றுவதற்கு மறு துவக்கம் " -#~ "செய்ய வேண்டும். %sமுதல் துவக்கம் முடிந்தவுடன் மறு துவக்கம் செய்து, இந்த மாற்றத்தை தொடர " -#~ "வேண்டுமா?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "பிழை! துவக்க ஏற்றி கட்டமைப்பு கோப்பு இல்லை, கட்டமைப்பை நிறுத்துகிறது!" diff --git a/anaconda-addon/po/ta_IN.po b/anaconda-addon/po/ta_IN.po deleted file mode 100644 index fa81d93..0000000 --- a/anaconda-addon/po/ta_IN.po +++ /dev/null @@ -1,113 +0,0 @@ -# Shantha kumar , 2012. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 06:42-0500\n" -"Last-Translator: Shantha kumar \n" -"Language-Team: Tamil <>\n" -"Language: ta-IN\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump என்பது ஒரு கர்னல் அழிவு டம்பிங்க்கிங் தொழில்நுட்பம். கணினி சேதமடையும் போது, kdump " -"உங்கள் கணினி சேதமடைய காரணமான மதிப்பில்லாத தகவல்களை எடுக்கிறது.kdumpக்கு வேறு " -"பயன்களுக்கு இல்லாத கணினி நினைவகத்தின் ஒரு பகுதி தேவைப்படும் என்பதை குறித்து கொள்ளவும்." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "ஒதுக்கி வைக்க வேண்டிய நினைவகம் (MB): (_R)" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "மொத்த கணினி நினைவகம் (MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "பயன்படுத்தும் கணினி நினைவகம் (MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "kdumpஐ செயல்படுத்த வேண்டுமா? (_E)" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump நினைவக ஒதுக்கீடு:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "(_A) தானியங்கி" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "கைமுறை (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "தற்போது ஒதுக்கி வைக்கப்பட்டுள்ள நினைவகம் (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "மேம்பட்ட kdump அமைவாக்கம்" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "உங்கள் கணினியில் kdump கொண்டிருக்க போதிய நினைவகம் இல்லை!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "இந்த நேரத்தில் Xen கர்னல்களை kdump துணை புரியவில்லை!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "இந்த நேரத்தில் %s கணினி kdump க்கு துணைப்புரிவதில்லை!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "நினைவகத்தை மறு ஒதுக்கீடு செய்வதற்கேற்ப Kdump அமைவுகளை மாற்றுவதற்கு மறு துவக்கம் " -#~ "செய்ய வேண்டும். %sமுதல் துவக்கம் முடிந்தவுடன் மறு துவக்கம் செய்து, இந்த மாற்றத்தை தொடர " -#~ "வேண்டுமா?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "பிழை! துவக்க ஏற்றி கட்டமைப்பு கோப்பு இல்லை, கட்டமைப்பை நிறுத்துகிறது!" diff --git a/anaconda-addon/po/te.po b/anaconda-addon/po/te.po deleted file mode 100644 index 26634ca..0000000 --- a/anaconda-addon/po/te.po +++ /dev/null @@ -1,116 +0,0 @@ -# translation of te.po to Telugu -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Krishna Babu K , 2007, 2010. -# kkrothap , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 09:17-0500\n" -"Last-Translator: kkrothap \n" -"Language-Team: Telugu \n" -"Language: te\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n!=1);\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"కెడంప్ కెర్నల్ క్రాష్ డంపింగ్ మిషన్.మీ సిస్టమ్ క్రాషైనప్పుడు కెడంప్ సిస్టమ్ నుండి సమాచారాన్ని సేకరింస్తుంది,ఇది " -"క్రాషవడానికి గల కారణాలను నిర్దారించడానికి వీలుకానిది అయిఉండొచ్చు." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "రిజర్వు చేయవలసిన మెమొరీ (MB) (_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "మొత్తం సిస్టమ్ మెమొరి(MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "ఉపయోగకరమైన సిస్టమ్ మెమొరి(MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "కెడంప్ సిద్దపరచు(_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "కెడంప్ మెమొర రిజర్వేషన్:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "స్వయంచాలక (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "మానవీయ (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "ప్రస్తుతం రిజర్వు అయిన మెమొరీ (MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "అధునాతన కెడంప్ ఆకృతీకరణ" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "క్షమించాలి,మీ సిస్టమ్ కెడంప్ కు తగినంత మెమొరీని కలిగి లేదు!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "క్షమించాలి, xen కెర్నల్సు కెడంప్ కు ఈసమయంలో మద్దతీయటలేదు!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "క్షమించాలి,ఈ సమయమందు %s నిర్మాణం కెడంప్ కు మద్దతునీయదు!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "కెడంప్ అమరికలు మార్చినట్లైతే వాటికి తగినట్లు మెమొరీని తిరిగికేటాయించుటకు సిస్టమ్ పునఃప్రారంభించవలెను. " -#~ "మీరు ఈ మార్పుతో కొనసాగటానికి మరియు ఫస్టుబూట్ పూర్తైనతరువాత రీబూట్ చేయటానికి ఇష్టపడతారా?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "దోషం!బూట్ లోడర్ ఆకృతీకరణ దస్త్రం కనబడలేదు,ఆకృతీకరణ రద్దుచేయబడుతోంది!" diff --git a/anaconda-addon/po/tr.po b/anaconda-addon/po/tr.po deleted file mode 100644 index 0c6d778..0000000 --- a/anaconda-addon/po/tr.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: tr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=2; plural=(n>1)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/uk.po b/anaconda-addon/po/uk.po deleted file mode 100644 index d949d59..0000000 --- a/anaconda-addon/po/uk.po +++ /dev/null @@ -1,115 +0,0 @@ -# Ukrainian translation to kexec-tools. -# Copyright (C) Free Software Foundation -# This file is distributed under the same license as the kexec-tools package. -# Maxim Dziumanenko , 2007. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2007-01-23 07:15-0500\n" -"Last-Translator: Maxim Dziumanenko \n" -"Language-Team: Ukrainian \n" -"Language: uk\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump - це механізм створення дампів ядра. При виникненні системної помилки " -"kdump збирає потрібну інформацію для подальшого визначення причини помилки. " -"Зауважте, що kdump резервує частину пам'яті системи, що робить її " -"недоступною для інших користувачів." - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -#, fuzzy -msgid "Total System Memory (MB):" -msgstr "_Загальний розмір системної пам'яті (МБ):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -#, fuzzy -msgid "Usable System Memory (MB):" -msgstr "_Системна пам'ять, що використовується (МБ):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -#, fuzzy -msgid "Kdump Memory Reservation:" -msgstr "Па'мять _Kdump (MБ):" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "" -#~ "Система не має достатньої кількості пам'яті для нормальної роботи kdump!" - -#, fuzzy -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "Наразі ядра Xen не підтримують kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "Архітектура %s наразі не підтримує kdump!" - -#, fuzzy -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "Зміна параметрів Kdump потребує перезавантаження системи для " -#~ "перерозподілу пам'яті. %sПродовжити роботу чи перезавантажити систему? " - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "" -#~ "Помилка! Не знайдено конфігураційний файл завантажувача, налаштовування " -#~ "перервано!" diff --git a/anaconda-addon/po/ur.po b/anaconda-addon/po/ur.po deleted file mode 100644 index 345c340..0000000 --- a/anaconda-addon/po/ur.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/vi.po b/anaconda-addon/po/vi.po deleted file mode 100644 index 4e8c548..0000000 --- a/anaconda-addon/po/vi.po +++ /dev/null @@ -1,78 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: \n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: vi\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "" diff --git a/anaconda-addon/po/zanata.xml b/anaconda-addon/po/zanata.xml deleted file mode 100644 index 59f0439..0000000 --- a/anaconda-addon/po/zanata.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - https://translate.zanata.org/zanata/ - kexec-tools - F18 - gettext - - - ar - as - bg - bn-IN - ca - cs - da - de-CH - de-DE - el - en-GB - es-ES - es-MX - fa - fi - fr - gu - he - hi - hr - hu - id - is - it - ja - kn - ko - lv - ml - mr - ms - nb - nl - or - pl - pt-PT - pt-BR - ru - si - sk - sr-Cyrl - sr-Latn - sv - ta-IN - te - th - tr - uk - zh-Hans-CN - zh-Hant-TW - af - am - az - bn-BD - cy - eo - et - eu - ga - gl - ka - lt - nn - ro - sl - sq - vi - ast - bs - nds - ky - la - mn - tl - xh - pa - mai - es - de - brx - ta - br - kk - - - diff --git a/anaconda-addon/po/zh_CN.po b/anaconda-addon/po/zh_CN.po deleted file mode 100644 index dccc689..0000000 --- a/anaconda-addon/po/zh_CN.po +++ /dev/null @@ -1,120 +0,0 @@ -# translation of zh_CN.po to Wei Liu -# translation of zh_CN.po to -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Xi HUANG , 2007. -# Leah Liu , 2010. -# leahliu , 2012. #zanata -# yangrr , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-20 10:07-0500\n" -"Last-Translator: yangrr \n" -"Language-Team: Wei Liu\n" -"Language: zh-Hans-CN\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump 是一个内核崩溃转储机制。在系统崩溃的时候,kdump 将捕获系统信息,这对于" -"诊断崩溃的原因非常有用。注意,kdump 需要预留一部分系统内存,且这部分内存对于" -"其他用户是不可用的。" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "要保留的内存(MB):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "总系统内存(MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "可用系统内存(MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "启用 kdump (_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "为 Kdump 保留的内存:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "自动(_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "手动(_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "目前保留的内存(MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "高级 kdump 配置" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "对不起,您的系统没有足够的内存在运行 kdump!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "对不起,现在 Xen 内核不支持 kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "对不起,%s 体系结构此时不支持 kdump!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "更改 Kdump 设置需要重新启动系统以便根据情况重新分配内存。您要保留这些修改" -#~ "并在 firstboot 完成后重新启动系统吗?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "错误!找不到引导装载程序的配置文件,配置终止!" diff --git a/anaconda-addon/po/zh_TW.po b/anaconda-addon/po/zh_TW.po deleted file mode 100644 index fefb8c4..0000000 --- a/anaconda-addon/po/zh_TW.po +++ /dev/null @@ -1,118 +0,0 @@ -# translation of zh_TW.po to Traditional Chinese -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Chester Cheng , 2007. -# Terry Chuang , 2010. -# snowlet , 2012. #zanata -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 15:52+0800\n" -"PO-Revision-Date: 2012-12-18 01:50-0500\n" -"Last-Translator: snowlet \n" -"Language-Team: Traditional Chinese \n" -"Language: zh-Hant-TW\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Zanata 2.0.2\n" -"Plural-Forms: nplurals=1; plural=0\n" - -#: ../com_redhat_kdump/ks/kdump.py:112 -#, python-format -msgid "Invalid value %s for --reserve-mb" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:56 -msgid "Kdump" -msgstr "Kdump" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:84 -#: ../com_redhat_kdump/gui/spokes/kdump.py:139 -msgid "Kdump is enabled" -msgstr "" - -#: ../com_redhat_kdump/tui/spokes/kdump.py:86 -#: ../com_redhat_kdump/gui/spokes/kdump.py:141 -msgid "Kdump is disabled" -msgstr "" - -#: ../com_redhat_kdump/gui/spokes/kdump.py:44 tmp/fedora.glade.h:1 -#: tmp/RHEL.glade.h:1 -msgid "KDUMP" -msgstr "" - -#: tmp/fedora.glade.h:2 tmp/RHEL.glade.h:2 -msgid "" -"Kdump is a kernel crash dumping mechanism. In the event of a system crash, " -"kdump will capture information from your system that can be invaluable in " -"determining the cause of the crash. Note that kdump does require reserving a " -"portion of system memory that will be unavailable for other uses." -msgstr "" -"Kdump 是核心當機時的傾印機制。當系統當機時,kdump 會擷取系統資訊,以找出導致" -"當機的原因。請注意,kdump 需要保留部份系統記憶體,其他使用者將無法使用這些記" -"憶體。" - -#: tmp/fedora.glade.h:3 tmp/RHEL.glade.h:7 -msgid "Memory To Be _Reserved (MB):" -msgstr "要保留的記憶體(MB)(_R):" - -#: tmp/fedora.glade.h:4 tmp/RHEL.glade.h:8 -msgid "Total System Memory (MB):" -msgstr "總系統記憶體(MB):" - -#: tmp/fedora.glade.h:5 tmp/RHEL.glade.h:9 -msgid "Usable System Memory (MB):" -msgstr "可用的系統記憶體(MB):" - -#: tmp/fedora.glade.h:6 tmp/RHEL.glade.h:3 -msgid "_Enable kdump?" -msgstr "啟用 kdump(_E)?" - -#: tmp/RHEL.glade.h:4 -msgid "Kdump Memory Reservation:" -msgstr "Kdump 保留記憶體:" - -#: tmp/RHEL.glade.h:5 -msgid "_Automatic" -msgstr "自動 (_A)" - -#: tmp/RHEL.glade.h:6 -msgid "_Manual" -msgstr "首棟 (_M)" - -#~ msgid "%s" -#~ msgstr "%s" - -#~ msgid "Memory Currently Reserved (MB):" -#~ msgstr "目前保留的記憶體(MB):" - -#~ msgid "" -#~ "\n" -#~ "Advanced kdump configuration" -#~ msgstr "" -#~ "\n" -#~ "kdump 進階配置" - -#~ msgid "" -#~ "Sorry, your system does not have enough memory for kdump to be viable!" -#~ msgstr "您的系統沒有足夠的記憶體以執行 kdump!" - -#~ msgid "Sorry, Xen kernels do not support kdump at this time!" -#~ msgstr "很抱歉,Xen kernel 目前尚不支援 kdump!" - -#~ msgid "Sorry, the %s architecture does not support kdump at this time!" -#~ msgstr "%s 架構尚不支援 kdump!" - -#~ msgid "" -#~ "Changing Kdump settings requires rebooting the system to reallocate " -#~ "memory accordingly. Would you like to continue with this change and " -#~ "reboot the system after firstboot is complete?" -#~ msgstr "" -#~ "變更 Kdump 設定之後,必須重新啟動系統,以重新分配記憶體。您是否希望繼續進" -#~ "行這項變更,並在 firstboot 完成後重新啟動系統?" - -#~ msgid "Error! No bootloader config file found, aborting configuration!" -#~ msgstr "錯誤,找不到 bootloader(開機載入程式)的設定檔,放棄設定!" From e9f3823082b16088fefc0162cf77fc42913b8ab2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 Aug 2018 17:19:19 +0800 Subject: [PATCH 070/806] Release 2.0.17-9 --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index e1b72ed..7f27bd4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -320,6 +320,11 @@ done %endif %changelog +* Tue Aug 07 2018 Kairui Song - 2.0.17-9 +- Remove redundant kdump-anaconda-addon source codes +- dracut-module-setup: Fix DRM module inclusion test for hyper-v +- Remove kdump-anaconda subpackage + * Thu Jul 26 2018 Dave Young - 2.0.17-8 - Fix armv7hl build failure From 94a7b43407645020a0d5fff179926753fa6011f5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 9 Aug 2018 10:15:52 +0800 Subject: [PATCH 071/806] Always drop nofail or nobootwait options If nofail or nobootwait option is used, systemd's local-fs.target won't wait for the mounting to complete, and kdump might start before the required mount point is ready and then fail. The host might use nofail for reasons like the device may get unpluged, and if the device is not mounted and it is set as kdump target as the same time then kdump service won't start, we will never enter the capture kernel. By the time we have entered the capture kernel, the target device must exist and ready to use, or else kdump would fail anyway. So force remove nofail and nobootwait option. Also drop rootflags=nofail option, as we don't depend on rootfs anymore if the dump target don't required it. So the nofail option is no longer needed. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump.sysconfig.i386 | 2 +- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- kdump.sysconfig.s390x | 2 +- kdump.sysconfig.x86_64 | 2 +- mkdumprd | 3 +++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 18c407e..b5ec653 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 rootflags=nofail transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 55a01cc..e142c6e 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 rootflags=nofail kvm_cma_resv_ratio=0 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 55a01cc..e142c6e 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 rootflags=nofail kvm_cma_resv_ratio=0 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index b3aec3c..6edc2fa 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 rootflags=nofail transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never" # Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index f269d02..4a5ec1c 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/mkdumprd b/mkdumprd index 3d89a80..078f988 100644 --- a/mkdumprd +++ b/mkdumprd @@ -104,6 +104,9 @@ to_mount() { _options=$(echo $_options | sed 's/\bnoauto\b//') #mount fs target as rw in 2nd kernel _options=$(echo $_options | sed 's/\bro\b/rw/') + # drop nofail or nobootwait + _options=$(echo $_options | sed 's/\bnofail\b//') + _options=$(echo $_options | sed 's/\bnobootwait\b//') _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From d92b9364ae28e861e25424a1fe58c5092fa97b21 Mon Sep 17 00:00:00 2001 From: Kenneth Dsouza Date: Fri, 10 Aug 2018 06:05:54 +0530 Subject: [PATCH 072/806] kdumpctl: Error out if path is set more than once. Currently the kdumpctl script doesn't check if the path option is set more than once due to which a vmcore is not captured. This patch addresses this issue by ensuring that only one path is specified in /etc/kdump.conf file. Signed-off-by: Kenneth D'souza Acked-by: Kairui Song --- kdumpctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kdumpctl b/kdumpctl index 6a01c13..e07ec06 100755 --- a/kdumpctl +++ b/kdumpctl @@ -204,6 +204,13 @@ check_config() return 1 } + # Check if path option is set more than once. + nr=$(awk 'BEGIN{cnt=0} /^path /{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) + [ $nr -gt 1 ] && { + echo "Mutiple paths specifed in $KDUMP_CONFIG_FILE" + return 1 + } + nr=$(grep "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE | grep -o "\-\-mount" | wc -l) [ $nr -gt 1 ] && { echo "Multiple mount targets specified in one \"dracut_args\"." From 00da17176dd15a5f417dd6b2b0f4514e01dab7f2 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Wed, 22 Aug 2018 01:53:33 +0530 Subject: [PATCH 073/806] kexec: fix for "Unhandled rela relocation: R_X86_64_PLT32" error Resolves: bz1619122 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1619122 This patch fixes the "Unhandled rela relocation: R_X86_64_PLT32" error that we are seeing with Fedora 29 (and newer kernels > 4.18) which trying to run kexec/kdump on x86_64 machines. The patch is being discussed upstream and has been ACK'ed by Baoquan and myself (see ) and I have also tested the same on Fedora 29/rawhide x86_64 machine as well: Before the patch: ---------------- [root@hp-bl480c-01 ~]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Unhandled rela relocation: R_X86_64_PLT32 kexec: failed to load kdump kernel Starting kdump: [FAILED] After the patch: --------------- [root@hp-bl480c-01 ~]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] kexec: loaded kdump kernel Starting kdump: [OK] Suggested Upstream Fix: In response to a change in binutils, commit b21ebf2fb4c (x86: Treat R_X86_64_PLT32 as R_X86_64_PC32) was applied to the linux kernel during the 4.16 development cycle and has since been backported to earlier stable kernel series. The change results in the failure message in $SUBJECT when rebooting via kexec. Fix this by replicating the change in kexec. Signed-off-by: Chris Clayton Signed-off-by: Bhupesh Sharma Acked-by: Kairui Song --- ...handled-rela-relocation-R_X86_64_PLT.patch | 37 +++++++++++++++++++ kexec-tools.spec | 3 ++ 2 files changed, 40 insertions(+) create mode 100644 kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch diff --git a/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch b/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch new file mode 100644 index 0000000..ace1ea9 --- /dev/null +++ b/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch @@ -0,0 +1,37 @@ +From 35a2fb50293da9fbd94f29a2ed6a4f114fd8044f Mon Sep 17 00:00:00 2001 +From: Bhupesh Sharma +Date: Tue, 21 Aug 2018 16:22:31 +0530 +Subject: [PATCH] kexec: fix for "Unhandled rela relocation: R_X86_64_PLT32" + error + +In response to a change in binutils, commit b21ebf2fb4c +(x86: Treat R_X86_64_PLT32 as R_X86_64_PC32) was applied to +the linux kernel during the 4.16 development cycle and has +since been backported to earlier stable kernel series. The +change results in the failure message in $SUBJECT when +rebooting via kexec. + +Fix this by replicating the change in kexec. + +Signed-off-by: Chris Clayton +--- + kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c +index 7fdde73a5eca..af33689a7d43 100644 +--- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c ++++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c +@@ -78,7 +78,8 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), + if ((int64_t)value != *(int32_t *)location) + goto overflow; + break; +- case R_X86_64_PC32: ++ case R_X86_64_PC32: ++ case R_X86_64_PLT32: + *(uint32_t *)location = value - address; + break; + default: +-- +2.7.4 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 7f27bd4..38d46b5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -71,6 +71,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # +Patch101: kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -101,6 +102,8 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch101 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 67e5c8d226d790a699194076df5cfe8ed6d7d66a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 22 Aug 2018 16:31:18 +0800 Subject: [PATCH 074/806] Release 2.0.17-10 Signed-off-by: Kairui Song --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 38d46b5..a411182 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -323,6 +323,11 @@ done %endif %changelog +* Wed Aug 22 2018 Kairui Song - 2.0.17-10 +- kexec: fix for "Unhandled rela relocation: R_X86_64_PLT32" error +- kdumpctl: Error out if path is set more than once +- Always drop nofail or nobootwait options + * Tue Aug 07 2018 Kairui Song - 2.0.17-9 - Remove redundant kdump-anaconda-addon source codes - dracut-module-setup: Fix DRM module inclusion test for hyper-v From ac55095191b7ea8fa9f4e7018c3336a8f4eca892 Mon Sep 17 00:00:00 2001 From: Kenneth Dsouza Date: Thu, 11 Oct 2018 13:54:58 +0530 Subject: [PATCH 075/806] kdump-lib-initramfs.sh: Add check to remount to rw mode only if dump target is ro. Currently the script does not check if the dump target is read-only and would always mount to read-write mode. This caused an issue with nfs mount as the fstab options would be reconsidered while remounting to read-write mode. The remount would fail with the below error as all options cannot be changed runtime. mount.nfs: mount(2): Invalid argument mount.nfs: an incorrect mount option was specified Which in result would not save the vmcore on the dump target. This patch addresses this issue by checking the dump target status for read-only. If yes, remount to read-write mode without reconsidering the fstab options. Signed-off-by: Kenneth D'souza Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 2c18c87..c7f874f 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -87,6 +87,7 @@ dump_fs() local _dev=$(findmnt -k -f -n -r -o SOURCE $1) local _mp=$(findmnt -k -f -n -r -o TARGET $1) + local _op=$(findmnt -k -f -n -r -o OPTIONS $1) echo "kdump: dump target is $_dev" @@ -100,7 +101,12 @@ dump_fs() echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" - mount -o remount,rw $_mp || return 1 + # Only remount to read-write mode if the dump target is mounted read-only. + if [[ "$_op" = "ro"* ]]; then + echo "kdump: Mounting Dump target $_dev in rw mode." + mount -o remount,rw $_dev $_mp || return 1 + fi + mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1 save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" From 5b385cbd0ccc3985724c500fb823a722b07f0e8f Mon Sep 17 00:00:00 2001 From: Kenneth Dsouza Date: Wed, 15 Aug 2018 18:44:15 +0530 Subject: [PATCH 076/806] kdumpctl: Print warning in case the raw device is formatted and contains filesystem. Currently the kdumpctl script doesn't check if the raw device is formatted which might destroy existing data at the time of dump capture. This patch addresses this issue, by ensuring kdumpctl prints a warning in case it finds the raw device to be formatted. Signed-off-by: Kenneth D'souza Acked-by: Kairui Song --- kdumpctl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdumpctl b/kdumpctl index e07ec06..ece406f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -786,6 +786,11 @@ save_raw() echo "raw partition $raw_target not found" return 1 } + check_fs=$(lsblk --nodeps -npo FSTYPE $raw_target) + if [[ $(echo $check_fs | wc -w) -ne 0 ]]; then + echo "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." + return 0 + fi kdump_dir=`grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2-` if [ -z "${kdump_dir}" ]; then coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" From 9b6e3124477212b8321392b2f365beddd7881e22 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 15 Oct 2018 15:01:31 +0800 Subject: [PATCH 077/806] Enable dracut squash module In dracut-049, a new squash module is introduced, it can reduce the memory usage of kdump initramfs in the capture kernel, this helps a lot on lowering the risk of OOM failure. Tested with latest rawhide with NFS, SSH and local dump. Signed-off-by: Kairui Song --- dracut-module-setup.sh | 2 +- kexec-tools.spec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a10244b..2f9d762 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -18,7 +18,7 @@ check() { } depends() { - local _dep="base shutdown" + local _dep="base shutdown squash" if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then _dep="$_dep drm" diff --git a/kexec-tools.spec b/kexec-tools.spec index a411182..46c0eef 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -51,6 +51,7 @@ Requires(postun): systemd-units Requires(pre): coreutils sed zlib Requires: dracut >= 047-34.git20180604 Requires: dracut-network >= 044-117 +Requires: dracut-squash >= 049-4 Requires: ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext From 80357ee9b41550c8e302af2ea8635db57a8c306b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 15 Oct 2018 15:28:44 +0800 Subject: [PATCH 078/806] Release 2.0.17-11 Signed-off-by: Kairui Song --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 46c0eef..6330534 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 10%{?dist} +Release: 11%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -324,6 +324,11 @@ done %endif %changelog +* Mon Oct 15 2018 Kairui Song - 2.0.17-11 +- Enable dracut squash module +- kdumpctl: Print warning in case the raw device is formatted and contains filesystem +- kdump-lib-initramfs.sh: Add check to remount to rw mode only if dump target is ro + * Wed Aug 22 2018 Kairui Song - 2.0.17-10 - kexec: fix for "Unhandled rela relocation: R_X86_64_PLT32" error - kdumpctl: Error out if path is set more than once From b34ce3a7b42d2a350f7a69374eef51ab55da2b49 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 23 Oct 2018 22:13:28 +0800 Subject: [PATCH 079/806] kdumpctl: Add reload support Add reload support to kdumpctl, reload will simply unload current loaded kexec crash kernel and initramfs, and load it again. Changes in /etc/sysconfig/kdump will take effect with kdumpctl reload, but reloading will not check the content of /etc/kdump.conf and won't rebuild anything. reload is fast, the only time-consuming part of kdumpctl reload is loading kernel and initramfs with kexec which is always necessary. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump.service | 1 + kdumpctl | 59 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/kdump.service b/kdump.service index 5144597..f888dd6 100644 --- a/kdump.service +++ b/kdump.service @@ -7,6 +7,7 @@ DefaultDependencies=no Type=oneshot ExecStart=/usr/bin/kdumpctl start ExecStop=/usr/bin/kdumpctl stop +ExecReload=/usr/bin/kdumpctl reload RemainAfterExit=yes StartLimitInterval=0 diff --git a/kdumpctl b/kdumpctl index ece406f..6236f21 100755 --- a/kdumpctl +++ b/kdumpctl @@ -283,6 +283,16 @@ get_pcs_cluster_modified_files() setup_initrd() { + KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") + + if [ -z "$KDUMP_KERNELVER" ]; then + kdump_kver=`uname -r` + else + kdump_kver=$KDUMP_KERNELVER + fi + + kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" + DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img" DEFAULT_INITRD_BAK="${KDUMP_BOOTDIR}/.initramfs-`uname -r`.img.default" if [ $DEFAULT_DUMP_MODE == "fadump" ]; then @@ -533,16 +543,8 @@ check_rebuild() local _force_no_rebuild force_no_rebuild="0" local ret system_modified="0" - KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") - - if [ -z "$KDUMP_KERNELVER" ]; then - kdump_kver=`uname -r` - else - kdump_kver=$KDUMP_KERNELVER - fi - - kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" setup_initrd + if [ $? -ne 0 ]; then return 1 fi @@ -1004,6 +1006,42 @@ start() echo "Starting kdump: [OK]" } +reload() +{ + check_current_status + if [ $? -ne 0 ]; then + echo "Kdump is not running: [WARNING]" + return 0 + fi + + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + stop_fadump + else + stop_kdump + fi + + if [ $? -ne 0 ]; then + echo "Stopping kdump: [FAILED]" + return 1 + fi + + echo "Stopping kdump: [OK]" + + setup_initrd + if [ $? -ne 0 ]; then + echo "Starting kdump: [FAILED]" + return 1 + fi + + start_dump + if [ $? -ne 0 ]; then + echo "Starting kdump: [FAILED]" + return 1 + fi + + echo "Starting kdump: [OK]" +} + stop_fadump() { echo 0 > $FADUMP_REGISTER_SYS_NODE @@ -1087,6 +1125,9 @@ main () esac exit $EXIT_CODE ;; + reload) + reload + ;; restart) stop start From 227c18506c0fe28bdb5ab6e153ad2186fb2b3e65 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 24 Oct 2018 16:58:51 +0800 Subject: [PATCH 080/806] Rewrite kdump's udev rules According to udev's man page, PROGRAM is either used to determine device's name or whether the device matches the rule. So we should use RUN insteand. Meanwhile, both RUN / PROGRAM only accepts very short-running foreground tasks, but kdump restart may take a long time if there are any device changes that will lead to image rebuild, which may lead to buggy behavior. On the other hand, memory / CPU hot plug should never trigger a initramfs rebuild. To solve this problem, we will use new introduced "kdumpctl reload" instead, and use systemd-run to create a transient service unit for the reload and run it in no-block mode, so udev won't be blocked by anything. We need to make systemd-run execute in non-blocking mode, and do not synchronously wait for the operation to finish, because udev expect the command line in RUN to be finished immediately, however, kdumpctl reload may take 0.5-1s for an ordinary reload, or even slower on some machines. So we give systemd-run an explicit --no-block option to run in non-blocking mode. Without --no-blocking, systemd-run will verify, enqueue and wait for the operation to finish. By using the --no-block option, systemd-run will only verify and enqueue the unit then return. In this way, we make sure the command is executed asynchronously, and the status will be monitored and logged by systemd, which is reliable and non-blocking. Another thing to mention is that --no-block is only needed after systemd-v220, before v220 systemd-run uses non-blocking mode by default and --no-block option is not available on earlier systemd versions. Also reformat the udev rules to a more maintanceable format. Signed-off-by: Kairui Song Acked-by: Dave Young --- 98-kexec.rules | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/98-kexec.rules b/98-kexec.rules index e32ee13..a866cf9 100644 --- a/98-kexec.rules +++ b/98-kexec.rules @@ -1,4 +1,12 @@ -SUBSYSTEM=="cpu", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="cpu", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service" -SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service" +SUBSYSTEM=="cpu", ACTION=="add", GOTO="kdump_reload" +SUBSYSTEM=="cpu", ACTION=="remove", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload" + +GOTO="kdump_reload_end" + +LABEL="kdump_reload" + +RUN+="/usr/bin/systemd-run --no-block /usr/bin/kdumpctl reload" + +LABEL="kdump_reload_end" From 1c97aee728f3e670b05f2e51f2cdef937e2fdd09 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 30 Oct 2018 18:35:34 +0800 Subject: [PATCH 081/806] Throttle kdump reload request triggered by udev event Previously, kdump will restart / reload for many times on hotplug event, especially memory hotplug events. Hotplugged memory may generate many udev event as memory are managed and hotplugged in small chunks by the kernel. This results in unnecessary system workload and an actually longer delay of kdump reload and the hotplug event, as udev will either get blocked or kdumpctl will be waiting for other triggered operation. To fix this, introduce a kdump-udev-throttler as an agent which will be called by udev and merge concurrent kdump restart requests. Tested with a Hyper-V VM which is failing due to udev timeout previously, no new issues found. Signed-off-by: Kairui Song Acked-by: Dave Young --- 98-kexec.rules | 2 +- kdump-udev-throttler | 47 ++++++++++++++++++++++++++++++++++++++++++++ kexec-tools.spec | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 kdump-udev-throttler diff --git a/98-kexec.rules b/98-kexec.rules index a866cf9..2f88c77 100644 --- a/98-kexec.rules +++ b/98-kexec.rules @@ -7,6 +7,6 @@ GOTO="kdump_reload_end" LABEL="kdump_reload" -RUN+="/usr/bin/systemd-run --no-block /usr/bin/kdumpctl reload" +RUN+="/usr/bin/systemd-run --no-block /usr/lib/udev/kdump-udev-throttler" LABEL="kdump_reload_end" diff --git a/kdump-udev-throttler b/kdump-udev-throttler new file mode 100755 index 0000000..6cbb99a --- /dev/null +++ b/kdump-udev-throttler @@ -0,0 +1,47 @@ +#!/bin/bash +# This util helps to reduce the workload of kdump service restarting +# on udev event. When hotplugging memory / CPU, multiple udev +# events may be triggered concurrently, and obviously, we don't want +# to restart kdump service for each event. + +# This script will be called by udev, and make sure kdump service is +# restart after all events we are watching are settled. + +# On each call, this script will update try to aquire the $throttle_lock +# The first instance acquired the file lock will keep waiting for events +# to settle and then reload kdump. Other instances will just exit +# In this way, we can make sure kdump service is restarted immediately +# and for exactly once after udev events are settled. + + +throttle_lock="/var/lock/kdump-udev-throttle" +interval=2 + +# Don't reload kdump service if kdump service is not started by systemd +systemctl is-active kdump.service &>/dev/null || exit 0 + +exec 9>$throttle_lock +if [ $? -ne 0 ]; then + echo "Failed to create the lock file! Fallback to non-throttled kdump service restart" + /bin/kdumpctl reload + exit 1 +fi + +flock -n 9 +if [ $? -ne 0 ]; then + echo "Throttling kdump restart for concurrent udev event" + exit 0 +fi + +# Wait for at least 1 second, at most 4 seconds for udev to settle +# Idealy we will have a less than 1 second lag between udev events settle +# and kdump reload +sleep 1 && udevadm settle --timeout 3 + +# Release the lock, /bin/kdumpctl will block and make the process +# holding two locks at the same time and we might miss some events +exec 9>&- + +/bin/kdumpctl reload + +exit 0 diff --git a/kexec-tools.spec b/kexec-tools.spec index 6330534..91d322f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump.sysconfig.ppc64le Source25: kdumpctl.8 Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt +Source28: kdump-udev-throttler ####################################### # These are sources for mkdumpramfs @@ -171,6 +172,7 @@ install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initram # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules +install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler %endif install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service @@ -298,6 +300,7 @@ done %config(noreplace,missingok) %{_sysconfdir}/kdump.conf %ifnarch s390x %config %{_udevrulesdir} +%{_udevrulesdir}/../kdump-udev-throttler %endif %{dracutlibdir}/modules.d/* %dir %{_localstatedir}/crash From 0c609b0a37b7d825913087d31e7c3406af867de6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 1 Nov 2018 22:54:44 +0800 Subject: [PATCH 082/806] Release 2.0.17-12 Signed-off-by: Kairui Song --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 91d322f..d1077d2 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.17 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component From 435cc06cee7607b59f4745b88783e4dd372529ac Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 5 Nov 2018 23:54:44 +0800 Subject: [PATCH 083/806] Release 2.0.18-1 (Also add missing change log for 2.0.17-12) Signed-off-by: Kairui Song --- kexec-tools.spec | 15 ++++++++++----- sources | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d1077d2..890b176 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools -Version: 2.0.17 -Release: 12%{?dist} +Version: 2.0.18 +Release: 1%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -73,7 +73,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # -Patch101: kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -104,8 +103,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch101 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif @@ -327,6 +324,14 @@ done %endif %changelog +* Mon Nov 5 2018 Kairui Song - 2.0.18-1 +- Update to kexec-tools 2.0.18 + +* Thu Nov 1 2018 Kairui Song - 2.0.17-12 +- Throttle kdump reload request triggered by udev event +- Rewrite kdump's udev rules +- kdumpctl: Add reload support + * Mon Oct 15 2018 Kairui Song - 2.0.17-11 - Enable dracut squash module - kdumpctl: Print warning in case the raw device is formatted and contains filesystem diff --git a/sources b/sources index 6e846c8..b728ee8 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f -SHA512 (kexec-tools-2.0.17.tar.xz) = e0f254ca2b26fa02cb61ba9a0735423b26bac2693fbd920eaf7cc2822c298de958bd65f7c37947ca1f6811a3752a58f7cf8aa903494f0109ea76b7159a037fa6 +SHA512 (kexec-tools-2.0.18.tar.xz) = a4142e703a752eb270da29f02ea4fb213f3f4f965e73bb483c388a378821094317a4c63406ab0afe118f79eb168ff63b9d2d9530551c984592165430e269d697 SHA512 (makedumpfile-1.6.4.tar.gz) = 0d564096a5400074f6154b751ee50c94b8f85a2e3ff478db69ddbb0a47852cbd895594030ca8a2e45a1ca1a641ce5d13f826922fa36054660c23380663f2c080 From 32fc6070a6794f1edc905299c74f70f95285fe93 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 9 Nov 2018 11:09:27 +0800 Subject: [PATCH 084/806] Add missing usage info In commit b34ce3a reload support was added to kdumpctl but the usage info is not updated. Now add reload to usage output to let user aware of the new command. Signed-off-by: Kairui Song --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 6236f21..ca47705 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1141,7 +1141,7 @@ main () show_reserved_mem ;; *) - echo $"Usage: $0 {start|stop|status|restart|propagate|showmem}" + echo $"Usage: $0 {start|stop|status|restart|reload|propagate|showmem}" exit 1 esac } From 65807d98556c7d9612fafcfb25a74348e83c4b1d Mon Sep 17 00:00:00 2001 From: Markus Linnala Date: Sun, 28 Oct 2018 11:09:57 +0200 Subject: [PATCH 085/806] As /etc/kdump.conf timestamp is updated do not compare it when doing rpm --verify --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 890b176..a4f796c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -294,7 +294,7 @@ done %{_sysconfdir}/makedumpfile.conf.sample %endif %config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump -%config(noreplace,missingok) %{_sysconfdir}/kdump.conf +%config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf %ifnarch s390x %config %{_udevrulesdir} %{_udevrulesdir}/../kdump-udev-throttler From 31222d611d136bb0a0543a2ba1d3fb4ff4ef42ec Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 5 Nov 2018 03:34:59 +0530 Subject: [PATCH 086/806] doc/kdump.conf: Local dump path should be //%HOST_IP-%DATE Resolves: bz1561837 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1561837 Currently 'kdump.conf' and 'kdump.conf MAN page' entries state that the local dump path should be: - Will mount -t , and copy /proc/vmcore to //%DATE/. The correct vmcore path instead should be: //%HOST_IP-%DATE/ Signed-off-by: Bhupesh Sharma Acked-by: Dave Young Acked-by: Kairui Song --- kdump.conf | 2 +- kdump.conf.5 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kdump.conf b/kdump.conf index 57af7b6..286ad27 100644 --- a/kdump.conf +++ b/kdump.conf @@ -32,7 +32,7 @@ # # # - Will mount -t , and copy -# /proc/vmcore to //%DATE/. +# /proc/vmcore to //%HOST_IP-%DATE/. # NOTE: can be a device node, label or uuid. # It's recommended to use persistent device names # such as /dev/vg/. diff --git a/kdump.conf.5 b/kdump.conf.5 index 11b1fad..990076e 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -55,7 +55,7 @@ The default value is /root/.ssh/kdump_id_rsa. .B .RS Will mount -t , and copy /proc/vmcore to -//%DATE/. NOTE: can be a device node, label +//%HOST_IP-%DATE/. NOTE: can be a device node, label or uuid. It's recommended to use persistent device names such as /dev/vg/. Otherwise it's suggested to use label or uuid. .RE From d4f04afa47dea89ad5ca42ad0b2ddc355ce93a64 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 21 Nov 2018 17:08:13 +0800 Subject: [PATCH 087/806] mkdumprd: drop some nfs mount options when reading from kernel nfs service will append extra mount options to kernel mount options. Those extra options represent current mounting details, but they may not suitable for the second kernel. IP address may change, and we only enable a single network stack (v4/v6), if nfs prefered another network stack, inheriting the options will force nfs service to use previous network stack and disable nfs's fallback mechanic and fail. As nfs service have the capability to negotiate required protocols and detect proper IP address, just drop those options and let nfs automatically adapt the possible change in the second kernel. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 078f988..a6f7fe8 100644 --- a/mkdumprd +++ b/mkdumprd @@ -98,7 +98,14 @@ to_mount() { _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) [[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev) - [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) + if [ -z "$_options" ]; then + _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) + if [[ $_fstype == "nfs"* ]]; then + _options=$(echo $_options | sed 's/,addr=[^,]*//') + _options=$(echo $_options | sed 's/,proto=[^,]*//') + _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') + fi + fi # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here. _options=$(echo $_options | sed 's/\bnoauto\b//') From a0dc92f46cc5a95cb7b13bb7fcfc0a095275fd40 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 12 Nov 2018 20:27:18 +0800 Subject: [PATCH 088/806] dracut-module-setup: Fix routing failure on multipath route Currently we still don't support multipath route, when parsing multipath route kdumpctl will wrongly consider 'nexthop' as the destination address, and raise errors in second kernel. When multipath route is in use, ip route output should be like this: $ /sbin/ip route show default via 192.168.122.1 dev ens1 proto dhcp metric 100 192.168.122.0/24 dev ens1 proto kernel scope link src 192.168.122.161 metric 100 192.168.122.8 nexthop via 192.168.122.1 dev ens1 weight 50 nexthop via 192.168.122.2 dev ens1 weight 5 As we don't care about HA/performance, simply use the rule with highest weight and ignore the rest. Signed-off-by: Kairui Song Acked-by: Baoquan He --- dracut-module-setup.sh | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2f9d762..7499678 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -126,7 +126,8 @@ kdump_static_ip() { echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi - /sbin/ip $_ipv6_flag route show | grep -v default | grep ".*via.* $_netdev " |\ + /sbin/ip $_ipv6_flag route show | grep -v default |\ + grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ while read _route; do _target=`echo $_route | cut -d ' ' -f1` _nexthop=`echo $_route | cut -d ' ' -f3` @@ -136,6 +137,44 @@ kdump_static_ip() { fi echo "rd.route=$_target:$_nexthop:$_netdev" done >> ${initdir}/etc/cmdline.d/45route-static.conf + + kdump_handle_mulitpath_route $_netdev $_srcaddr +} + +kdump_handle_mulitpath_route() { + local _netdev="$1" _srcaddr="$2" _ipv6_flag + local _target _nexthop _route _weight _max_weight _rule + + if is_ipv6_address $_srcaddr; then + _ipv6_flag="-6" + fi + + while IFS="" read _route; do + if [[ "$_route" =~ [[:space:]]+nexthop ]]; then + _route=$(echo "$_route" | sed -e 's/^[[:space:]]*//') + # Parse multipath route, using previous _target + [[ "$_target" == 'default' ]] && continue + [[ "$_route" =~ .*via.*\ $_netdev ]] || continue + + _weight=`echo "$_route" | cut -d ' ' -f7` + if [[ "$_weight" -gt "$_max_weight" ]]; then + _nexthop=`echo "$_route" | cut -d ' ' -f3` + _max_weight=$_weight + if [ "x" != "x"$_ipv6_flag ]; then + _rule="rd.route=[$_target]:[$_nexthop]:$_netdev" + else + _rule="rd.route=$_target:$_nexthop:$_netdev" + fi + fi + else + [[ -n "$_rule" ]] && echo "$_rule" + _target=`echo "$_route" | cut -d ' ' -f1` + _rule="" _max_weight=0 _weight=0 + fi + done >> ${initdir}/etc/cmdline.d/45route-static.conf\ + < <(/sbin/ip $_ipv6_flag route show) + + [[ -n $_rule ]] && echo $_rule >> ${initdir}/etc/cmdline.d/45route-static.conf } kdump_get_mac_addr() { From 3a36568581e5eec9157138c78d5398fa735dd6b9 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 22 Nov 2018 22:56:08 +0800 Subject: [PATCH 089/806] Make udev reload rules quiet during bootup In commit 1c97aee and commit 227c185 udev rules was rewritten to use systemd-run to run in a non-blocking mode. The problem is that it's a bit noise, especially on machine bootup, systemd will always generate extra logs for service start, you might see your journal full of lines like these if you have many CPUs (each CPU generates a udev event on boot): ... Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. ... While system is still booting up, kdump service is not started yet, so systemd-run calls will end up doing nothing, the throttler being called by systemd-run will just exit if kdump is not loaded. This patch avoid systemd-run from being called at first place if kdump service is not running by checking kdump.service status in udev rule, so there won't be unnecessary logs. Also remove the kdump service checking logic in kdump-udev-throttler as udev is the only expected callee of this script, if it's not being called at first place when kdump service is running, this checking will be redundant. And even if any user called this script manually, it will still work well as this script will call 'kdumpctl reload', it reload the kdump resource only if kdump is loaded already. Signed-off-by: Kairui Song Acked-by: Dave Young --- 98-kexec.rules | 6 +++++- kdump-udev-throttler | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/98-kexec.rules b/98-kexec.rules index 2f88c77..b73b701 100644 --- a/98-kexec.rules +++ b/98-kexec.rules @@ -7,6 +7,10 @@ GOTO="kdump_reload_end" LABEL="kdump_reload" -RUN+="/usr/bin/systemd-run --no-block /usr/lib/udev/kdump-udev-throttler" +# If kdump is not loaded, calling kdump-udev-throttle will end up +# doing nothing, but systemd-run will always generate extra logs for +# each call, so trigger the kdump-udev-throttler only if kdump +# service is active to avoid unnecessary logs +RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" LABEL="kdump_reload_end" diff --git a/kdump-udev-throttler b/kdump-udev-throttler index 6cbb99a..cd77a31 100755 --- a/kdump-udev-throttler +++ b/kdump-udev-throttler @@ -13,12 +13,7 @@ # In this way, we can make sure kdump service is restarted immediately # and for exactly once after udev events are settled. - throttle_lock="/var/lock/kdump-udev-throttle" -interval=2 - -# Don't reload kdump service if kdump service is not started by systemd -systemctl is-active kdump.service &>/dev/null || exit 0 exec 9>$throttle_lock if [ $? -ne 0 ]; then From fca27c3a4480878e8481e039a56f66b70ceca053 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 7 Dec 2018 01:31:55 +0800 Subject: [PATCH 090/806] Update makedumpfile to 1.6.5 Signed-off-by: Kairui Song --- kexec-tools.spec | 18 +++++++++--------- sources | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a4f796c..b70168c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.4/makedumpfile-1.6.4.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.5/makedumpfile-1.6.5.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source14: 98-kexec.rules @@ -129,8 +129,8 @@ cp %{SOURCE27} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.4 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.4 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.6.5 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif %install @@ -176,13 +176,13 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.4/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.6.4/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.4/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.4/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.4/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-1.6.5/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 644 makedumpfile-1.6.5/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.6.5/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.6.5/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.6.5/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.4/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.6.5/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') diff --git a/sources b/sources index b728ee8..b1aa049 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f SHA512 (kexec-tools-2.0.18.tar.xz) = a4142e703a752eb270da29f02ea4fb213f3f4f965e73bb483c388a378821094317a4c63406ab0afe118f79eb168ff63b9d2d9530551c984592165430e269d697 -SHA512 (makedumpfile-1.6.4.tar.gz) = 0d564096a5400074f6154b751ee50c94b8f85a2e3ff478db69ddbb0a47852cbd895594030ca8a2e45a1ca1a641ce5d13f826922fa36054660c23380663f2c080 +SHA512 (makedumpfile-1.6.5.tar.gz) = bfbf9b373d435857530121f29fb3915cb263cfbaa2b877684a8cde2e8cd8b73fc2f02ffdf9b9108613d42aab7e5653877b092846545ceab865e9909e86145970 From 9c2dc2871313d3ef34311146165b7b37b9a128a6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 7 Dec 2018 01:32:52 +0800 Subject: [PATCH 091/806] Release 2.0.18-2 Signed-off-by: Kairui Song --- kexec-tools.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index b70168c..c081975 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.18 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -324,6 +324,15 @@ done %endif %changelog +* Fri Dec 7 2018 Kairui Song - 2.0.18-2 +- Update makedumpfile 1.6.5 +- Make udev reload rules quiet during bootup +- dracut-module-setup: Fix routing failure on multipath route +- mkdumprd: drop some nfs mount options when reading from kernel +- doc/kdump.conf: Local dump path should be //%HOST_IP-%DATE +- As /etc/kdump.conf timestamp is updated do not compare it when doing rpm --verify +- Add missing usage info + * Mon Nov 5 2018 Kairui Song - 2.0.18-1 - Update to kexec-tools 2.0.18 From 89565289c64aa5323278cf5722c725a58b369af8 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 4 Dec 2018 11:09:43 +0800 Subject: [PATCH 092/806] kdump-lib-initramfs.sh: using -force option when poweroff If default action is poweroff, we can observe that the machine is rebooted, instead of poweroff. That is due to the following two race processes: systemctl poweroff systemctl reboot -f which is launched by kdump-error-handle.sh. Unfortunately, although both of them are executed in systemd block mode, but due to poweroff will tear down some internal things in systemd, there is no guarantee for the block mode. As we can see the msg "Failed to execute operation: Connection reset by peer", which is thrown by "systemctl reboot -f". poweroff and reboot share most of code, if one fails, then the other should also fails, so it is meaningless to use reboot as the backup of poweroff. Using "systemctl poweroff -f", the sdbus will teared down immediately, which prevent the following "systemctl reboot -f" from executing. Meanwhile, as man systemctl says: -f, --force When used with enable, overwrite any existing conflicting symlinks. When used with halt, poweroff, reboot or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. Hence, replacing the 'poweroff' with 'systemctl poweroff -f' Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c7f874f..f5155a4 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -63,7 +63,7 @@ get_kdump_confs() DEFAULT_ACTION="halt" ;; poweroff) - DEFAULT_ACTION="poweroff" + DEFAULT_ACTION="systemctl poweroff -f" ;; dump_to_rootfs) DEFAULT_ACTION="dump_to_rootfs" From 4a44eee472745f8dd43b18815851bd668b7497da Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 25 Dec 2018 22:51:35 +0800 Subject: [PATCH 093/806] dracut-module-setup: Don't build squashed image if required modules are missing When someone is using a minimal kernel without squash module installed, including squash dracut module will either either fail to build or fail to boot the initramfs. As kdump always build the image for one single kernel, we can safely just use modprobe to check if a modules is already built in, or it exists and loadable for the kernel we are using for kdump image, and don't include the squash module if they are missing. Everything will still work just fine without squash module. We do the check in kdump dracut modules not in squash dracut module because kdump dracut module could leverage of the KDUMP_KERNELVER variable to know which kernel it should check against, squash dracut module may be used to build for a generic image. And we only check for the kernel module dependency, other binary dependencies are either well checked or well declared in dracut. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7499678..db7cd23 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -18,7 +18,23 @@ check() { } depends() { - local _dep="base shutdown squash" + local _dep="base shutdown" + + is_squash_available() { + for kmodule in squashfs overlay loop; do + if [ -z "$KDUMP_KERNELVER" ]; then + modprobe --dry-run $kmodule &>/dev/null || return 1 + else + modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 + fi + done + } + + if is_squash_available; then + _dep="$_dep squash" + else + dwarning "Required modules to build a squashed kdump image is missing!" + fi if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then _dep="$_dep drm" From 231061657202140b7dddb10b0462802538cb6ce2 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Wed, 12 Dec 2018 09:49:18 -0500 Subject: [PATCH 094/806] mkdumprd: allow spaces after 'path' config phrase with network dump setting Without this patch, when there are two or more spaces after 'path' configuration phrase with ssh or nfs setting, SAVE_PATH is set to '/var/crash' in mkdumprd, and in most cases kdump service fails to start by checking the /var/crash directory regardless of the path value. ssh kdump(a)192.168.122.1 path /kdump ^^ This behavior would be too sensitive and different from the other configurations. With this patch, mkdumprd allows such spaces. Signed-off-by: Kazuhito Hagio --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index a6f7fe8..aa0abfd 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,7 +13,7 @@ export IN_KDUMP=1 conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) +SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) From 3316c2d7356c6653aa83ef140c1eb3f1c21627f8 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Wed, 9 Jan 2019 22:29:52 +0800 Subject: [PATCH 095/806] earlykdump: fix kexec fails to load the early kdump kernel Early kdump always fails to load the vmlinuz-xxx after the 'binutils' package has been installed, and outputs the following messages: ... dracut-cmdline[309]: Cannot determine the file type of /boot/vmlinuz-4.18.0-51.el8.x86_64 dracut-cmdline[309]: kexec: failed to load early-kdump kernel ... The reason is that the vmlinuz-xxx image is mistakenly stripped when using dracut to generate the kdump initrd. Because dracut always find all executable binary files to strip only if the 'binutils' package is installed, otherwise it will skip the stripping. Therefore, remove the executable permissions of the vmlinuz-xxx in '${initrd}' in order to let dracut skip the mistakenly stripping. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-early-kdump-module-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 7613fbc..a004a49 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -41,4 +41,5 @@ install() { prepare_kernel_initrd inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" + chmod -x "${initdir}/$KDUMP_KERNEL" } From 8a476dabf055d6d3390b6e6ec42330ae4fb6b20f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 10 Jan 2019 18:07:41 +0800 Subject: [PATCH 096/806] earlykdump: generate symlink with stable name to kernel image and iniramfs There is currently a problem with earlykdump image building, when a user is upgrading kernel, dracut will generate new initramfs for the new kernel, and earlykdump will install currently running version of kernel into the initramfs, and remain the version based kernel image naming untouched. But after a reboot the new kernel is running, and it will try to load the image corresponding to the new kernel version by file naming. This patch fixes the problem by creating a symlink with unified stable naming to the installed kernel image and initramfs, and use the symlink instand so it will always work despite the kernel version number change. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 4 ++++ dracut-early-kdump.sh | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index a004a49..44edc06 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -41,5 +41,9 @@ install() { prepare_kernel_initrd inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" + + ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" + ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img" + chmod -x "${initdir}/$KDUMP_KERNEL" } diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 34a9909..69a34eb 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -18,17 +18,8 @@ prepare_parameters() EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") - #make early-kdump kernel string - if [ -z "$KDUMP_KERNELVER" ]; then - EARLY_KDUMP_KERNELVER=`uname -r` - else - EARLY_KDUMP_KERNELVER=$KDUMP_KERNELVER - fi - - EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${EARLY_KDUMP_KERNELVER}${KDUMP_IMG_EXT}" - - #make early-kdump initrd string - EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${EARLY_KDUMP_KERNELVER}kdump.img" + EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" + EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-earlykdump.img" } early_kdump_load() From d45da38dca884ce0fb9ed6f69664c32747b7e189 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 10 Jan 2019 14:44:15 +0800 Subject: [PATCH 097/806] earlykdump: add more sanity check when generating initramfs Currently when earlykdump failed to install required kernel image or initramfs, it will still install the earlykdump hook and other utils. But it won't work due to the absent of kernel image or kdump initramfs, so the hook and installed utils is meanless. We can't simply fail dracut building, as if earlykdump is included by dracut config file, this may fail kernel update, where kernel image is installed but initramfs failed to generate, and then it will fail booting. So this patch let it skip earlydkump install if anything is missing and give a clean error message to let the user better ware of the situation. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 44edc06..886b7b2 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -32,13 +32,25 @@ prepare_kernel_initrd() { } install() { + prepare_kernel_initrd + if [ ! -f "$KDUMP_KERNEL" ]; then + derror "Could not find required kernel for earlykdump," \ + "earlykdump will not work!" + return 1 + fi + if [ ! -f "$KDUMP_INITRD" ]; then + derror "Could not find required kdump initramfs for earlykdump," \ + "please ensure kdump initramfs is generated first," \ + "earlykdump will not work!" + return 1 + fi + inst_multiple tail find cut dirname hexdump inst_simple "/etc/sysconfig/kdump" inst_binary "/usr/sbin/kexec" inst_binary "/usr/bin/gawk" "/usr/bin/awk" inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst_hook cmdline 00 "$moddir/early-kdump.sh" - prepare_kernel_initrd inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" From 8c8dc9d64129f41453fe704769589e529793e8ba Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 10 Jan 2019 16:24:44 +0800 Subject: [PATCH 098/806] earlykdump: warn when installed kernel version differs from dracut target Previously we handled the case when the installed kernel version for early kdump is different from dracut target, it will be better to print a warning even if installation successed, to let the user know that an different kernel is used. No warn message will be given if the user specified a KDUMP_KERNELVER value, as in such case a different kernel version is used on purpose. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 886b7b2..e069867 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -24,6 +24,10 @@ prepare_kernel_initrd() { KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") if [ -z "$KDUMP_KERNELVER" ]; then kdump_kver=`uname -r` + if [ "$kernel" != "$kdump_kver" ]; then + dwarn "Using current kernel version '$kdump_kver' for early kdump," \ + "but the initramfs is generated for kernel version '$kernel'" + fi else kdump_kver=$KDUMP_KERNELVER fi From 0c24dce730c44ad302680d5cc89146ef53c31b28 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 9 Jan 2019 22:05:41 +0800 Subject: [PATCH 099/806] mkdumprd: force drop earlykdump module earlykdump is not suppose to be loaded for a kdump initramfs, and user may add it into dracut's config file so it will be included by default. It will also make the image building always fail because earlykdump actually detect if it's being used for kdump image and raise an error if so. In that case, we always force drop this module to avoid such problem. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index aa0abfd..de9ca48 100644 --- a/mkdumprd +++ b/mkdumprd @@ -37,7 +37,7 @@ is_wdt_addition_needed [[ $? -eq 0 ]] && WDTCFG="-a watchdog" extra_modules="" -dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg" $WDTCFG) +dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg earlykdump" $WDTCFG) OVERRIDE_RESETTABLE=0 add_dracut_arg() { From cc95f0a74481150d4b9e986894061f5ae29ec631 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 17 Jan 2019 15:31:23 -0500 Subject: [PATCH 100/806] Add failure_action as alias of default and make default obsolete In preparation for adding 'final_action' option, since it's confusing to have the 'final_action' and 'default' options at the same time, this patch introduces 'failure_action' as an alias of the 'default' option to /etc/kdump.conf, and makes 'default' obsolete to be removed in the future. Also, the "default action" term is renamed to "failure action". Signed-off-by: Kazuhito Hagio Cc: Dave Young Cc: Lianbo Jiang Cc: Bhupesh Sharma Acked-by: Bhupesh Sharma Acked-by: Dave Young Signed-off-by: Kairui Song --- dracut-kdump-error-handler.service | 2 +- dracut-kdump-error-handler.sh | 2 +- fadump-howto.txt | 12 +++++----- kdump-lib-initramfs.sh | 20 ++++++++-------- kdump-lib.sh | 6 ++--- kdump.conf | 12 ++++++---- kdump.conf.5 | 10 ++++++-- kdumpctl | 38 ++++++++++++++++++++---------- kexec-kdump-howto.txt | 12 +++++----- 9 files changed, 68 insertions(+), 46 deletions(-) diff --git a/dracut-kdump-error-handler.service b/dracut-kdump-error-handler.service index 13090be..32b74ab 100644 --- a/dracut-kdump-error-handler.service +++ b/dracut-kdump-error-handler.service @@ -6,7 +6,7 @@ # (at your option) any later version. # This service will run the real kdump error handler code. Executing the -# default action configured in kdump.conf +# failure action configured in kdump.conf [Unit] Description=Kdump Error Handler diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh index 2f0f1d1..fc2b932 100755 --- a/dracut-kdump-error-handler.sh +++ b/dracut-kdump-error-handler.sh @@ -6,5 +6,5 @@ set -o pipefail export PATH=$PATH:$KDUMP_SCRIPT_DIR get_kdump_confs -do_default_action +do_failure_action do_final_action diff --git a/fadump-howto.txt b/fadump-howto.txt index be17da3..2730f4b 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -71,8 +71,8 @@ The control flow of fadump works as follows: process.) 09. Captures dump according to /etc/kdump.conf 10. Is dump capture successful (yes goto 12, no goto 11) -11. Perfom the default action specified in /etc/kdump.conf (Default action - is reboot, if unspecified) +11. Perform the failure action specified in /etc/kdump.conf + (The default failure action is reboot, if unspecified) 12. Reboot @@ -227,12 +227,12 @@ to initate the dump and then click "Restart blade with NMI". This issues a system reset and invokes xmon debugger. -Advanced Setups & Default action: +Advanced Setups & Failure action: -Kdump and fadump exhibit similar behavior in terms of setup & default action. +Kdump and fadump exhibit similar behavior in terms of setup & failure action. For fadump advanced setup related information see section "Advanced Setups" in -"kexec-kdump-howto.txt" document. Refer to "Default action" section in "kexec- -kdump-howto.txt" document for fadump default action related information. +"kexec-kdump-howto.txt" document. Refer to "Failure action" section in "kexec- +kdump-howto.txt" document for fadump failure action related information. Compression and filtering diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index f5155a4..8df2b6c 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -6,7 +6,7 @@ KDUMP_PATH="/var/crash" CORE_COLLECTOR="" DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" DMESG_COLLECTOR="/sbin/vmcore-dmesg" -DEFAULT_ACTION="systemctl reboot -f" +FAILURE_ACTION="systemctl reboot -f" DATEDIR=`date +%Y-%m-%d-%T` HOST_IP='127.0.0.1' DUMP_INSTRUCTION="" @@ -51,22 +51,22 @@ get_kdump_confs() fence_kdump_nodes) FENCE_KDUMP_NODES="$config_val" ;; - default) + failure_action|default) case $config_val in shell) - DEFAULT_ACTION="kdump_emergency_shell" + FAILURE_ACTION="kdump_emergency_shell" ;; reboot) - DEFAULT_ACTION="systemctl reboot -f" + FAILURE_ACTION="systemctl reboot -f" ;; halt) - DEFAULT_ACTION="halt" + FAILURE_ACTION="halt" ;; poweroff) - DEFAULT_ACTION="systemctl poweroff -f" + FAILURE_ACTION="systemctl poweroff -f" ;; dump_to_rootfs) - DEFAULT_ACTION="dump_to_rootfs" + FAILURE_ACTION="dump_to_rootfs" ;; esac ;; @@ -159,10 +159,10 @@ kdump_emergency_shell() rm -f /etc/profile } -do_default_action() +do_failure_action() { - echo "Kdump: Executing default action $DEFAULT_ACTION" - eval $DEFAULT_ACTION + echo "Kdump: Executing failure action $FAILURE_ACTION" + eval $FAILURE_ACTION } do_final_action() diff --git a/kdump-lib.sh b/kdump-lib.sh index 6acab8c..36a1043 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -149,10 +149,10 @@ get_block_dump_target() is_dump_to_rootfs() { - grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null + grep -E "^(failure_action|default)[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null } -get_default_action_target() +get_failure_action_target() { local _target @@ -181,7 +181,7 @@ get_kdump_targets() fi # Add the root device if dump_to_rootfs is specified. - _root=$(get_default_action_target) + _root=$(get_failure_action_target) if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then kdump_targets="$kdump_targets $_root" fi diff --git a/kdump.conf b/kdump.conf index 286ad27..1c7408a 100644 --- a/kdump.conf +++ b/kdump.conf @@ -6,8 +6,8 @@ # processed. # # Currently, only one dump target and path can be specified. If the dumping to -# the configured target fails, the default action which can be configured via -# the "default" directive will be performed. +# the configured target fails, the failure action which can be configured via +# the "failure_action" directive will be performed. # # Supported options: # @@ -99,7 +99,7 @@ # Multiple modules can be listed, separated by spaces, and any # dependent modules will automatically be included. # -# default +# failure_action # - Action to perform in case dumping fails. # reboot: Reboot the system. # halt: Halt the system. @@ -110,6 +110,10 @@ # reboot. Useful when non-root dump target is specified. # The default option is "reboot". # +# default +# - Same as the "failure_action" directive above, but this directive +# is obsolete and will be removed in the future. +# # force_rebuild <0 | 1> # - By default, kdump initrd will only be rebuilt when necessary. # Specify 1 to force rebuilding kdump initrd every time when kdump @@ -155,7 +159,7 @@ core_collector makedumpfile -l --message-level 1 -d 31 #kdump_pre /var/crash/scripts/kdump-pre.sh #extra_bins /usr/bin/lftp #extra_modules gfs2 -#default shell +#failure_action shell #force_rebuild 1 #force_no_rebuild 1 #dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" diff --git a/kdump.conf.5 b/kdump.conf.5 index 990076e..c7098c9 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -148,7 +148,7 @@ modules can be listed, separated by spaces, and any dependent modules will automatically be included. .RE -.B default +.B failure_action .RS Action to perform in case dumping to the intended target fails. The default is "reboot". reboot: Reboot the system (this is what most people will want, as it returns the system @@ -156,10 +156,16 @@ to a normal state). halt: Halt the system and lose the vmcore. poweroff: The s will be powered down. shell: Drop to a shell session inside the initramfs, from which you can manually perform additional recovery actions. Exiting this shell reboots the system. Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump -target is specified, the default action can be set as dump_to_rootfs. That means when +target is specified, the failure action can be set as dump_to_rootfs. That means when dumping to target fails, dump vmcore to rootfs from initramfs context and reboot. .RE +.B default +.RS +Same as the "failure_action" directive above, but this directive is obsolete +and will be removed in the future. +.RE + .B force_rebuild <0 | 1> .RS By default, kdump initrd will only be rebuilt when necessary. diff --git a/kdumpctl b/kdumpctl index ca47705..25d9c28 100755 --- a/kdumpctl +++ b/kdumpctl @@ -228,7 +228,7 @@ check_config() case "$config_opt" in \#* | "") ;; - raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) + raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) # remove inline comments after the end of a directive. config_val=$(strip_comments $config_val) [ -z "$config_val" ] && { @@ -247,7 +247,7 @@ check_config() esac done < $KDUMP_CONFIG_FILE - check_default_config || return 1 + check_failure_action_config || return 1 check_fence_kdump_config || return 1 @@ -935,23 +935,35 @@ start_dump() return $? } -check_default_config() +check_failure_action_config() { local default_option + local failure_action + local option="failure_action" default_option=$(awk '$1 ~ /^default$/ {print $2;}' $KDUMP_CONFIG_FILE) - if [ -z "$default_option" ]; then + failure_action=$(awk '$1 ~ /^failure_action$/ {print $2;}' $KDUMP_CONFIG_FILE) + + if [ -z "$failure_action" -a -z "$default_option" ]; then return 0 - else - case "$default_option" in - reboot|halt|poweroff|shell|dump_to_rootfs) - return 0 - ;; - *) - echo $"Usage kdump.conf: default {reboot|halt|poweroff|shell|dump_to_rootfs}" - return 1 - esac + elif [ -n "$failure_action" -a -n "$default_option" ]; then + echo "Cannot specify 'failure_action' and 'default' option together" + return 1 fi + + if [ -n "$default_option" ]; then + option="default" + failure_action="$default_option" + fi + + case "$failure_action" in + reboot|halt|poweroff|shell|dump_to_rootfs) + return 0 + ;; + *) + echo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" + return 1 + esac } start() diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index f46563f..011a19f 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -463,21 +463,21 @@ storage device, such as an iscsi target disk or clustered file system, you may need to manually specify additional kernel modules to load into your kdump initrd. -Default action +Failure action ============== -Default action specifies what to do when dump to configured dump target -fails. By default, default action is "reboot" and that is system reboots +Failure action specifies what to do when dump to configured dump target +fails. By default, failure action is "reboot" and that is system reboots if attempt to save dump to dump target fails. -There are other default actions available though. +There are other failure actions available though. - dump_to_rootfs This option tries to mount root and save dump on root filesystem in a path specified by "path". This option will generally make sense when dump target is not root filesystem. For example, if dump is being saved over network using "ssh" then one can specify - default to "dump_to_rootfs" to try saving dump to root filesystem - if dump over network fails. + failure action to "dump_to_rootfs" to try saving dump to root + filesystem if dump over network fails. - shell Drop into a shell session inside initramfs. From 242da37c5829e6306fd71065918ea5ce47d57f9c Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 17 Jan 2019 15:31:24 -0500 Subject: [PATCH 101/806] Add final_action option to kdump.conf If a crash occurs repeatedly after enabling kdump, the system goes into a crash loop and the dump target may get filled up by vmcores. This is likely especially with early kdump. This patch introduces 'final_action' option to kdump.conf, in order for users to be able to power off the system even after capturing a vmcore successfully. Signed-off-by: Kazuhito Hagio Cc: Dave Young Cc: Lianbo Jiang Cc: Bhupesh Sharma Acked-by: Bhupesh Sharma Acked-by: Dave Young Signed-off-by: Kairui Song --- fadump-howto.txt | 3 ++- kdump-lib-initramfs.sh | 13 +++++++++++++ kdump.conf | 12 ++++++++++-- kdump.conf.5 | 14 ++++++++++++-- kdumpctl | 22 +++++++++++++++++++++- 5 files changed, 58 insertions(+), 6 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index 2730f4b..7061f02 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -73,7 +73,8 @@ The control flow of fadump works as follows: 10. Is dump capture successful (yes goto 12, no goto 11) 11. Perform the failure action specified in /etc/kdump.conf (The default failure action is reboot, if unspecified) -12. Reboot +12. Perform the final action specified in /etc/kdump.conf + (The default final action is reboot, if unspecified) How to configure fadump: diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 8df2b6c..d6c01d1 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -70,6 +70,19 @@ get_kdump_confs() ;; esac ;; + final_action) + case $config_val in + reboot) + FINAL_ACTION="systemctl reboot -f" + ;; + halt) + FINAL_ACTION="halt" + ;; + poweroff) + FINAL_ACTION="systemctl poweroff -f" + ;; + esac + ;; esac done < $KDUMP_CONF diff --git a/kdump.conf b/kdump.conf index 1c7408a..1f0fc2d 100644 --- a/kdump.conf +++ b/kdump.conf @@ -105,15 +105,23 @@ # halt: Halt the system. # poweroff: Power down the system. # shell: Drop to a bash shell. -# Exiting the shell reboots the system. +# Exiting the shell reboots the system by default, +# or perform "final_action". # dump_to_rootfs: Dump vmcore to rootfs from initramfs context and -# reboot. Useful when non-root dump target is specified. +# reboot by default or perform "final_action". +# Useful when non-root dump target is specified. # The default option is "reboot". # # default # - Same as the "failure_action" directive above, but this directive # is obsolete and will be removed in the future. # +# final_action +# - Action to perform in case dumping succeeds. Also performed +# when "shell" or "dump_to_rootfs" failure action finishes. +# Each action is same as the "failure_action" directive above. +# The default is "reboot". +# # force_rebuild <0 | 1> # - By default, kdump initrd will only be rebuilt when necessary. # Specify 1 to force rebuilding kdump initrd every time when kdump diff --git a/kdump.conf.5 b/kdump.conf.5 index c7098c9..5a0952b 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -155,9 +155,11 @@ reboot: Reboot the system (this is what most people will want, as it returns the to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system will be powered down. shell: Drop to a shell session inside the initramfs, from which you can manually perform additional recovery actions. Exiting this shell reboots the -system. Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump +system by default or performs "final_action". +Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump target is specified, the failure action can be set as dump_to_rootfs. That means when -dumping to target fails, dump vmcore to rootfs from initramfs context and reboot. +dumping to target fails, dump vmcore to rootfs from initramfs context and reboot +by default or perform "final_action". .RE .B default @@ -166,6 +168,14 @@ Same as the "failure_action" directive above, but this directive is obsolete and will be removed in the future. .RE +.B final_action +.RS +Action to perform in case dumping to the intended target succeeds. +Also performed when "shell" or "dump_to_rootfs" failure action finishes. +Each action is same as the "failure_action" directive above. +The default is "reboot". +.RE + .B force_rebuild <0 | 1> .RS By default, kdump initrd will only be rebuilt when necessary. diff --git a/kdumpctl b/kdumpctl index 25d9c28..de6da39 100755 --- a/kdumpctl +++ b/kdumpctl @@ -228,7 +228,7 @@ check_config() case "$config_opt" in \#* | "") ;; - raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) + raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) # remove inline comments after the end of a directive. config_val=$(strip_comments $config_val) [ -z "$config_val" ] && { @@ -248,6 +248,7 @@ check_config() done < $KDUMP_CONFIG_FILE check_failure_action_config || return 1 + check_final_action_config || return 1 check_fence_kdump_config || return 1 @@ -966,6 +967,25 @@ check_failure_action_config() esac } +check_final_action_config() +{ + local final_action + + final_action=$(awk '$1 ~ /^final_action$/ {print $2;}' $KDUMP_CONFIG_FILE) + if [ -z "$final_action" ]; then + return 0 + else + case "$final_action" in + reboot|halt|poweroff) + return 0 + ;; + *) + echo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" + return 1 + esac + fi +} + start() { check_dump_feasibility From f022398ddbd09f3147cd3a16379b56996cb15c54 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 17 Jan 2019 15:31:25 -0500 Subject: [PATCH 102/806] earlykdump: Add a note of final_action option to avoid crash loop Since early kdump is generally used for capturing vmcore when boot-time panic occurs, if a system always reboots after capturing vmcore, it can go into a crash loop. To avoid this issue, this patch add a note of 'final_action' option to the early kdump document. Signed-off-by: Kazuhito Hagio Cc: Dave Young Cc: Lianbo Jiang Acked-by: Bhupesh Sharma Acked-by: Dave Young Signed-off-by: Kairui Song --- early-kdump-howto.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt index fe4f13f..9af0ef1 100644 --- a/early-kdump-howto.txt +++ b/early-kdump-howto.txt @@ -1,6 +1,7 @@ Early Kdump HOWTO Introduction +------------ Kdump service starts too late, so early crashes will have no chance to get kdump kernel booting, this will cause crash information to be lost. It is @@ -12,7 +13,8 @@ which is disabled by default. For the normal kdump service, it can check whether the early kdump has loaded the crash kernel and initramfs. It has no conflict with the early kdump. -How to configure early kdump: +How to configure early kdump +---------------------------- We assume if you're reading this document, you should already have kexec-tools installed. @@ -21,6 +23,16 @@ You can rebuild the initramfs with earlykdump support with below steps: 1. start kdump service to make sure kdump initramfs is created. # systemctl start kdump + NOTE: If a crash occurs during boot process, early kdump captures a vmcore + and reboot the system by default, so the system might go into crash loop. + You can avoid such a crash loop by adding the following settings, which + power off the system after dump capturing, to kdump.conf in advance: + + final_action poweroff + failure_action poweroff + + For the failure_action, you can choose anything other than "reboot". + 2. rebuild system initramfs with earlykdump support. # dracut --add earlykdump @@ -50,5 +62,6 @@ kdump kernel Mar 09 10:02:47 localhost.localdomain dracut-cmdline[189]: early-kdump is disabled. Limitation +---------- At present, early kdump doesn't support fadump. From 7f9dd4568891050648bd63681f68c2185c639551 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 22 Jan 2019 18:08:05 +0800 Subject: [PATCH 103/806] Release 2.0.18-3 Signed-off-by: Kairui Song --- kexec-tools.spec | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c081975..b8bf1da 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.18 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -324,6 +324,19 @@ done %endif %changelog +* Tue Jan 22 2019 Kairui Song - 2.0.18-3 +- earlykdump: Add a note of final_action option to avoid crash loop +- Add final_action option to kdump.conf +- Add failure_action as alias of default and make default obsolete +- mkdumprd: force drop earlykdump module +- earlykdump: warn when installed kernel version differs from dracut target +- earlykdump: add more sanity check when generating initramfs +- earlykdump: generate symlink with stable name to kernel image and iniramfs +- earlykdump: fix kexec fails to load the early kdump kernel +- mkdumprd: allow spaces after 'path' config phrase with network dump setting +- dracut-module-setup: Don't build squashed image if required modules are missing +- kdump-lib-initramfs.sh: using -force option when poweroff + * Fri Dec 7 2018 Kairui Song - 2.0.18-2 - Update makedumpfile 1.6.5 - Make udev reload rules quiet during bootup From 05cec1657f600d5a3769bf977b91f302e2570a65 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 28 Jan 2019 13:21:33 +0800 Subject: [PATCH 104/806] mkdumprd: refine regex on dropping mount options Currently we use "\b" (word boundary) as the delimiter for ro option, which is not correct. For mount options like "defaults,errors=remount-ro" the ro on the tail will also be replaced and result in an invalid mount option. So we use a more strict logic on detecting ro mount option. It should either starts with "," or "^" (begin of line) and ends with "," or "$" (end of line), and keep the delimiter untouched. This should ensure only valid mount option got detected and replaced. This passed following tests: defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro, defaults,errors=remount-ro => defaults,errors=remount-ro defaults,ro,relatime => defaults,rw,relatime defaults,ro => defaults,rw Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mkdumprd b/mkdumprd index de9ca48..6fc68fe 100644 --- a/mkdumprd +++ b/mkdumprd @@ -106,14 +106,14 @@ to_mount() { _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') fi fi + # mount fs target as rw in 2nd kernel + _options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g') # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here. - _options=$(echo $_options | sed 's/\bnoauto\b//') - #mount fs target as rw in 2nd kernel - _options=$(echo $_options | sed 's/\bro\b/rw/') + _options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g') # drop nofail or nobootwait - _options=$(echo $_options | sed 's/\bnofail\b//') - _options=$(echo $_options | sed 's/\bnobootwait\b//') + _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') + _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From 95e9a62674e3dedc52d82ffaed3d5d29cc0a7f4d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 28 Jan 2019 20:17:50 +0100 Subject: [PATCH 105/806] Remove obsolete Group tag References: https://fedoraproject.org/wiki/Changes/Remove_Group_Tag --- kexec-tools.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index b8bf1da..d5dcced 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -2,7 +2,6 @@ Name: kexec-tools Version: 2.0.18 Release: 3%{?dist} License: GPLv2 -Group: Applications/System Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz From b5736e4663fe26189ab86865269e4ec5533c3750 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 1 Feb 2019 05:20:38 +0000 Subject: [PATCH 106/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d5dcced..cd90e3d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.18 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -323,6 +323,9 @@ done %endif %changelog +* Fri Feb 01 2019 Fedora Release Engineering - 2.0.18-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Tue Jan 22 2019 Kairui Song - 2.0.18-3 - earlykdump: Add a note of final_action option to avoid crash loop - Add final_action option to kdump.conf From 159307d057c4d5774783a1365631a4d90e18db91 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 11 Feb 2019 11:19:55 +0800 Subject: [PATCH 107/806] Remove unused patches Signed-off-by: Kairui Song --- ...ls-2.0.16-koji-build-fail-workaround.patch | 13 ------- ...handled-rela-relocation-R_X86_64_PLT.patch | 37 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 kexec-tools-2.0.16-koji-build-fail-workaround.patch delete mode 100644 kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch diff --git a/kexec-tools-2.0.16-koji-build-fail-workaround.patch b/kexec-tools-2.0.16-koji-build-fail-workaround.patch deleted file mode 100644 index c406063..0000000 --- a/kexec-tools-2.0.16-koji-build-fail-workaround.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 49ce80a..97b7a03 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -67,7 +67,7 @@ $(PURGATORY): $(PURGATORY_OBJS) - $(MKDIR) -p $(@D) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@.sym $^ - # $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB) -- $(STRIP) --strip-debug -o $@ $@.sym -+ $(STRIP) --strip-debug --no-merge-notes -o $@ $@.sym - - echo:: - @echo "PURGATORY_SRCS $(PURGATORY_SRCS)" diff --git a/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch b/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch deleted file mode 100644 index ace1ea9..0000000 --- a/kexec-tools-2.0.17-kexec-fix-for-Unhandled-rela-relocation-R_X86_64_PLT.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 35a2fb50293da9fbd94f29a2ed6a4f114fd8044f Mon Sep 17 00:00:00 2001 -From: Bhupesh Sharma -Date: Tue, 21 Aug 2018 16:22:31 +0530 -Subject: [PATCH] kexec: fix for "Unhandled rela relocation: R_X86_64_PLT32" - error - -In response to a change in binutils, commit b21ebf2fb4c -(x86: Treat R_X86_64_PLT32 as R_X86_64_PC32) was applied to -the linux kernel during the 4.16 development cycle and has -since been backported to earlier stable kernel series. The -change results in the failure message in $SUBJECT when -rebooting via kexec. - -Fix this by replicating the change in kexec. - -Signed-off-by: Chris Clayton ---- - kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c -index 7fdde73a5eca..af33689a7d43 100644 ---- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c -+++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c -@@ -78,7 +78,8 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), - if ((int64_t)value != *(int32_t *)location) - goto overflow; - break; -- case R_X86_64_PC32: -+ case R_X86_64_PC32: -+ case R_X86_64_PLT32: - *(uint32_t *)location = value - address; - break; - default: --- -2.7.4 - From 2fc7312546250a74276f599dabb309713e52f7f7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 11 Feb 2019 11:20:28 +0800 Subject: [PATCH 108/806] Enable building with hardening flags Backport the patches required to make the hardening build flags work with kexec-tools and makedumpfile, and enabld hardening flags in spec file. This will make the pacakge pass all warnings for kexec and makedumpfile reported by annocheck. Didn't find any issue with basic tests with kexec and makedumpfile. Signed-off-by: Kairui Song Acked-by: Dave Young --- ...es-honor-the-CFLAGS-from-environment.patch | 41 +++++++++++++++++++ ...0.18-purgatory-Use-standalond-CFLAGS.patch | 34 +++++++++++++++ kexec-tools.spec | 7 +++- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch create mode 100644 kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch diff --git a/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch b/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch new file mode 100644 index 0000000..e4052fa --- /dev/null +++ b/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch @@ -0,0 +1,41 @@ +From 2f007b48c581a81d7e95678b6bcb77cfbe177135 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Tue, 29 Jan 2019 11:14:15 +0800 +Subject: [PATCH] [PATCH v2] honor the CFLAGS from environment variables + +This makes it possible to pass in extra cflags, for example, hardening +flags could be passed in with environment variable when building a +hardened package. + +Also introduce a CFLAGS_BASE to hold common CFLAGS, which simplify the +CFLAGS definition. + +Suggested-by: Kazuhito Hagio +Signed-off-by: Kairui Song +--- + Makefile | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/Makefile b/Makefile +index ea3c47d..bd681d2 100644 +--- a/makedumpfile-1.6.5/Makefile ++++ b/makedumpfile-1.6.5/Makefile +@@ -8,11 +8,10 @@ ifeq ($(strip $CC),) + CC = gcc + endif + +-CFLAGS = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ +- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \ +- -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' +-CFLAGS_ARCH = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ +- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE ++CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ ++ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE ++CFLAGS := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' ++CFLAGS_ARCH := $(CFLAGS_BASE) + # LDFLAGS = -L/usr/local/lib -I/usr/local/include + + HOST_ARCH := $(shell uname -m) +-- +2.20.1 + diff --git a/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch b/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch new file mode 100644 index 0000000..9639877 --- /dev/null +++ b/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch @@ -0,0 +1,34 @@ +From c493af72ac796e8ab3f3f4299205bd402dcee861 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Mon, 28 Jan 2019 18:50:40 +0800 +Subject: [PATCH] purgatory: Use standalond CFLAGS + +There has been a lot of workarounds for purgatory disabling many +specified CFLAGS that will break purgatory. It will be better to not +let the CFLAGS used to compile purgatory honor the CFLAGS from +environment variables. So we will have stable CFLAGS for purgatory. + +If anyone still wants to change purgatory CFLAGS, PURGATORY_EXTRA_CFLAGS +is still honored. + +Signed-off-by: Simon Horman +--- + purgatory/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/purgatory/Makefile b/purgatory/Makefile +index 49ce80a..2dd6c47 100644 +--- a/purgatory/Makefile ++++ b/purgatory/Makefile +@@ -45,7 +45,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c + $(COMPILE.c) -o $@ $^ + + $(PURGATORY): CC=$(TARGET_CC) +-$(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \ ++$(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ + $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ + -Os -fno-builtin -ffreestanding \ + -fno-zero-initialized-in-bss \ +-- +2.20.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index cd90e3d..46639c5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -61,8 +61,6 @@ BuildRequires: automake autoconf libtool Obsoletes: diskdumputils netdump kexec-tools-eppic %endif -%undefine _hardened_build - #START INSERT # @@ -87,6 +85,8 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 601 onward are generic patches # +Patch601: kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch +Patch602: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -102,6 +102,9 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch601 -p1 +%patch602 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 97890ecbacb076b481fe071207eac1cd24cc7ddb Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 13 Feb 2019 00:35:53 +0800 Subject: [PATCH 109/806] Update eppic to latest upstream snapshot eppic project have moved to github, update to latest upstream snapshot, change source link and tar file naming style to fit github's URL format. This fix the O0 warning reported by annocheck and passes all distro package flag checking. Signed-off-by: Kairui Song Acked-by: Dave Young --- kexec-tools.spec | 9 ++++++--- sources | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 46639c5..2e7140f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,3 +1,6 @@ +%global eppic_ver 0209874f4b46b8af5a2d42662ba6775cf5a1dc44 +%global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) + Name: kexec-tools Version: 2.0.18 Release: 4%{?dist} @@ -19,7 +22,7 @@ Source14: 98-kexec.rules Source15: kdump.conf.5 Source16: kdump.service Source18: kdump.sysconfig.s390x -Source19: eppic_050615.tar.gz +Source19: https://github.com/lucchouina/eppic/archive/%{eppic_ver}/eppic-%{eppic_shortver}.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh @@ -130,9 +133,9 @@ cp %{SOURCE27} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -make -C eppic/libeppic +make -C eppic-%{eppic_ver}/libeppic make -C makedumpfile-1.6.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.5 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.5 LDFLAGS="-I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so %endif %install diff --git a/sources b/sources index b1aa049..9ab7761 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf34b36f3bb2d5ddac2cdd3657bbe640beec447725988e928962baf62cf9deff8849da734390280a4f SHA512 (kexec-tools-2.0.18.tar.xz) = a4142e703a752eb270da29f02ea4fb213f3f4f965e73bb483c388a378821094317a4c63406ab0afe118f79eb168ff63b9d2d9530551c984592165430e269d697 SHA512 (makedumpfile-1.6.5.tar.gz) = bfbf9b373d435857530121f29fb3915cb263cfbaa2b877684a8cde2e8cd8b73fc2f02ffdf9b9108613d42aab7e5653877b092846545ceab865e9909e86145970 +SHA512 (eppic-0209874.tar.gz) = 4b42b3c5565f961d661ae6828876cdb0b6e296f9bdadc35ba596c4f63167016a7e20142e3048c37af1f963ba591c688c87faae52c19bd6a24e45d81b56b4a7e1 From be6200f04455606a47096a3f335501a04d97ade4 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 22 Feb 2019 17:09:49 +0800 Subject: [PATCH 110/806] Release 2.0.18-5 Signed-off-by: Kairui Song --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2e7140f..5069bca 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -3,7 +3,7 @@ Name: kexec-tools Version: 2.0.18 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -329,6 +329,13 @@ done %endif %changelog +* Fri Feb 22 2019 Kairui Song - 2.0.18-5 +- Update eppic to latest upstream snapshot +- Enable building with hardening flags +- Remove unused patches +- Remove obsolete Group tag +- mkdumprd: refine regex on dropping mount options + * Fri Feb 01 2019 Fedora Release Engineering - 2.0.18-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild From da6b75f59bdd34c8a3c0b49dc233977b71fabe20 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Wed, 6 Feb 2019 01:47:38 +0530 Subject: [PATCH 111/806] fadump: use the original initrd to rebuild fadump initrdfrom The idea behind adding support for dracut '--rebuild' option was to ensure the initrd built for fadump takes into consideration all the build parameters passed to original initrd. Pass original initrd instead of current default initrd for rebuild as current initrd might already have build parameters from original initrd along with parameters from previous fadump intird build making the build parameters look like this after a few iterations: -H --persistent-policy 'by-uuid' -f --quiet --hostonly --hostonly- cmdline --hostonly-i18n --hostonly-mode 'strict' -o 'plymouth dash resume ifcfg' --mount '/dev/mapper/rhel_zzfp219--lp3-home /kdumproot //home xfs defaults' -f --kver '4.18.0-60.el8.ppc64le' --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode 'strict' -o 'plymouth dash resume ifcfg' --mount '/dev/mapper/rhel_zzfp219--lp3-home /kdumproot//home xfs defaults' -f --kver '4.18.0-60.el8.ppc64le' --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode 'strict' -o 'plymouth dash resume ifcfg' --mount '/dev/mapper/rhel_zzfp219--lp3-home /kdumproot//home xfs defaults' -f --kver '4.18.0-60.el8.ppc64le' --include '/tmp/fadump.initramfs' '/etc/fadump.initramfs' --include '/tmp/fadump.initramfs' '/etc/fadump.initramfs' --include '/tmp/fadump.initramfs' '/etc/fadump.initramfs' -- Since it is not desirable to build initrd with stale and/or duplicate build parameters, use original initrd (backed up) to rebuild fadump initrd, instead of current default initrd. Signed-off-by: Hari Bathini Acked-by: Dave Young --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index de6da39..5ecae06 100755 --- a/kdumpctl +++ b/kdumpctl @@ -94,7 +94,7 @@ rebuild_fadump_initrd() # this file tells the initrd is fadump enabled touch /tmp/fadump.initramfs target_initrd_tmp="$TARGET_INITRD.tmp" - $MKDUMPRD $target_initrd_tmp --rebuild $TARGET_INITRD --kver $kdump_kver \ + $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $kdump_kver \ -i /tmp/fadump.initramfs /etc/fadump.initramfs if [ $? != 0 ]; then echo "mkdumprd: failed to rebuild initrd with fadump support" >&2 From 689fca5af3997212f45b667c4228e933b432c993 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 28 Feb 2019 10:20:29 +0530 Subject: [PATCH 112/806] fadump: leverage kernel support to re-regisgter FADump With kernel commit 0823c68b054b ("powerpc/fadump: re-register firmware- assisted dump if already registered") support is enabled to re-register when FADump is alredy registered. Leverage that option in kdump scripts. Signed-off-by: Hari Bathini Acked-by: Kairui Song --- kdumpctl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 5ecae06..1cfbe31 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1047,7 +1047,8 @@ reload() fi if [ $DEFAULT_DUMP_MODE == "fadump" ]; then - stop_fadump + reload_fadump + return $? else stop_kdump fi @@ -1103,6 +1104,26 @@ stop_kdump() return 0 } +reload_fadump() +{ + echo 1 > $FADUMP_REGISTER_SYS_NODE + if [ $? == 0 ]; then + echo "fadump: re-registered successfully" + return 0 + else + # FADump could fail on older kernel where re-register + # support is not enabled. Try stop/start from userspace + # to handle such scenario. + stop_fadump + if [ $? == 0 ]; then + start_fadump + return $? + fi + fi + + return 1 +} + stop() { if [ $DEFAULT_DUMP_MODE == "fadump" ]; then From ace66284ab5ce0a4dd8a7ae6fdaa5789443de65e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 21 Mar 2019 11:15:23 +0800 Subject: [PATCH 113/806] Update eppic to latest snapshot Also don't override LDFLAGS when building eppic lib, this ensure hardening won't get overrided. Signed-off-by: Kairui Song --- kexec-tools.spec | 4 ++-- sources | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 5069bca..12a3f96 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,4 +1,4 @@ -%global eppic_ver 0209874f4b46b8af5a2d42662ba6775cf5a1dc44 +%global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) Name: kexec-tools @@ -135,7 +135,7 @@ make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic-%{eppic_ver}/libeppic make -C makedumpfile-1.6.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.5 LDFLAGS="-I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.5 LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so %endif %install diff --git a/sources b/sources index 9ab7761..e9bb23e 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (kexec-tools-2.0.18.tar.xz) = a4142e703a752eb270da29f02ea4fb213f3f4f965e73bb483c388a378821094317a4c63406ab0afe118f79eb168ff63b9d2d9530551c984592165430e269d697 SHA512 (makedumpfile-1.6.5.tar.gz) = bfbf9b373d435857530121f29fb3915cb263cfbaa2b877684a8cde2e8cd8b73fc2f02ffdf9b9108613d42aab7e5653877b092846545ceab865e9909e86145970 -SHA512 (eppic-0209874.tar.gz) = 4b42b3c5565f961d661ae6828876cdb0b6e296f9bdadc35ba596c4f63167016a7e20142e3048c37af1f963ba591c688c87faae52c19bd6a24e45d81b56b4a7e1 +SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d From 24f9b31080a78d9f6a6c0b9d6aa7a9cc0c1d1903 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 21 Mar 2019 11:22:09 +0800 Subject: [PATCH 114/806] Release 2.0.19-1 Rebase to latest kexec-tools upstream and remove backport patch. Signed-off-by: Kairui Song --- ...0.18-purgatory-Use-standalond-CFLAGS.patch | 34 ------------------- kexec-tools.spec | 13 ++++--- sources | 2 +- 3 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch diff --git a/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch b/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch deleted file mode 100644 index 9639877..0000000 --- a/kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch +++ /dev/null @@ -1,34 +0,0 @@ -From c493af72ac796e8ab3f3f4299205bd402dcee861 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Mon, 28 Jan 2019 18:50:40 +0800 -Subject: [PATCH] purgatory: Use standalond CFLAGS - -There has been a lot of workarounds for purgatory disabling many -specified CFLAGS that will break purgatory. It will be better to not -let the CFLAGS used to compile purgatory honor the CFLAGS from -environment variables. So we will have stable CFLAGS for purgatory. - -If anyone still wants to change purgatory CFLAGS, PURGATORY_EXTRA_CFLAGS -is still honored. - -Signed-off-by: Simon Horman ---- - purgatory/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 49ce80a..2dd6c47 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -45,7 +45,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c - $(COMPILE.c) -o $@ $^ - - $(PURGATORY): CC=$(TARGET_CC) --$(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \ -+$(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ - $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ - -Os -fno-builtin -ffreestanding \ - -fno-zero-initialized-in-bss \ --- -2.20.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 12a3f96..a1e6686 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -2,8 +2,8 @@ %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.18 -Release: 5%{?dist} +Version: 2.0.19 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -88,8 +88,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.18-purgatory-Use-standalond-CFLAGS.patch -Patch602: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch +Patch601: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -106,7 +105,6 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch601 -p1 -%patch602 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -329,6 +327,11 @@ done %endif %changelog +* Fri Mar 22 2019 Kairui Song - 2.0.19-1 +- Update eppic to latest snapshot +- fadump: leverage kernel support to re-regisgter FADump +- fadump: use the original initrd to rebuild fadump initrdfrom + * Fri Feb 22 2019 Kairui Song - 2.0.18-5 - Update eppic to latest upstream snapshot - Enable building with hardening flags diff --git a/sources b/sources index e9bb23e..6e740dd 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (kexec-tools-2.0.18.tar.xz) = a4142e703a752eb270da29f02ea4fb213f3f4f965e73bb483c388a378821094317a4c63406ab0afe118f79eb168ff63b9d2d9530551c984592165430e269d697 SHA512 (makedumpfile-1.6.5.tar.gz) = bfbf9b373d435857530121f29fb3915cb263cfbaa2b877684a8cde2e8cd8b73fc2f02ffdf9b9108613d42aab7e5653877b092846545ceab865e9909e86145970 SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d +SHA512 (kexec-tools-2.0.19.tar.xz) = 68b15fe46f9633d55c5ae51a6e7114b0c66bd8f4fe81197f581121939a7b21990a2eea89a0961ac6eb7af364ba0d3981ea504df81c7b4cc0b288ca6ac896730f From 289e16c8816c86dba4608fb13d2d522f3d1cddc1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 24 Feb 2019 23:00:17 +0800 Subject: [PATCH 115/806] mkdumprd: Improve the config reading logic Seems some dead codes are left here for historical reason, just remove them, read the config and strip comments only for once. This improve the speed by a lot (2.6s -> 0.498s for reading a simple config in my test case, on HDD) and make the code cleaner. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mkdumprd b/mkdumprd index 6fc68fe..a99d5f1 100644 --- a/mkdumprd +++ b/mkdumprd @@ -444,13 +444,9 @@ do add_dracut_arg $config_val ;; *) - if [ -n $(echo $config_opt | grep "^#.*$") ] - then - continue - fi ;; esac -done < $conf_file +done <<< "$(grep -v -e "^#" -e "^$" $conf_file)" handle_default_dump_target From 594ac119c51007b5c947eb00dabbf8843111da18 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 29 Mar 2019 11:29:30 +0800 Subject: [PATCH 116/806] kdumpctl: add rebuild support Use "kdumpctl rebuild" to rebuild the image directly. This could help admins to rebuild kdump image directly. Also merge fadump related initramfs backup/restore into setup_initrd, and do permission only when actually trying to rebuild the image. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/kdumpctl b/kdumpctl index 1cfbe31..ac7b86f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -123,6 +123,11 @@ rebuild_kdump_initrd() rebuild_initrd() { + if [[ ! -w "$KDUMP_BOOTDIR" ]];then + echo "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" + return 1 + fi + if [ $DEFAULT_DUMP_MODE == "fadump" ]; then rebuild_fadump_initrd else @@ -298,12 +303,17 @@ setup_initrd() DEFAULT_INITRD_BAK="${KDUMP_BOOTDIR}/.initramfs-`uname -r`.img.default" if [ $DEFAULT_DUMP_MODE == "fadump" ]; then TARGET_INITRD="$DEFAULT_INITRD" - if [ ! -s "$TARGET_INITRD" ]; then - echo "Error: No initrd found to rebuild!" - return 1 - fi + + # backup initrd for reference before replacing it + # with fadump aware initrd + backup_default_initrd else TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" + + # check if a backup of default initrd exists. If yes, + # it signifies a switch from fadump mode. So, restore + # the backed up default initrd. + restore_default_initrd fi } @@ -602,8 +612,6 @@ check_rebuild() system_modified="1" fi - handle_mode_switch - if [ $image_time -eq 0 ]; then echo -n "No kdump initial ramdisk found."; echo elif [ "$capture_capable_initrd" == "0" ]; then @@ -616,11 +624,6 @@ check_rebuild() return 0 fi - if [[ ! -w "$KDUMP_BOOTDIR" ]];then - echo "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" - return 1 - fi - echo "Rebuilding $TARGET_INITRD" rebuild_initrd return $? @@ -745,20 +748,6 @@ show_reserved_mem() echo "Reserved "$mem_mb"MB memory for crash kernel" } -handle_mode_switch() -{ - if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then - # backup initrd for reference before replacing it - # with fadump aware initrd - backup_default_initrd - else - # check if a backup of default initrd exists. If yes, - # it signifies a switch from fadump mode. So, restore - # the backed up default initrd. - restore_default_initrd - fi -} - check_current_fadump_status() { # Check if firmware-assisted dump has been registered. @@ -1141,6 +1130,17 @@ stop() return 0 } +rebuild() { + setup_initrd + if [ $? -ne 0 ]; then + return 1 + fi + + echo "Rebuilding $TARGET_INITRD" + rebuild_initrd + return $? +} + if [ ! -f "$KDUMP_CONFIG_FILE" ]; then echo "Error: No kdump config file found!" >&2 exit 1 @@ -1185,6 +1185,9 @@ main () stop start ;; + rebuild) + rebuild + ;; condrestart) ;; propagate) @@ -1194,7 +1197,7 @@ main () show_reserved_mem ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|propagate|showmem}" + echo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem}" exit 1 esac } From a53be67929427c69bcc4534dd00470e13cca1042 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 13 Mar 2019 20:28:59 +0800 Subject: [PATCH 117/806] Update man page for new kdumpctl command: reload / rebuild These two command are not documented, update the man page to let user know how to use them. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl.8 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kdumpctl.8 b/kdumpctl.8 index 023562b..ae97af7 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -32,6 +32,12 @@ It returns non-zero value if kdump is not operational. Is equal to .I start; stop .TP +.I reload +reload crash kernel image and initramfs without triggering a rebuild. +.TP +.I rebuild +rebuild the crash kernel initramfs. +.TP .I propagate Helps to setup key authentication for ssh storage since it's impossible to use password authentication during kdump. From 50aa6dea246486bee2c3b7d07fba4ca286dece02 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Tue, 26 Mar 2019 16:33:18 +0800 Subject: [PATCH 118/806] kexec-kdump-howto: Add note on setting correct value of kptr_restrict kdumpctl fails to load a crash kernel if KASLR is enabled. The incorrect configuration of the kptr_restrict parameter causes that the kdumpctl fails to load a crash kernel. The problem occurs when the Kernel Address Space Layout Randomization (KASLR) mechanism is enabled. The value of kptr_restrict decides how to expose the content of /proc files. Inappropriate setting will cause that the /proc/kallsyms file is being printed as all zeros. This configuration will break the kdump loading process since it needs access to the conntent of /proc/kallsyms if KASLR is enabled. Set kptr_restrict to 1 to avoid the problem described above. Signed-off-by: Baoquan He Acked-by: Dave Young --- kexec-kdump-howto.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 011a19f..12a9450 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -91,6 +91,12 @@ This line tells kexec to reserve 64M of ram if the system contains between 512M and 2G of physical memory. If the system contains 2G or more of physical memory, 128M should be reserved. +Besides, since kdump needs to access /proc/kallsyms during a kernel +loading if KASLR is enabled, check /proc/sys/kernel/kptr_restrict to +make sure that the content of /proc/kallsyms is exposed correctly. +We recommend to set the value of kptr_restrict to '1'. Otherwise +capture kernel loading could fail. + After making said changes, reboot your system, so that the X MB of memory is left untouched by the normal system, reserved for the capture kernel. Take note that the output of 'free -m' will show X MB less memory than without this From a585f981bde6c64b032ccd1c0bee675a6ea2bb64 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 30 Apr 2019 11:55:10 +0800 Subject: [PATCH 119/806] kexec.rules: create dedicated udev rules for ppc64 On powerpc, after hot add cpu and trigger crash on the hot-added cpu, the kdump kernel hangs after "I'm in purgatory". The current udev rules expects the dtb to be rebuit on cpu add/remove event. But since powerpc does not follow the standard cpu hot add framework, it only ejects online/offline event to user space when cpu is hot added/removed, instead of add/remove event. Pingfan tried fixing that but it didn't please the maintainer as it breaks some old userspace tools. Due to the failure of dtb's rebuilding, KDump kernel fails to get the 'boot_cpuid' and eventually fails to boot [see early_init_dt_scan_cpus() in arch/powerpc/kernel/prom.c file] if system crashes on hot-added CPU. Work around it by changing udev rules on powerpc to onlne/offline. As for offline message, it is even useless on powerpc, and can be dropped. See the explain: On powerpc, /sys/devices/system/cpu/cpuX nodes are present for all "possible", irrespective of whether a CPU is hot-added/removed. crash_notes are already built for all /sys/devices/system/cpu/cpuX nodes and these nodes are present for all "possible" CPUs (online/offline/could-be-hot-removed/could-be-hot-added) Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- 98-kexec.rules.ppc64 | 15 +++++++++++++++ kexec-tools.spec | 10 ++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 98-kexec.rules.ppc64 diff --git a/98-kexec.rules.ppc64 b/98-kexec.rules.ppc64 new file mode 100644 index 0000000..1a91220 --- /dev/null +++ b/98-kexec.rules.ppc64 @@ -0,0 +1,15 @@ +SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload" +SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload" + +GOTO="kdump_reload_end" + +LABEL="kdump_reload" + +# If kdump is not loaded, calling kdump-udev-throttle will end up +# doing nothing, but systemd-run will always generate extra logs for +# each call, so trigger the kdump-udev-throttler only if kdump +# service is active to avoid unnecessary logs +RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" + +LABEL="kdump_reload_end" diff --git a/kexec-tools.spec b/kexec-tools.spec index a1e6686..3ebf9da 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -18,7 +18,8 @@ Source8: kdump.conf Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.5/makedumpfile-1.6.5.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 -Source14: 98-kexec.rules +Source13: 98-kexec.rules +Source14: 98-kexec.rules.ppc64 Source15: kdump.conf.5 Source16: kdump.service Source18: kdump.sysconfig.s390x @@ -169,10 +170,15 @@ install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh %ifnarch s390x +install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler +%endif +%ifnarch s390x ppc64 ppc64le # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required +install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules +%endif +%ifarch ppc64 ppc64le install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules -install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler %endif install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service From 09f50350d9ecfceb11ece4ebd03c9830b6224581 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 29 Apr 2019 15:12:29 +0800 Subject: [PATCH 120/806] Revert "kdumpctl: Rebuild initramfs if loaded kernel modules changed" This reverts commit 6b479b657266f130e6dc343817986e88883cabaf. Check initramfs rebuild by looking at if there is any change of load kernel modules list is not very stable after all. Previously we are counting on udev to settle before kdump is started to ensure all modules is ready, but actually any service may cause a kernel module load, even after udev is settled. The previous commit is trying to workaround an issue that VM created with disk snapshot may fail in the kdump initramfs. The better fix is to not include the kdump initramfs in the disk snapshot at all, as the kdump initramfs is not generated for a generic use. And With new added "kdumpctl reload" command, admins could rebuild the image easily, and should rebuild the initramfs on hardware change manually. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/kdumpctl b/kdumpctl index ac7b86f..3f80ba4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -486,31 +486,6 @@ check_wdt_modified() return 1 } -check_kmodules_modified() -{ - # always sort again to avoid LANG/LC inconsistent problem - local _old_modules="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/loaded-kernel-modules.txt | sort)" - local _new_modules="$(get_loaded_kernel_modules | sort)" - - [[ -z $_old_modules ]] && echo "Warning: Previous loaded kernel module list is absent or empty" - - local _added_modules=$(comm -13 <(echo "$_old_modules") <(echo "$_new_modules")) - local _dropped_modules=$(comm -23 <(echo "$_old_modules") <(echo "$_new_modules")) - - if [ "$_old_modules" != "$_new_modules" ]; then - echo "Detected change(s) of loaded kernel modules list:" - [[ -n $_added_modules ]] && for _module in $_added_modules; do - echo " +$_module" - done - [[ -n $_dropped_modules ]] && for _module in $_dropped_modules; do - echo " -$_module" - done - return 1 - fi - - return 0 -} - # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -538,11 +513,6 @@ check_system_modified() return 1 fi - check_kmodules_modified - if [ $? -ne 0 ]; then - return 1 - fi - return 0 } From 1c1159a58601004ca7c7255ae948dbfe334036d2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 May 2019 14:19:18 +0800 Subject: [PATCH 121/806] kdumpctl: Detect block device driver change for initramfs rebuild Previous we rebuild the initramfs when kenrel load module list changed, but this is not very stable as some async services may load/unload kernel modules, and cause unnecessary initramfs rebuild. Instead, it's better to just check if the module required to dump to the dump target is loaded or not, and rebuild if not loaded. This avoids most false-positives, and ensure local target change is always covered. Currently only local fs dump target is covered, because this check requires the dump target to be mounted when building the initramfs, this guarantee that the module is in the loaded kernel module list, else we may still get some false positive. dracut-install could be leveraged to combine the modalias list with kernel loaded module list as a more stable module list in the initramfs, but upstream dracut change need to be done first. Passed test on a KVM VM, changing the storage between SATA/USB/VirtIO will trigger initramfs rebuild and didn't notice any false-positive. Also passed test on my laptop with no false-positive. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kdumpctl b/kdumpctl index 3f80ba4..75eebac 100755 --- a/kdumpctl +++ b/kdumpctl @@ -357,6 +357,9 @@ check_dump_fs_modified() local _old_dev _old_mntpoint _old_fstype local _new_dev _new_mntpoint _new_fstype local _target _path _dracut_args + local _target_drivers _module_name + + local _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/loaded-kernel-modules.txt | tr '\n' ' ')" # No need to check in case of mount target specified via "dracut_args". if is_mount_in_dracut_args; then @@ -385,6 +388,36 @@ check_dump_fs_modified() fi fi + _record_block_drivers() { + local _drivers + if [[ -b /dev/block/$1 ]]; then + _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') + fi + if [[ -b $1 ]]; then + _drivers=$(udevadm info -a "$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') + fi + for _driver in $_drivers; do + if ! [[ " $_target_drivers " == *" $_driver "* ]]; then + _target_drivers="$_target_drivers $_driver" + fi + done + return 1 + } + + check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" + for _driver in $_target_drivers; do + # Target is mounted already, if module is not included by current kernel, + # could be a deprecated/invalid driver name or a built-in module + _module_name=$(modinfo --set-version "$kdump_kver" -F name $_driver 2>/dev/null) + if [ $? -ne 0 ] || [ -z "$_module_name" ]; then + continue + fi + if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then + echo "Detected change in block device driver, new loaded module: $_module_name" + return 1 + fi + done + if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then _new_dev=$_target else From f544a12e78efe2bf12d04bbe1964d2594e0b0b4a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 10 May 2019 15:09:44 +0800 Subject: [PATCH 122/806] kexec-kdump-howto.txt: Add document about initramfs rebiuld Add some note about the limitation of kdumpctl's auto detect and rebuild feature, and suggest the user to rebuild the initramfs manually on major system change, and don't include the initramfs in disk images. Put the note about system change in front part of the document so user will less likely to miss it. Signed-off-by: Kairui Song Acked-by: Dave Young --- kexec-kdump-howto.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 12a9450..fa01a3d 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -136,6 +136,22 @@ perform postmortem analysis: and so on... +Notes: + +When kdump starts, the kdump kernel is loaded together with the kdump +initramfs. To save memory usage and disk space, the kdump initramfs is +generated strictly against the system it will run on, and contains the +minimum set of kernel modules and utilities to boot the machine to a stage +where the dump target could be mounted. + +With kdump service enabled, kdumpctl will try to detect possible system +change and rebuild the kdump initramfs if needed. But it can not guarantee +to cover every possible case. So after a hardware change, disk migration, +storage setup update or any similar system level changes, it's highly +recommended to rebuild the initramfs manually with following command: + + # kdumpctl rebuild + Saving vmcore-dmesg.txt ---------------------- Kernel log bufferes are one of the most important information available @@ -654,6 +670,20 @@ not been written in watchdog-core framework then this option will not have any effect and module will not be added. Please note that only systemd watchdog daemon is supported as watchdog kick application. +Notes for disk images: + +Kdump initramfs is a critical component for capturing the crash dump. +But it's strictly generated for the machine it will run on, and have +no generality. If you install a new machine with a previous disk image +(eg. VMs created with disk image or snapshot), kdump could be broken +easily due to hardware changes or disk ID changes. So it's strongly +recommended to not include the kdump initramfs in the disk image in the +first place, this helps to save space, and kdumpctl will build the +initramfs automatically if it's missing. If you have already installed +a machine with a disk image which have kdump initramfs embedded, you +should rebuild the initramfs using "kdumpctl rebuild" command manually, +or else kdump may not work as expeceted. + Parallel Dumping Operation ========================== Kexec allows kdump using multiple cpus. So parallel feature can accelerate From 8d4db658fd04b8aebfea968b10e6111a3f41f2bf Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 10 May 2019 15:11:26 +0800 Subject: [PATCH 123/806] kexec-kdump-howto.txt: Add document about encrypted targets Currently kdump is not working well with encrypted targets, add document about this issue. Signed-off-by: Kairui Song Acked-by: Dave Young --- kexec-kdump-howto.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index fa01a3d..7e9e58a 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -684,6 +684,20 @@ a machine with a disk image which have kdump initramfs embedded, you should rebuild the initramfs using "kdumpctl rebuild" command manually, or else kdump may not work as expeceted. +Notes on encrypted dump target: + +Currently, kdump is not working well with encrypted dump target. +First, user have to give the password manually in capture kernel, +so a working interactive terminal is required in the capture kernel. +And another major issue is that an OOM problem will occur with certain +encryption setup. For example, the default setup for LUKS2 will use a +memory hard key derivation function to mitigate brute force attach, +it's impossible to reduce the memory usage for mounting the encrypted +target. In such case, you have to either reserved enough memory for +crash kernel according, or update your encryption setup. +It's recommanded to use a non-encrypted target (eg. remote target) +instead. + Parallel Dumping Operation ========================== Kexec allows kdump using multiple cpus. So parallel feature can accelerate From 9529191d95d25de391b7bbe7a688e84a51a45963 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 16 May 2019 13:09:21 +0800 Subject: [PATCH 124/806] earlykdump: provide a prompt message after the rebuilding of kdump initramfs. Early kdump inherits the settings of normal kdump, so any changes that caused normal kdump rebuilding also require rebuilding the system initramfs to make sure that the changes take effect for early kdump. Therefore, when the early kdump is enabled, provide a prompt message after the rebuilding of kdump initramfs is completed. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- early-kdump-howto.txt | 9 ++++++++- kdumpctl | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt index 9af0ef1..b8cab6a 100644 --- a/early-kdump-howto.txt +++ b/early-kdump-howto.txt @@ -38,10 +38,17 @@ You can rebuild the initramfs with earlykdump support with below steps: 3. add rd.earlykdump in grub kernel command line. -Note: earlykdump initramfs size will be large because it includes vmlinuz and +Note: +[1]. Early kdump initramfs size will be large because it includes vmlinuz and kdump initramfs. And for step 2 if you are sure to overwrite system initramfs you can backup the original initramfs and use "--force" option. +[2]. Early kdump inherits the settings of normal kdump, so any changes that +caused normal kdump rebuilding also require rebuilding the system initramfs +to make sure that the changes take effect for early kdump. Therefore, after +the rebuilding of kdump initramfs is completed, provide a prompt message to +tell the fact. + After making said changes, reboot your system to take effect. Of course, if you want to disable early kdump, you can simply remove "rd.earlykdump" from kernel boot parameters in grub, and reboot system like above. diff --git a/kdumpctl b/kdumpctl index 75eebac..72f9d7e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -110,6 +110,12 @@ rebuild_fadump_initrd() return 0 } +check_earlykdump_is_enabled() +{ + grep -q -w "rd.earlykdump" /proc/cmdline + return $? +} + rebuild_kdump_initrd() { $MKDUMPRD $TARGET_INITRD $kdump_kver @@ -118,6 +124,10 @@ rebuild_kdump_initrd() return 1 fi + if check_earlykdump_is_enabled; then + echo "Tips: If early kdump is enabled, also require rebuilding the system initramfs to make the changes take effect for early kdump." + fi + return 0 } From 75d9132417e00aca8498ef5d1d882f6b95091290 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 17 May 2019 16:48:46 +0800 Subject: [PATCH 125/806] Get rid of duplicated strip_comments when reading config When reading kdump configs, a single parsing should be enough and this saves a lot of duplicated striping call which speed up the total load speed. Speed up about 2 second when building and 0.1 second for reload in my tests. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-kdump.sh | 3 +-- dracut-module-setup.sh | 3 +-- kdump-lib-initramfs.sh | 3 +-- kdump-lib.sh | 8 ++++++++ kdumpctl | 8 ++------ mkdumprd | 3 +-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b75c2a5..2ae1c7c 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -144,7 +144,6 @@ read_kdump_conf() while read config_opt config_val; do # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) case "$config_opt" in dracut_args) config_val=$(get_dracut_args_target "$config_val") @@ -160,7 +159,7 @@ read_kdump_conf() add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac - done < $KDUMP_CONF + done <<< "$(read_strip_comments $KDUMP_CONF)" } fence_kdump_notify() diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index db7cd23..2998c72 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -501,7 +501,6 @@ kdump_install_conf() { while read _opt _val; do # remove inline comments after the end of a directive. - _val=$(strip_comments $_val) case "$_opt" in raw) _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val) @@ -529,7 +528,7 @@ kdump_install_conf() { dracut_install "${_val%%[[:blank:]]*}" ;; esac - done < /etc/kdump.conf + done <<< "$(read_strip_comments /etc/kdump.conf)" default_dump_target_install_conf diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index d6c01d1..608dc6e 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -26,7 +26,6 @@ get_kdump_confs() while read config_opt config_val; do # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) case "$config_opt" in path) KDUMP_PATH="$config_val" @@ -84,7 +83,7 @@ get_kdump_confs() esac ;; esac - done < $KDUMP_CONF + done <<< "$(read_strip_comments $KDUMP_CONF)" if [ -z "$CORE_COLLECTOR" ]; then CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" diff --git a/kdump-lib.sh b/kdump-lib.sh index 36a1043..4feb7d0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -61,6 +61,14 @@ strip_comments() echo $@ | sed -e 's/\(.*\)#.*/\1/' } +# Read from kdump config file stripping all comments +read_strip_comments() +{ + # strip heading spaces, and print any content starting with + # neither space or #, and strip everything after # + sed -n -e "s/^\s*\([^# \t][^#]\+\).*/\1/gp" $1 +} + # Check if fence kdump is configured in Pacemaker cluster is_pcs_fence_kdump() { diff --git a/kdumpctl b/kdumpctl index 72f9d7e..08c5667 100755 --- a/kdumpctl +++ b/kdumpctl @@ -245,7 +245,6 @@ check_config() ;; raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) [ -z "$config_val" ] && { echo "Invalid kdump config value for option $config_opt." return 1; @@ -260,7 +259,7 @@ check_config() return 1; ;; esac - done < $KDUMP_CONFIG_FILE + done <<< "$(read_strip_comments $KDUMP_CONFIG_FILE)" check_failure_action_config || return 1 check_final_action_config || return 1 @@ -676,7 +675,6 @@ check_ssh_config() case "$config_opt" in sshkey) # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) if [ -f "$config_val" ]; then # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m $config_val) @@ -685,17 +683,15 @@ check_ssh_config() fi ;; path) - config_val=$(strip_comments $config_val) SAVE_PATH=$config_val ;; ssh) - config_val=$(strip_comments $config_val) DUMP_TARGET=$config_val ;; *) ;; esac - done < $KDUMP_CONFIG_FILE + done <<< "$(read_strip_comments $KDUMP_CONFIG_FILE)" #make sure they've configured kdump.conf for ssh dumps local SSH_TARGET=`echo -n $DUMP_TARGET | sed -n '/.*@/p'` diff --git a/mkdumprd b/mkdumprd index a99d5f1..cf3533f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -392,7 +392,6 @@ fi while read config_opt config_val; do # remove inline comments after the end of a directive. - config_val=$(strip_comments $config_val) case "$config_opt" in extra_modules) extra_modules="$extra_modules $config_val" @@ -446,7 +445,7 @@ do *) ;; esac -done <<< "$(grep -v -e "^#" -e "^$" $conf_file)" +done <<< "$(read_strip_comments $conf_file)" handle_default_dump_target From 30913fd667d2590a7e9c15fc915b4899a203e2e0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 May 2019 14:20:24 +0800 Subject: [PATCH 126/806] kdumpctl: follow symlink when checking for modified files Previously only the symlink's timestamp is used for checking if file are modified, this will not trigger a rebuild if the symlink target it modified. So check both symlink timestamp and symlink target timestamp, rebuild the initramfs on both symlink changed and target changed. Also give a proper error message if the file doesn't exist. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kdumpctl b/kdumpctl index 08c5667..27d2fad 100755 --- a/kdumpctl +++ b/kdumpctl @@ -347,11 +347,23 @@ check_files_modified() [ $? -ne 0 ] && return 2 for file in $files; do - time_stamp=`stat -c "%Y" $file` - if [ "$time_stamp" -gt "$image_time" ]; then - modified_files="$modified_files $file" + if [ -e "$file" ]; then + time_stamp=`stat -c "%Y" $file` + if [ "$time_stamp" -gt "$image_time" ]; then + modified_files="$modified_files $file" + fi + if [ -L "$file" ]; then + file=$(readlink -m $file) + time_stamp=`stat -c "%Y" $file` + if [ "$time_stamp" -gt "$image_time" ]; then + modified_files="$modified_files $file" + fi + fi + else + echo "$file doesn't exist" fi done + if [ -n "$modified_files" ]; then echo "Detected change(s) in the following file(s):" echo -n " "; echo "$modified_files" | sed 's/\s/\n /g' From 2efc0f1854aef629d5d483213e594a27372c771c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 May 2019 14:20:25 +0800 Subject: [PATCH 127/806] kdumpctl: don't always rebuild when extra_modules is set We don't necessarily have to always rebuild the initramfs when extra_modules is set. Instead, just detect if any module is updated, and only rebuild initramfs if found any updated kernel module. Tested with in-tree kernel modules, out-of-tree kernel modules, weak modules, all worked as expected. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index 27d2fad..20afb30 100755 --- a/kdumpctl +++ b/kdumpctl @@ -343,6 +343,28 @@ check_files_modified() files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" [[ -e /etc/fstab ]] && files="$files /etc/fstab" + # Check for any updated extra module + EXTRA_MODULES="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed 's/^extra_modules\s*//')" + if [ -n "$EXTRA_MODULES" ]; then + if [ -e /lib/modules/$kdump_kver/modules.dep ]; then + files="$files /lib/modules/$kdump_kver/modules.dep" + fi + for _module in $EXTRA_MODULES; do + _module_file="$(modinfo --set-version "$kdump_kver" --filename "$_module" 2>/dev/null)" + if [[ $? -eq 0 ]]; then + files="$files $_module_file" + for _dep_modules in $(modinfo -F depends $_module | tr ',' ' '); do + files="$files $(modinfo --set-version "$kdump_kver" --filename $_dep_modules 2>/dev/null)" + done + else + # If it's not a module nor builtin, give an error + if ! ( modprobe --set-version "$kdump_kver" --dry-run "$_module" &>/dev/null ); then + echo "Module $_module not found" + fi + fi + done + fi + check_exist "$files" && check_executable "$EXTRA_BINS" [ $? -ne 0 ] && return 2 @@ -572,7 +594,6 @@ check_system_modified() check_rebuild() { - local extra_modules local capture_capable_initrd="1" local _force_rebuild force_rebuild="0" local _force_no_rebuild force_no_rebuild="0" @@ -612,10 +633,6 @@ check_rebuild() return 0 fi - #will rebuild every time if extra_modules are specified - extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE` - [ -n "$extra_modules" ] && force_rebuild="1" - #check to see if dependent files has been modified #since last build of the image file if [ -f $TARGET_INITRD ]; then From 8af28759ec1568f0325a5f88c40b15172d932292 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 20 May 2019 17:07:58 +0800 Subject: [PATCH 128/806] Release 2.0.19-2 Signed-off-by: Kairui Song --- kexec-tools.spec | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3ebf9da..67450f8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -3,7 +3,7 @@ Name: kexec-tools Version: 2.0.19 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -333,6 +333,21 @@ done %endif %changelog +* Mon May 20 2019 Kairui Song - 2.0.19-2 +- kdumpctl: don't always rebuild when extra_modules is set +- kdumpctl: follow symlink when checking for modified files +- Get rid of duplicated strip_comments when reading config +- earlykdump: provide a prompt message after the rebuilding of kdump initramfs. +- kexec-kdump-howto.txt: Add document about encrypted targets +- kexec-kdump-howto.txt: Add document about initramfs rebiuld +- kdumpctl: Detect block device driver change for initramfs rebuild +- Revert "kdumpctl: Rebuild initramfs if loaded kernel modules changed" +- kexec.rules: create dedicated udev rules for ppc64 +- kexec-kdump-howto: Add note on setting correct value of kptr_restrict +- Update man page for new kdumpctl command: reload / rebuild +- kdumpctl: add rebuild support +- mkdumprd: Improve the config reading logic + * Fri Mar 22 2019 Kairui Song - 2.0.19-1 - Update eppic to latest snapshot - fadump: leverage kernel support to re-regisgter FADump From 43c26b7312f7678722dedd32ee3c9e4085818b17 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 23 May 2019 17:34:05 +0800 Subject: [PATCH 129/806] kdumpctl: Check kdump.conf for error when rebuild is called Although "kdumpctl rebuild" is introduced to help user rebuild the initramfs without modifying the kdump.conf, if the kdump.conf is modified and "kdumpctl rebuild" is called, a initramfs with a faulty kdump.conf will be built. Kdump will refuse to load the initramfs when restarted, but kdumpctl reload may load the faulty initramfs. So need to make sure the faulty build won't be generate in the first place. Check for kdump.conf error before building the initramfs to ensure such failure won't happen. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdumpctl b/kdumpctl index 20afb30..bb61415 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1169,6 +1169,11 @@ stop() } rebuild() { + check_config + if [ $? -ne 0 ]; then + return 1 + fi + setup_initrd if [ $? -ne 0 ]; then return 1 From f0fa5c8e91e7be6bea9bd57e5a7975095e6f3f1b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 27 May 2019 14:46:49 +0800 Subject: [PATCH 130/806] kdumpctl: check for ssh path availability when rebuild Currently kdumpctl rebuild will simply rebuild the initramfs, and only perform basic config syntax check. But it should also check if the target path is available when using SSH target, else kdump may fail. is second kernel. kdumpctl rebuild should cover this case, and create the path if it doesn't exist. This patch make rebuild and restart behaves the same, rebuild is now equal to restart, except it won't check config change or reload kdump resource. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdumpctl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kdumpctl b/kdumpctl index bb61415..a1a6ee2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1174,6 +1174,12 @@ rebuild() { return 1 fi + if check_ssh_config; then + if ! check_ssh_target; then + return 1 + fi + fi + setup_initrd if [ $? -ne 0 ]; then return 1 From 3001788f4c73a68445d6ff4be8a9e972c32a951e Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 27 May 2019 16:59:07 +0530 Subject: [PATCH 131/806] Add aarch64 specific kdump.sysconfig and use 'nr_cpus' instead of 'maxcpus' 'maxcpus' setting normally don't work on several kdump enabled systems due to a known udev issue. Currently the fedora kdump configuration is set as the following on the aarch64 systems: # cat /etc/sysconfig/kdump <..snip..> # This variable lets us append arguments to the current kdump # commandline after processed by KDUMP_COMMANDLINE_REMOVE # KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices" <..snip..> Since the 'maxcpus' setting doesn't limit the number of SMP CPUs, so the kdump kernel still boots with all CPUs available on the system. For e.g on the qualcomm amberwing its 46 CPUs: # lscpu Architecture: aarch64 Byte Order: Little Endian CPU(s): 46 On-line CPU(s) list: 0-45 Thread(s) per core: 1 Core(s) per socket: 46 Socket(s): 1 NUMA node(s): 1 Vendor ID: Qualcomm Model: 1 Model name: Falkor Stepping: 0x0 CPU max MHz: 2600.0000 CPU min MHz: 600.0000 BogoMIPS: 40.00 L1d cache: 32K L1i cache: 64K L2 cache: 512K L3 cache: 58880K NUMA node0 CPU(s): 0-45 Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm This causes the memory consumption in the kdump kernel to swell up and we can end up having OOM issues in the kdump kernel boot. Whereas if we use 'nr_cpus=1' in the bootargs, the number of SMP CPUs in the kdump kernel get limited to 1. The 'swiotlb=noforce' setting in bootargs provide us extra guarding, to ensure the crash kernel size requirements do not swell on systems which support swiotlb. With the above settings, crashkernel boots properly (without OOM) on all the aarch64 boards I could test on - qualcomm amberwings, hp-moonshots and hpe-apache (thunderx2) for crash dump saving on local disk. Signed-off-by: Bhupesh Sharma Acked-by: Pingfan Liu --- kdump.sysconfig.aarch64 | 37 +++++++++++++++++++++++++++++++++++++ kexec-tools.spec | 1 + 2 files changed, 38 insertions(+) create mode 100644 kdump.sysconfig.aarch64 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 new file mode 100644 index 0000000..0a6b14c --- /dev/null +++ b/kdump.sysconfig.aarch64 @@ -0,0 +1,37 @@ +# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump +# If no version is specified, then the init script will try to find a +# kdump kernel with the same version number as the running kernel. +KDUMP_KERNELVER="" + +# The kdump commandline is the command line that needs to be passed off to +# the kdump kernel. This will likely match the contents of the grub kernel +# line. For example: +# KDUMP_COMMANDLINE="ro root=LABEL=/" +# Dracut depends on proper root= options, so please make sure that appropriate +# root= options are copied from /proc/cmdline. In general it is best to append +# command line options using "KDUMP_COMMANDLINE_APPEND=". +# If a command line is not specified, the default will be taken from +# /proc/cmdline +KDUMP_COMMANDLINE="" + +# This variable lets us remove arguments from the current kdump commandline +# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline +# NOTE: some arguments such as crashkernel will always be removed +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" + +# This variable lets us append arguments to the current kdump commandline +# after processed by KDUMP_COMMANDLINE_REMOVE +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 swiotlb=noforce reset_devices" + +# Any additional kexec arguments required. In most situations, this should +# be left empty +# +# Example: +# KEXEC_ARGS="--elf32-core-headers" +KEXEC_ARGS="" + +#Where to find the boot image +#KDUMP_BOOTDIR="/boot" + +#What is the image type used for kdump +KDUMP_IMG="vmlinuz" diff --git a/kexec-tools.spec b/kexec-tools.spec index 67450f8..b19b534 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -33,6 +33,7 @@ Source25: kdumpctl.8 Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler +Source29: kdump.sysconfig.aarch64 ####################################### # These are sources for mkdumpramfs From fd1eccf9200db73bdbc257c9c10809ed1a4a83e0 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 27 May 2019 16:59:08 +0530 Subject: [PATCH 132/806] aarch64/kdump.sysconfig: Make config options similar to x86_64 Looking at the difference of the x86_64 and aarch64 kdump.sysconfig options for Fedora, one can see the following options which are different: Present in kdump.sysconfig.x86_64 but not in kdump.sysconfig.aarch64: --------------------------------------------------------------------- cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr Present in kdump.sysconfig.aarch64 but not in kdump.sysconfig.x86_64: --------------------------------------------------------------------- swiotlb=noforce After going through all the options, it makes sense to add the following options added to kdump.sysconfig.aarch64: KDUMP_COMMANDLINE_APPEND="cgroup_disable=memory udev.children-max=2 panic=10 irqpoll nr_cpus=1 swiotlb=noforce reset_devices" This has helped reduce the memory footprint of crashkernel on several aarch64 machines available in the beaker lab. For e.g. I was seeing OOM issues on large aws ec2 instances with the default crashkernel size of 512M, and I had to use an increased crashkernel size of 786M on the same to boot the crash dump kernel. Signed-off-by: Bhupesh Sharma Acked-by: Pingfan Liu --- kdump.sysconfig.aarch64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 0a6b14c..c72a040 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 swiotlb=noforce reset_devices" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce" # Any additional kexec arguments required. In most situations, this should # be left empty From b1250de3898b8d691f29627cfaf1ec07735fd0c5 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 3 Jun 2019 22:44:02 +0800 Subject: [PATCH 133/806] makedumpfile: x86_64: Add support for AMD Secure Memory Encryption Backport from the makedumpfile devel branch in upstream. commit d222b01e516bba73ef9fefee4146734a5f260fa1 (HEAD -> devel) Author: Lianbo Jiang Date: Wed Jan 30 10:48:53 2019 +0800 [PATCH] x86_64: Add support for AMD Secure Memory Encryption On AMD machine with Secure Memory Encryption (SME) feature, if SME is enabled, page tables contain a specific attribute bit (C-bit) in their entries to indicate whether a page is encrypted or unencrypted. So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of the C-bit position, and drop it to obtain the true physical address. Signed-off-by: Lianbo Jiang Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- ...-support-for-AMD-Secure-Memory-Encry.patch | 198 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 200 insertions(+) create mode 100644 kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch diff --git a/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch b/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch new file mode 100644 index 0000000..662fd27 --- /dev/null +++ b/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch @@ -0,0 +1,198 @@ +From d222b01e516bba73ef9fefee4146734a5f260fa1 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Wed, 30 Jan 2019 10:48:53 +0800 +Subject: [PATCH] [PATCH] x86_64: Add support for AMD Secure Memory Encryption + +On AMD machine with Secure Memory Encryption (SME) feature, if SME is +enabled, page tables contain a specific attribute bit (C-bit) in their +entries to indicate whether a page is encrypted or unencrypted. + +So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of +the C-bit position, and drop it to obtain the true physical address. + +Signed-off-by: Lianbo Jiang +--- + arch/x86_64.c | 30 +++++++++++++++++++----------- + makedumpfile.c | 4 ++++ + makedumpfile.h | 1 + + 3 files changed, 24 insertions(+), 11 deletions(-) + +diff --git a/arch/x86_64.c b/arch/x86_64.c +index 9db1f8139f28..46e93366f0be 100644 +--- a/makedumpfile-1.6.5/arch/x86_64.c ++++ b/makedumpfile-1.6.5/arch/x86_64.c +@@ -297,6 +297,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + unsigned long page_dir, pgd, pud_paddr, pud_pte, pmd_paddr, pmd_pte; + unsigned long pte_paddr, pte; + unsigned long p4d_paddr, p4d_pte; ++ unsigned long entry_mask = ENTRY_MASK; + + /* + * Get PGD. +@@ -308,6 +309,9 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + return NOT_PADDR; + } + ++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) ++ entry_mask &= ~(NUMBER(sme_mask)); ++ + if (check_5level_paging()) { + page_dir += pgd5_index(vaddr) * sizeof(unsigned long); + if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { +@@ -324,7 +328,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + /* + * Get P4D. + */ +- p4d_paddr = pgd & ENTRY_MASK; ++ p4d_paddr = pgd & entry_mask; + p4d_paddr += p4d_index(vaddr) * sizeof(unsigned long); + if (!readmem(PADDR, p4d_paddr, &p4d_pte, sizeof p4d_pte)) { + ERRMSG("Can't get p4d_pte (p4d_paddr:%lx).\n", p4d_paddr); +@@ -337,7 +341,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + ERRMSG("Can't get a valid p4d_pte.\n"); + return NOT_PADDR; + } +- pud_paddr = p4d_pte & ENTRY_MASK; ++ pud_paddr = p4d_pte & entry_mask; + }else { + page_dir += pgd_index(vaddr) * sizeof(unsigned long); + if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { +@@ -351,7 +355,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + ERRMSG("Can't get a valid pgd.\n"); + return NOT_PADDR; + } +- pud_paddr = pgd & ENTRY_MASK; ++ pud_paddr = pgd & entry_mask; + } + + /* +@@ -370,13 +374,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + return NOT_PADDR; + } + if (pud_pte & _PAGE_PSE) /* 1GB pages */ +- return (pud_pte & ENTRY_MASK & PUD_MASK) + ++ return (pud_pte & entry_mask & PUD_MASK) + + (vaddr & ~PUD_MASK); + + /* + * Get PMD. + */ +- pmd_paddr = pud_pte & ENTRY_MASK; ++ pmd_paddr = pud_pte & entry_mask; + pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long); + if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) { + ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr); +@@ -390,13 +394,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + return NOT_PADDR; + } + if (pmd_pte & _PAGE_PSE) /* 2MB pages */ +- return (pmd_pte & ENTRY_MASK & PMD_MASK) + ++ return (pmd_pte & entry_mask & PMD_MASK) + + (vaddr & ~PMD_MASK); + + /* + * Get PTE. + */ +- pte_paddr = pmd_pte & ENTRY_MASK; ++ pte_paddr = pmd_pte & entry_mask; + pte_paddr += pte_index(vaddr) * sizeof(unsigned long); + if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) { + ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr); +@@ -409,7 +413,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) + ERRMSG("Can't get a valid pte.\n"); + return NOT_PADDR; + } +- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr); ++ return (pte & entry_mask) + PAGEOFFSET(vaddr); + } + + unsigned long long +@@ -642,6 +646,7 @@ find_vmemmap_x86_64() + unsigned long pmd, tpfn; + unsigned long pvaddr = 0; + unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0; ++ unsigned long pmask = PMASK; + /* + * data_addr is the paddr of the page holding the page structs. + * We keep lists of contiguous pages and the pfn's that their +@@ -662,6 +667,9 @@ find_vmemmap_x86_64() + return FAILED; + } + ++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) ++ pmask &= ~(NUMBER(sme_mask)); ++ + pagestructsize = size_table.page; + hugepagesize = PTRS_PER_PMD * info->page_size; + vaddr_base = info->vmemmap_start; +@@ -692,7 +700,7 @@ find_vmemmap_x86_64() + } + + /* mask the pgd entry for the address of the pud page */ +- pud_addr &= PMASK; ++ pud_addr &= pmask; + if (pud_addr == 0) + continue; + /* read the entire pud page */ +@@ -705,7 +713,7 @@ find_vmemmap_x86_64() + /* pudp points to an entry in the pud page */ + for (pudp = (unsigned long *)pud_page, pudindex = 0; + pudindex < PTRS_PER_PUD; pudindex++, pudp++) { +- pmd_addr = *pudp & PMASK; ++ pmd_addr = *pudp & pmask; + /* read the entire pmd page */ + if (pmd_addr == 0) + continue; +@@ -747,7 +755,7 @@ find_vmemmap_x86_64() + * - we discontiguous page is a string of valids + */ + if (pmd) { +- data_addr = (pmd & PMASK); ++ data_addr = (pmd & pmask); + if (start_range) { + /* first-time kludge */ + start_data_addr = data_addr; +diff --git a/makedumpfile.c b/makedumpfile.c +index 7dfe70fb8792..590f759c84f1 100644 +--- a/makedumpfile-1.6.5/makedumpfile.c ++++ b/makedumpfile-1.6.5/makedumpfile.c +@@ -993,6 +993,8 @@ next_page: + read_size = MIN(info->page_size - PAGEOFFSET(paddr), size); + + pgaddr = PAGEBASE(paddr); ++ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) ++ pgaddr = pgaddr & ~(NUMBER(sme_mask)); + pgbuf = cache_search(pgaddr, read_size); + if (!pgbuf) { + ++cache_miss; +@@ -2292,6 +2294,7 @@ write_vmcoreinfo_data(void) + WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); + WRITE_NUMBER("N_ONLINE", N_ONLINE); + WRITE_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); ++ WRITE_NUMBER("sme_mask", sme_mask); + + WRITE_NUMBER("PG_lru", PG_lru); + WRITE_NUMBER("PG_private", PG_private); +@@ -2695,6 +2698,7 @@ read_vmcoreinfo(void) + READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); + READ_NUMBER("N_ONLINE", N_ONLINE); + READ_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); ++ READ_NUMBER("sme_mask", sme_mask); + + READ_NUMBER("PG_lru", PG_lru); + READ_NUMBER("PG_private", PG_private); +diff --git a/makedumpfile.h b/makedumpfile.h +index 2e73beca48c5..5ad38e9ae40c 100644 +--- a/makedumpfile-1.6.5/makedumpfile.h ++++ b/makedumpfile-1.6.5/makedumpfile.h +@@ -1913,6 +1913,7 @@ struct number_table { + long NR_FREE_PAGES; + long N_ONLINE; + long pgtable_l5_enabled; ++ long sme_mask; + + /* + * Page flags +-- +2.17.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index b19b534..b642543 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -75,6 +75,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # +Patch101: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -107,6 +108,7 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch601 -p1 +%patch101 -p1 %ifarch ppc %define archdef ARCH=ppc From c4a2ecb6e43efee8829e20cbeb52df9739c79162 Mon Sep 17 00:00:00 2001 From: Vasiliy Glazov Date: Tue, 11 Jun 2019 07:46:47 +0000 Subject: [PATCH 134/806] Add systemd-udev require. It is needed to proper owning of /usr/lib/udev/rules.d directory. --- kexec-tools.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index b642543..73a293f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -66,6 +66,10 @@ BuildRequires: automake autoconf libtool Obsoletes: diskdumputils netdump kexec-tools-eppic %endif +%ifnarch s390x +Requires: systemd-udev%{?_isa} +%endif + #START INSERT # From ace23737ab3478d9fdc5b5ea657541639dbbe0cf Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 13 Jun 2019 11:45:36 +0800 Subject: [PATCH 135/806] dracut-kdump-capture.service: Use OnFailureJobMode instead of deprecated OnFailureIsolate systemd has the following message "OnFailureIsolate is deprecated. Please use OnFailureJobMode= instead" Changing the file to meet systemd's requirement Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-kdump-capture.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service index 57139c9..3f20aba 100644 --- a/dracut-kdump-capture.service +++ b/dracut-kdump-capture.service @@ -12,7 +12,7 @@ After=dracut-initqueue.service dracut-pre-mount.service dracut-mount.service dra Before=initrd-cleanup.service ConditionPathExists=/etc/initrd-release OnFailure=emergency.target -OnFailureIsolate=yes +OnFailureJobMode=isolate [Service] Environment=DRACUT_SYSTEMD=1 From b998b9019740efcfb8c858fdcfb8f77ac2ad99d5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 1 Jul 2019 19:48:13 +0800 Subject: [PATCH 136/806] kdump.sysconfig/x86_64: Disable HEST by default Some firmware will provide a ACPI HEST table with massive amount of entries, and the way how kernel handles these entries will consume a lot of memory which will lead to OOM issue in kdump kernel. During testing on certain machine, disable HEST saved ~60M of memory. Kdump is only for emergency use in case of a kernel panic, so temporarily disable hardware error report & recovery related feature is acceptable in general. So disable HEST support in kdump kernel to save memory. Currently such issue is only observed on x86_64, so limit this change to x86_64 only. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump.sysconfig.x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 4a5ec1c..17ae5e6 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable" # Any additional kexec arguments required. In most situations, this should # be left empty From 5b26c1f8b23f19d523fca27f1b75c5fa4973615b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 28 Jun 2019 21:44:03 +0800 Subject: [PATCH 137/806] Forward logs in kdump kernel to console directly Don't use any log storage and forward to console directly, this make console output more useful, and also save more memory. On a fresh installed Fedora 30 it saved ~5M of memory, and the amount of log being printed to console is still accetable. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2998c72..07200b7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -822,4 +822,11 @@ install() { echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf fi + + # Forward logs to console directly, this avoids unneccessary memory + # consumption and make console output more useful + mkdir -p ${initdir}/etc/systemd/journald.conf.d + echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf } From cf5d362dca1bf957a22553296243f86082f392ce Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 14 Jun 2019 15:49:42 +0800 Subject: [PATCH 138/806] dracut-module-setup.sh: Don't use squash module for fadump Squash module is used to save memory. For fadump this is not neccessary and may slow down the build time, and make it more fragile. fadump initramfs is used for normal boot as well, although squash module is capable of being used for generic normal boot, but there are cases where is doesn't work well. So disable it and make fadump more robust. Signed-off-by: Kairui Song Tested-by: Hari Bathini Acked-by: Dave Young --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 07200b7..27b9f02 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -30,7 +30,7 @@ depends() { done } - if is_squash_available; then + if is_squash_available && ! is_fadump_capable; then _dep="$_dep squash" else dwarning "Required modules to build a squashed kdump image is missing!" From 603cd09b76584a1e3a2363f939cec0b7e29e52fb Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jul 2019 11:23:07 +0000 Subject: [PATCH 139/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index b642543..7973b93 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -3,7 +3,7 @@ Name: kexec-tools Version: 2.0.19 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -336,6 +336,9 @@ done %endif %changelog +* Thu Jul 25 2019 Fedora Release Engineering - 2.0.19-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Mon May 20 2019 Kairui Song - 2.0.19-2 - kdumpctl: don't always rebuild when extra_modules is set - kdumpctl: follow symlink when checking for modified files From 17981c14eca00839627597da138e353a5b86dba4 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 31 Jul 2019 01:07:35 +0800 Subject: [PATCH 140/806] kexec-tools.spec: Use a macro for makedumpfile version Don't repeat it again and again and make it easier to maintain. Signed-off-by: Kairui Song --- kexec-tools.spec | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 7973b93..34ca2a4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,5 +1,6 @@ %global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) +%global mkdf_ver 1.6.5 Name: kexec-tools Version: 2.0.19 @@ -15,7 +16,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.5/makedumpfile-1.6.5.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/%{mkdf_ver}/makedumpfile-%{mkdf_ver}.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source13: 98-kexec.rules @@ -136,8 +137,8 @@ cp %{SOURCE27} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic-%{eppic_ver}/libeppic -make -C makedumpfile-1.6.5 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.5 LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so +make -C makedumpfile-%{mkdf_ver} LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so %endif %install @@ -188,13 +189,13 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.5/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile -install -m 644 makedumpfile-1.6.5/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.5/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.5/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.5/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.5/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') From 4b7198f6512287836c2f3b39603125196fcab447 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 31 Jul 2019 01:09:59 +0800 Subject: [PATCH 141/806] Update makedumpfile to 1.6.6 Signed-off-by: Kairui Song --- ...es-honor-the-CFLAGS-from-environment.patch | 41 ---- ...-support-for-AMD-Secure-Memory-Encry.patch | 198 ------------------ kexec-tools.spec | 7 +- sources | 2 +- 4 files changed, 2 insertions(+), 246 deletions(-) delete mode 100644 kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch delete mode 100644 kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch diff --git a/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch b/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch deleted file mode 100644 index e4052fa..0000000 --- a/kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 2f007b48c581a81d7e95678b6bcb77cfbe177135 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Tue, 29 Jan 2019 11:14:15 +0800 -Subject: [PATCH] [PATCH v2] honor the CFLAGS from environment variables - -This makes it possible to pass in extra cflags, for example, hardening -flags could be passed in with environment variable when building a -hardened package. - -Also introduce a CFLAGS_BASE to hold common CFLAGS, which simplify the -CFLAGS definition. - -Suggested-by: Kazuhito Hagio -Signed-off-by: Kairui Song ---- - Makefile | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/Makefile b/Makefile -index ea3c47d..bd681d2 100644 ---- a/makedumpfile-1.6.5/Makefile -+++ b/makedumpfile-1.6.5/Makefile -@@ -8,11 +8,10 @@ ifeq ($(strip $CC),) - CC = gcc - endif - --CFLAGS = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \ -- -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' --CFLAGS_ARCH = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -+CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -+ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -+CFLAGS := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' -+CFLAGS_ARCH := $(CFLAGS_BASE) - # LDFLAGS = -L/usr/local/lib -I/usr/local/include - - HOST_ARCH := $(shell uname -m) --- -2.20.1 - diff --git a/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch b/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch deleted file mode 100644 index 662fd27..0000000 --- a/kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch +++ /dev/null @@ -1,198 +0,0 @@ -From d222b01e516bba73ef9fefee4146734a5f260fa1 Mon Sep 17 00:00:00 2001 -From: Lianbo Jiang -Date: Wed, 30 Jan 2019 10:48:53 +0800 -Subject: [PATCH] [PATCH] x86_64: Add support for AMD Secure Memory Encryption - -On AMD machine with Secure Memory Encryption (SME) feature, if SME is -enabled, page tables contain a specific attribute bit (C-bit) in their -entries to indicate whether a page is encrypted or unencrypted. - -So get NUMBER(sme_mask) from vmcoreinfo, which stores the value of -the C-bit position, and drop it to obtain the true physical address. - -Signed-off-by: Lianbo Jiang ---- - arch/x86_64.c | 30 +++++++++++++++++++----------- - makedumpfile.c | 4 ++++ - makedumpfile.h | 1 + - 3 files changed, 24 insertions(+), 11 deletions(-) - -diff --git a/arch/x86_64.c b/arch/x86_64.c -index 9db1f8139f28..46e93366f0be 100644 ---- a/makedumpfile-1.6.5/arch/x86_64.c -+++ b/makedumpfile-1.6.5/arch/x86_64.c -@@ -297,6 +297,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - unsigned long page_dir, pgd, pud_paddr, pud_pte, pmd_paddr, pmd_pte; - unsigned long pte_paddr, pte; - unsigned long p4d_paddr, p4d_pte; -+ unsigned long entry_mask = ENTRY_MASK; - - /* - * Get PGD. -@@ -308,6 +309,9 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ entry_mask &= ~(NUMBER(sme_mask)); -+ - if (check_5level_paging()) { - page_dir += pgd5_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { -@@ -324,7 +328,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - /* - * Get P4D. - */ -- p4d_paddr = pgd & ENTRY_MASK; -+ p4d_paddr = pgd & entry_mask; - p4d_paddr += p4d_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, p4d_paddr, &p4d_pte, sizeof p4d_pte)) { - ERRMSG("Can't get p4d_pte (p4d_paddr:%lx).\n", p4d_paddr); -@@ -337,7 +341,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid p4d_pte.\n"); - return NOT_PADDR; - } -- pud_paddr = p4d_pte & ENTRY_MASK; -+ pud_paddr = p4d_pte & entry_mask; - }else { - page_dir += pgd_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, page_dir, &pgd, sizeof pgd)) { -@@ -351,7 +355,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid pgd.\n"); - return NOT_PADDR; - } -- pud_paddr = pgd & ENTRY_MASK; -+ pud_paddr = pgd & entry_mask; - } - - /* -@@ -370,13 +374,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - if (pud_pte & _PAGE_PSE) /* 1GB pages */ -- return (pud_pte & ENTRY_MASK & PUD_MASK) + -+ return (pud_pte & entry_mask & PUD_MASK) + - (vaddr & ~PUD_MASK); - - /* - * Get PMD. - */ -- pmd_paddr = pud_pte & ENTRY_MASK; -+ pmd_paddr = pud_pte & entry_mask; - pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof pmd_pte)) { - ERRMSG("Can't get pmd_pte (pmd_paddr:%lx).\n", pmd_paddr); -@@ -390,13 +394,13 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - return NOT_PADDR; - } - if (pmd_pte & _PAGE_PSE) /* 2MB pages */ -- return (pmd_pte & ENTRY_MASK & PMD_MASK) + -+ return (pmd_pte & entry_mask & PMD_MASK) + - (vaddr & ~PMD_MASK); - - /* - * Get PTE. - */ -- pte_paddr = pmd_pte & ENTRY_MASK; -+ pte_paddr = pmd_pte & entry_mask; - pte_paddr += pte_index(vaddr) * sizeof(unsigned long); - if (!readmem(PADDR, pte_paddr, &pte, sizeof pte)) { - ERRMSG("Can't get pte (pte_paddr:%lx).\n", pte_paddr); -@@ -409,7 +413,7 @@ __vtop4_x86_64(unsigned long vaddr, unsigned long pagetable) - ERRMSG("Can't get a valid pte.\n"); - return NOT_PADDR; - } -- return (pte & ENTRY_MASK) + PAGEOFFSET(vaddr); -+ return (pte & entry_mask) + PAGEOFFSET(vaddr); - } - - unsigned long long -@@ -642,6 +646,7 @@ find_vmemmap_x86_64() - unsigned long pmd, tpfn; - unsigned long pvaddr = 0; - unsigned long data_addr = 0, last_data_addr = 0, start_data_addr = 0; -+ unsigned long pmask = PMASK; - /* - * data_addr is the paddr of the page holding the page structs. - * We keep lists of contiguous pages and the pfn's that their -@@ -662,6 +667,9 @@ find_vmemmap_x86_64() - return FAILED; - } - -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ pmask &= ~(NUMBER(sme_mask)); -+ - pagestructsize = size_table.page; - hugepagesize = PTRS_PER_PMD * info->page_size; - vaddr_base = info->vmemmap_start; -@@ -692,7 +700,7 @@ find_vmemmap_x86_64() - } - - /* mask the pgd entry for the address of the pud page */ -- pud_addr &= PMASK; -+ pud_addr &= pmask; - if (pud_addr == 0) - continue; - /* read the entire pud page */ -@@ -705,7 +713,7 @@ find_vmemmap_x86_64() - /* pudp points to an entry in the pud page */ - for (pudp = (unsigned long *)pud_page, pudindex = 0; - pudindex < PTRS_PER_PUD; pudindex++, pudp++) { -- pmd_addr = *pudp & PMASK; -+ pmd_addr = *pudp & pmask; - /* read the entire pmd page */ - if (pmd_addr == 0) - continue; -@@ -747,7 +755,7 @@ find_vmemmap_x86_64() - * - we discontiguous page is a string of valids - */ - if (pmd) { -- data_addr = (pmd & PMASK); -+ data_addr = (pmd & pmask); - if (start_range) { - /* first-time kludge */ - start_data_addr = data_addr; -diff --git a/makedumpfile.c b/makedumpfile.c -index 7dfe70fb8792..590f759c84f1 100644 ---- a/makedumpfile-1.6.5/makedumpfile.c -+++ b/makedumpfile-1.6.5/makedumpfile.c -@@ -993,6 +993,8 @@ next_page: - read_size = MIN(info->page_size - PAGEOFFSET(paddr), size); - - pgaddr = PAGEBASE(paddr); -+ if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -+ pgaddr = pgaddr & ~(NUMBER(sme_mask)); - pgbuf = cache_search(pgaddr, read_size); - if (!pgbuf) { - ++cache_miss; -@@ -2292,6 +2294,7 @@ write_vmcoreinfo_data(void) - WRITE_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); - WRITE_NUMBER("N_ONLINE", N_ONLINE); - WRITE_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); -+ WRITE_NUMBER("sme_mask", sme_mask); - - WRITE_NUMBER("PG_lru", PG_lru); - WRITE_NUMBER("PG_private", PG_private); -@@ -2695,6 +2698,7 @@ read_vmcoreinfo(void) - READ_NUMBER("NR_FREE_PAGES", NR_FREE_PAGES); - READ_NUMBER("N_ONLINE", N_ONLINE); - READ_NUMBER("pgtable_l5_enabled", pgtable_l5_enabled); -+ READ_NUMBER("sme_mask", sme_mask); - - READ_NUMBER("PG_lru", PG_lru); - READ_NUMBER("PG_private", PG_private); -diff --git a/makedumpfile.h b/makedumpfile.h -index 2e73beca48c5..5ad38e9ae40c 100644 ---- a/makedumpfile-1.6.5/makedumpfile.h -+++ b/makedumpfile-1.6.5/makedumpfile.h -@@ -1913,6 +1913,7 @@ struct number_table { - long NR_FREE_PAGES; - long N_ONLINE; - long pgtable_l5_enabled; -+ long sme_mask; - - /* - * Page flags --- -2.17.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 34ca2a4..3c4371c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ %global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.6.5 +%global mkdf_ver 1.6.6 Name: kexec-tools Version: 2.0.19 @@ -76,7 +76,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # -Patch101: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Memory-Encry.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -92,7 +91,6 @@ Patch101: kexec-tools-2.0.19-makedumpfiles-x86_64-Add-support-for-AMD-Secure-Mem # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.18-makedumpfiles-honor-the-CFLAGS-from-environment.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -108,9 +106,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch601 -p1 -%patch101 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif diff --git a/sources b/sources index 6e740dd..d6bb213 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (makedumpfile-1.6.5.tar.gz) = bfbf9b373d435857530121f29fb3915cb263cfbaa2b877684a8cde2e8cd8b73fc2f02ffdf9b9108613d42aab7e5653877b092846545ceab865e9909e86145970 SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d SHA512 (kexec-tools-2.0.19.tar.xz) = 68b15fe46f9633d55c5ae51a6e7114b0c66bd8f4fe81197f581121939a7b21990a2eea89a0961ac6eb7af364ba0d3981ea504df81c7b4cc0b288ca6ac896730f +SHA512 (makedumpfile-1.6.6.tar.gz) = f4926d7800fe21b9125c03b8ce043e7cc3420b997a7d9f4ce7b565cde7f5b4aaf9ac958dbbefe5868ee3cb639ccb2d40c10f774ac2720baeac2242fc0bf66df2 From 03fd19454ba724f40b2306c6388dd03fcea23486 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 31 Jul 2019 15:54:00 +0800 Subject: [PATCH 142/806] Release 2.0.20-1 Rebase to latest upstream and make a release Signed-off-by: Kairui Song --- kexec-tools.spec | 16 ++++++++++++++-- sources | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3c4371c..56fede7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -3,8 +3,8 @@ %global mkdf_ver 1.6.6 Name: kexec-tools -Version: 2.0.19 -Release: 3%{?dist} +Version: 2.0.20 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -332,6 +332,18 @@ done %endif %changelog +* Wed Jul 31 2019 Kairui Song - 2.0.20-1 +- Update makedumpfile to 1.6.6 +- dracut-module-setup.sh: Don't use squash module for fadump +- Forward logs in kdump kernel to console directly +- kdump.sysconfig/x86_64: Disable HEST by default +- dracut-kdump-capture.service: Use OnFailureJobMode instead of deprecated OnFailureIsolate +- makedumpfile: x86_64: Add support for AMD Secure Memory Encryption +- aarch64/kdump.sysconfig: Make config options similar to x86_64 +- Add aarch64 specific kdump.sysconfig and use 'nr_cpus' instead of 'maxcpus' +- kdumpctl: check for ssh path availability when rebuild +- kdumpctl: Check kdump.conf for error when rebuild is called + * Thu Jul 25 2019 Fedora Release Engineering - 2.0.19-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild diff --git a/sources b/sources index d6bb213..1d5c7d0 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d -SHA512 (kexec-tools-2.0.19.tar.xz) = 68b15fe46f9633d55c5ae51a6e7114b0c66bd8f4fe81197f581121939a7b21990a2eea89a0961ac6eb7af364ba0d3981ea504df81c7b4cc0b288ca6ac896730f SHA512 (makedumpfile-1.6.6.tar.gz) = f4926d7800fe21b9125c03b8ce043e7cc3420b997a7d9f4ce7b565cde7f5b4aaf9ac958dbbefe5868ee3cb639ccb2d40c10f774ac2720baeac2242fc0bf66df2 +SHA512 (kexec-tools-2.0.20.tar.xz) = 3112b6202c1030705c53e3f65a2b58aec14d65333a35aad681d48b9f2bd1c51a2e05c985a1e5e867ab02f8a9c97708483d9d225619db7c6993676f1a242e2d99 From 88bbab963f11a71aae2f7cff224ce0f5038111a8 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 1 Aug 2019 10:34:05 +0800 Subject: [PATCH 143/806] dracut-module-setup.sh: skip alias of localhost in get_pcs_fence_kdump_nodes() The current code only exclude the hostname, while localhost can have alias in /etc/hosts. All of the alias should be excluded from the fence dump node to avoid deadlock issue. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 27b9f02..9ef6021 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,6 +689,21 @@ kdump_check_iscsi_targets () { } } +is_localhost() { + local hostnames=$(hostname -A) + local shortnames=$(hostname -A -s) + local nodename=$1 + + hostnames="$hostnames $shortnames" + + for name in ${hostnames}; do + if [ "$name" == "$nodename" ]; then + return 0 + fi + done + return 1 +} + # retrieves fence_kdump nodes from Pacemaker cluster configuration get_pcs_fence_kdump_nodes() { local nodes @@ -703,7 +718,7 @@ get_pcs_fence_kdump_nodes() { eval $node nodename=$uname # Skip its own node name - if [ "$nodename" = `hostname` -o "$nodename" = `hostname -s` ]; then + if is_localhost $nodename; then continue fi nodes="$nodes $nodename" From cb1e5463b5298b064e9b6c86ad6fe3505fec9298 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 2 Aug 2019 11:23:15 +0800 Subject: [PATCH 144/806] x86: Fix broken multiboot2 buliding for i386 When building for i386, an error occured: kexec/arch/i386/kexec-x86.c:39:22: error: 'multiboot2_x86_probe' undeclared here (not in a function); did you mean 'multiboot_x86_probe'? 39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, | ^~~~~~~~~~~~~~~~~~~~ | multiboot_x86_probe kexec/arch/i386/kexec-x86.c:39:44: error: 'multiboot2_x86_load' undeclared here (not in a function); did you mean 'multiboot_x86_load'? 39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, | ^~~~~~~~~~~~~~~~~~~ | multiboot_x86_load kexec/arch/i386/kexec-x86.c:40:4: error: 'multiboot2_x86_usage' undeclared here (not in a function); did you mean 'multiboot_x86_usage'? 40 | multiboot2_x86_usage }, | ^~~~~~~~~~~~~~~~~~~~ | multiboot_x86_usage Fix this issue by putting the definition in the right header, also tidy up Makefile. Signed-off-by: Kairui Song --- ...-broken-multiboot2-buliding-for-i386.patch | 88 +++++++++++++++++++ kexec-tools.spec | 5 +- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch diff --git a/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch b/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch new file mode 100644 index 0000000..3f0fb33 --- /dev/null +++ b/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch @@ -0,0 +1,88 @@ +From 940c3a1e1a304fbecc850c593a272215b0f52eab Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 31 Jul 2019 16:30:47 +0800 +Subject: [PATCH] x86: Fix broken multiboot2 buliding for i386 + +When building for i386, an error occured: + +kexec/arch/i386/kexec-x86.c:39:22: error: 'multiboot2_x86_probe' +undeclared here (not in a function); did you mean 'multiboot_x86_probe'? +39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, + | ^~~~~~~~~~~~~~~~~~~~ + | multiboot_x86_probe + +kexec/arch/i386/kexec-x86.c:39:44: error: 'multiboot2_x86_load' +undeclared here (not in a function); did you mean 'multiboot_x86_load'? +39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, + | ^~~~~~~~~~~~~~~~~~~ + | multiboot_x86_load +kexec/arch/i386/kexec-x86.c:40:4: error: 'multiboot2_x86_usage' + undeclared here (not in a function); did you mean 'multiboot_x86_usage'? +40 | multiboot2_x86_usage }, + | ^~~~~~~~~~~~~~~~~~~~ + | multiboot_x86_usage + +Fix this issue by putting the definition in the right header, also tidy +up Makefile. + +Fixes: 22a2ed55132e ("x86: Support multiboot2 images") +Signed-off-by: Kairui Song +--- + kexec/arch/i386/Makefile | 2 +- + kexec/arch/i386/kexec-x86.h | 5 +++++ + kexec/arch/x86_64/kexec-x86_64.h | 5 ----- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/kexec/arch/i386/Makefile b/kexec/arch/i386/Makefile +index 105cefd..f486103 100644 +--- a/kexec/arch/i386/Makefile ++++ b/kexec/arch/i386/Makefile +@@ -7,6 +7,7 @@ i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c + i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c + i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c + i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c ++i386_KEXEC_SRCS += kexec/arch/i386/kexec-mb2-x86.c + i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c + i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c + i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c +@@ -14,7 +15,6 @@ i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c + + dist += kexec/arch/i386/Makefile $(i386_KEXEC_SRCS) \ + kexec/arch/i386/crashdump-x86.h \ +- kexec/arch/i386/kexec-mb2-x86.c \ + kexec/arch/i386/kexec-x86.h \ + kexec/arch/i386/x86-linux-setup.h \ + kexec/arch/i386/include/arch/options.h +diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h +index 1b58c3b..16d0f6c 100644 +--- a/kexec/arch/i386/kexec-x86.h ++++ b/kexec/arch/i386/kexec-x86.h +@@ -60,6 +60,11 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info); + void multiboot_x86_usage(void); + ++int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len, ++ struct kexec_info *info); ++void multiboot2_x86_usage(void); ++int multiboot2_x86_probe(const char *buf, off_t buf_len); ++ + int elf_x86_probe(const char *buf, off_t len); + int elf_x86_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info); +diff --git a/kexec/arch/x86_64/kexec-x86_64.h b/kexec/arch/x86_64/kexec-x86_64.h +index 21c3a73..4cdeffb 100644 +--- a/kexec/arch/x86_64/kexec-x86_64.h ++++ b/kexec/arch/x86_64/kexec-x86_64.h +@@ -33,9 +33,4 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info); + void bzImage64_usage(void); + +-int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len, +- struct kexec_info *info); +-void multiboot2_x86_usage(void); +-int multiboot2_x86_probe(const char *buf, off_t buf_len); +- + #endif /* KEXEC_X86_64_H */ +-- +2.21.0 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 56fede7..4000cf5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -72,6 +72,7 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # # Patches 0 through 100 are meant for x86 kexec-tools enablement # +Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement @@ -100,12 +101,14 @@ binary and ancillary utilities that together form the userspace component of the kernel's kexec feature. %prep -%setup -q +%setup -q mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch0 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 80de7235664c0b55487ac5e7302458f091fe2c92 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 2 Aug 2019 14:50:18 +0800 Subject: [PATCH 145/806] Release 2.0.20-2 Signed-off-by: Kairui Song --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 4000cf5..0c82769 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -335,6 +335,10 @@ done %endif %changelog +* Fri Aug 02 2019 Kairui Song - 2.0.20-2 +- x86: Fix broken multiboot2 buliding for i386 +- dracut-module-setup.sh: skip alias of localhost in get_pcs_fence_kdump_nodes() + * Wed Jul 31 2019 Kairui Song - 2.0.20-1 - Update makedumpfile to 1.6.6 - dracut-module-setup.sh: Don't use squash module for fadump From 4a0f9763c006152bb5c677b2cfa8c1bb0ca6a032 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 5 Aug 2019 14:34:04 +0800 Subject: [PATCH 146/806] Don't forward and drop journalctl logs for fadump fadump will alter the normal boot initramfs and we don't want a normal boot to foward and drop the journalctl logs. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 9ef6021..3fa696d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -839,9 +839,12 @@ install() { fi # Forward logs to console directly, this avoids unneccessary memory - # consumption and make console output more useful - mkdir -p ${initdir}/etc/systemd/journald.conf.d - echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + # consumption and make console output more useful. + # Only do so for non fadump image. + if ! is_fadump_capable; then + mkdir -p ${initdir}/etc/systemd/journald.conf.d + echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + fi } From 076b839dd47b51530b708234db8f0bc3a49a38b0 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Fri, 2 Aug 2019 10:59:37 -0400 Subject: [PATCH 147/806] makedumpfile: Do not proceed when get_num_dumpable_cyclic() fails Backport from the makedumpfile devel branch in upstream. commit c1b834f80311706db2b5070cbccdcba3aacc90e5 Author: Kazuhito Hagio Date: Tue Jul 23 11:50:52 2019 -0400 [PATCH] Do not proceed when get_num_dumpable_cyclic() fails Currently, when get_num_dumpable_cyclic() fails and returns FALSE in create_dump_bitmap(), info->num_dumpable is set to 0 and makedumpfile proceeds to write a broken dumpfile slowly with incorrect progress indicator due to the value. It should not proceed when get_num_dumpable_cyclic() fails. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Dave Young Acked-by: Kairui Song --- ...d-when-get_num_dumpable_cyclic-fails.patch | 44 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 46 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch b/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch new file mode 100644 index 0000000..4cbdfa1 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch @@ -0,0 +1,44 @@ +From c1b834f80311706db2b5070cbccdcba3aacc90e5 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 23 Jul 2019 11:50:52 -0400 +Subject: [PATCH 1/2] Do not proceed when get_num_dumpable_cyclic() fails + +Currently, when get_num_dumpable_cyclic() fails and returns FALSE in +create_dump_bitmap(), info->num_dumpable is set to 0 and makedumpfile +proceeds to write a broken dumpfile slowly with incorrect progress +indicator due to the value. + +It should not proceed when get_num_dumpable_cyclic() fails. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index d76a4358a2b2..88df788fd6e7 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -7344,7 +7344,8 @@ create_dump_bitmap(void) + if (!prepare_bitmap2_buffer()) + goto out; + +- info->num_dumpable = get_num_dumpable_cyclic(); ++ if (!(info->num_dumpable = get_num_dumpable_cyclic())) ++ goto out; + + if (!info->flag_elf_dumpfile) + free_bitmap2_buffer(); +@@ -7362,7 +7363,8 @@ create_dump_bitmap(void) + if (!create_2nd_bitmap(&cycle)) + goto out; + +- info->num_dumpable = get_num_dumpable_cyclic(); ++ if (!(info->num_dumpable = get_num_dumpable_cyclic())) ++ goto out; + } + + ret = TRUE; +-- +2.18.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 0c82769..d4ab5a7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -92,6 +92,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 601 onward are generic patches # +Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -108,6 +109,7 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch0 -p1 +%patch601 -p1 %ifarch ppc %define archdef ARCH=ppc From 15f6d2627ff9be8e3e3cc7dc35606c7381787086 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Fri, 2 Aug 2019 10:59:38 -0400 Subject: [PATCH 148/806] makedumpfile: Increase SECTION_MAP_LAST_BIT to 4 Backport from the makedumpfile devel branch in upstream. commit 7bdb468c2c99dd780c9a5321f93c79cbfdce2527 Author: Kazuhito Hagio Date: Tue Jul 23 12:24:47 2019 -0400 [PATCH] Increase SECTION_MAP_LAST_BIT to 4 kernel commit 326e1b8f83a4 ("mm/sparsemem: introduce a SECTION_IS_EARLY flag") added the flag to mem_section->section_mem_map value, and it caused makedumpfile an error like the following: readmem: Can't convert a virtual address(fffffc97d1000000) to physical address. readmem: type_addr: 0, addr:fffffc97d1000000, size:32768 __exclude_unnecessary_pages: Can't read the buffer of struct page. create_2nd_bitmap: Can't exclude unnecessary pages. To fix this, SECTION_MAP_LAST_BIT needs to be updated. The bit has not been used until the addition, so we can just increase the value. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Dave Young Acked-by: Kairui Song --- ...e-Increase-SECTION_MAP_LAST_BIT-to-4.patch | 38 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 40 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch b/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch new file mode 100644 index 0000000..050d83c --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch @@ -0,0 +1,38 @@ +From 7bdb468c2c99dd780c9a5321f93c79cbfdce2527 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 23 Jul 2019 12:24:47 -0400 +Subject: [PATCH 2/2] Increase SECTION_MAP_LAST_BIT to 4 + +kernel commit 326e1b8f83a4 ("mm/sparsemem: introduce a SECTION_IS_EARLY +flag") added the flag to mem_section->section_mem_map value, and it caused +makedumpfile an error like the following: + + readmem: Can't convert a virtual address(fffffc97d1000000) to physical address. + readmem: type_addr: 0, addr:fffffc97d1000000, size:32768 + __exclude_unnecessary_pages: Can't read the buffer of struct page. + create_2nd_bitmap: Can't exclude unnecessary pages. + +To fix this, SECTION_MAP_LAST_BIT needs to be updated. The bit has not +been used until the addition, so we can just increase the value. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile.h b/makedumpfile.h +index 24b2f69f400c..df745b9f53e5 100644 +--- a/makedumpfile-1.6.6/makedumpfile.h ++++ b/makedumpfile-1.6.6/makedumpfile.h +@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) + * 2. it has been verified that (1UL<<2) was never set, so it is + * safe to mask that bit off even in old kernels. + */ +-#define SECTION_MAP_LAST_BIT (1UL<<3) ++#define SECTION_MAP_LAST_BIT (1UL<<4) + #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) + #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) + #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) +-- +2.18.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index d4ab5a7..eb6fe29 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -93,6 +93,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch +Patch602: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -110,6 +111,7 @@ tar -z -x -v -f %{SOURCE19} %patch0 -p1 %patch601 -p1 +%patch602 -p1 %ifarch ppc %define archdef ARCH=ppc From c1a06343df3a7bd6b43c21be18d7a406a3951ce3 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 12 Aug 2019 16:07:39 +0800 Subject: [PATCH 149/806] kdumpctl: wait a while for network ready if dump target is ssh If dump target is ipv6 address, a host should have ipv6 address ready before starting kdump service. Otherwise, kdump service fails to start due to the failure "ssh dump_server_ip mkdir -p $SAVE_PATH". And user can see message like: "Could not create root@2620:52:0:10da:46a8:42ff:fe23:3272/var/crash" I observe a long period (about 30s) on some machine before they got ipv6 address dynamiclly, which is never seen on ipv4 host. Hence kdump service has a dependency on ipv6 address. But there is no good way to resolve it. One way is asking user to run the cmd "nmcli connection modify eth0 ipv6.may-fail false". But this will block systemd until ipv6 address is ready. Despite doing so, kdump can try its best (wait 1 minutes after it starts up) before failure. How to implement the wait is arguable. It will involve too many technique details if explicitly waiting on ipv6 address, instead, just lean on 'ssh' return value to see the availability of network. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/kdumpctl b/kdumpctl index a1a6ee2..2f2d819 100755 --- a/kdumpctl +++ b/kdumpctl @@ -730,12 +730,39 @@ check_ssh_config() return 0 } +# ipv6 host address may takes a long time to be ready. +# Instead of checking against ipv6 address, we just check the network reachable +# by the return val of 'ssh' +check_and_wait_network_ready() +{ + local start_time=$(date +%s) + local cur + local diff + + while true; do + ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH + # ssh exits with the exit status of the remote command or with 255 if an error occurred + if [ $? -eq 0 ]; then + return 0 + elif [ $? -ne 255 ]; then + return 1 + fi + cur=$(date +%s) + diff=$( $cur - $start_time ) + # 60s time out + if [ $diff -gt 60 ]; then + break; + fi + sleep 1 + done + + return 1 +} + check_ssh_target() { - local _ret - ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH - _ret=$? - if [ $_ret -ne 0 ]; then + check_and_wait_network_ready + if [ $? -ne 0 ]; then echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 return 1 fi From d9c0c2f68f1d2a8fb85ee21d95bd30be92161331 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 12 Aug 2019 18:08:12 +0800 Subject: [PATCH 150/806] Release 2.0.20-3 Signed-off-by: Kairui Song --- kexec-tools.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index eb6fe29..71898da 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -339,6 +339,12 @@ done %endif %changelog +* Mon Aug 12 2019 Kairui Song - 2.0.20-3 +- kdumpctl: wait a while for network ready if dump target is ssh +- makedumpfile: Increase SECTION_MAP_LAST_BIT to 4 +- makedumpfile: Do not proceed when get_num_dumpable_cyclic() fails +- Don't forward and drop journalctl logs for fadump + * Fri Aug 02 2019 Kairui Song - 2.0.20-2 - x86: Fix broken multiboot2 buliding for i386 - dracut-module-setup.sh: skip alias of localhost in get_pcs_fence_kdump_nodes() From f0b5493b2e224131e916c6e3ee706144baddee96 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 26 Aug 2019 17:03:12 +0800 Subject: [PATCH 151/806] dracut-module-setup: get localhost alias by manual 'hostname -A' can not get the alias, meanwhile 'hostname -a' is deprecated. So we should do it by ourselves. The parsing is based on the format of /etc/hosts, i.e. IP_address canonical_hostname [aliases...] Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3fa696d..7333047 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,12 +689,31 @@ kdump_check_iscsi_targets () { } } +# hostname -a is deprecated, do it by ourself +get_alias() { + local ips + local entries + local alias_set + + ips=$(hostname -I) + for ip in $ips + do + entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0 }') + if [ $? -eq 0 ]; then + alias_set="$alias_set $entries" + fi + done + + echo $alias_set +} + is_localhost() { local hostnames=$(hostname -A) local shortnames=$(hostname -A -s) + local aliasname=$(get_alias) local nodename=$1 - hostnames="$hostnames $shortnames" + hostnames="$hostnames $shortnames $aliasname" for name in ${hostnames}; do if [ "$name" == "$nodename" ]; then From a5ea190af28ebcba186a4f83e6e25356cc459207 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 26 Aug 2019 17:03:13 +0800 Subject: [PATCH 152/806] dracut-module-setup: filter out localhost for generic_fence_kdump The localhost is filtered out in case of is_pcs_fence_kdump, do it too in case of is_generic_fence_kdump. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7333047..a995dfc 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -754,6 +754,21 @@ get_pcs_fence_kdump_args() { fi } +get_generic_fence_kdump_nodes() { + local filtered + local nodes + + nodes=$(get_option_value "fence_kdump_nodes") + for node in ${nodes}; do + # Skip its own node name + if is_localhost $node; then + continue + fi + filtered="$filtered $node" + done + echo $filtered +} + # setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { @@ -762,7 +777,7 @@ kdump_configure_fence_kdump () { local args if is_generic_fence_kdump; then - nodes=$(get_option_value "fence_kdump_nodes") + nodes=$(get_generic_fence_kdump_nodes) elif is_pcs_fence_kdump; then nodes=$(get_pcs_fence_kdump_nodes) From 75297d6f202143f5b1528571ace8980c301044b4 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 21 Aug 2019 10:59:49 +0800 Subject: [PATCH 153/806] dracut-module-setup: fix bond ifcfg processing Bond options in ifcfg is space separated, dracut expected it to be comma separated, so it have to be parsed and converted during initramfs building. The currently parsing and convert pattern is flawed, for example: " downdelay=0 miimon=100 mode=802.3ad updelay=0 " is converted to : ":,downdelay=0 miimon=100 mode=802.3ad updelay=0 " should be: ":downdelay=0,miimon=100,mode=802.3ad,updelay=0" So fix this issue by using more simple but robust method for processing the options. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a995dfc..b186b38 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -264,7 +264,7 @@ kdump_setup_bond() { source_ifcfg_file $_netdev - bondoptions="$(echo :$BONDING_OPTS | sed 's/\s\+/,/')" + bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")" echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } From ff329689b3405a0343711e375ec9b160ccf24e36 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 May 2019 10:47:58 +0800 Subject: [PATCH 154/806] Disable device dump by default Device dump may use a log of memory and cause OOM issue, so append "novmcoredd" option for second kernel and disable it by default. To use device dump, user should remove the vmcoredd parameter manually. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump.sysconfig | 2 +- kdump.sysconfig.aarch64 | 2 +- kdump.sysconfig.i386 | 2 +- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- kdump.sysconfig.s390x | 2 +- kdump.sysconfig.x86_64 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index ffe1df8..df518d6 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index c72a040..d5d7624 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index b5ec653..c31a8cb 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index e142c6e..1f95452 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index e142c6e..1f95452 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 6edc2fa..abd45a2 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" # Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 17ae5e6..09de2eb 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd" # Any additional kexec arguments required. In most situations, this should # be left empty From 3e8526cf04a07fb2a69c1d86e40f8160d4fd7ecb Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 May 2019 17:00:43 +0800 Subject: [PATCH 155/806] kexec-kdump-howto.txt: Add notes about device dump Currently there are two issues with device dump: - It may use too much memory - kdump won't automatically include required driver in second kernel User should manually reserve enough memory, and include the required driver by using extra_modules. Add some notes about the issues in kexec-kdump-howto.txt Signed-off-by: Kairui Song Acked-by: Dave Young --- kexec-kdump-howto.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 7e9e58a..8e6cc4c 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -698,6 +698,23 @@ crash kernel according, or update your encryption setup. It's recommanded to use a non-encrypted target (eg. remote target) instead. +Notes on device dump: + +Device dump allows drivers to append dump data to vmcore, so you can +collect driver specified debug info. The drivers could append the +data without any limit, and the data is stored in memory, this may +bring a significant memory stress. So device dump is disabled by default +by passing "novmcoredd" command line option to the kdump capture kernel. +If you want to collect debug data with device dump, you need to modify +"KDUMP_COMMANDLINE_APPEND=" value in /etc/sysconfig/kdump and remove the +"novmcoredd" option. You also need to increase the "crashkernel=" value +accordingly in case of OOM issue. +Besides, kdump initramfs won't automatically include the device drivers +which support device dump, only device drivers that are required for +the dump target setup will be included. To ensure the device dump data +will be included in the vmcore, you need to force include related +device drivers by using "extra_modules" option in /etc/kdump.conf + Parallel Dumping Operation ========================== Kexec allows kdump using multiple cpus. So parallel feature can accelerate From 680c0d3414a81066027cc0d9da643c107915a689 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 28 Aug 2019 15:22:22 +0800 Subject: [PATCH 156/806] kdumpctl: distinguish the failed reason of ssh On a host with ipaddr not ready before kdump service, ssh return errno 255. While if no ssh-key, ssh also return errno 255. For both of cases, the current kdump code promote user to run 'kdumpctl propagate'. This confuses user who already installs ssh-key. In order to tell these two cases from each other, the ssh warning message should be involved, and parsed. For the no ssh-key case , warning message is "Permission denied" or "No such file or directory". For the other, warning message is "Network Unreachable" This patch also does a slight change to enlarge the timeout from 60s to 180s. This value can meet test at the time being Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/kdumpctl b/kdumpctl index 2f2d819..f75b820 100755 --- a/kdumpctl +++ b/kdumpctl @@ -738,24 +738,38 @@ check_and_wait_network_ready() local start_time=$(date +%s) local cur local diff + local retval + local errmsg while true; do - ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH + errmsg=$(ssh -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH 2>&1) + retval=$? + # ssh exits with the exit status of the remote command or with 255 if an error occurred - if [ $? -eq 0 ]; then + if [ $retval -eq 0 ]; then return 0 - elif [ $? -ne 255 ]; then + elif [ $retval -ne 255 ]; then + echo "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" >&2 return 1 fi + + # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa + echo $errmsg | grep -q "Permission denied\|No such file or directory" + if [ $? -eq 0 ]; then + echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 + return 1 + fi + cur=$(date +%s) - diff=$( $cur - $start_time ) + let "diff = $cur - $start_time" # 60s time out - if [ $diff -gt 60 ]; then + if [ $diff -gt 180 ]; then break; fi sleep 1 done + echo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" >&2 return 1 } @@ -763,7 +777,6 @@ check_ssh_target() { check_and_wait_network_ready if [ $? -ne 0 ]; then - echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 return 1 fi return 0 From 68f9e69a1693466e8535dcc8945826470c742439 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 9 Sep 2019 16:55:15 -0400 Subject: [PATCH 157/806] makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR Backport from the makedumpfile devel branch in upstream. commit aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Author: Kazuhito Hagio Date: Thu Aug 29 12:26:34 2019 -0400 [PATCH] x86_64: Fix incorrect exclusion by -e option with KASLR The -e option uses info->vmemmap_start for creating a table to determine the positions of page structures that should be excluded, but it is a hardcoded value even with KASLR-enabled vmcore. As a result, the option excludes incorrect pages from it. To fix this, get the vmemmap start address from info->mem_map_data. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...-Fix-incorrect-exclusion-by-e-option.patch | 41 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 43 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch diff --git a/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch b/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch new file mode 100644 index 0000000..fa60b6a --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch @@ -0,0 +1,41 @@ +From aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Thu, 29 Aug 2019 12:26:34 -0400 +Subject: [PATCH] x86_64: Fix incorrect exclusion by -e option with KASLR + +The -e option uses info->vmemmap_start for creating a table to determine +the positions of page structures that should be excluded, but it is a +hardcoded value even with KASLR-enabled vmcore. As a result, the option +excludes incorrect pages from it. + +To fix this, get the vmemmap start address from info->mem_map_data. + +Signed-off-by: Kazuhito Hagio +--- + arch/x86_64.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c +index 3c0fdc5..4eeaf49 100644 +--- a/makedumpfile-1.6.6/arch/x86_64.c ++++ b/makedumpfile-1.6.6/arch/x86_64.c +@@ -679,6 +679,16 @@ find_vmemmap_x86_64() + if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) + pmask &= ~(NUMBER(sme_mask)); + ++ /* ++ * vmemmap region can be randomized by KASLR. ++ * (currently we don't utilize info->vmemmap_end on x86_64.) ++ * ++ if (info->mem_map_data && ++ info->mem_map_data[0].mem_map != NOT_MEMMAP_ADDR) ++ info->vmemmap_start = info->mem_map_data[0].mem_map; ++ ++ DEBUG_MSG("vmemmap_start: %16lx\n", info->vmemmap_start); ++ + pagestructsize = size_table.page; + hugepagesize = PTRS_PER_PMD * info->page_size; + vaddr_base = info->vmemmap_start; +-- +2.20.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 71898da..3fd41a7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -77,6 +77,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # +Patch101: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -112,6 +113,7 @@ tar -z -x -v -f %{SOURCE19} %patch0 -p1 %patch601 -p1 %patch602 -p1 +%patch101 -p1 %ifarch ppc %define archdef ARCH=ppc From bdd3061883174d861d85edb267b40ad2466fabb1 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 9 Sep 2019 16:55:16 -0400 Subject: [PATCH 158/806] makedumpfile: Fix exclusion range in find_vmemmap_pages() Backport from the makedumpfile devel branch in upstream. commit b461971bfac0f193a0c274c3b657d158e07d4995 Author: Kazuhito Hagio Date: Thu Aug 29 14:51:56 2019 -0400 [PATCH] Fix exclusion range in find_vmemmap_pages() In the function, since pfn ranges are literally start and end, not start and end+1, if the struct page of endpfn is at the last in a vmemmap page, the vmemmap page is dropped by the following code, and not excluded. npfns_offset = endpfn - vmapp->rep_pfn_start; vmemmap_offset = npfns_offset * size_table.page; // round down to page boundary vmemmap_offset -= (vmemmap_offset % pagesize); We can use (endpfn+1) here to fix. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...xclusion-range-in-find_vmemmap_pages.patch | 37 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 39 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch b/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch new file mode 100644 index 0000000..2c94711 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch @@ -0,0 +1,37 @@ +From b461971bfac0f193a0c274c3b657d158e07d4995 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Thu, 29 Aug 2019 14:51:56 -0400 +Subject: [PATCH] Fix exclusion range in find_vmemmap_pages() + +In the function, since pfn ranges are literally start and end, not start +and end+1, if the struct page of endpfn is at the last in a vmemmap page, +the vmemmap page is dropped by the following code, and not excluded. + + npfns_offset = endpfn - vmapp->rep_pfn_start; + vmemmap_offset = npfns_offset * size_table.page; + // round down to page boundary + vmemmap_offset -= (vmemmap_offset % pagesize); + +We can use (endpfn+1) here to fix. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index 88df788..37df77d 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -6315,7 +6315,7 @@ find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long * + start_vmemmap_pfn = vmapp->vmap_pfn_start + vmemmap_pfns; + *vmappfn = start_vmemmap_pfn; + +- npfns_offset = endpfn - vmapp->rep_pfn_start; ++ npfns_offset = (endpfn+1) - vmapp->rep_pfn_start; + vmemmap_offset = npfns_offset * size_table.page; + // round down to page boundary + vmemmap_offset -= (vmemmap_offset % pagesize); +-- +2.20.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 3fd41a7..4d356ad 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -78,6 +78,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # Patch101: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch +Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -114,6 +115,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 %patch101 -p1 +%patch102 -p1 %ifarch ppc %define archdef ARCH=ppc From a0db00d575a0f92ca143e79697158669e22714f1 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 9 Sep 2019 16:55:17 -0400 Subject: [PATCH 159/806] makedumpfile: Fix inconsistent return value from find_vmemmap() Backport from the makedumpfile devel branch in upstream. commit 8425342a52b23d462f10bceeeb1c8a3a43d56bf0 Author: Kazuhito Hagio Date: Fri Sep 6 09:50:34 2019 -0400 [PATCH] Fix inconsistent return value from find_vmemmap() When -e option is given, the find_vmemmap() returns FAILED(1) if it failed on x86_64, but on architectures other than that, it is stub_false() and returns FALSE(0). if (info->flag_excludevm) { if (find_vmemmap() == FAILED) { ERRMSG("Can't find vmemmap pages\n"); #define find_vmemmap() stub_false() As a result, on the architectures other than x86_64, the -e option does some unnecessary processing with no effect, and marks the dump DUMP_DH_EXCLUDED_VMEMMAP unexpectedly. Also, the functions for the -e option return COMPLETED or FAILED, which are for command return value, not for function return value. So let's fix the issue by following the common style that returns TRUE or FALSE, and avoid confusion. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...stent-return-value-from-find_vmemmap.patch | 327 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 329 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch b/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch new file mode 100644 index 0000000..61cbda0 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch @@ -0,0 +1,327 @@ +From 8425342a52b23d462f10bceeeb1c8a3a43d56bf0 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Fri, 6 Sep 2019 09:50:34 -0400 +Subject: [PATCH] Fix inconsistent return value from find_vmemmap() + +When -e option is given, the find_vmemmap() returns FAILED(1) if +it failed on x86_64, but on architectures other than that, it is +stub_false() and returns FALSE(0). + + if (info->flag_excludevm) { + if (find_vmemmap() == FAILED) { + ERRMSG("Can't find vmemmap pages\n"); + + #define find_vmemmap() stub_false() + +As a result, on the architectures other than x86_64, the -e option +does some unnecessary processing with no effect, and marks the dump +DUMP_DH_EXCLUDED_VMEMMAP unexpectedly. + +Also, the functions for the -e option return COMPLETED or FAILED, +which are for command return value, not for function return value. + +So let's fix the issue by following the common style that returns +TRUE or FALSE, and avoid confusion. + +Signed-off-by: Kazuhito Hagio +--- + arch/x86_64.c | 12 ++++----- + makedumpfile.c | 70 ++++++++++++++++++++++++-------------------------- + 2 files changed, 40 insertions(+), 42 deletions(-) + +diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c +index 4eeaf4925f43..876644f932be 100644 +--- a/makedumpfile-1.6.6/arch/x86_64.c ++++ b/makedumpfile-1.6.6/arch/x86_64.c +@@ -673,7 +673,7 @@ find_vmemmap_x86_64() + + if (init_level4_pgt == NOT_FOUND_SYMBOL) { + ERRMSG("init_level4_pgt/init_top_pgt not found\n"); +- return FAILED; ++ return FALSE; + } + + if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) +@@ -715,7 +715,7 @@ find_vmemmap_x86_64() + if (!readmem(PADDR, (unsigned long long)pgdp, (void *)&pud_addr, + sizeof(unsigned long))) { + ERRMSG("Can't get pgd entry for slot %d.\n", pgd_index); +- return FAILED; ++ return FALSE; + } + + /* mask the pgd entry for the address of the pud page */ +@@ -726,7 +726,7 @@ find_vmemmap_x86_64() + if (!readmem(PADDR, (unsigned long long)pud_addr, (void *)pud_page, + PTRS_PER_PUD * sizeof(unsigned long))) { + ERRMSG("Can't get pud entry for pgd slot %ld.\n", pgdindex); +- return FAILED; ++ return FALSE; + } + /* step thru each pmd address in the pud page */ + /* pudp points to an entry in the pud page */ +@@ -739,7 +739,7 @@ find_vmemmap_x86_64() + if (!readmem(PADDR, pmd_addr, (void *)pmd_page, + PTRS_PER_PMD * sizeof(unsigned long))) { + ERRMSG("Can't get pud entry for slot %ld.\n", pudindex); +- return FAILED; ++ return FALSE; + } + /* pmdp points to an entry in the pmd */ + for (pmdp = (unsigned long *)pmd_page, pmdindex = 0; +@@ -815,7 +815,7 @@ find_vmemmap_x86_64() + num_pmds_valid++; + if (!(pmd & _PAGE_PSE)) { + printf("vmemmap pmd not huge, abort\n"); +- return FAILED; ++ return FALSE; + } + } else { + if (last_valid) { +@@ -947,7 +947,7 @@ find_vmemmap_x86_64() + i++; + } while (cur != vmaphead); + nr_gvmem_pfns = i; +- return COMPLETED; ++ return TRUE; + } + + #endif /* x86_64 */ +diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +index 37df77d181dd..af4db3c006c9 100644 +--- a/makedumpfile-1.6.6/makedumpfile.c ++++ b/makedumpfile-1.6.6/makedumpfile.c +@@ -6213,20 +6213,20 @@ init_save_control() + flags = O_RDWR|O_CREAT|O_TRUNC; + if ((sc.sc_fd = open(sc.sc_filename, flags, S_IRUSR|S_IWUSR)) < 0) { + ERRMSG("Can't open the pfn file %s.\n", sc.sc_filename); +- return FAILED; ++ return FALSE; + } + unlink(sc.sc_filename); + + sc.sc_buf = malloc(info->page_size); + if (!sc.sc_buf) { + ERRMSG("Can't allocate a page for pfn buf.\n"); +- return FAILED; ++ return FALSE; + } + sc.sc_buflen = info->page_size; + sc.sc_bufposition = 0; + sc.sc_fileposition = 0; + sc.sc_filelen = 0; +- return COMPLETED; ++ return TRUE; + } + + /* +@@ -6243,7 +6243,7 @@ save_deletes(unsigned long startpfn, unsigned long numpfns) + if (i != sc.sc_buflen) { + ERRMSG("save: Can't write a page to %s\n", + sc.sc_filename); +- return FAILED; ++ return FALSE; + } + sc.sc_filelen += sc.sc_buflen; + sc.sc_bufposition = 0; +@@ -6252,12 +6252,12 @@ save_deletes(unsigned long startpfn, unsigned long numpfns) + scp->startpfn = startpfn; + scp->numpfns = numpfns; + sc.sc_bufposition += sizeof(struct sc_entry); +- return COMPLETED; ++ return TRUE; + } + + /* + * Get a starting pfn and number of pfns for delete from bitmap. +- * Return 0 for success, 1 for 'no more' ++ * Return TRUE(1) for success, FALSE(0) for 'no more' + */ + int + get_deletes(unsigned long *startpfn, unsigned long *numpfns) +@@ -6266,14 +6266,14 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) + struct sc_entry *scp; + + if (sc.sc_fileposition >= sc.sc_filelen) { +- return FAILED; ++ return FALSE; + } + + if (sc.sc_bufposition == sc.sc_buflen) { + i = read(sc.sc_fd, sc.sc_buf, sc.sc_buflen); + if (i <= 0) { + ERRMSG("Can't read a page from %s.\n", sc.sc_filename); +- return FAILED; ++ return FALSE; + } + sc.sc_bufposition = 0; + } +@@ -6282,7 +6282,7 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) + *numpfns = scp->numpfns; + sc.sc_bufposition += sizeof(struct sc_entry); + sc.sc_fileposition += sizeof(struct sc_entry); +- return COMPLETED; ++ return TRUE; + } + + /* +@@ -6290,7 +6290,7 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) + * that represent them. + * (pfn ranges are literally start and end, not start and end+1) + * see the array of vmemmap pfns and the pfns they represent: gvmem_pfns +- * Return COMPLETED for delete, FAILED for not to delete. ++ * Return TRUE(1) for delete, FALSE(0) for not to delete. + */ + int + find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long *vmappfn, +@@ -6323,12 +6323,12 @@ find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long * + end_vmemmap_pfn = vmapp->vmap_pfn_start + vmemmap_pfns; + npages = end_vmemmap_pfn - start_vmemmap_pfn; + if (npages == 0) +- return FAILED; ++ return FALSE; + *nmapnpfns = npages; +- return COMPLETED; ++ return TRUE; + } + } +- return FAILED; ++ return FALSE; + } + + /* +@@ -6359,12 +6359,12 @@ find_unused_vmemmap_pages(void) + if (lseek(bitmap1->fd, new_offset1, SEEK_SET) < 0 ) { + ERRMSG("Can't seek the bitmap(%s). %s\n", + bitmap1->file_name, strerror(errno)); +- return FAILED; ++ return FALSE; + } + if (read(bitmap1->fd, bitmap1->buf, BUFSIZE_BITMAP) != BUFSIZE_BITMAP) { + ERRMSG("Can't read the bitmap(%s). %s\n", + bitmap1->file_name, strerror(errno)); +- return FAILED; ++ return FALSE; + } + bitmap1->no_block = pfn / PFN_BUFBITMAP; + +@@ -6372,12 +6372,12 @@ find_unused_vmemmap_pages(void) + if (lseek(bitmap2->fd, new_offset2, SEEK_SET) < 0 ) { + ERRMSG("Can't seek the bitmap(%s). %s\n", + bitmap2->file_name, strerror(errno)); +- return FAILED; ++ return FALSE; + } + if (read(bitmap2->fd, bitmap2->buf, BUFSIZE_BITMAP) != BUFSIZE_BITMAP) { + ERRMSG("Can't read the bitmap(%s). %s\n", + bitmap2->file_name, strerror(errno)); +- return FAILED; ++ return FALSE; + } + bitmap2->no_block = pfn / PFN_BUFBITMAP; + +@@ -6422,12 +6422,11 @@ find_unused_vmemmap_pages(void) + endpfn = startpfn + + (numwords * BITS_PER_WORD) - 1; + if (find_vmemmap_pages(startpfn, endpfn, +- &vmapstartpfn, &vmapnumpfns) == +- COMPLETED) { +- if (save_deletes(vmapstartpfn, +- vmapnumpfns) == FAILED) { ++ &vmapstartpfn, &vmapnumpfns)) { ++ if (!save_deletes(vmapstartpfn, ++ vmapnumpfns)) { + ERRMSG("save_deletes failed\n"); +- return FAILED; ++ return FALSE; + } + deleted_pages += vmapnumpfns; + } +@@ -6444,11 +6443,10 @@ find_unused_vmemmap_pages(void) + not start and end + 1 */ + endpfn = startpfn + (numwords * BITS_PER_WORD) - 1; + if (find_vmemmap_pages(startpfn, endpfn, +- &vmapstartpfn, &vmapnumpfns) == COMPLETED) { +- if (save_deletes(vmapstartpfn, vmapnumpfns) +- == FAILED) { ++ &vmapstartpfn, &vmapnumpfns)) { ++ if (!save_deletes(vmapstartpfn, vmapnumpfns)) { + ERRMSG("save_deletes failed\n"); +- return FAILED; ++ return FALSE; + } + deleted_pages += vmapnumpfns; + } +@@ -6457,7 +6455,7 @@ find_unused_vmemmap_pages(void) + } + PROGRESS_MSG("\nExcluded %ld unused vmemmap pages\n", deleted_pages); + +- return COMPLETED; ++ return TRUE; + } + + /* +@@ -6468,7 +6466,7 @@ delete_unused_vmemmap_pages(void) + { + unsigned long startpfn, numpfns, pfn, i; + +- while (get_deletes(&startpfn, &numpfns) == COMPLETED) { ++ while (get_deletes(&startpfn, &numpfns)) { + for (i = 0, pfn = startpfn; i < numpfns; i++, pfn++) { + clear_bit_on_2nd_bitmap_for_kernel(pfn, (struct cycle *)0); + // note that this is never to be used in cyclic mode! +@@ -6496,23 +6494,23 @@ reset_save_control() + { + int i; + if (sc.sc_bufposition == 0) +- return COMPLETED; ++ return TRUE; + + i = write(sc.sc_fd, sc.sc_buf, sc.sc_buflen); + if (i != sc.sc_buflen) { + ERRMSG("reset: Can't write a page to %s\n", + sc.sc_filename); +- return FAILED; ++ return FALSE; + } + sc.sc_filelen += sc.sc_bufposition; + + if (lseek(sc.sc_fd, 0, SEEK_SET) < 0) { + ERRMSG("Can't seek the pfn file %s).", sc.sc_filename); +- return FAILED; ++ return FALSE; + } + sc.sc_fileposition = 0; + sc.sc_bufposition = sc.sc_buflen; /* trigger 1st read */ +- return COMPLETED; ++ return TRUE; + } + + int +@@ -6602,11 +6600,11 @@ create_2nd_bitmap(struct cycle *cycle) + + /* --exclude-unused-vm means exclude vmemmap page structures for unused pages */ + if (info->flag_excludevm) { +- if (init_save_control() == FAILED) ++ if (!init_save_control()) + return FALSE; +- if (find_unused_vmemmap_pages() == FAILED) ++ if (!find_unused_vmemmap_pages()) + return FALSE; +- if (reset_save_control() == FAILED) ++ if (!reset_save_control()) + return FALSE; + delete_unused_vmemmap_pages(); + finalize_save_control(); +@@ -10095,7 +10093,7 @@ create_dumpfile(void) + + /* create an array of translations from pfn to vmemmap pages */ + if (info->flag_excludevm) { +- if (find_vmemmap() == FAILED) { ++ if (!find_vmemmap()) { + ERRMSG("Can't find vmemmap pages\n"); + info->flag_excludevm = 0; + } +-- +2.18.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 4d356ad..a4c3b9c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -96,6 +96,7 @@ Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pa # Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch Patch602: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch +Patch603: kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -116,6 +117,7 @@ tar -z -x -v -f %{SOURCE19} %patch602 -p1 %patch101 -p1 %patch102 -p1 +%patch603 -p1 %ifarch ppc %define archdef ARCH=ppc From e07fc3e071cb2ce5a71ee60c341b4d26a68e600a Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 24 Sep 2019 11:19:12 +0800 Subject: [PATCH 160/806] kdumpctl: echo msg when waiting for connection Print some message during the long wait period to reflect the process. The message will look like: Network dump target is not usable, waiting for it to be ready ... Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kdumpctl b/kdumpctl index f75b820..dc0c64b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -736,6 +736,7 @@ check_ssh_config() check_and_wait_network_ready() { local start_time=$(date +%s) + local warn_once=1 local cur local diff local retval @@ -760,6 +761,12 @@ check_and_wait_network_ready() return 1 fi + if [ $warn_once -eq 1 ]; then + echo "Network dump target is not usable, waiting for it to be ready" + warn_once=0 + fi + echo -n . + cur=$(date +%s) let "diff = $cur - $start_time" # 60s time out From e31d5baf5955b7c7b670295a1df61a03cbfd5d32 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 24 Sep 2019 14:57:59 +0800 Subject: [PATCH 161/806] Release 2.0.20-4 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a4c3b9c..36b15b8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -345,6 +345,18 @@ done %endif %changelog +* Tue Sep 24 2019 Kairui Song - 2.0.20-4 +- kdumpctl: echo msg when waiting for connection +- makedumpfile: Fix inconsistent return value from find_vmemmap() +- makedumpfile: Fix exclusion range in find_vmemmap_pages() +- makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR +- kdumpctl: distinguish the failed reason of ssh +- kexec-kdump-howto.txt: Add notes about device dump +- Disable device dump by default +- dracut-module-setup: fix bond ifcfg processing +- dracut-module-setup: filter out localhost for generic_fence_kdump +- dracut-module-setup: get localhost alias by manual + * Mon Aug 12 2019 Kairui Song - 2.0.20-3 - kdumpctl: wait a while for network ready if dump target is ssh - makedumpfile: Increase SECTION_MAP_LAST_BIT to 4 From 4714c7c8a3654ab98cb2b7464e1ec297a8550e58 Mon Sep 17 00:00:00 2001 From: Yuval Turgeman Date: Tue, 24 Sep 2019 12:19:43 +0300 Subject: [PATCH 162/806] kdump-lib: strip grub device from kdump_bootdir When trying to setup kdump for fedora-coreos, kdumpctl start fails to find the correct boot directory since BOOT_IMAGE start with the grub device name Signed-off-by: Yuval Turgeman --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 4feb7d0..f393c76 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -667,7 +667,7 @@ check_boot_dir() kdump_bootdir="/boot" else eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) - kdump_bootdir="/boot"$(dirname $BOOT_IMAGE) + kdump_bootdir="/boot"$(dirname ${BOOT_IMAGE#*)}) fi echo $kdump_bootdir } From 6dee286467e5a697d25148712a110da1a720ac96 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 27 Sep 2019 18:17:32 +0800 Subject: [PATCH 163/806] Don't mount the dump target unless needed For fadump, this helps to reduce the risk of boot failure, and may also help speed up the boot by a bit. For normal kdump, this will delay the dump target mounting, and no longer depend on systemd to do the mounting job. And currently there is a failure that caused by some mount handling bug with kernel and systemd that is failing the system booting: [FAILED] Failed to mount /kdumproot/home. See 'systemctl status kdumproot-home.mount' for details. [DEPEND] Dependency failed for Local File Systems. [ OK ] Reached target Remote File Systems (Pre). [ OK ] Reached target Remote File Systems. Starting udev Coldplug all Devices... Starting Create Volatile Files and Directories... Starting Kdump Emergency... This patch can bypass it. The fix of root cause is still WIP, but this patch itself is a nice to have optimization so it's reasonable to do so. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 30 +++++++++++++++++++++++++----- mkdumprd | 5 +++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 608dc6e..c409dce 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -96,16 +96,31 @@ get_kdump_confs() # dump_fs dump_fs() { - + local _do_umount="" local _dev=$(findmnt -k -f -n -r -o SOURCE $1) local _mp=$(findmnt -k -f -n -r -o TARGET $1) local _op=$(findmnt -k -f -n -r -o OPTIONS $1) - echo "kdump: dump target is $_dev" - if [ -z "$_mp" ]; then - echo "kdump: error: Dump target $_dev is not mounted." - return 1 + _dev=$(findmnt -s -f -n -r -o SOURCE $1) + _mp=$(findmnt -s -f -n -r -o TARGET $1) + _op=$(findmnt -s -f -n -r -o OPTIONS $1) + + if [ -n "$_dev" ] && [ -n "$_mp" ]; then + echo "kdump: dump target $_dev is not mounted, trying to mount..." + mkdir -p $_mp + mount -o $_op $_dev $_mp + + if [ $? -ne 0 ]; then + echo "kdump: mounting failed (mount point: $_mp, option: $_op)" + return 1 + fi + _do_umount=1 + else + echo "kdump: error: Dump target $_dev is not usable" + fi + else + echo "kdump: dump target is $_dev" fi # Remove -F in makedumpfile case. We don't want a flat format dump here. @@ -129,6 +144,11 @@ dump_fs() sync echo "kdump: saving vmcore complete" + + if [ $_do_umount ]; then + umount $_mp || echo "kdump: warn: failed to umount target" + fi + # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure return 0 } diff --git a/mkdumprd b/mkdumprd index cf3533f..50472a9 100644 --- a/mkdumprd +++ b/mkdumprd @@ -108,12 +108,13 @@ to_mount() { fi # mount fs target as rw in 2nd kernel _options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g') - # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd - # kernel, filter it out here. + # filter out 'noauto' here, it will be force appended later, avoid duplication _options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g') # drop nofail or nobootwait _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') + # only mount the dump target when needed. + _options="$_options,noauto" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From e7a207d166633dc80ba1e499f0b0516d9088a9a2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 15 Oct 2019 13:54:11 +0800 Subject: [PATCH 164/806] Release 2.0.20-5 Signed-off-by: Kairui Song --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6f05e21..2881615 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -349,6 +349,11 @@ done %endif %changelog +* Tue Oct 15 2019 Kairui Song - 2.0.20-5 +- Don't mount the dump target unless needed +- kdump-lib: strip grub device from kdump_bootdir +- Add systemd-udev require. + * Tue Sep 24 2019 Kairui Song - 2.0.20-4 - kdumpctl: echo msg when waiting for connection - makedumpfile: Fix inconsistent return value from find_vmemmap() From 72ed97683fd46dbe1185ddc029698e5cc6477357 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 17 Oct 2019 14:01:14 +0800 Subject: [PATCH 165/806] kdumpctl: bail out immediately if host key verification failed In kdump.conf, if sshkey points to an invalid ssh key, 'kdumpctl restart' can bail out immediately instead of retry. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index dc0c64b..048e9f5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -755,7 +755,7 @@ check_and_wait_network_ready() fi # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa - echo $errmsg | grep -q "Permission denied\|No such file or directory" + echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" if [ $? -eq 0 ]; then echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 return 1 From 882b920c2f36b85817fdb3e621f9a0c29c9eeb91 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 22 Oct 2019 16:03:57 +0800 Subject: [PATCH 166/806] module-setup: re-fix 99kdumpbase network dependency In commit a431a7e354b (module-setup: fix 99kdumpbase network dependency), the statement for OR operation is still wrong. The OR condition statement should be: if a || b Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b186b38..74c2f48 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -40,7 +40,7 @@ depends() { _dep="$_dep drm" fi - if is_generic_fence_kdump -o is_pcs_fence_kdump; then + if is_generic_fence_kdump || is_pcs_fence_kdump; then _dep="$_dep network" fi From 18ee888eab917cc1eb935f075a9b917e136a15f2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 18 Oct 2019 14:10:15 +0800 Subject: [PATCH 167/806] mkdumprd: ensure ssh path exists before check size check_size checks if the specified dump path on the ssh target have enough space. And if the path doesn't exits, it will fail and exit. mkdir_save_path_ssh should be called first to check if the path exists, and create the path if it doesn't exits, so the size check can always work properly. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index 50472a9..aafd808 100644 --- a/mkdumprd +++ b/mkdumprd @@ -429,10 +429,10 @@ do ssh) if strstr "$config_val" "@"; then - check_size ssh $config_val mkdir_save_path_ssh $config_val + check_size ssh $config_val add_dracut_module "ssh-client" - add_dracut_sshkey "$SSH_KEY_LOCATION" + add_dracut_sshkey "$SSH_KEY_LOCATION" else perror_exit "Bad ssh dump target $config_val" fi From 5e76e53a70240350252e4263d7507ec271cafab7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 1 Jul 2019 00:41:07 +0800 Subject: [PATCH 168/806] module-setup.sh: Simplify the network setup code Merge kdump_setup_netdev into kdump_install_net. kdump_install_net is a wrapper of calling kdump_setup_netdev, and it do following three extra things: 1. Sanitize and resolve the hostname 2. Resolve the route to the destination 3. Set the default gateway for once There is currently only one caller of kdump_setup_netdev, the iscsi network setup code, and it's doing 1 and 2 by itself. And there should only be one default gateway in kdump enviroment, so applying 3 here is fine. And the comment of kdump_install_net is wrong and obsoleted, update the comment too. Just merge kdump_setup_netdev into kdump_install_net and always use kdump_install_net instead. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 88 +++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 74c2f48..37aaa80 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -327,11 +327,45 @@ kdump_setup_znet() { echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} > ${initdir}/etc/cmdline.d/30znet.conf } -# Setup dracut to bringup a given network interface -kdump_setup_netdev() { - local _netdev=$1 _srcaddr=$2 +kdump_get_ip_route() +{ + local _route=$(/sbin/ip -o route get to $1 2>&1) + [ $? != 0 ] && die "Bad kdump network destination: $1" + echo $_route +} + +kdump_get_ip_route_field() +{ + if `echo $1 | grep -q $2`; then + echo ${1##*$2} | cut -d ' ' -f1 + fi +} + +kdump_get_remote_ip() +{ + local _remote=$(get_remote_host $1) _remote_temp + if is_hostname $_remote; then + _remote_temp=`getent ahosts $_remote | grep -v : | head -n 1` + if [ -z "$_remote_temp" ]; then + _remote_temp=`getent ahosts $_remote | head -n 1` + fi + _remote=`echo $_remote_temp | cut -d' ' -f1` + fi + echo $_remote +} + +# Setup dracut to bring up network interface that enable +# initramfs accessing giving destination +# $1: destination host +kdump_install_net() { + local _destaddr _srcaddr _route _netdev local _static _proto _ip_conf _ip_opts _ifname_opts - local _netmac=$(kdump_get_mac_addr $_netdev) + + _destaddr=$(kdump_get_remote_ip $1) + _route=$(kdump_get_ip_route $_destaddr) + _srcaddr=$(kdump_get_ip_route_field "$_route" "src") + _netdev=$(kdump_get_ip_route_field "$_route" "dev") + _netmac=$(kdump_get_mac_addr $_netdev) if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev @@ -372,42 +406,8 @@ kdump_setup_netdev() { fi kdump_setup_dns "$_netdev" -} -get_ip_route_field() -{ - if `echo $1 | grep -q $2`; then - echo ${1##*$2} | cut -d ' ' -f1 - fi -} - -#Function:kdump_install_net -#$1: config values of net line in kdump.conf -#$2: srcaddr of network device -kdump_install_net() { - local _server _netdev _srcaddr _route _serv_tmp - local config_val="$1" - - _server=$(get_remote_host $config_val) - - if is_hostname $_server; then - _serv_tmp=`getent ahosts $_server | grep -v : | head -n 1` - if [ -z "$_serv_tmp" ]; then - _serv_tmp=`getent ahosts $_server | head -n 1` - fi - _server=`echo $_serv_tmp | cut -d' ' -f1` - fi - - _route=`/sbin/ip -o route get to $_server 2>&1` - [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 - - #the field in the ip output changes if we go to another subnet - _srcaddr=$(get_ip_route_field "$_route" "src") - _netdev=$(get_ip_route_field "$_route" "dev") - - kdump_setup_netdev "${_netdev}" "${_srcaddr}" - - #save netdev used for kdump as cmdline + # Save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling # kdump_install_net() for another time. For example, after setting eth0 as @@ -592,9 +592,6 @@ kdump_setup_iscsi_device() { local tgt_name; local tgt_ipaddr; local username; local password; local userpwd_str; local username_in; local password_in; local userpwd_in_str; - local netdev - local srcaddr - local idev local netroot_str ; local initiator_str; local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi" @@ -633,12 +630,7 @@ kdump_setup_iscsi_device() { [ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in" - netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \ - sed 's|.*dev \(.*\).*|\1|g') - srcaddr=$(echo $netdev | awk '{ print $3; exit }') - netdev=$(echo $netdev | awk '{ print $1; exit }') - - kdump_setup_netdev $netdev $srcaddr + kdump_install_net "$tgt_ipaddr" # prepare netroot= command line # FIXME: Do we need to parse and set other parameters like protocol, port From 39352d0cfc98b43ce60ac262b6fc4dd5c6e084dd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 30 Oct 2019 17:09:07 +0800 Subject: [PATCH 169/806] Don't execute final_action if failure_action terminates the system If failure_action is shutdown/reboot/halt, final_action is pointless as the system will be already stopping. And if final_action is different from failure_action, it will trigger a systemd race problem and cause unexpected behavior to occur. So let the error handler stop and exit after performing failure_action successfully if failure_action is one of shutdown/reboot/halt. This way, final_action will not be executed. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c409dce..8530556 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -56,13 +56,13 @@ get_kdump_confs() FAILURE_ACTION="kdump_emergency_shell" ;; reboot) - FAILURE_ACTION="systemctl reboot -f" + FAILURE_ACTION="systemctl reboot -f && exit" ;; halt) - FAILURE_ACTION="halt" + FAILURE_ACTION="halt && exit" ;; poweroff) - FAILURE_ACTION="systemctl poweroff -f" + FAILURE_ACTION="systemctl poweroff -f && exit" ;; dump_to_rootfs) FAILURE_ACTION="dump_to_rootfs" From d9d4483b7a77b8489b656051aefe7b397edea2a8 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 7 Nov 2019 12:32:57 +0800 Subject: [PATCH 170/806] spec: move binaries from /sbin to /usr/sbin Before this patch $rpm -ql kexec-tools | grep sbin /sbin/kexec /sbin/makedumpfile /sbin/mkdumprd /sbin/vmcore-dmesg After this patch $rpm -ql kexec-tools | grep sbin /usr/sbin/kexec /usr/sbin/makedumpfile /usr/sbin/mkdumprd /usr/sbin/vmcore-dmesg Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kexec-tools.spec | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2881615..f8d4c1c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -138,7 +138,7 @@ autoreconf --host=powerpc64le-redhat-linux-gnu \ --build=powerpc64le-redhat-linux-gnu \ %endif - --sbindir=/sbin + --sbindir=/usr/sbin rm -f kexec-tools.spec.in # setup the docs cp %{SOURCE10} . @@ -154,7 +154,7 @@ make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libep %endif %install -mkdir -p -m755 $RPM_BUILD_ROOT/sbin +mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ @@ -168,8 +168,8 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl -install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/sbin/kexec -install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/sbin/vmcore-dmesg +install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec +install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ @@ -178,7 +178,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump -install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd +install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 @@ -201,7 +201,7 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile +install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample @@ -306,12 +306,12 @@ do done %files -/sbin/kexec +/usr/sbin/kexec %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -/sbin/makedumpfile +/usr/sbin/makedumpfile %endif -/sbin/mkdumprd -/sbin/vmcore-dmesg +/usr/sbin/mkdumprd +/usr/sbin/vmcore-dmesg %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump From 0a9aabaadd4c42c7cb4e557801500b57e8cce6fc Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Wed, 30 Oct 2019 17:02:29 +0530 Subject: [PATCH 171/806] kdumpctl: make reload fail proof When large amount of memory, about 1TB, is removed with DLPAR memory remove operation, kdump reload could fail due to race condition with device tree property update. In such scenario, the subsequent kdump reload requests would also fail as reload() only proceeds if current load status is active. Since the possibility of this race condition couldn't be wished away due to the nature of the scenario, workaround it by proceeding to load even if current load status is not active as long as kdump service is active, which kdump udev rules already check for. Signed-off-by: Hari Bathini Acked-by: Kairui Song --- kdumpctl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 048e9f5..2d21a41 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1116,8 +1116,7 @@ reload() { check_current_status if [ $? -ne 0 ]; then - echo "Kdump is not running: [WARNING]" - return 0 + echo "Kdump was not running: [WARNING]" fi if [ $DEFAULT_DUMP_MODE == "fadump" ]; then From 5633e8331866098c97e72e99f233a254fa479a4d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 6 Nov 2019 16:17:21 +0800 Subject: [PATCH 172/806] Always set vm.zone_reclaim_mode = 3 in kdump kernel By default kernel have vm.zone_reclaim_mode = 0 and large page allocation might fail as kernel is very conservative on memory reclaiming. If the page allocation failure is not handled carefully it could lead to more serious problems. This issue can be reproduced by change with following steps: - Fill up page cache use: # dd if=/dev/urandom of=/test bs=1M count=1300 - Now the memory is filled with write cache: # free -m total used free shared buff/cache available Mem: 1790 184 132 2 1473 1348 Swap: 2119 7 2112 - Insert a module which simply calls "kmalloc(SZ_1M, GFP_KERNEL)" for 512 times: (Notice: vmalloc don't have such problem) # insmod debug_module.ko - Got following allocation failure: insmod: page allocation failure: order:8, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0 - Clean up and repeat again with vm.zone_reclaim_mode = 3, OOM is not observed. In kdump kernel there is usually only one online CPU and limited memory, so we set vm.zone_reclaim_mode = 3 to let kernel reclaim memory more aggresively to avoid such issue. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 37aaa80..e6358a8 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -537,16 +537,18 @@ kdump_install_conf() { rm -f ${initdir}/tmp/$$-kdump.conf } -# Default sysctl parameters should suffice for kdump kernel. -# Remove custom configurations sysctl.conf & sysctl.d/* -remove_sysctl_conf() { - +# Remove user custom configurations sysctl.conf & sysctl.d/* +# and apply some optimization for kdump +overwrite_sysctl_conf() { # As custom configurations like vm.min_free_kbytes can lead # to OOM issues in kdump kernel, avoid them rm -f "${initdir}/etc/sysctl.conf" rm -rf "${initdir}/etc/sysctl.d" rm -rf "${initdir}/run/sysctl.d" rm -rf "${initdir}/usr/lib/sysctl.d" + + mkdir -p "${initdir}/etc/sysctl.d" + echo "vm.zone_reclaim_mode = 3" > "${initdir}/etc/sysctl.d/99-zone-reclaim.conf" } kdump_iscsi_get_rec_val() { @@ -812,7 +814,7 @@ kdump_install_random_seed() { install() { kdump_install_conf - remove_sysctl_conf + overwrite_sysctl_conf if is_ssh_dump_target; then kdump_install_random_seed From f13eab60cbb57a255a443a94c9689b1647898fff Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 20 Nov 2019 22:58:10 +0800 Subject: [PATCH 173/806] mkdumprd: simplify dracut args parsing Previously dracut_args is stored as an array in the shell code, so we can just pass this array as argument to dracut. But when trying to append new dracut argument, we have to manually handle the quotes and spaces to ensure the appended argument is splitted into array elements in the right way. This is complex and hard to read or maintain. Instead, just store the dracut_args as a plain string, and let xargs help parse it and call dracut. Simply passing $dracut_args or "$dracut_args" will either let dracut consider the whole string as a single argument, or loss all the quotes. xargs can handle it well and cover more corner cases. Eg. one corner case before, if we have: dracut_args --mount "/dev/sda1 /mnt/test xfs rw" Kdump will fail, because the function add_dracut_arg() will wrongly change the arguments into: (Notice the extra space.) dracut_args --mount " /dev/sda1 /mnt/test xfs rw" Instead of fixing it just use xargs instead. Tested with above config and multiple other dracut_args values. Resolves: bz1700136 Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/mkdumprd b/mkdumprd index aafd808..76ae7a0 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,6 +17,10 @@ SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +OVERRIDE_RESETTABLE=0 + +extra_modules="" +dracut_args="--quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" is_wdt_addition_needed() { local active @@ -32,40 +36,8 @@ is_wdt_addition_needed() { return 1 } -WDTCFG="" -is_wdt_addition_needed -[[ $? -eq 0 ]] && WDTCFG="-a watchdog" - -extra_modules="" -dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg earlykdump" $WDTCFG) -OVERRIDE_RESETTABLE=0 - add_dracut_arg() { - local arg qarg is_quoted=0 - while [ $# -gt 0 ]; - do - arg="${1//\'/\"}" - #Handle quoted substring properly for passing it to dracut_args array. - if [ $is_quoted -eq 0 ]; then - if [[ "$arg" == "\"" ]] || [[ $arg != ${arg#\"} ]]; then - is_quoted=1 - arg=${arg#\"} - fi - fi - if [ $is_quoted -eq 1 ]; then - qarg="$qarg $arg" - if [[ "$arg" == "\"" ]] || [[ $arg != ${arg%\"} ]]; then - is_quoted=0 - arg=${qarg%\"} - qarg="" - else - shift - continue - fi - fi - dracut_args+=("$arg") - shift - done + dracut_args="$dracut_args $@" } add_dracut_module() { @@ -390,6 +362,10 @@ if [ "$(uname -m)" = "s390x" ]; then add_dracut_module "znet" fi +if is_wdt_addition_needed; then + add_dracut_arg "-a" "watchdog" +fi + while read config_opt config_val; do # remove inline comments after the end of a directive. @@ -463,7 +439,8 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -dracut "${dracut_args[@]}" "$@" +echo "$dracut_args $@" | xargs dracut + _rc=$? sync exit $_rc From d13fd38df4b8d7ae5aced63b288c350a6f68dd28 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Nov 2019 14:25:43 +0800 Subject: [PATCH 174/806] kdump-error-handler.service: Remove ExecStopPost Currently "systemctl --fail --no-block default" will be executed on kdump-error-handler exit due to the config. This may makes systemd try to isolate to the default target again. The execute chain will be like: initrd.target -> kdump.sh (failed) -> kdump-error-handler.service -> failure_action -> final_action -> ExecStopPost (go to initrd.target again) Currently, reboot/shutdown/halt is called by either by executing failure_action or final_action. So the loop will be stopped. However nont of the reboot/shutdown/halt call is blocking so it might lead to race issue. Just drop the ExecStopPost to fix this potential issue. Signed-off-by: Kairui Song Acked-by: Pingfan Liu Tested-by: HATAYAMA Daisuke --- dracut-kdump-error-handler.service | 1 - 1 file changed, 1 deletion(-) diff --git a/dracut-kdump-error-handler.service b/dracut-kdump-error-handler.service index 32b74ab..a23b75e 100644 --- a/dracut-kdump-error-handler.service +++ b/dracut-kdump-error-handler.service @@ -21,7 +21,6 @@ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ ExecStart=/bin/kdump-error-handler.sh -ExecStopPost=-/usr/bin/systemctl --fail --no-block default Type=oneshot StandardInput=tty-force StandardOutput=inherit From ee742fcf6b73d873d88628b0fd642fb43bb89e78 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 28 Nov 2019 17:51:33 +0800 Subject: [PATCH 175/806] Release 2.0.20-6 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f8d4c1c..27ec729 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -349,6 +349,18 @@ done %endif %changelog +* Thu Nov 28 2019 Kairui Song - 2.0.20-6 +- kdump-error-handler.service: Remove ExecStopPost +- mkdumprd: simplify dracut args parsing +- Always set vm.zone_reclaim_mode = 3 in kdump kernel +- kdumpctl: make reload fail proof +- spec: move binaries from /sbin to /usr/sbin +- Don't execute final_action if failure_action terminates the system +- module-setup.sh: Simplify the network setup code +- mkdumprd: ensure ssh path exists before check size +- module-setup: re-fix 99kdumpbase network dependency +- kdumpctl: bail out immediately if host key verification failed + * Tue Oct 15 2019 Kairui Song - 2.0.20-5 - Don't mount the dump target unless needed - kdump-lib: strip grub device from kdump_bootdir From 68dcfcfb479d5937b8a1ff73af52f6935f5c6b7f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 29 Nov 2019 22:09:43 +0800 Subject: [PATCH 176/806] mkdumprd: Fix dracut args parsing Previous commit f13eab6 ('mkdumprd: simplify dracut args parsing') break dracut arguments parsing for some use case, this should fix it well. Passed nfs/local/iscsi/ssh dump test, and with extra dracut_argss. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkdumprd b/mkdumprd index 76ae7a0..6c33fc5 100644 --- a/mkdumprd +++ b/mkdumprd @@ -41,15 +41,15 @@ add_dracut_arg() { } add_dracut_module() { - add_dracut_arg "--add" "$1" + add_dracut_arg "--add" "\"$1\"" } add_dracut_mount() { - add_dracut_arg "--mount" "$1" + add_dracut_arg "--mount" "\"$1\"" } add_dracut_sshkey() { - add_dracut_arg "--sshkey" "$1" + add_dracut_arg "--sshkey" "\"$1\"" } # caller should ensure $1 is valid and mounted in 1st kernel From b301d6c4f45e693a802e044418e900966cf4e357 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sat, 28 Dec 2019 03:12:27 +0800 Subject: [PATCH 177/806] Fix building failure due to makedumpfile's compile flag From: Pingfan Liu makedumpfile: remove -lebl -lebl has been removed from elfutils. Signed-off-by: Kairui Song --- ...ools-2.0.20-makedumpfile-remove-lebl.patch | 26 +++++++++++++++++++ kexec-tools.spec | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-remove-lebl.patch diff --git a/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch b/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch new file mode 100644 index 0000000..ca63d82 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch @@ -0,0 +1,26 @@ +From 3beef142bc003d9cf2e957c6a21e51d661f9b13e Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 28 Nov 2019 21:23:00 +0800 +Subject: [PATCH] makedumpfile: remove -lebl + +Signed-off-by: Pingfan Liu +--- + makedumpfile-1.6.6/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.6/Makefile b/makedumpfile-1.6.6/Makefile +index 1fdb628..df21b93 100644 +--- a/makedumpfile-1.6.6/Makefile ++++ b/makedumpfile-1.6.6/Makefile +@@ -50,7 +50,7 @@ OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) + SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c + OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) + +-LIBS = -ldw -lbz2 -lebl -ldl -lelf -lz ++LIBS = -ldw -lbz2 -ldl -lelf -lz + ifneq ($(LINKTYPE), dynamic) + LIBS := -static $(LIBS) + endif +-- +2.20.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 27ec729..d7e1bc4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -101,6 +101,7 @@ Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pa Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch Patch602: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch Patch603: kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch +Patch604: kexec-tools-2.0.20-makedumpfile-remove-lebl.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -122,6 +123,7 @@ tar -z -x -v -f %{SOURCE19} %patch101 -p1 %patch102 -p1 %patch603 -p1 +%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc From d01c6de3382911a2d43192e896b61b3d88570e6c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 29 Dec 2019 02:29:20 +0800 Subject: [PATCH 178/806] Release 2.0.20-7 Signed-off-by: Kairui Song --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d7e1bc4..522936a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -351,6 +351,10 @@ done %endif %changelog +* Sun Dec 29 2019 Kairui Song - 2.0.20-7 +- Fix building failure due to makedumpfile's compile flag +- mkdumprd: Fix dracut args parsing + * Thu Nov 28 2019 Kairui Song - 2.0.20-6 - kdump-error-handler.service: Remove ExecStopPost - mkdumprd: simplify dracut args parsing From d10f2029961227194196b2dd673c44b7c2027e38 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 9 May 2019 14:31:24 +0800 Subject: [PATCH 179/806] kdump-lib: Don't abuse echo, and clean up Some of echo $(...) code segment is pointless, just call the command directly, and remove some useless if / return statement. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index f393c76..2318e2d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -121,11 +121,7 @@ get_user_configured_dump_disk() get_root_fs_device() { - local _target - _target=$(findmnt -k -f -n -o SOURCE /) - [ -n "$_target" ] && echo $_target - - return + findmnt -k -f -n -o SOURCE / } get_save_path() @@ -230,9 +226,9 @@ get_bind_mount_directory() echo $_mntpoint } -get_mntpoint_from_path() +get_mntpoint_from_path() { - echo $(df $1 | tail -1 | awk '{print $NF}') + df $1 | tail -1 | awk '{print $NF}' } get_target_from_path() @@ -244,9 +240,9 @@ get_target_from_path() echo $_target } -get_fs_type_from_target() +get_fs_type_from_target() { - echo $(findmnt -k -f -n -r -o FSTYPE $1) + findmnt -k -f -n -r -o FSTYPE $1 } # input: device path @@ -281,7 +277,7 @@ get_mntpoint_from_target() # get_option_value # retrieves value of option defined in kdump.conf get_option_value() { - echo $(strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`) + strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` } #This function compose a absolute path with the mount From 03111c797b6e5a9939b1835aa426c971b054ab15 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sat, 30 Nov 2019 23:46:55 +0800 Subject: [PATCH 180/806] Always use get_save_path to get the 'path' option This help deduplicate the code. Use a single function instead of repeat the same logic. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 15 +++------------ kdump-lib.sh | 9 ++++----- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e6358a8..8e9fe42 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -428,12 +428,7 @@ default_dump_target_install_conf() is_user_configured_dump_target && return - _save_path=$(get_option_value "path") - [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH - - # strip the duplicated "/" - _save_path=$(echo $_save_path | tr -s /) - + _save_path=$(get_save_path) _mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path) @@ -472,13 +467,9 @@ default_dump_target_install_conf() adjust_bind_mount_path() { local _target=$1 - local _save_path=$(get_option_value "path") - [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH - - # strip the duplicated "/" - _save_path=$(echo $_save_path | tr -s /) - + local _save_path=$(get_save_path) local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path + _absolute_save_path=$(echo "$_absolute_save_path" | tr -s /) local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) diff --git a/kdump-lib.sh b/kdump-lib.sh index 2318e2d..d35282d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -126,12 +126,11 @@ get_root_fs_device() get_save_path() { - local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') - if [ -z "$_save_path" ]; then - _save_path=$DEFAULT_PATH - fi + local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') + [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH - echo $_save_path + # strip the duplicated "/" + echo $(echo $_save_path | tr -s /) } get_block_dump_target() From b76c56732594e28e8568be12c618718fc184e2d5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sat, 30 Nov 2019 23:53:02 +0800 Subject: [PATCH 181/806] kdump-lib.sh: Fix is_nfs_dump_target Previously is_nfs_dump_target didn't cover the case that 'path ' where points to a nfs mount point. This function is never used in first kernel before so so far it worked. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d35282d..8aad556 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -28,6 +28,11 @@ perror() { echo $@ >&2 } +is_fs_type_nfs() +{ + [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] +} + is_ssh_dump_target() { grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf @@ -35,8 +40,23 @@ is_ssh_dump_target() is_nfs_dump_target() { - grep -q "^nfs" /etc/kdump.conf || \ - [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)") = nfs* ]] + if grep -q "^nfs" /etc/kdump.conf; then + return 0; + fi + + if is_fs_type_nfs $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)"); then + return 0 + fi + + local _save_path=$(get_save_path) + local _target=$(get_target_from_path $_save_path) + local _fstype=$(get_fs_type_from_target $_target) + + if is_fs_type_nfs $_fstype; then + return 0 + fi + + return 1 } is_raw_dump_target() @@ -44,13 +64,6 @@ is_raw_dump_target() grep -q "^raw" /etc/kdump.conf } -is_fs_type_nfs() -{ - local _fstype=$1 - [ $_fstype = "nfs" ] || [ $_fstype = "nfs4" ] && return 0 - return 1 -} - is_fs_dump_target() { egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf @@ -104,8 +117,7 @@ to_dev_name() { is_user_configured_dump_target() { - return $(is_mount_in_dracut_args || is_ssh_dump_target || is_nfs_dump_target || \ - is_raw_dump_target || is_fs_dump_target) + grep -q "^ext[234]|^xfs|^btrfs|^minix|^raw|^nfs|^ssh" /etc/kdump.conf || is_mount_in_dracut_args; } get_user_configured_dump_disk() From bcdcf35759833f33039a6ae46b2b0407ab80da41 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Dec 2019 13:02:00 +0800 Subject: [PATCH 182/806] Fix potential ssh/nfs kdump failure of missing "ip" command For ssh/nfs dump, kdump need the 'ip' tool to get the host ip address for naming the vmcore. But kdump-module-setup.sh never installed this tool. kdump-module-setup.sh worked so far as dracut network module will help install it. After dracut changed to use 35network-manager for network setup, "ip" command won't be installed in second kernel by default. So need to ensure "ip" is installed when installing kdump dracut module. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8e9fe42..9babae8 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -839,6 +839,11 @@ install() { # at some point of time. kdump_check_iscsi_targets + # nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail + if is_nfs_dump_target || is_ssh_dump_target; then + inst "ip" + fi + # For the lvm type target under kdump, in /etc/lvm/lvm.conf we can # safely replace "reserved_memory=XXXX"(default value is 8192) with # "reserved_memory=1024" to lower memory pressure under kdump. We do From 24b00298d0b869c94dc7a894c673c2aff6dd83d7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 1 Dec 2019 00:00:50 +0800 Subject: [PATCH 183/806] Always install sed and awk sed and awk is heavily used everywhere in the code, but it's not explicitely installed by kdump dracut module. If the module in dracut stop installing them (which already happened with latest dracut upstream), kdump will break. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 9babae8..3558a0f 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -819,6 +819,8 @@ install() { inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/bin/head" "/bin/head" + inst "/bin/awk" "/bin/awk" + inst "/bin/sed" "/bin/sed" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" From cee618593c35443f3cf5dbce85cf5b04cbeb34de Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 9 Jan 2020 00:53:41 +0800 Subject: [PATCH 184/806] Add a hook to wait for kdump target in initqueue The dracut initqueue may quit immediately and won't trigger any hook if there is no "finished" hook still pending (finished hook will be deleted once it return 0). This issue start to appear with latest dracut, latest dracut use network-manager to configure the network, network-manager module only install "settled" hook, and we didn't install any other hook. So NFS/SSH dump will fail. iSCSI dump works because dracut iscsi module will install a "finished" hook to detect if the iscsi target is up. So for NFS/SSH we keep initqueue running until the host successfully get a valid IP address, which means the network is ready. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-kdump-wait-for-target.sh | 23 ++++++++++++++++ dracut-kdump.sh | 48 --------------------------------- dracut-module-setup.sh | 2 ++ kdump-lib-initramfs.sh | 48 +++++++++++++++++++++++++++++++++ kexec-tools.spec | 2 ++ 5 files changed, 75 insertions(+), 48 deletions(-) create mode 100755 dracut-kdump-wait-for-target.sh diff --git a/dracut-kdump-wait-for-target.sh b/dracut-kdump-wait-for-target.sh new file mode 100755 index 0000000..ce984d0 --- /dev/null +++ b/dracut-kdump-wait-for-target.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# only wait if it's kdump kernel +if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then + exit 0 +fi + +. /lib/dracut-lib.sh +. /lib/kdump-lib-initramfs.sh + +# For SSH/NFS target, need to wait for the network to setup +if is_nfs_dump_target; then + get_host_ip + exit $? +fi + +if is_ssh_dump_target; then + get_host_ip + exit $? +fi + +# No need to wait for dump target +exit 0 diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 2ae1c7c..8add48d 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -114,54 +114,6 @@ save_vmcore_dmesg_ssh() { fi } -get_host_ip() -{ - local _host - if is_nfs_dump_target || is_ssh_dump_target - then - kdumpnic=$(getarg kdumpnic=) - [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 - _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` - [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - _host=`echo $_host | head -n 1 | cut -d' ' -f2` - _host="${_host%%/*}" - [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - HOST_IP=$_host - fi - return 0 -} - -read_kdump_conf() -{ - if [ ! -f "$KDUMP_CONF" ]; then - echo "kdump: $KDUMP_CONF not found" - return - fi - - get_kdump_confs - - # rescan for add code for dump target - while read config_opt config_val; - do - # remove inline comments after the end of a directive. - case "$config_opt" in - dracut_args) - config_val=$(get_dracut_args_target "$config_val") - [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" - ;; - ext[234]|xfs|btrfs|minix|nfs) - add_dump_code "dump_fs $config_val" - ;; - raw) - add_dump_code "dump_raw $config_val" - ;; - ssh) - add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" - ;; - esac - done <<< "$(read_strip_comments $KDUMP_CONF)" -} - fence_kdump_notify() { if [ -n "$FENCE_KDUMP_NODES" ]; then diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3558a0f..570bd62 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -842,7 +842,9 @@ install() { kdump_check_iscsi_targets # nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail + # also need to let initqueue wait for target to become ready if is_nfs_dump_target || is_ssh_dump_target; then + inst_hook initqueue/finished 01 $moddir/kdump-wait-for-target.sh inst "ip" fi diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 8530556..d5d2ee2 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -201,3 +201,51 @@ do_final_action() { eval $FINAL_ACTION } + +get_host_ip() +{ + local _host + if is_nfs_dump_target || is_ssh_dump_target + then + kdumpnic=$(getarg kdumpnic=) + [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 + _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` + [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + _host=`echo $_host | head -n 1 | cut -d' ' -f2` + _host="${_host%%/*}" + [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + HOST_IP=$_host + fi + return 0 +} + +read_kdump_conf() +{ + if [ ! -f "$KDUMP_CONF" ]; then + echo "kdump: $KDUMP_CONF not found" + return + fi + + get_kdump_confs + + # rescan for add code for dump target + while read config_opt config_val; + do + # remove inline comments after the end of a directive. + case "$config_opt" in + dracut_args) + config_val=$(get_dracut_args_target "$config_val") + [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" + ;; + ext[234]|xfs|btrfs|minix|nfs) + add_dump_code "dump_fs $config_val" + ;; + raw) + add_dump_code "dump_raw $config_val" + ;; + ssh) + add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" + ;; + esac + done <<< "$(read_strip_comments $KDUMP_CONF)" +} diff --git a/kexec-tools.spec b/kexec-tools.spec index 522936a..616b504 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -50,6 +50,7 @@ Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target Source108: dracut-early-kdump.sh Source109: dracut-early-kdump-module-setup.sh +Source110: dracut-kdump-wait-for-target.sh Requires(post): systemd-units Requires(preun): systemd-units @@ -225,6 +226,7 @@ cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} +cp %{SOURCE110} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE110}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump From 69b920db5de9acca427d79d2f298eeaa349d86d1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 Jan 2020 08:22:37 +0800 Subject: [PATCH 185/806] Update makedumpfile to 1.6.7 Signed-off-by: Kairui Song --- ...d-when-get_num_dumpable_cyclic-fails.patch | 44 --- ...xclusion-range-in-find_vmemmap_pages.patch | 37 -- ...stent-return-value-from-find_vmemmap.patch | 327 ------------------ ...e-Increase-SECTION_MAP_LAST_BIT-to-4.patch | 38 -- ...ools-2.0.20-makedumpfile-remove-lebl.patch | 26 -- ...-Fix-incorrect-exclusion-by-e-option.patch | 41 --- kexec-tools.spec | 14 +- sources | 2 +- 8 files changed, 2 insertions(+), 527 deletions(-) delete mode 100644 kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-remove-lebl.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch b/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch deleted file mode 100644 index 4cbdfa1..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch +++ /dev/null @@ -1,44 +0,0 @@ -From c1b834f80311706db2b5070cbccdcba3aacc90e5 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 23 Jul 2019 11:50:52 -0400 -Subject: [PATCH 1/2] Do not proceed when get_num_dumpable_cyclic() fails - -Currently, when get_num_dumpable_cyclic() fails and returns FALSE in -create_dump_bitmap(), info->num_dumpable is set to 0 and makedumpfile -proceeds to write a broken dumpfile slowly with incorrect progress -indicator due to the value. - -It should not proceed when get_num_dumpable_cyclic() fails. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile.c b/makedumpfile.c -index d76a4358a2b2..88df788fd6e7 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -7344,7 +7344,8 @@ create_dump_bitmap(void) - if (!prepare_bitmap2_buffer()) - goto out; - -- info->num_dumpable = get_num_dumpable_cyclic(); -+ if (!(info->num_dumpable = get_num_dumpable_cyclic())) -+ goto out; - - if (!info->flag_elf_dumpfile) - free_bitmap2_buffer(); -@@ -7362,7 +7363,8 @@ create_dump_bitmap(void) - if (!create_2nd_bitmap(&cycle)) - goto out; - -- info->num_dumpable = get_num_dumpable_cyclic(); -+ if (!(info->num_dumpable = get_num_dumpable_cyclic())) -+ goto out; - } - - ret = TRUE; --- -2.18.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch b/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch deleted file mode 100644 index 2c94711..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch +++ /dev/null @@ -1,37 +0,0 @@ -From b461971bfac0f193a0c274c3b657d158e07d4995 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Thu, 29 Aug 2019 14:51:56 -0400 -Subject: [PATCH] Fix exclusion range in find_vmemmap_pages() - -In the function, since pfn ranges are literally start and end, not start -and end+1, if the struct page of endpfn is at the last in a vmemmap page, -the vmemmap page is dropped by the following code, and not excluded. - - npfns_offset = endpfn - vmapp->rep_pfn_start; - vmemmap_offset = npfns_offset * size_table.page; - // round down to page boundary - vmemmap_offset -= (vmemmap_offset % pagesize); - -We can use (endpfn+1) here to fix. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index 88df788..37df77d 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -6315,7 +6315,7 @@ find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long * - start_vmemmap_pfn = vmapp->vmap_pfn_start + vmemmap_pfns; - *vmappfn = start_vmemmap_pfn; - -- npfns_offset = endpfn - vmapp->rep_pfn_start; -+ npfns_offset = (endpfn+1) - vmapp->rep_pfn_start; - vmemmap_offset = npfns_offset * size_table.page; - // round down to page boundary - vmemmap_offset -= (vmemmap_offset % pagesize); --- -2.20.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch b/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch deleted file mode 100644 index 61cbda0..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch +++ /dev/null @@ -1,327 +0,0 @@ -From 8425342a52b23d462f10bceeeb1c8a3a43d56bf0 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Fri, 6 Sep 2019 09:50:34 -0400 -Subject: [PATCH] Fix inconsistent return value from find_vmemmap() - -When -e option is given, the find_vmemmap() returns FAILED(1) if -it failed on x86_64, but on architectures other than that, it is -stub_false() and returns FALSE(0). - - if (info->flag_excludevm) { - if (find_vmemmap() == FAILED) { - ERRMSG("Can't find vmemmap pages\n"); - - #define find_vmemmap() stub_false() - -As a result, on the architectures other than x86_64, the -e option -does some unnecessary processing with no effect, and marks the dump -DUMP_DH_EXCLUDED_VMEMMAP unexpectedly. - -Also, the functions for the -e option return COMPLETED or FAILED, -which are for command return value, not for function return value. - -So let's fix the issue by following the common style that returns -TRUE or FALSE, and avoid confusion. - -Signed-off-by: Kazuhito Hagio ---- - arch/x86_64.c | 12 ++++----- - makedumpfile.c | 70 ++++++++++++++++++++++++-------------------------- - 2 files changed, 40 insertions(+), 42 deletions(-) - -diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c -index 4eeaf4925f43..876644f932be 100644 ---- a/makedumpfile-1.6.6/arch/x86_64.c -+++ b/makedumpfile-1.6.6/arch/x86_64.c -@@ -673,7 +673,7 @@ find_vmemmap_x86_64() - - if (init_level4_pgt == NOT_FOUND_SYMBOL) { - ERRMSG("init_level4_pgt/init_top_pgt not found\n"); -- return FAILED; -+ return FALSE; - } - - if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) -@@ -715,7 +715,7 @@ find_vmemmap_x86_64() - if (!readmem(PADDR, (unsigned long long)pgdp, (void *)&pud_addr, - sizeof(unsigned long))) { - ERRMSG("Can't get pgd entry for slot %d.\n", pgd_index); -- return FAILED; -+ return FALSE; - } - - /* mask the pgd entry for the address of the pud page */ -@@ -726,7 +726,7 @@ find_vmemmap_x86_64() - if (!readmem(PADDR, (unsigned long long)pud_addr, (void *)pud_page, - PTRS_PER_PUD * sizeof(unsigned long))) { - ERRMSG("Can't get pud entry for pgd slot %ld.\n", pgdindex); -- return FAILED; -+ return FALSE; - } - /* step thru each pmd address in the pud page */ - /* pudp points to an entry in the pud page */ -@@ -739,7 +739,7 @@ find_vmemmap_x86_64() - if (!readmem(PADDR, pmd_addr, (void *)pmd_page, - PTRS_PER_PMD * sizeof(unsigned long))) { - ERRMSG("Can't get pud entry for slot %ld.\n", pudindex); -- return FAILED; -+ return FALSE; - } - /* pmdp points to an entry in the pmd */ - for (pmdp = (unsigned long *)pmd_page, pmdindex = 0; -@@ -815,7 +815,7 @@ find_vmemmap_x86_64() - num_pmds_valid++; - if (!(pmd & _PAGE_PSE)) { - printf("vmemmap pmd not huge, abort\n"); -- return FAILED; -+ return FALSE; - } - } else { - if (last_valid) { -@@ -947,7 +947,7 @@ find_vmemmap_x86_64() - i++; - } while (cur != vmaphead); - nr_gvmem_pfns = i; -- return COMPLETED; -+ return TRUE; - } - - #endif /* x86_64 */ -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index 37df77d181dd..af4db3c006c9 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -6213,20 +6213,20 @@ init_save_control() - flags = O_RDWR|O_CREAT|O_TRUNC; - if ((sc.sc_fd = open(sc.sc_filename, flags, S_IRUSR|S_IWUSR)) < 0) { - ERRMSG("Can't open the pfn file %s.\n", sc.sc_filename); -- return FAILED; -+ return FALSE; - } - unlink(sc.sc_filename); - - sc.sc_buf = malloc(info->page_size); - if (!sc.sc_buf) { - ERRMSG("Can't allocate a page for pfn buf.\n"); -- return FAILED; -+ return FALSE; - } - sc.sc_buflen = info->page_size; - sc.sc_bufposition = 0; - sc.sc_fileposition = 0; - sc.sc_filelen = 0; -- return COMPLETED; -+ return TRUE; - } - - /* -@@ -6243,7 +6243,7 @@ save_deletes(unsigned long startpfn, unsigned long numpfns) - if (i != sc.sc_buflen) { - ERRMSG("save: Can't write a page to %s\n", - sc.sc_filename); -- return FAILED; -+ return FALSE; - } - sc.sc_filelen += sc.sc_buflen; - sc.sc_bufposition = 0; -@@ -6252,12 +6252,12 @@ save_deletes(unsigned long startpfn, unsigned long numpfns) - scp->startpfn = startpfn; - scp->numpfns = numpfns; - sc.sc_bufposition += sizeof(struct sc_entry); -- return COMPLETED; -+ return TRUE; - } - - /* - * Get a starting pfn and number of pfns for delete from bitmap. -- * Return 0 for success, 1 for 'no more' -+ * Return TRUE(1) for success, FALSE(0) for 'no more' - */ - int - get_deletes(unsigned long *startpfn, unsigned long *numpfns) -@@ -6266,14 +6266,14 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) - struct sc_entry *scp; - - if (sc.sc_fileposition >= sc.sc_filelen) { -- return FAILED; -+ return FALSE; - } - - if (sc.sc_bufposition == sc.sc_buflen) { - i = read(sc.sc_fd, sc.sc_buf, sc.sc_buflen); - if (i <= 0) { - ERRMSG("Can't read a page from %s.\n", sc.sc_filename); -- return FAILED; -+ return FALSE; - } - sc.sc_bufposition = 0; - } -@@ -6282,7 +6282,7 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) - *numpfns = scp->numpfns; - sc.sc_bufposition += sizeof(struct sc_entry); - sc.sc_fileposition += sizeof(struct sc_entry); -- return COMPLETED; -+ return TRUE; - } - - /* -@@ -6290,7 +6290,7 @@ get_deletes(unsigned long *startpfn, unsigned long *numpfns) - * that represent them. - * (pfn ranges are literally start and end, not start and end+1) - * see the array of vmemmap pfns and the pfns they represent: gvmem_pfns -- * Return COMPLETED for delete, FAILED for not to delete. -+ * Return TRUE(1) for delete, FALSE(0) for not to delete. - */ - int - find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long *vmappfn, -@@ -6323,12 +6323,12 @@ find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long * - end_vmemmap_pfn = vmapp->vmap_pfn_start + vmemmap_pfns; - npages = end_vmemmap_pfn - start_vmemmap_pfn; - if (npages == 0) -- return FAILED; -+ return FALSE; - *nmapnpfns = npages; -- return COMPLETED; -+ return TRUE; - } - } -- return FAILED; -+ return FALSE; - } - - /* -@@ -6359,12 +6359,12 @@ find_unused_vmemmap_pages(void) - if (lseek(bitmap1->fd, new_offset1, SEEK_SET) < 0 ) { - ERRMSG("Can't seek the bitmap(%s). %s\n", - bitmap1->file_name, strerror(errno)); -- return FAILED; -+ return FALSE; - } - if (read(bitmap1->fd, bitmap1->buf, BUFSIZE_BITMAP) != BUFSIZE_BITMAP) { - ERRMSG("Can't read the bitmap(%s). %s\n", - bitmap1->file_name, strerror(errno)); -- return FAILED; -+ return FALSE; - } - bitmap1->no_block = pfn / PFN_BUFBITMAP; - -@@ -6372,12 +6372,12 @@ find_unused_vmemmap_pages(void) - if (lseek(bitmap2->fd, new_offset2, SEEK_SET) < 0 ) { - ERRMSG("Can't seek the bitmap(%s). %s\n", - bitmap2->file_name, strerror(errno)); -- return FAILED; -+ return FALSE; - } - if (read(bitmap2->fd, bitmap2->buf, BUFSIZE_BITMAP) != BUFSIZE_BITMAP) { - ERRMSG("Can't read the bitmap(%s). %s\n", - bitmap2->file_name, strerror(errno)); -- return FAILED; -+ return FALSE; - } - bitmap2->no_block = pfn / PFN_BUFBITMAP; - -@@ -6422,12 +6422,11 @@ find_unused_vmemmap_pages(void) - endpfn = startpfn + - (numwords * BITS_PER_WORD) - 1; - if (find_vmemmap_pages(startpfn, endpfn, -- &vmapstartpfn, &vmapnumpfns) == -- COMPLETED) { -- if (save_deletes(vmapstartpfn, -- vmapnumpfns) == FAILED) { -+ &vmapstartpfn, &vmapnumpfns)) { -+ if (!save_deletes(vmapstartpfn, -+ vmapnumpfns)) { - ERRMSG("save_deletes failed\n"); -- return FAILED; -+ return FALSE; - } - deleted_pages += vmapnumpfns; - } -@@ -6444,11 +6443,10 @@ find_unused_vmemmap_pages(void) - not start and end + 1 */ - endpfn = startpfn + (numwords * BITS_PER_WORD) - 1; - if (find_vmemmap_pages(startpfn, endpfn, -- &vmapstartpfn, &vmapnumpfns) == COMPLETED) { -- if (save_deletes(vmapstartpfn, vmapnumpfns) -- == FAILED) { -+ &vmapstartpfn, &vmapnumpfns)) { -+ if (!save_deletes(vmapstartpfn, vmapnumpfns)) { - ERRMSG("save_deletes failed\n"); -- return FAILED; -+ return FALSE; - } - deleted_pages += vmapnumpfns; - } -@@ -6457,7 +6455,7 @@ find_unused_vmemmap_pages(void) - } - PROGRESS_MSG("\nExcluded %ld unused vmemmap pages\n", deleted_pages); - -- return COMPLETED; -+ return TRUE; - } - - /* -@@ -6468,7 +6466,7 @@ delete_unused_vmemmap_pages(void) - { - unsigned long startpfn, numpfns, pfn, i; - -- while (get_deletes(&startpfn, &numpfns) == COMPLETED) { -+ while (get_deletes(&startpfn, &numpfns)) { - for (i = 0, pfn = startpfn; i < numpfns; i++, pfn++) { - clear_bit_on_2nd_bitmap_for_kernel(pfn, (struct cycle *)0); - // note that this is never to be used in cyclic mode! -@@ -6496,23 +6494,23 @@ reset_save_control() - { - int i; - if (sc.sc_bufposition == 0) -- return COMPLETED; -+ return TRUE; - - i = write(sc.sc_fd, sc.sc_buf, sc.sc_buflen); - if (i != sc.sc_buflen) { - ERRMSG("reset: Can't write a page to %s\n", - sc.sc_filename); -- return FAILED; -+ return FALSE; - } - sc.sc_filelen += sc.sc_bufposition; - - if (lseek(sc.sc_fd, 0, SEEK_SET) < 0) { - ERRMSG("Can't seek the pfn file %s).", sc.sc_filename); -- return FAILED; -+ return FALSE; - } - sc.sc_fileposition = 0; - sc.sc_bufposition = sc.sc_buflen; /* trigger 1st read */ -- return COMPLETED; -+ return TRUE; - } - - int -@@ -6602,11 +6600,11 @@ create_2nd_bitmap(struct cycle *cycle) - - /* --exclude-unused-vm means exclude vmemmap page structures for unused pages */ - if (info->flag_excludevm) { -- if (init_save_control() == FAILED) -+ if (!init_save_control()) - return FALSE; -- if (find_unused_vmemmap_pages() == FAILED) -+ if (!find_unused_vmemmap_pages()) - return FALSE; -- if (reset_save_control() == FAILED) -+ if (!reset_save_control()) - return FALSE; - delete_unused_vmemmap_pages(); - finalize_save_control(); -@@ -10095,7 +10093,7 @@ create_dumpfile(void) - - /* create an array of translations from pfn to vmemmap pages */ - if (info->flag_excludevm) { -- if (find_vmemmap() == FAILED) { -+ if (!find_vmemmap()) { - ERRMSG("Can't find vmemmap pages\n"); - info->flag_excludevm = 0; - } --- -2.18.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch b/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch deleted file mode 100644 index 050d83c..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 7bdb468c2c99dd780c9a5321f93c79cbfdce2527 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 23 Jul 2019 12:24:47 -0400 -Subject: [PATCH 2/2] Increase SECTION_MAP_LAST_BIT to 4 - -kernel commit 326e1b8f83a4 ("mm/sparsemem: introduce a SECTION_IS_EARLY -flag") added the flag to mem_section->section_mem_map value, and it caused -makedumpfile an error like the following: - - readmem: Can't convert a virtual address(fffffc97d1000000) to physical address. - readmem: type_addr: 0, addr:fffffc97d1000000, size:32768 - __exclude_unnecessary_pages: Can't read the buffer of struct page. - create_2nd_bitmap: Can't exclude unnecessary pages. - -To fix this, SECTION_MAP_LAST_BIT needs to be updated. The bit has not -been used until the addition, so we can just increase the value. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile.h b/makedumpfile.h -index 24b2f69f400c..df745b9f53e5 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h -@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) - * 2. it has been verified that (1UL<<2) was never set, so it is - * safe to mask that bit off even in old kernels. - */ --#define SECTION_MAP_LAST_BIT (1UL<<3) -+#define SECTION_MAP_LAST_BIT (1UL<<4) - #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) - #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) - #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) --- -2.18.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch b/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch deleted file mode 100644 index ca63d82..0000000 --- a/kexec-tools-2.0.20-makedumpfile-remove-lebl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3beef142bc003d9cf2e957c6a21e51d661f9b13e Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Thu, 28 Nov 2019 21:23:00 +0800 -Subject: [PATCH] makedumpfile: remove -lebl - -Signed-off-by: Pingfan Liu ---- - makedumpfile-1.6.6/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/Makefile b/makedumpfile-1.6.6/Makefile -index 1fdb628..df21b93 100644 ---- a/makedumpfile-1.6.6/Makefile -+++ b/makedumpfile-1.6.6/Makefile -@@ -50,7 +50,7 @@ OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) - SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c - OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) - --LIBS = -ldw -lbz2 -lebl -ldl -lelf -lz -+LIBS = -ldw -lbz2 -ldl -lelf -lz - ifneq ($(LINKTYPE), dynamic) - LIBS := -static $(LIBS) - endif --- -2.20.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch b/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch deleted file mode 100644 index fa60b6a..0000000 --- a/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch +++ /dev/null @@ -1,41 +0,0 @@ -From aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Thu, 29 Aug 2019 12:26:34 -0400 -Subject: [PATCH] x86_64: Fix incorrect exclusion by -e option with KASLR - -The -e option uses info->vmemmap_start for creating a table to determine -the positions of page structures that should be excluded, but it is a -hardcoded value even with KASLR-enabled vmcore. As a result, the option -excludes incorrect pages from it. - -To fix this, get the vmemmap start address from info->mem_map_data. - -Signed-off-by: Kazuhito Hagio ---- - arch/x86_64.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c -index 3c0fdc5..4eeaf49 100644 ---- a/makedumpfile-1.6.6/arch/x86_64.c -+++ b/makedumpfile-1.6.6/arch/x86_64.c -@@ -679,6 +679,16 @@ find_vmemmap_x86_64() - if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) - pmask &= ~(NUMBER(sme_mask)); - -+ /* -+ * vmemmap region can be randomized by KASLR. -+ * (currently we don't utilize info->vmemmap_end on x86_64.) -+ * -+ if (info->mem_map_data && -+ info->mem_map_data[0].mem_map != NOT_MEMMAP_ADDR) -+ info->vmemmap_start = info->mem_map_data[0].mem_map; -+ -+ DEBUG_MSG("vmemmap_start: %16lx\n", info->vmemmap_start); -+ - pagestructsize = size_table.page; - hugepagesize = PTRS_PER_PMD * info->page_size; - vaddr_base = info->vmemmap_start; --- -2.20.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 616b504..73d985a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ %global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.6.6 +%global mkdf_ver 1.6.7 Name: kexec-tools Version: 2.0.20 @@ -82,8 +82,6 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # -Patch101: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch -Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -99,10 +97,6 @@ Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pa # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch -Patch602: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch -Patch603: kexec-tools-2.0.20-makedumpfile-Fix-inconsistent-return-value-from-find_vmemmap.patch -Patch604: kexec-tools-2.0.20-makedumpfile-remove-lebl.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -119,12 +113,6 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch0 -p1 -%patch601 -p1 -%patch602 -p1 -%patch101 -p1 -%patch102 -p1 -%patch603 -p1 -%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc diff --git a/sources b/sources index 1d5c7d0..574d13c 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d -SHA512 (makedumpfile-1.6.6.tar.gz) = f4926d7800fe21b9125c03b8ce043e7cc3420b997a7d9f4ce7b565cde7f5b4aaf9ac958dbbefe5868ee3cb639ccb2d40c10f774ac2720baeac2242fc0bf66df2 SHA512 (kexec-tools-2.0.20.tar.xz) = 3112b6202c1030705c53e3f65a2b58aec14d65333a35aad681d48b9f2bd1c51a2e05c985a1e5e867ab02f8a9c97708483d9d225619db7c6993676f1a242e2d99 +SHA512 (makedumpfile-1.6.7.tar.gz) = fdd78bfea5f96eda094269480ebbceead6ae8d9d2bb1184ffa1e18c6effda5c6df296fbcecc25735109194c0690d6f9ca684c37da1825d7d65568ba18a71a940 From 71d20dc825d7db5810b733fd2c615804d032c511 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 Jan 2020 08:17:29 +0800 Subject: [PATCH 186/806] Release 2.0.20-8 Signed-off-by: Kairui Song --- kexec-tools.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 73d985a..91ea245 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -341,6 +341,15 @@ done %endif %changelog +* Wed Jan 29 2020 Kairui Song - 2.0.20-8 +- Update makedumpfile to 1.6.7 +- Add a hook to wait for kdump target in initqueue +- Always install sed and awk +- Fix potential ssh/nfs kdump failure of missing "ip" command +- kdump-lib.sh: Fix is_nfs_dump_target +- Always use get_save_path to get the 'path' option +- kdump-lib: Don't abuse echo, and clean up + * Sun Dec 29 2019 Kairui Song - 2.0.20-7 - Fix building failure due to makedumpfile's compile flag - mkdumprd: Fix dracut args parsing From 47f2a819d5cd682b52b781dd5ef7ee700b024b1b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 Jan 2020 12:30:24 +0800 Subject: [PATCH 187/806] Fix builing failure on Fedora 32 Signed-off-by: Kairui Song --- ...ove-duplicated-variable-declarations.patch | 98 +++++++++++++++++++ ...move-duplicated-variable-declaration.patch | 36 +++++++ ...ove-duplicated-variable-declarations.patch | 76 ++++++++++++++ kexec-tools.spec | 7 ++ 4 files changed, 217 insertions(+) create mode 100644 kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch create mode 100644 kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch create mode 100644 kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch diff --git a/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch b/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch new file mode 100644 index 0000000..966f007 --- /dev/null +++ b/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch @@ -0,0 +1,98 @@ +From 23daba8bb97ff4291447e54859ed759cfe07975e Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 29 Jan 2020 10:48:27 +0800 +Subject: [PATCH] kexec-tools: Remove duplicated variable declarations + +When building kexec-tools for Fedora 32, following error is observed: + +/usr/bin/ld: kexec/arch/x86_64/kexec-bzImage64.o:(.bss+0x0): multiple definition of `bzImage_support_efi_boot'; +kexec/arch/i386/kexec-bzImage.o:(.bss+0x0): first defined here + +/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm/../../fs2dt.h:33: multiple definition of `my_debug'; +kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/kexec/fs2dt.h:33: first defined here + +/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:68: multiple definition of `arm64_mem'; +kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:68: first defined here + +/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:54: multiple definition of `initrd_size'; +kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:54: first defined here + +/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:53: multiple definition of `initrd_base'; +kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:53: first defined here + +And apparently, these variables are wrongly declared multiple times. So +remove duplicated declaration. + +Signed-off-by: Kairui Song +--- + kexec/arch/arm64/kexec-arm64.h | 6 +++--- + kexec/arch/ppc64/kexec-elf-ppc64.c | 2 -- + kexec/arch/x86_64/kexec-bzImage64.c | 1 - + kexec/fs2dt.h | 2 +- + 4 files changed, 4 insertions(+), 7 deletions(-) + +diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h +index 628de79..ed447ac 100644 +--- a/kexec/arch/arm64/kexec-arm64.h ++++ b/kexec/arch/arm64/kexec-arm64.h +@@ -50,8 +50,8 @@ int zImage_arm64_load(int argc, char **argv, const char *kernel_buf, + void zImage_arm64_usage(void); + + +-off_t initrd_base; +-off_t initrd_size; ++extern off_t initrd_base; ++extern off_t initrd_size; + + /** + * struct arm64_mem - Memory layout info. +@@ -65,7 +65,7 @@ struct arm64_mem { + }; + + #define arm64_mem_ngv UINT64_MAX +-struct arm64_mem arm64_mem; ++extern struct arm64_mem arm64_mem; + + uint64_t get_phys_offset(void); + uint64_t get_vp_offset(void); +diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c +index 3510b70..695b8b0 100644 +--- a/kexec/arch/ppc64/kexec-elf-ppc64.c ++++ b/kexec/arch/ppc64/kexec-elf-ppc64.c +@@ -44,8 +44,6 @@ + uint64_t initrd_base, initrd_size; + unsigned char reuse_initrd = 0; + const char *ramdisk; +-/* Used for enabling printing message from purgatory code */ +-int my_debug = 0; + + int elf_ppc64_probe(const char *buf, off_t len) + { +diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c +index 8edb3e4..ba8dc48 100644 +--- a/kexec/arch/x86_64/kexec-bzImage64.c ++++ b/kexec/arch/x86_64/kexec-bzImage64.c +@@ -42,7 +42,6 @@ + #include + + static const int probe_debug = 0; +-int bzImage_support_efi_boot; + + int bzImage64_probe(const char *buf, off_t len) + { +diff --git a/kexec/fs2dt.h b/kexec/fs2dt.h +index 7633273..fe24931 100644 +--- a/kexec/fs2dt.h ++++ b/kexec/fs2dt.h +@@ -30,7 +30,7 @@ extern struct bootblock bb[1]; + + /* Used for enabling printing message from purgatory code + * Only has implemented for PPC64 */ +-int my_debug; ++extern int my_debug; + extern int dt_no_old_root; + + void reserve(unsigned long long where, unsigned long long length); +-- +2.24.1 + diff --git a/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch b/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch new file mode 100644 index 0000000..8d77b9b --- /dev/null +++ b/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch @@ -0,0 +1,36 @@ +From 2837fb1f5f8362976c188b30ebe50dc8b0377f64 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 29 Jan 2020 11:33:18 +0800 +Subject: [PATCH] Remove duplicated variable declaration + +When building on Fedora 32, following error is observed: + +... +/usr/bin/ld: ../eppic/libeppic/libeppic.a(eppic_stat.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: multiple definition of `lastv'; +../eppic/libeppic/libeppic.a(eppic_func.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: first defined here +... + +And apparently, the variable is wrongly declared multiple times. So +remove duplicated declaration. + +Signed-off-by: Kairui Song +--- + libeppic/eppic.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libeppic/eppic.h b/libeppic/eppic.h +index 5664583..836b475 100644 +--- a/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h ++++ b/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h +@@ -471,7 +471,7 @@ type_t *eppic_addstorage(type_t *t1, type_t *t2); + type_t *eppic_getvoidstruct(int ctype); + + extern int lineno, needvar, instruct, nomacs, eppic_legacy; +-node_t *lastv; ++extern node_t *lastv; + + #define NULLNODE ((node_t*)0) + +-- +2.24.1 + diff --git a/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch b/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch new file mode 100644 index 0000000..f240e8c --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch @@ -0,0 +1,76 @@ +From efa29d476996a20052be80878767cfe09e4b6224 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 29 Jan 2020 10:59:08 +0800 +Subject: [PATCH] makedumpfile: Remove duplicated variable declarations + +When building on Fedora 32, following error is observed: + +/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010: +multiple definition of `crash_reserved_mem_nr'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010: first defined here +/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009: +multiple definition of `crash_reserved_mem'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009: first defined here +/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278: +multiple definition of `parallel_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278: first defined here +/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265: +multiple definition of `splitting_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265: first defined here + +And apparently, these variables are wrongly declared multiple times. So +remove duplicated declaration. + +Signed-off-by: Kairui Song +--- + makedumpfile.c | 2 ++ + makedumpfile.h | 10 ++++++---- + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index e290fbd..9aad77b 100644 +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c +@@ -34,6 +34,8 @@ struct array_table array_table; + struct number_table number_table; + struct srcfile_table srcfile_table; + struct save_control sc; ++struct parallel_info parallel_info_t; ++struct splitting_info splitting_info_t; + + struct vm_table vt = { 0 }; + struct DumpInfo *info = NULL; +diff --git a/makedumpfile.h b/makedumpfile.h +index 68d9691..614764c 100644 +--- a/makedumpfile-1.6.7/makedumpfile.h ++++ b/makedumpfile-1.6.7/makedumpfile.h +@@ -1262,7 +1262,8 @@ struct splitting_info { + mdf_pfn_t end_pfn; + off_t offset_eraseinfo; + unsigned long size_eraseinfo; +-} splitting_info_t; ++}; ++extern struct splitting_info splitting_info_t; + + struct parallel_info { + int fd_memory; +@@ -1275,7 +1276,8 @@ struct parallel_info { + #ifdef USELZO + lzo_bytep wrkmem; + #endif +-} parallel_info_t; ++}; ++extern struct parallel_info parallel_info_t; + + struct ppc64_vmemmap { + unsigned long phys; +@@ -2006,8 +2008,8 @@ struct memory_range { + }; + + #define CRASH_RESERVED_MEM_NR 8 +-struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; +-int crash_reserved_mem_nr; ++extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; ++extern int crash_reserved_mem_nr; + + unsigned long read_vmcoreinfo_symbol(char *str_symbol); + int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size); +-- +2.24.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 91ea245..8467854 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -97,6 +97,9 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 601 onward are generic patches # +Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch +Patch602: ./kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch +Patch603: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -114,6 +117,10 @@ tar -z -x -v -f %{SOURCE19} %patch0 -p1 +%patch601 -p1 +%patch602 -p1 +%patch603 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 1b89cc245f68fd917024b9cb9bce3cd1704f1402 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 29 Jan 2020 14:42:11 +0800 Subject: [PATCH 188/806] Release 2.0.20-9 Signed-off-by: Kairui Song --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8467854..d7f7dc8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -348,6 +348,9 @@ done %endif %changelog +* Wed Jan 29 2020 Kairui Song - 2.0.20-9 +- Fix building failure + * Wed Jan 29 2020 Kairui Song - 2.0.20-8 - Update makedumpfile to 1.6.7 - Add a hook to wait for kdump target in initqueue From 6a20bd54473e11011bf2b47efb52d0759d412854 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 16 Jan 2020 13:47:35 +0800 Subject: [PATCH 189/806] kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default UEFI Secure boot is a signature verification mechanism, designed to prevent malicious code being loaded and executed at the early boot stage. This makes sure that code executed is trusted by firmware. Previously, with kexec_file_load() interface, kernel prevents unsigned kernel image from being loaded if secure boot is enabled. So kdump will detect whether secure boot is enabled firstly, then decide which interface is chosen to execute, kexec_load() or kexec_file_load(). Otherwise unsigned kernel loading will fail if secure boot enabled, and kexec_file_load() is entered. Now, the implementation of kexec_file_load() is adjusted in below commit. With this change, if CONFIG_KEXEC_SIG_FORCE is not set, unsigned kernel still has a chance to be allowed to load under some conditions. commit 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE") And in the current Fedora, the CONFIG_KEXEC_SIG_FORCE is not set, only the CONFIG_KEXEC_SIG and CONFIG_BZIMAGE_VERIFY_SIG are set on x86_64 by default. It's time to spread kexec_file_load() onto all systems of x86_64, including Secure-boot platforms and legacy platforms. Please refer to the following form. .----------------------------------------------------------------------. | . | signed kernel | unsigned kernel | | . types |-----------------------|-----------------------| | . |Secure boot| Legacy |Secure boot| Legacy | | . |-----------|-----------|-----------|-----------| | options . | prev| now | prev| now | | | prev| now | | . |(file|(file|(only|(file| prev| now |(only|(file| | . |load)|load)|load)|load)| | |load)|load)| |----------------------|-----|-----|-----|-----|-----|-----|-----|-----| |KEXEC_SIG=y | | | | | | | | | |SIG_FORCE is not set |succ |succ |succ |succ | X | X |succ |succ | |BZIMAGE_VERIFY_SIG=y | | | | | | | | | |----------------------|-----|-----|-----|-----|-----|-----|-----|-----| |KEXEC_SIG=y | | | | | | | | | |SIG_FORCE is not set | | | | | | | | | |BZIMAGE_VERIFY_SIG is |fail |fail |succ |fail | X | X |succ |fail | |not set | | | | | | | | | |----------------------|-----|-----|-----|-----|-----|-----|-----|-----| |KEXEC_SIG=y | | | | | | | | | |SIG_FORCE=y |succ |succ |succ |fail | X | X |succ |fail | |BZIMAGE_VERIFY_SIG=y | | | | | | | | | |----------------------|-----|-----|-----|-----|-----|-----|-----|-----| |KEXEC_SIG=y | | | | | | | | | |SIG_FORCE=y | | | | | | | | | |BZIMAGE_VERIFY_SIG is |fail |fail |succ |fail | X | X |succ |fail | |not set | | | | | | | | | |----------------------|-----|-----|-----|-----|-----|-----|-----|-----| |KEXEC_SIG is not set | | | | | | | | | |SIG_FORCE is not set | | | | | | | | | |BZIMAGE_VERIFY_SIG is |fail |fail |succ |succ | X | X |succ |succ | |not set | | | | | | | | | ---------------------------------------------------------------------- Note: [1] The 'X' indicates that the 1st kernel(unsigned) can not boot when the Secure boot is enabled. Hence, in this patch, if on x86_64, let's use the kexec_file_load() only. See if anything wrong happened in this case, in Fedora firstly for the time being. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-early-kdump.sh | 5 +++-- kdump-lib.sh | 29 ----------------------------- kdump.sysconfig.x86_64 | 6 ++++++ kdumpctl | 13 +++++++------ 4 files changed, 16 insertions(+), 37 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 69a34eb..6788a6b 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -2,6 +2,7 @@ KEXEC=/sbin/kexec standard_kexec_args="-p" +KDUMP_FILE_LOAD="" EARLY_KDUMP_INITRD="" EARLY_KDUMP_KERNEL="" @@ -43,8 +44,8 @@ early_kdump_load() EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") - if is_secure_boot_enforced; then - echo "Secure Boot is enabled. Using kexec file based syscall." + if [ "$KDUMP_FILE_LOAD" == "on" ]; then + echo "Using kexec file based syscall." EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" fi diff --git a/kdump-lib.sh b/kdump-lib.sh index 8aad556..2428b5d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -596,35 +596,6 @@ need_64bit_headers() print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` } -# Check if secure boot is being enforced. -# -# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and -# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four -# bytes are the attributes associated with the variable and can safely be -# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot -# is 1 and SetupMode is 0, then secure boot is being enforced. -# -# Assume efivars is mounted at /sys/firmware/efi/efivars. -is_secure_boot_enforced() -{ - local secure_boot_file setup_mode_file - local secure_boot_byte setup_mode_byte - - secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) - - if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) - - if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then - return 0 - fi - fi - - return 1 -} - # # prepare_kexec_args # This function prepares kexec argument. diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 09de2eb..a43a970 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -38,3 +38,9 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" + +# Using kexec file based syscall by default +# +# Here, the "on" is the only valid value to enable the kexec file load and +# anything else is equal to the "off"(disable). +KDUMP_FILE_LOAD="on" diff --git a/kdumpctl b/kdumpctl index 2d21a41..97fe541 100755 --- a/kdumpctl +++ b/kdumpctl @@ -4,6 +4,7 @@ KEXEC=/sbin/kexec KDUMP_KERNELVER="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" +KDUMP_FILE_LOAD="" KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" @@ -678,11 +679,8 @@ load_kdump() KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - # For secureboot enabled machines, use new kexec file based syscall. - # Old syscall will always fail as it does not have capability to - # to kernel signature verification. - if is_secure_boot_enforced; then - echo "Secure Boot is enabled. Using kexec file based syscall." + if [ "$KDUMP_FILE_LOAD" == "on" ]; then + echo "Using kexec file based syscall." KEXEC_ARGS="$KEXEC_ARGS -s" fi @@ -694,6 +692,9 @@ load_kdump() return 0 else echo "kexec: failed to load kdump kernel" >&2 + if [ "$KDUMP_FILE_LOAD" == "on" ]; then + echo "kexec_file_load() failed, please try kexec_load()" >&2 + fi return 1 fi } @@ -1162,7 +1163,7 @@ stop_fadump() stop_kdump() { - if is_secure_boot_enforced; then + if [ "$KDUMP_FILE_LOAD" == "on" ]; then $KEXEC -s -p -u else $KEXEC -p -u From e3f2f926dd9536bc800be78686aceadded9d83d3 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Wed, 29 Jan 2020 01:04:48 +0530 Subject: [PATCH 190/806] powerpc: enable the scripts to capture dump on POWERNV platform With FADump support added on POWERNV paltform, enable the scripts to capture /proc/vmcore. Also, if CONFIG_OPAL_CORE is enabled, OPAL core is preserved and exported on POWERNV platform. So, offload OPAL core, if it is available. Signed-off-by: Hari Bathini Acked-by: Kairui Song --- dracut-kdump.sh | 31 +++++++++++++++++++++++++++++-- kdump-lib-initramfs.sh | 26 ++++++++++++++++++++++++++ kdumpctl | 3 +++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 8add48d..0f54ddc 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -1,8 +1,8 @@ #!/bin/sh # continue here only if we have to save dump. -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then - exit 0 +if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then + exit 0 fi exec &> /dev/console @@ -81,6 +81,7 @@ dump_ssh() ssh -q $_opt $_host mkdir -p $_dir || return 1 save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host + save_opalcore_ssh ${_dir} "${_opt}" $_host echo "kdump: saving vmcore" @@ -96,6 +97,32 @@ dump_ssh() return 0 } +save_opalcore_ssh() { + local _path=$1 + local _opts="$2" + local _location=$3 + + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi + + echo "kdump: saving opalcore" + scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete + if [ $? -ne 0 ]; then + echo "kdump: saving opalcore failed" + return 1 + fi + + ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore + echo "kdump: saving opalcore complete" + return 0 +} + save_vmcore_dmesg_ssh() { local _dmesg_collector=$1 local _path=$2 diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index d5d2ee2..a7c0bf9 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -18,6 +18,7 @@ KDUMP_CONF="/etc/kdump.conf" KDUMP_PRE="" KDUMP_POST="" NEWROOT="/sysroot" +OPALCORE="/sys/firmware/opal/mpipl/core" get_kdump_confs() { @@ -137,6 +138,7 @@ dump_fs() mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1 save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" + save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" echo "kdump: saving vmcore" $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1 @@ -173,6 +175,30 @@ save_vmcore_dmesg_fs() { fi } +save_opalcore_fs() { + local _path=$1 + + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi + + echo "kdump: saving opalcore" + cp $OPALCORE ${_path}/opalcore + if [ $? -ne 0 ]; then + echo "kdump: saving opalcore failed" + return 1 + fi + + sync + echo "kdump: saving opalcore complete" + return 0 +} + dump_to_rootfs() { diff --git a/kdumpctl b/kdumpctl index 97fe541..88128a3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -250,6 +250,9 @@ check_config() echo "Invalid kdump config value for option $config_opt." return 1; } + if [ -d "/proc/device-tree/ibm,opal/dump" ] && [ "$config_opt" == "raw" ]; then + echo "WARNING: Won't capture opalcore when 'raw' dump target is used." + fi ;; net|options|link_delay|disk_timeout|debug_mem_level|blacklist) echo "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." From a01270b64e86161cbf9390874949676c2306c514 Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Fri, 17 Jan 2020 02:14:32 +0530 Subject: [PATCH 191/806] kexec-tools/module-setup: Ensure eth devices get IP address for VLAN Currently while trying to save vmcore via vlan eth interface, the Kdump kernel fails with network unreachable message. This is because mkdumprd produces a vlan config that does not get ip address for vlan on eth device. Fix the same via this patch. Signed-off-by: Bhupesh Sharma Acked-by: Kairui Song --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 570bd62..8691f9c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -307,10 +307,10 @@ kdump_setup_vlan() { exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" - echo " vlan=$_netdev:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" - echo " vlan=$_netdev:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi } From 2af3537dfa832299fc8739dd8dd347f100623168 Mon Sep 17 00:00:00 2001 From: "s.morishima@fujitsu.com" Date: Wed, 29 Jan 2020 01:20:46 +0000 Subject: [PATCH 192/806] Fix typo in early-kdump-howto.txt Signed-off-by: Shigeki Morishima Acked-by: Kairui Song --- early-kdump-howto.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt index b8cab6a..89df4ef 100644 --- a/early-kdump-howto.txt +++ b/early-kdump-howto.txt @@ -58,7 +58,7 @@ on the command prompt: # journalctl -x|grep early-kdump -Then, you will see some useful logs, for exapmle: +Then, you will see some useful logs, for example: 1. if early kdump is successful. Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: early-kdump is enabled. From a878ad0100446874fb7cf8a0a0a4990ff929896c Mon Sep 17 00:00:00 2001 From: "s.morishima@fujitsu.com" Date: Thu, 6 Feb 2020 02:52:24 +0000 Subject: [PATCH 193/806] Add --force option to step 2 in early-kdump-howto.txt For step2 in early-kdump-howto.txt, --force option of dracut is necessary to rebuild system initramfs. Without --force option, executing step2 fails because system initramfs already exists. Signed-off-by: Shigeki Morishima Acked-by: Kairui Song --- early-kdump-howto.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt index 89df4ef..c29557e 100644 --- a/early-kdump-howto.txt +++ b/early-kdump-howto.txt @@ -34,14 +34,16 @@ You can rebuild the initramfs with earlykdump support with below steps: For the failure_action, you can choose anything other than "reboot". 2. rebuild system initramfs with earlykdump support. - # dracut --add earlykdump + # dracut --force --add earlykdump + + NOTE: Recommend to backup the original system initramfs before performing + this step to put it back if something happens during boot-up. 3. add rd.earlykdump in grub kernel command line. Note: [1]. Early kdump initramfs size will be large because it includes vmlinuz and -kdump initramfs. And for step 2 if you are sure to overwrite system initramfs -you can backup the original initramfs and use "--force" option. +kdump initramfs. [2]. Early kdump inherits the settings of normal kdump, so any changes that caused normal kdump rebuilding also require rebuilding the system initramfs From 16d2e4274d14b7ee2e49ff3a9579e36ba072cb53 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 13 Feb 2020 16:19:36 +0800 Subject: [PATCH 194/806] Release 2.0.20-10 Signed-off-by: Kairui Song --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d7f7dc8..d80b108 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -348,6 +348,13 @@ done %endif %changelog +* Thu Feb 13 2020 Kairui Song - 2.0.20-10 +- Add --force option to step 2 in early-kdump-howto.txt +- Fix typo in early-kdump-howto.txt +- kexec-tools/module-setup: Ensure eth devices get IP address for VLAN +- powerpc: enable the scripts to capture dump on POWERNV platform +- kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default + * Wed Jan 29 2020 Kairui Song - 2.0.20-9 - Fix building failure From b229a9773c31a16b7f608ccc6bf03120c974fb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?HAGIO=20KAZUHITO=28=E8=90=A9=E5=B0=BE=E3=80=80=E4=B8=80?= =?UTF-8?q?=E4=BB=81=29?= Date: Mon, 17 Feb 2020 21:47:33 +0000 Subject: [PATCH 195/806] Improves the early-kdump-howto.txt document in several points: (1) explain early kdump a little clearer in "Introduction" (2) move the notes out to a new "Notes" section for readability and add a note about need of reconfiguration after kernel update (3) change journalctl -x option to -b option because -x is unnecessary and -b will make it very faster if persistent journal is available (4) shorten the example messages for readability (5) add a note to "Limitation" about the earliness of early kdump Signed-off-by: Kazuhito Hagio Acked-by: Lianbo Jiang --- early-kdump-howto.txt | 67 +++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt index c29557e..68b23c7 100644 --- a/early-kdump-howto.txt +++ b/early-kdump-howto.txt @@ -3,12 +3,17 @@ Early Kdump HOWTO Introduction ------------ -Kdump service starts too late, so early crashes will have no chance to get -kdump kernel booting, this will cause crash information to be lost. It is -necessary to add a dracut module in order to load crash kernel and initramfs -as early as possible. You can provide "rd.earlykdump" in grub commandline -to enable, then the early kdump will load those files like the normal kdump, -which is disabled by default. +Early kdump is a mechanism to make kdump operational earlier than normal kdump +service. The kdump service starts early enough for general crash cases, but +there are some cases where it has no chance to make kdump operational in boot +sequence, such as detecting devices and starting early services. If you hit +such a case, early kdump may allow you to get more information of it. + +Early kdump is implemented as a dracut module. It adds a kernel (vmlinuz) and +initramfs for kdump to your system's initramfs in order to load them as early +as possible. After that, if you provide "rd.earlykdump" in kernel command line, +then in the initramfs, early kdump will load those files like the normal kdump +service. This is disabled by default. For the normal kdump service, it can check whether the early kdump has loaded the crash kernel and initramfs. It has no conflict with the early kdump. @@ -20,7 +25,9 @@ We assume if you're reading this document, you should already have kexec-tools installed. You can rebuild the initramfs with earlykdump support with below steps: + 1. start kdump service to make sure kdump initramfs is created. + # systemctl start kdump NOTE: If a crash occurs during boot process, early kdump captures a vmcore @@ -34,6 +41,7 @@ You can rebuild the initramfs with earlykdump support with below steps: For the failure_action, you can choose anything other than "reboot". 2. rebuild system initramfs with earlykdump support. + # dracut --force --add earlykdump NOTE: Recommend to backup the original system initramfs before performing @@ -41,16 +49,6 @@ You can rebuild the initramfs with earlykdump support with below steps: 3. add rd.earlykdump in grub kernel command line. -Note: -[1]. Early kdump initramfs size will be large because it includes vmlinuz and -kdump initramfs. - -[2]. Early kdump inherits the settings of normal kdump, so any changes that -caused normal kdump rebuilding also require rebuilding the system initramfs -to make sure that the changes take effect for early kdump. Therefore, after -the rebuilding of kdump initramfs is completed, provide a prompt message to -tell the fact. - After making said changes, reboot your system to take effect. Of course, if you want to disable early kdump, you can simply remove "rd.earlykdump" from kernel boot parameters in grub, and reboot system like above. @@ -58,19 +56,40 @@ boot parameters in grub, and reboot system like above. Once the boot is completed, you can check the status of the early kdump support on the command prompt: - # journalctl -x|grep early-kdump + # journalctl -b | grep early-kdump Then, you will see some useful logs, for example: -1. if early kdump is successful. -Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: early-kdump is enabled. -Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: kexec: loaded early- -kdump kernel +- if early kdump is successful. -2. if early kdump is disabled. -Mar 09 10:02:47 localhost.localdomain dracut-cmdline[189]: early-kdump is disabled. +Mar 09 09:57:56 localhost dracut-cmdline[190]: early-kdump is enabled. +Mar 09 09:57:56 localhost dracut-cmdline[190]: kexec: loaded early-kdump kernel + +- if early kdump is disabled. + +Mar 09 10:02:47 localhost dracut-cmdline[189]: early-kdump is disabled. + +Notes +----- + +- The size of early kdump initramfs will be large because it includes vmlinuz + and kdump initramfs. + +- Early kdump inherits the settings of normal kdump, so any changes that + caused normal kdump rebuilding also require rebuilding the system initramfs + to make sure that the changes take effect for early kdump. Therefore, after + the rebuilding of kdump initramfs is completed, provide a prompt message to + tell the fact. + +- If you install an updated kernel and reboot the system with it, the early + kdump will be disabled by default. To enable it with the new kernel, you + need to take the above steps again. Limitation ---------- -At present, early kdump doesn't support fadump. +- At present, early kdump doesn't support fadump. + +- Early kdump loads a crash kernel and initramfs at the beginning of the + process in system's initramfs, so a crash at earlier than that (e.g. in + kernel initialization) cannot be captured even with the early kdump. From 476a2b50f671720a3af62bef047c9a81fdf358e0 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 27 Feb 2020 11:18:19 -0500 Subject: [PATCH 196/806] makedumpfile: Introduce --check-params option Backport from the upstream makedumpfile devel branch. commit 989152e113bfcb4fbfbad6f3aed6f43be4455919 Author: Kazuhito Hagio Date: Tue Feb 25 16:04:55 2020 -0500 [PATCH] Introduce --check-params option Currently it's difficult to check whether a makedumpfile command-line is valid or not without an actual panic. This is inefficient and if a wrong configuration is not tested, you will miss the vmcore when an actual panic occurs. In order for kdump facilities like kexec-tools to be able to check the specified command-line parameters in advance, introduce the --check-params option that only checks them and exits immediately. Signed-off-by: Kazuhito Hagio Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...mpfile-Introduce-check-params-option.patch | 255 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 257 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch b/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch new file mode 100644 index 0000000..5314ad9 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch @@ -0,0 +1,255 @@ +From 989152e113bfcb4fbfbad6f3aed6f43be4455919 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 25 Feb 2020 16:04:55 -0500 +Subject: [PATCH] Introduce --check-params option + +Currently it's difficult to check whether a makedumpfile command-line +is valid or not without an actual panic. This is inefficient and if +a wrong configuration is not tested, you will miss the vmcore when an +actual panic occurs. + +In order for kdump facilities like kexec-tools to be able to check +the specified command-line parameters in advance, introduce the +--check-params option that only checks them and exits immediately. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.8 | 5 ++++ + makedumpfile.c | 75 ++++++++++++++++++++++++++++++++++++++------------ + print_info.c | 4 +++ + 4 files changed, 69 insertions(+), 17 deletions(-) + +diff --git a/makedumpfile-1.6.7/makedumpfile.8 b/makedumpfile-1.6.7/makedumpfile.8 +index bf156a8..c5d4806 100644 +--- a/makedumpfile-1.6.7/makedumpfile.8 ++++ b/makedumpfile-1.6.7/makedumpfile.8 +@@ -632,6 +632,11 @@ Show help message and LZO/snappy support status (enabled/disabled). + \fB\-v\fR + Show the version of makedumpfile. + ++.TP ++\fB\-\-check-params\fR ++Only check whether the command-line parameters are valid or not, and exit. ++Preferable to be given as the first parameter. ++ + .SH ENVIRONMENT VARIABLES + + .TP 8 +diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c +index 607e07f..f5860a1 100644 +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c +@@ -10978,12 +10978,6 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + if (info->flag_generate_vmcoreinfo || info->flag_rearrange) + return FALSE; + +- if ((message_level < MIN_MSG_LEVEL) +- || (MAX_MSG_LEVEL < message_level)) { +- message_level = DEFAULT_MSG_LEVEL; +- MSG("Message_level is invalid.\n"); +- return FALSE; +- } + if ((info->flag_compress && info->flag_elf_dumpfile) + || (info->flag_read_vmcoreinfo && info->name_vmlinux) + || (info->flag_read_vmcoreinfo && info->name_xen_syms)) +@@ -11013,6 +11007,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + if (info->flag_partial_dmesg && !info->flag_dmesg) + return FALSE; + ++ if (info->flag_excludevm && !info->working_dir) { ++ MSG("-%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); ++ return FALSE; ++ } ++ + if ((argc == optind + 2) && !info->flag_flatten + && !info->flag_split + && !info->flag_sadump_diskset) { +@@ -11408,6 +11407,23 @@ int show_mem_usage(void) + return TRUE; + } + ++static int set_message_level(char *str_ml) ++{ ++ int ml; ++ ++ ml = atoi(str_ml); ++ if ((ml < MIN_MSG_LEVEL) || (MAX_MSG_LEVEL < ml)) { ++ message_level = DEFAULT_MSG_LEVEL; ++ MSG("Message_level(%d) is invalid.\n", ml); ++ return FALSE; ++ } ++ ++ if (info->flag_check_params) ++ return TRUE; ++ ++ message_level = ml; ++ return TRUE; ++} + + static struct option longopts[] = { + {"split", no_argument, NULL, OPT_SPLIT}, +@@ -11429,6 +11445,7 @@ static struct option longopts[] = { + {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, + {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, + {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, ++ {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {0, 0, 0, 0} + }; + +@@ -11527,7 +11544,8 @@ main(int argc, char *argv[]) + info->flag_compress = DUMP_DH_COMPRESSED_LZO; + break; + case OPT_MESSAGE_LEVEL: +- message_level = atoi(optarg); ++ if (!set_message_level(optarg)) ++ goto out; + break; + case OPT_DUMP_DMESG: + info->flag_dmesg = 1; +@@ -11590,6 +11608,10 @@ main(int argc, char *argv[]) + case OPT_NUM_THREADS: + info->num_threads = MAX(atoi(optarg), 0); + break; ++ case OPT_CHECK_PARAMS: ++ info->flag_check_params = TRUE; ++ message_level = DEFAULT_MSG_LEVEL; ++ break; + case '?': + MSG("Commandline parameter is invalid.\n"); + MSG("Try `makedumpfile --help' for more information.\n"); +@@ -11599,11 +11621,9 @@ main(int argc, char *argv[]) + if (flag_debug) + message_level |= ML_PRINT_DEBUG_MSG; + +- if (info->flag_excludevm && !info->working_dir) { +- ERRMSG("Error: -%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); +- ERRMSG("Try `makedumpfile --help' for more information\n"); +- return COMPLETED; +- } ++ if (info->flag_check_params) ++ /* suppress debugging messages */ ++ message_level = DEFAULT_MSG_LEVEL; + + if (info->flag_show_usage) { + print_usage(); +@@ -11634,6 +11654,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!open_files_for_generating_vmcoreinfo()) + goto out; + +@@ -11657,6 +11680,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + +@@ -11677,6 +11703,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + +@@ -11690,6 +11719,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + if (!dump_dmesg()) +@@ -11703,6 +11735,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!populate_kernel_version()) + goto out; + +@@ -11721,6 +11756,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (info->flag_split) { + for (i = 0; i < info->num_dumpfile; i++) { + SPLITTING_FD_BITMAP(i) = -1; +@@ -11748,13 +11786,16 @@ main(int argc, char *argv[]) + MSG("The dumpfile is saved to %s.\n", info->name_dumpfile); + } + } ++check_ok: + retcd = COMPLETED; + out: +- MSG("\n"); +- if (retcd != COMPLETED) +- MSG("makedumpfile Failed.\n"); +- else if (!info->flag_mem_usage) +- MSG("makedumpfile Completed.\n"); ++ if (!info->flag_check_params) { ++ MSG("\n"); ++ if (retcd != COMPLETED) ++ MSG("makedumpfile Failed.\n"); ++ else if (!info->flag_mem_usage) ++ MSG("makedumpfile Completed.\n"); ++ } + + free_for_parallel(); + +diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h +index 7217407..03fb4ce 100644 +--- a/makedumpfile-1.6.7/makedumpfile.h ++++ b/makedumpfile-1.6.7/makedumpfile.h +@@ -1303,6 +1303,7 @@ struct DumpInfo { + int flag_read_vmcoreinfo; /* flag of reading vmcoreinfo file */ + int flag_show_usage; /* flag of showing usage */ + int flag_show_version; /* flag of showing version */ ++ int flag_check_params; /* only check parameters */ + int flag_flatten; /* flag of outputting flattened + format to a standard out */ + int flag_rearrange; /* flag of creating dumpfile from +@@ -2364,6 +2365,7 @@ struct elf_prstatus { + #define OPT_WORKING_DIR OPT_START+15 + #define OPT_NUM_THREADS OPT_START+16 + #define OPT_PARTIAL_DMESG OPT_START+17 ++#define OPT_CHECK_PARAMS OPT_START+18 + + /* + * Function Prototype. +diff --git a/makedumpfile-1.6.7/print_info.c b/makedumpfile-1.6.7/print_info.c +index 0be12ea..e0c38b4 100644 +--- a/makedumpfile-1.6.7/print_info.c ++++ b/makedumpfile-1.6.7/print_info.c +@@ -321,6 +321,10 @@ print_usage(void) + MSG(" [-v]:\n"); + MSG(" Show the version of makedumpfile.\n"); + MSG("\n"); ++ MSG(" [--check-params]:\n"); ++ MSG(" Only check whether the command-line parameters are valid or not, and exit.\n"); ++ MSG(" Preferable to be given as the first parameter.\n"); ++ MSG("\n"); + MSG(" VMLINUX:\n"); + MSG(" This is a pathname to the first kernel's vmlinux.\n"); + MSG(" This file must have the debug information of the first kernel to analyze\n"); +-- +2.24.1 + + diff --git a/kexec-tools.spec b/kexec-tools.spec index d80b108..208ba5f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -100,6 +100,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch Patch602: ./kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch Patch603: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch +Patch604: ./kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -120,6 +121,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 %patch603 -p1 +%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc From a1c28126ef02976556c60a4bd59a41b7c75321cd Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Thu, 27 Feb 2020 11:18:20 -0500 Subject: [PATCH 197/806] 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 } From 64d30f54b917f0009dace06ce764fc4a697bfb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?HAGIO=20KAZUHITO=28=E8=90=A9=E5=B0=BE=E3=80=80=E4=B8=80?= =?UTF-8?q?=E4=BB=81=29?= Date: Mon, 24 Feb 2020 17:11:02 +0000 Subject: [PATCH 198/806] kdump-lib.sh: Fix is_user_configured_dump_target() Currently, is_user_configured_dump_target() doesn't work as expected due to lack of grep -E option. As a result, kdump service with a ssh dump configuration can unnecessarily fail to start due to the non-existence of a directory at where the path option specifies on the local system: kdumpctl[9760]: Rebuilding /boot/initramfs-5.4.19-200.fc31.x86_64kdump.img kdumpctl[9760]: Dump path /var/crash/ssh does not exist. kdumpctl[9760]: mkdumprd: failed to make kdump initrd kdumpctl[9760]: Starting kdump: [FAILED] Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 2428b5d..9c41439 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -117,7 +117,7 @@ to_dev_name() { is_user_configured_dump_target() { - grep -q "^ext[234]|^xfs|^btrfs|^minix|^raw|^nfs|^ssh" /etc/kdump.conf || is_mount_in_dracut_args; + grep -E -q "^ext[234]|^xfs|^btrfs|^minix|^raw|^nfs|^ssh" /etc/kdump.conf || is_mount_in_dracut_args; } get_user_configured_dump_disk() From 760beb7e57408018819507c8fcf35b5cafedabdc Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 9 Mar 2020 18:08:40 +0530 Subject: [PATCH 199/806] mkdumprd: Use DUMP_TARGET which printing error message during ssh When building kdump initramfs for a SSH dump target, mkdumprd would check whether it has the write permission on the SSH Server's $DUMP_TARGET. However $DUMP_TARGET is missing in the actual error message when the user doesn't not have the write permission. For example: # kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Could not create temporary directory on :/home/bhsharma/test. Make sure user has write permission on destination mkdumprd: failed to make kdump initrd Starting kdump: [FAILED] This patch using $1 value passed to mkdumprd, to print the $DUMP_TARGET inside mkdir_save_path_ssh() function to fix the issue. Signed-off-by: Bhupesh Sharma Acked-by: Kairui Song --- mkdumprd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkdumprd b/mkdumprd index b46fd32..f80304b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -130,7 +130,7 @@ get_ssh_size() { #mkdir if save path does not exist on ssh dump target #$1=ssh dump target -#caller should ensure write permission on $DUMP_TARGET:$SAVE_PATH +#caller should ensure write permission on $1:$SAVE_PATH #called from while loop and shouldn't read from stdin, so we're using "ssh -n" mkdir_save_path_ssh() { @@ -139,14 +139,14 @@ mkdir_save_path_ssh() ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null _ret=$? if [ $_ret -ne 0 ]; then - perror_exit "mkdir failed on $DUMP_TARGET:$SAVE_PATH" + perror_exit "mkdir failed on $1:$SAVE_PATH" fi - #check whether user has write permission on $SAVE_PATH/$DUMP_TARGET + #check whether user has write permission on $1:$SAVE_PATH _dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null) _ret=$? if [ $_ret -ne 0 ]; then - perror_exit "Could not create temporary directory on $DUMP_TARGET:$SAVE_PATH. Make sure user has write permission on destination" + perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" fi ssh -qn $_opt $1 rmdir $_dir From c9c50f9a36d72379a6735648119e4e13e8a82f04 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 16 Mar 2020 16:29:46 +0800 Subject: [PATCH 200/806] dracut-module-setup.sh: Ensure initrd.target.wants dir exists Latest dracut release stopped creating $systemdsystemunitdir/initrd.target.wants dir for us, so ensure it exists before creating the symlink. Signed-off-by: Kairui Song Tested-and-Reviewed-by: Bhupesh Sharma --- dracut-module-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8691f9c..a18d765 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -827,6 +827,7 @@ install() { inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" + mkdir -p "$initdir/$systemdsystemunitdir/initrd.target.wants" ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service" inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service" From 2fbcdf41e30795f97b740e5be2df4def2f5818ee Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 16 Mar 2020 23:18:38 +0800 Subject: [PATCH 201/806] kdumpctl: check hostonly-kernel-modules.txt for kernel module Since Dracut commit a0d9ad6 loaded-kernel-modules is renamed to hostonly-kernel-modules and contains all hostonly modules. So check hostonly-kernel-modules instead for module change. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 88128a3..55e333b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -406,7 +406,7 @@ check_dump_fs_modified() local _target _path _dracut_args local _target_drivers _module_name - local _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/loaded-kernel-modules.txt | tr '\n' ' ')" + local _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" # No need to check in case of mount target specified via "dracut_args". if is_mount_in_dracut_args; then From 632c369ec2f74aec9b4ef614abb39e6ba96ae58f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Mar 2020 15:51:21 +0800 Subject: [PATCH 202/806] kdumpctl: fix driver change detection on latest Fedora Now modinfo will return "(builtin)" instead of empty string for builtin module. Sync the code logic. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdumpctl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kdumpctl b/kdumpctl index 55e333b..2da3846 100755 --- a/kdumpctl +++ b/kdumpctl @@ -404,7 +404,7 @@ check_dump_fs_modified() local _old_dev _old_mntpoint _old_fstype local _new_dev _new_mntpoint _new_fstype local _target _path _dracut_args - local _target_drivers _module_name + local _target_drivers _module_name _module_filename local _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" @@ -453,10 +453,10 @@ check_dump_fs_modified() check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" for _driver in $_target_drivers; do - # Target is mounted already, if module is not included by current kernel, - # could be a deprecated/invalid driver name or a built-in module + # Skip deprecated/invalid driver name or built-in module _module_name=$(modinfo --set-version "$kdump_kver" -F name $_driver 2>/dev/null) - if [ $? -ne 0 ] || [ -z "$_module_name" ]; then + _module_filename=$(modinfo --set-version "$kdump_kver" -n $_driver 2>/dev/null) + if [ $? -ne 0 ] || [ -z "$_module_name" ] || [[ "$_module_filename" = *"(builtin)"* ]]; then continue fi if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then From e78639b46f9f5be01cf4e30792199da6a531bf92 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 11 Mar 2020 01:32:32 +0800 Subject: [PATCH 203/806] Use read_strip_comments to filter the installed kdump.conf This help remove redundant spaces and tailing comment in installed kdump.conf, currently installed kdump.conf always contain extra empty lines. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a18d765..b4cfe0e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -487,7 +487,7 @@ adjust_bind_mount_path() #install kdump.conf and what user specifies in kdump.conf kdump_install_conf() { local _opt _val _pdev - sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf + (read_strip_comments /etc/kdump.conf) > ${initdir}/tmp/$$-kdump.conf while read _opt _val; do From 424ac0bf800355932025ea5e586afcbdcd25d4dd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Mar 2020 02:35:11 +0800 Subject: [PATCH 204/806] Fix a potential syntax error Process substitution is not POSIX standard syntax, so if bash is configured to strictly follow POSIC, this will fail. Just use a POSIX friendly syntax instead. Fixes: bz1708321 Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b4cfe0e..7a2c7b4 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -188,7 +188,7 @@ kdump_handle_mulitpath_route() { _rule="" _max_weight=0 _weight=0 fi done >> ${initdir}/etc/cmdline.d/45route-static.conf\ - < <(/sbin/ip $_ipv6_flag route show) + <<< "$(/sbin/ip $_ipv6_flag route show)" [[ -n $_rule ]] && echo $_rule >> ${initdir}/etc/cmdline.d/45route-static.conf } From 4b43ba063ddbcdccf95d761d2a3641f3006d814d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 24 Mar 2020 01:47:30 +0800 Subject: [PATCH 205/806] Release 2.0.20-11 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 208ba5f..a393801 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 10%{?dist} +Release: 11%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -350,6 +350,18 @@ done %endif %changelog +* Thu Mar 24 2020 Kairui Song - 2.0.20-11 +- Fix a potential syntax error +- Use read_strip_comments to filter the installed kdump.conf +- kdumpctl: fix driver change detection on latest Fedora +- kdumpctl: check hostonly-kernel-modules.txt for kernel module +- dracut-module-setup.sh: Ensure initrd.target.wants dir exists +- mkdumprd: Use DUMP_TARGET which printing error message during ssh +- kdump-lib.sh: Fix is_user_configured_dump_target() +- mkdumprd: Use makedumpfile --check-params option +- makedumpfile: Introduce --check-params option +- Improves the early-kdump-howto.txt document in several points: + * Thu Feb 13 2020 Kairui Song - 2.0.20-10 - Add --force option to step 2 in early-kdump-howto.txt - Fix typo in early-kdump-howto.txt From 3be5f74df08483a95d0844b728031ddc1bdf81f1 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 13 Mar 2020 11:05:49 +0800 Subject: [PATCH 206/806] dracut-module-setup.sh: improve get_alias() In /etc/hosts, the alias name can come at the 2nd column, regardless of the recommendation. E.g. the following format is valid although not recommended cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.22.21 fastvm-rhel-7-6-21 fastvm-rhel-7-6-21.localdomain 192.168.22.22 fastvm-rhel-7-6-22 fastvm-rhel-7-6-22.localdomain 192.168.22.21 node1_hb 192.168.22.22 node2_hb So filtering out both 2nd and 3rd column for matching. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7a2c7b4..2c8d714 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -683,7 +683,8 @@ get_alias() { ips=$(hostname -I) for ip in $ips do - entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0 }') + # in /etc/hosts, alias can come at the 2nd column + entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }') if [ $? -eq 0 ]; then alias_set="$alias_set $entries" fi From c1c7f004c8d6dd5bdb3428abeb90d43eab9513aa Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Mar 2020 15:34:06 +0800 Subject: [PATCH 207/806] Remove is_dump_target_configured It's basically same with is_user_configured_dump_target and only have one caller. And the name is confusing, the dump target is always configured, it's either user configured or path based. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdumpctl | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/kdumpctl b/kdumpctl index 2da3846..fb264c3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -896,15 +896,6 @@ save_raw() return 0 } -is_dump_target_configured() -{ - local _target - - _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" /etc/kdump.conf) - - [ -n "$_target" ] -} - local_fs_dump_target() { local _target @@ -919,7 +910,11 @@ path_to_be_relabeled() { local _path _target _mnt="/" _rmnt - if is_dump_target_configured; then + if is_user_configured_dump_target; then + if is_mount_in_dracut_args; then + return; + fi + _target=$(local_fs_dump_target) if [[ -n "$_target" ]]; then _mnt=$(findmnt -k -f -n -r -o TARGET $_target) @@ -931,9 +926,6 @@ path_to_be_relabeled() fi fi - if is_mount_in_dracut_args; then - return; - fi _path=$(get_save_path) # if $_path is masked by other mount, we will not relabel it. _rmnt=$(df $_mnt/$_path 2>/dev/null | tail -1 | awk '{ print $NF }') From fd7e7be48331bcaca9b33a2286179efe6812b456 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 8 Mar 2020 16:41:10 +0800 Subject: [PATCH 208/806] mkdumprd: Use get_save_path instead of parsing config get_save_path provides default value fail back and error check, no need to repeat it again. Also remove a redundant echo and grep in get_save_path Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 4 ++-- mkdumprd | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 9c41439..d06a417 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -138,11 +138,11 @@ get_root_fs_device() get_save_path() { - local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') + local _save_path=$(awk '$1 == "path" {print $2}' /etc/kdump.conf) [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH # strip the duplicated "/" - echo $(echo $_save_path | tr -s /) + echo $_save_path | tr -s / } get_block_dump_target() diff --git a/mkdumprd b/mkdumprd index f80304b..f04f565 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,10 +13,7 @@ export IN_KDUMP=1 conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file) -[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH -# strip the duplicated "/" -SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" From b5b0b905216df31a148ba786ded9dc19bbe856e8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 8 Mar 2020 23:24:50 +0800 Subject: [PATCH 209/806] mkdumprd: Simplify handling of user specified target For user specified target, the config value is used as the dump target, and SAVE_PATH (path in kdump.conf) value is used as the dump path within the dump target, no need to do anything extra with the path value. Current code logic is not only complicated, it also wrongly generate an redundantly long path in atomic/silverblue environment. The right way is only check two things, and do nothing else: 1. The path exists within the target; 2. The target is large enough to hold to contain the vmcore. Currently checking the target still requires it to be mounted so it will error out if it's not mounted. Will implement some auto mount as next step. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 29 +++++++++-------------------- mkdumprd | 15 ++++----------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d06a417..6d421d3 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -291,26 +291,6 @@ get_option_value() { strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` } -#This function compose a absolute path with the mount -#point and the relative $SAVE_PATH. -#target is passed in as argument, could be UUID, LABEL, -#block device or even nfs server export of the form of -#"my.server.com:/tmp/export"? -#And possibly this could be used for both default case -#as well as when dump taret is specified. When dump -#target is not specified, then $target would be null. -make_absolute_save_path() -{ - local _target=$1 - local _mnt - - [ -n $_target ] && _mnt=$(get_mntpoint_from_target $1) - _mnt="${_mnt}/$SAVE_PATH" - - # strip the duplicated "/" - echo "$_mnt" | tr -s / -} - check_save_path_fs() { local _path=$1 @@ -320,6 +300,15 @@ check_save_path_fs() fi } +# Check if path exists within dump target +check_save_path_user_configured() +{ + local _target=$1 _path=$2 + local _mnt=$(get_mntpoint_from_target $_target) + + check_save_path_fs "$_mnt/$_path" +} + is_atomic() { grep -q "ostree" /proc/cmdline diff --git a/mkdumprd b/mkdumprd index f04f565..4fcce1c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -387,20 +387,13 @@ do perror_exit "Dump target $config_val is probably not mounted." fi - _absolute_save_path=$(make_absolute_save_path $config_val) - _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) - if is_atomic && is_bind_mount $_mntpoint; then - SAVE_PATH=${_absolute_save_path##"$_mntpoint"} - # the real dump path in the 2nd kernel, if the mount point is bind mounted. - SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH - fi - + # User configured target, use $SAVE_PATH as the dump path within the target + check_save_path_user_configured "$config_val" "$SAVE_PATH" + check_size fs "$config_val" add_mount "$config_val" - check_save_path_fs $_absolute_save_path - check_size fs $config_val ;; raw) - #checking raw disk writable + # checking raw disk writable dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } From bde4b7af3b1517b78bb03f92f9fd7183aa532712 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 10 Mar 2020 23:52:33 +0800 Subject: [PATCH 210/806] No longer treat atomic/silverblue specially This commit remove almost all special workaround for atomic, and treat all bind mounts in any environment equally. Use a helper get_bind_mount_directory_from_path to get the bind mount source path of given path. is_atomic function now only used to determine the right /boot path for atomic/silverblue environment. And remove get_mntpoint_from_path(), it's the only function that never ignore bind mount, and it have no caller after this clean up. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 36 +++++----------------- kdump-lib.sh | 69 +++++++++++++----------------------------- mkdumprd | 17 +++-------- 3 files changed, 32 insertions(+), 90 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2c8d714..0f6f1cb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -428,19 +428,9 @@ default_dump_target_install_conf() is_user_configured_dump_target && return - _save_path=$(get_save_path) - _mntpoint=$(get_mntpoint_from_path $_save_path) + _save_path=$(get_bind_mount_source $(get_save_path)) _target=$(get_target_from_path $_save_path) - - if is_atomic && is_bind_mount $_mntpoint; then - _save_path=${_save_path##"$_mntpoint"} - # the real dump path in the 2nd kernel, if the mount point is bind mounted. - _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path - _mntpoint=$(get_mntpoint_from_target $_target) - - # the absolute path in the 1st kernel - _save_path=$_mntpoint/$_save_path - fi + _mntpoint=$(get_mntpoint_from_target $_target) _fstype=$(get_fs_type_from_target $_target) if is_fs_type_nfs $_fstype; then @@ -452,8 +442,6 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf - # strip the duplicated "/" - _save_path=$(echo $_save_path | tr -s /) # don't touch the path under root mount if [ "$_mntpoint" != "/" ]; then _save_path=${_save_path##"$_mntpoint"} @@ -466,21 +454,13 @@ default_dump_target_install_conf() adjust_bind_mount_path() { - local _target=$1 local _save_path=$(get_save_path) - local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path + local _mntpoint=$(get_mntpoint_from_target $1) + local _absolute_save_path=$(get_bind_mount_source $_mntpoint$_save_path) - _absolute_save_path=$(echo "$_absolute_save_path" | tr -s /) - local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) - - if is_bind_mount $_mntpoint; then - _save_path=${_absolute_save_path##"$_mntpoint"} - # the real dump path in the 2nd kernel, if the mount point is bind mounted. - _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path - - #erase the old path line, then insert the parsed path + if [ $_absolute_save_path != $_save_path ]; then sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf - echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf + echo "path $_absolute_save_path" >> ${initdir}/tmp/$$-kdump.conf fi } @@ -500,9 +480,7 @@ kdump_install_conf() { ext[234]|xfs|btrfs|minix) _pdev=$(kdump_get_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf - if is_atomic; then - adjust_bind_mount_path "$_val" - fi + adjust_bind_mount_path "$_val" ;; ssh|nfs) kdump_install_net "$_val" diff --git a/kdump-lib.sh b/kdump-lib.sh index 6d421d3..b079f27 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -204,44 +204,39 @@ get_kdump_targets() echo "$kdump_targets" } - +# Return the bind mount source path, return the path itself if it's not bind mounted +# Eg. if /path/to/src is bind mounted to /mnt/bind, then: +# /mnt/bind -> /path/to/src, /mnt/bind/dump -> /path/to/src/dump +# # findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] # in the SOURCE column for bind-mounts, then if $_mntpoint equals to # $_mntpoint_nofsroot, the mountpoint is not bind mounted directory. -is_bind_mount() -{ - local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') - local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') - - if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then - return 1 - else - return 0 - fi -} - +# # Below is just an example for mount info # /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the # directory is bind mounted. The former part represents the device path, rest # part is the bind mounted directory which quotes by bracket "[]". -get_bind_mount_directory() +get_bind_mount_source() { - local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') - local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') + local _path=$1 + # In case it's a sub path in a mount point, get the mount point first + local _mnt_top=$(df $_path | tail -1 | awk '{print $NF}') + local _mntpoint=$(findmnt $_mnt_top | tail -n 1 | awk '{print $2}') + local _mntpoint_nofsroot=$(findmnt -v $_mnt_top | tail -n 1 | awk '{print $2}') + + if [[ "$_mntpoint" = $_mntpoint_nofsroot ]]; then + echo $_path && return + fi _mntpoint=${_mntpoint#*$_mntpoint_nofsroot} - _mntpoint=${_mntpoint#[} _mntpoint=${_mntpoint%]} + _path=${_path#$_mnt_top} - echo $_mntpoint -} - -get_mntpoint_from_path() -{ - df $1 | tail -1 | awk '{print $NF}' + echo $_mntpoint$_path } +# Return the real underlaying device of a path, ignore bind mounts get_target_from_path() { local _target @@ -256,33 +251,11 @@ get_fs_type_from_target() findmnt -k -f -n -r -o FSTYPE $1 } -# input: device path -# output: the general mount point -# find the general mount point, not the bind mounted point in atomic -# As general system, Use the previous code -# -# ERROR and EXIT: -# the device can be umounted the general mount point, if one of the mount point is bind mounted -# For example: -# mount /dev/sda /mnt/ -# mount -o bind /mnt/var /var -# umount /mnt +# Find the general mount point of a dump target, not the bind mount point get_mntpoint_from_target() { - if is_atomic; then - for _mnt in $(findmnt -k -n -r -o TARGET $1) - do - if ! is_bind_mount $_mnt; then - echo $_mnt - return - fi - done - - echo "Mount $1 firstly, without the bind mode" >&2 - exit 1 - else - echo $(findmnt -k -f -n -r -o TARGET $1) - fi + # Expcilitly specify --source to findmnt could ensure non-bind mount is returned + findmnt -k -f -n -r -o TARGET --source $1 } # get_option_value diff --git a/mkdumprd b/mkdumprd index 4fcce1c..35f5eed 100644 --- a/mkdumprd +++ b/mkdumprd @@ -240,20 +240,11 @@ handle_default_dump_target() check_save_path_fs $SAVE_PATH - _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) - _target=$(get_target_from_path $SAVE_PATH) + _save_path=$(get_bind_mount_source $SAVE_PATH) + _target=$(get_target_from_path $_save_path) + _mntpoint=$(get_mntpoint_from_target $_target) - if is_atomic && is_bind_mount $_mntpoint; then - SAVE_PATH=${SAVE_PATH##"$_mntpoint"} - # the real dump path in the 2nd kernel, if the mount point is bind mounted. - SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH - _mntpoint=$(get_mntpoint_from_target $_target) - - # the absolute path in the 1st kernel - SAVE_PATH=$_mntpoint/$SAVE_PATH - fi - - SAVE_PATH=${SAVE_PATH##"$_mntpoint"} + SAVE_PATH=${_save_path##"$_mntpoint"} add_mount "$_target" check_size fs $_target } From 3b09c4910d45c020d27b944e2e6a74c98880f7c1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 11 Mar 2020 01:21:30 +0800 Subject: [PATCH 211/806] Remove adjust_bind_mount_path call If user configured target is used, path should be used as the absolute path within the dump target direct, and user should be fully aware of the path structure within the target device. The adjust_bind_mount_path call here make it very hard to control the behavior. Especially, if it's a cross device bind mount, this will likely create a invalid path in the target. And for atomic case, adjust_bind_mount_path call here assumes user will always pass root device as the explicitly configured dump target, which is not true. If user configured target device is used, the path is always be the absolute path inside of given target. If user don't know about the path structure in the target device, then user should either use the path based config, or carefully exam the target device before using it as a dump target. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 0f6f1cb..fdef509 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -452,18 +452,6 @@ default_dump_target_install_conf() echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf } -adjust_bind_mount_path() -{ - local _save_path=$(get_save_path) - local _mntpoint=$(get_mntpoint_from_target $1) - local _absolute_save_path=$(get_bind_mount_source $_mntpoint$_save_path) - - if [ $_absolute_save_path != $_save_path ]; then - sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf - echo "path $_absolute_save_path" >> ${initdir}/tmp/$$-kdump.conf - fi -} - #install kdump.conf and what user specifies in kdump.conf kdump_install_conf() { local _opt _val _pdev @@ -480,7 +468,6 @@ kdump_install_conf() { ext[234]|xfs|btrfs|minix) _pdev=$(kdump_get_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf - adjust_bind_mount_path "$_val" ;; ssh|nfs) kdump_install_net "$_val" From b5b252ae273cbd1a866c3e1ae25a52e55eb6cd0c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 2 Apr 2020 01:47:47 +0800 Subject: [PATCH 212/806] Release 2.0.20-12 Signed-off-by: Kairui Song --- kexec-tools.spec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a393801..6bada4a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -350,6 +350,14 @@ done %endif %changelog +* Thu Apr 2 2020 Kairui Song - 2.0.20-12 +- Remove adjust_bind_mount_path call +- No longer treat atomic/silverblue specially +- mkdumprd: Simplify handling of user specified target +- mkdumprd: Use get_save_path instead of parsing config +- Remove is_dump_target_configured +- dracut-module-setup.sh: improve get_alias() + * Thu Mar 24 2020 Kairui Song - 2.0.20-11 - Fix a potential syntax error - Use read_strip_comments to filter the installed kdump.conf From 6348398743a6a7c684deac93dab3bef868f3b6a9 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 24 Mar 2020 11:02:24 +0800 Subject: [PATCH 213/806] dracut-module-setup.sh: ensure cluster info is ready before query There is a race issue between "pcs" and "kdumpctl restart" -1. set up cluster # pcs cluster setup --start mycluster node1 node2 # pcs stonith create kdump fence_kdump pcmk_reboot_action="off" # pcs stonith level add 1 node1 kdump # pcs stonith level add 1 node2 kdump -2. Then here comes the command _immediately_ in kdumpctl # pcs cluster cib But due to some pcs internal mechanism, "pcs cluster cib" can not fetch the updated info in time. Fix these issue by forcing the upgrade of cib. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index fdef509..685b858 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -678,6 +678,7 @@ is_localhost() { get_pcs_fence_kdump_nodes() { local nodes + pcs cluster sync && pcs cluster cib-upgrade # get cluster nodes from cluster cib, get interface and ip address nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` From f33f30eb614741f97d621fcc0c260e8da6148c86 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 20 Apr 2020 11:16:00 +0800 Subject: [PATCH 214/806] dracut-module-setup.sh: fix breakage in get_pcs_fence_kdump_nodes() pcs cluster and cluster cib-upgrade may throw some information and disturb the parsing. Mute them Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 685b858..024e333 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -678,7 +678,7 @@ is_localhost() { get_pcs_fence_kdump_nodes() { local nodes - pcs cluster sync && pcs cluster cib-upgrade + pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1 # get cluster nodes from cluster cib, get interface and ip address nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` From 74081a2b64b485345443632ded76521ad13f3d99 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 20 Apr 2020 19:03:24 +0000 Subject: [PATCH 215/806] Don't unmount the dump target just after saving vmcore Since commit 6dee286467e5 ("Don't mount the dump target unless needed"), dump_fs function unmounts the dump target just after saving vmcore. This broke the condition that it's mounted when executing "kdump_post", which had been stable since RHEL5, and a certain tool which uses the kdump_post hook to save information of 2nd kernel to the dump target started to fail. As unmounting it is done by systemd-shutdown before reboot without the umount command as below, so let's don't unmount it in dump_fs. systemd-shutdown[1]: Unmounting file systems. [547]: Remounting '/sysroot' read-only in with options '(null)'. EXT4-fs (dm-0): re-mounted. Opts: (null) [548]: Unmounting '/sysroot'. Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index a7c0bf9..7b314a7 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -97,7 +97,6 @@ get_kdump_confs() # dump_fs dump_fs() { - local _do_umount="" local _dev=$(findmnt -k -f -n -r -o SOURCE $1) local _mp=$(findmnt -k -f -n -r -o TARGET $1) local _op=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -116,7 +115,6 @@ dump_fs() echo "kdump: mounting failed (mount point: $_mp, option: $_op)" return 1 fi - _do_umount=1 else echo "kdump: error: Dump target $_dev is not usable" fi @@ -147,10 +145,6 @@ dump_fs() echo "kdump: saving vmcore complete" - if [ $_do_umount ]; then - umount $_mp || echo "kdump: warn: failed to umount target" - fi - # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure return 0 } From ce0305d4f95cf00535d00a887c9a1d2323159b0b Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Wed, 15 Apr 2020 17:23:59 +0800 Subject: [PATCH 216/806] Add a new option 'rd.znet_ifname' in order to use it in udev rules In most cases, it always provides a persistent MAC address. But for the s390 Arch, sometimes, kernel could run in the LPAR mode and it doesn't provide a persistent MAC address, which caused the kdump failure. Currently, some rules rely on the persistent MAC address, for the above case, which won't work in kdump kernel because non-persistent MAC could not match with udev rules. To fix this issue, need to add a new option 'rd.znet_ifname' in order to provide extra parameters such as 'ifname' and 'subchannels' for some rules, which ensures kdump can also work appropriately without the persistent MAC. Please refer to the following commit in dracut: 872eb69936bd ("95znet: Add a rd.znet_ifname= option") Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-module-setup.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 024e333..5397eb5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -318,13 +318,14 @@ kdump_setup_vlan() { # $1: netdev name kdump_setup_znet() { local _options="" + local _netdev=$1 - source_ifcfg_file $1 + source_ifcfg_file $_netdev for i in $OPTIONS; do _options=${_options},$i done - echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} > ${initdir}/etc/cmdline.d/30znet.conf + echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf } kdump_get_ip_route() From d624a0326f5d17fd580e5edb687b4c27f7bbbfa7 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 23 Mar 2020 18:58:49 +0530 Subject: [PATCH 217/806] fadump: update fadump-howto.txt with some troubleshooting help Add recommendations on how much memory is required for FADump. Also, mention the optimizations applied to default initrd when FADump is used and how to workaround it. Signed-off-by: Hari Bathini Acked-by: Pingfan Liu --- fadump-howto.txt | 86 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index 7061f02..89675a1 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -84,19 +84,25 @@ kexec-tools installed. If not, you install it via the following command: # yum install kexec-tools -To be able to do much of anything interesting in the way of debug analysis, -you'll also need to install the kernel-debuginfo package, of the same arch -as your running kernel, and the crash utility: +Make the kernel to be configured with FADump as the default boot entry, if +it isn't already: + + # grubby --set-default=/boot/vmlinuz- + +Boot into the kernel to be configured for FADump. To be able to do much of +anything interesting in the way of debug analysis, you'll also need to install +the kernel-debuginfo package, of the same arch as your running kernel, and the +crash utility: # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash Next up, we need to modify some boot parameters to enable firmware assisted dump. With the help of grubby, it's very easy to append "fadump=on" to the end -of your kernel boot parameters. Optionally, user can also append -'fadump_reserve_mem=X' kernel cmdline to specify size of the memory to reserve -for boot memory dump preservation. +of your kernel boot parameters. To reserve the appropriate amount of memory +for boot memory preservation, pass 'crashkernel=X' kernel cmdline parameter. +For the recommended value of X, see 'FADump Memory Requirements' section. - # grubby --args="fadump=on" --update-kernel=/boot/vmlinuz-`uname -r` + # grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r` The term 'boot memory' means size of the low memory chunk that is required for a kernel to boot successfully when booted with restricted memory. By default, @@ -145,7 +151,7 @@ perform postmortem analysis: and so on... Saving vmcore-dmesg.txt ----------------------- +----------------------- Kernel log bufferes are one of the most important information available in vmcore. Now before saving vmcore, kernel log bufferes are extracted from /proc/vmcore and saved into a file vmcore-dmesg.txt. After @@ -153,6 +159,57 @@ vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will not be available if dump target is raw device. +FADump Memory Requirements: + + System Memory Recommended memory +--------------------- ---------------------- + 4 GB - 16 GB : 768 MB + 16 GB - 64 GB : 1024 MB + 64 GB - 128 GB : 2 GB + 128 GB - 1 TB : 4 GB + 1 TB - 2 TB : 6 GB + 2 TB - 4 TB : 12 GB + 4 TB - 8 TB : 20 GB + 8 TB - 16 TB : 36 GB + 16 TB - 32 TB : 64 GB + 32 TB - 64 TB : 128 GB + 64 TB & above : 180 GB + +Things to remember: + +1) The memory required to boot capture Kernel is a moving target that depends + on many factors like hardware attached to the system, kernel and modules in + use, packages installed and services enabled, there is no one-size-fits-all. + But the above recommendations are based on system memory. So, the above + recommendations for FADump come with a few assumptions, based on available + system memory, about the resources the system could have. So, please take + the recommendations with a pinch of salt and remember to try capturing dump + a few times to confirm that the system is configured successfully with dump + capturing support. + +2) Though the memory requirements for FADump seem high, this memory is not + completely set aside but made available for userspace applications to use, + through the CMA allocator. + +3) As the same initrd is used for booting production kernel as well as capture + kernel and with dump being captured in a restricted memory environment, few + optimizations (like not inclding network dracut module, disabling multipath + and such) are applied while building the initrd. In case, the production + environment needs these optimizations to be avoided, dracut_args option in + /etc/kdump.conf file could be leveraged. For example, if a user wishes for + network module to be included in the initrd, adding the below entry in + /etc/kdump.conf file and restarting kdump service would take care of it. + + dracut_args --add "network" + +4) If FADump is configured to capture vmcore to a remote dump target using SSH + or NFS protocol, the network interface is renamed to kdump- + if is generic, for example, *eth#, or net#. This problem + occurs because the vmcore capture scripts in the initial RAM disk (initrd) + add the kdump- prefix to the network interface name to secure persistent + naming. As the same initrd is used for production kernel boot, the interface + name is changed for the production kernel too. + Dump Triggering methods: This section talks about the various ways, other than a Kernel Panic, in which @@ -250,3 +307,16 @@ initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely. + +How to disable FADump: + +Remove "fadump=on" from kernel cmdline parameters: + + # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=on" + +If KDump is to be used as the dump capturing mechanism, update the crashkernel +parameter (Else, remove "crashkernel=" parameter too, using grubby): + + # grubby --update-kernel=/boot/vmlinuz-$kver --args="crashkernl=auto" + +Reboot the system for the settings to take effect. From b82c35c842a64be6f73212eab879d5b2a4acf86d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 30 Apr 2020 17:33:15 +0800 Subject: [PATCH 218/806] Partially Revert "Don't mount the dump target unless needed" This partially reverts commit 6dee286467e5a697d25148712a110da1a720ac96. There are reports that NFSv3 is failing after this commit, and after more debug, I found NFSv4 may not work properly if "nfs4_disable_idmapping" is set to 0. The cause of the failure is that kdump.sh runs after dracut's pre-pivot and clean up hook, many dracut module will install hooks to kill some running services, so if the dump target requires a service to be running but it's killed, mount will fail. Dracut ensures the configured mount points are ready before pre-pivot. After pre-pivot, any further mounting operation may not work as expected. Although there is no report of other type of dump target failure except NFSv3, it's better to revert this, to avoid other potential risk, and wait for a proper fix for that systemd/kernel issue. Else, this may bring more trouble for further development. But still keep the change in kdump-lib-initramfs.sh for better robustness. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mkdumprd b/mkdumprd index 35f5eed..cedf536 100644 --- a/mkdumprd +++ b/mkdumprd @@ -77,13 +77,12 @@ to_mount() { fi # mount fs target as rw in 2nd kernel _options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g') - # filter out 'noauto' here, it will be force appended later, avoid duplication + # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd + # kernel, filter it out here. _options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g') # drop nofail or nobootwait _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') - # only mount the dump target when needed. - _options="$_options,noauto" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From 33e79681d9d4d3e8927c40b8b716e7fb4a24680c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Mar 2020 23:58:49 +0800 Subject: [PATCH 219/806] Fix the problem that kdump prints redundant / In second kernel, kdump always prints redundant '/': kdump: saving to /sysroot//var/crash/127.0.0.1-2020-03-12-21:32:54/ Just trim it. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump-lib-initramfs.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 7b314a7..49b12dc 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -125,7 +125,9 @@ dump_fs() # Remove -F in makedumpfile case. We don't want a flat format dump here. [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"` - echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" + local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) + + echo "kdump: saving to $_dump_path" # Only remount to read-write mode if the dump target is mounted read-only. if [[ "$_op" = "ro"* ]]; then @@ -133,14 +135,14 @@ dump_fs() mount -o remount,rw $_dev $_mp || return 1 fi - mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1 + mkdir -p $_dump_path || return 1 - save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" - save_opalcore_fs "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" + save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path" + save_opalcore_fs "$_dump_path" echo "kdump: saving vmcore" - $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete || return 1 - mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore + $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete || return 1 + mv $_dump_path/vmcore-incomplete $_dump_path/vmcore sync echo "kdump: saving vmcore complete" From 539bff40830e961d7ef85248e39bff0e40b23c91 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 11 May 2020 14:32:05 +0800 Subject: [PATCH 220/806] Append both nofail and x-systemd.before to kdump mount target By this point, there is still an unresolved vfs kernel issue that blocks systemd from mounting the dump target properly from time to time. To prevent systemd from failing by mounting the dump target, we can add nofail option to the kdump mount point. But adding nofail will wipe out default dependency of the mount point, see commit 94a7b43, so systemd randomize the order of calling kdump.sh and mounting the dump target and lead to unexpected behavior. However we can use x-systemd.before to ensure the mount is done in right order. In dracut-kdump-capture.service, we have "After=initrd.target", and look at dracut.bootup.7, systems start processing of fstab by initrd-fs.target, so set "After=initrd.target" could ensure the mount is ready before pre-pivot and kdump-capture service. Now with both nofail and x-systemd.before=initrd.target, systemd will try to mount the dump target before calling kdump, and even if the mount failed, kdump.sh will still be called and try to mount again. See dump_fs function, which will try to mount if the target is not mounted. Kdump will only fail if both mount attemp fails. Else if the kdump target mount failed or unstable, systemd will directly jump to kdump failure action, and kdump fails. This should improve the robustness in general with no other risk. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkdumprd b/mkdumprd index cedf536..a8f41d4 100644 --- a/mkdumprd +++ b/mkdumprd @@ -83,6 +83,9 @@ to_mount() { # drop nofail or nobootwait _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') + # use both nofail and x-systemd.before to ensure systemd will try best to + # mount it before kdump starts, this is an attempt to improve robustness + _options="$_options,nofail,x-systemd.before=initrd-fs.target" _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name From 43ea36b3e8a00df88de153e81e3668e9ee583391 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Mar 2020 23:28:53 +0800 Subject: [PATCH 221/806] Introduce get_kdump_mntpoint_from_target and fix duplicated / User a helper to get the path to mount dump target in kdump kernel, and fix duplicated '/' in the mount path problem. Fixes: bz1785371 Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump-lib.sh | 19 +++++++++++++++++++ kdumpctl | 7 +------ mkdumprd | 20 +++++--------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index b079f27..2157c34 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -258,6 +258,25 @@ get_mntpoint_from_target() findmnt -k -f -n -r -o TARGET --source $1 } +# Get the path where the target will be mounted in kdump kernel +# $1: kdump target device +get_kdump_mntpoint_from_target() +{ + local _mntpoint=$(get_mntpoint_from_target $1) + + # mount under /sysroot if dump to root disk or mount under + # /kdumproot/$_mntpoint in other cases in 2nd kernel. systemd + # will be in charge to umount it. + if [ "$_mntpoint" = "/" ];then + _mntpoint="/sysroot" + else + _mntpoint="/kdumproot/$_mntpoint" + fi + + # strip duplicated "/" + echo $_mntpoint | tr -s "/" +} + # get_option_value # retrieves value of option defined in kdump.conf get_option_value() { diff --git a/kdumpctl b/kdumpctl index fb264c3..081720e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -480,12 +480,7 @@ check_dump_fs_modified() return 2 fi - if [[ "$_target" = "$(get_root_fs_device)" ]]; then - _new_mntpoint="/sysroot" - else - _new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)" - fi - + _new_mntpoint="$(get_kdump_mntpoint_from_target $_target)" _dracut_args=$(lsinitrd $TARGET_INITRD -f usr/lib/dracut/build-parameter.txt) if [[ -z "$_dracut_args" ]];then echo "Warning: No dracut arguments found in initrd" diff --git a/mkdumprd b/mkdumprd index a8f41d4..c80e3e0 100644 --- a/mkdumprd +++ b/mkdumprd @@ -51,21 +51,12 @@ add_dracut_sshkey() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _dev=$1 _source _target _fstype _options _mntopts _pdev + local _dev=$1 _source _new_mntpoint _fstype _options _mntopts _pdev _source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _target=$(get_mntpoint_from_target $_dev) - # mount under /sysroot if dump to root disk or mount under - #/kdumproot/$_target in other cases in 2nd kernel. systemd - #will be in charge to umount it. - - if [ "$_target" = "/" ];then - _target="/sysroot" - else - _target="/kdumproot/$_target" - fi - _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) + _new_mntpoint=$(get_kdump_mntpoint_from_target $_dev) + [[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev) if [ -z "$_options" ]; then _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) @@ -87,14 +78,13 @@ to_mount() { # mount it before kdump starts, this is an attempt to improve robustness _options="$_options,nofail,x-systemd.before=initrd-fs.target" - _mntopts="$_target $_fstype $_options" - #for non-nfs _dev converting to use udev persistent name + _mntopts="$_new_mntpoint $_fstype $_options" + # for non-nfs _dev converting to use udev persistent name if [ -b "$_source" ]; then _pdev="$(get_persistent_dev $_source)" if [ -z "$_pdev" ]; then return 1 fi - else _pdev=$_dev fi From 06241484147be6d92886a8c27b934c9dde19990a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 11 Mar 2020 21:06:03 +0800 Subject: [PATCH 222/806] Add a is_mounted helper Use is_mounted helper instaed of calling findmnt directly or checking if "mount" value is empty. If findmnt looks for fstab as well, some non mounted entry will also return value. Required to support non-mounted target. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 2 +- kdump-lib.sh | 5 +++++ kdumpctl | 2 +- mkdumprd | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 49b12dc..c374c4b 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -101,7 +101,7 @@ dump_fs() local _mp=$(findmnt -k -f -n -r -o TARGET $1) local _op=$(findmnt -k -f -n -r -o OPTIONS $1) - if [ -z "$_mp" ]; then + if ! is_mounted "$_mp"; then _dev=$(findmnt -s -f -n -r -o SOURCE $1) _mp=$(findmnt -s -f -n -r -o TARGET $1) _op=$(findmnt -s -f -n -r -o OPTIONS $1) diff --git a/kdump-lib.sh b/kdump-lib.sh index 2157c34..a5951ad 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -246,6 +246,11 @@ get_target_from_path() echo $_target } +is_mounted() +{ + findmnt -k -n $1 &>/dev/null +} + get_fs_type_from_target() { findmnt -k -f -n -r -o FSTYPE $1 diff --git a/kdumpctl b/kdumpctl index 081720e..c840b28 100755 --- a/kdumpctl +++ b/kdumpctl @@ -475,7 +475,7 @@ check_dump_fs_modified() fi fi - if ! findmnt $_target >/dev/null; then + if ! is_mounted $_target; then echo "Dump target $_target is probably not mounted." return 2 fi diff --git a/mkdumprd b/mkdumprd index c80e3e0..d62746e 100644 --- a/mkdumprd +++ b/mkdumprd @@ -366,7 +366,7 @@ do extra_modules="$extra_modules $config_val" ;; ext[234]|xfs|btrfs|minix|nfs) - if ! findmnt $config_val >/dev/null; then + if ! is_mounted $config_val; then perror_exit "Dump target $config_val is probably not mounted." fi From 70deeb474bc08a83e0990f08fa97fc01a9d3e65c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Mar 2020 20:49:58 +0800 Subject: [PATCH 223/806] Allow calling mkdumprd from kdumpctl even if targat not mounted Ignore mount check in kdumpctl, mkdumprd will still fail building and exit if target is not mounted. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdumpctl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index c840b28..23c0c38 100755 --- a/kdumpctl +++ b/kdumpctl @@ -475,11 +475,6 @@ check_dump_fs_modified() fi fi - if ! is_mounted $_target; then - echo "Dump target $_target is probably not mounted." - return 2 - fi - _new_mntpoint="$(get_kdump_mntpoint_from_target $_target)" _dracut_args=$(lsinitrd $TARGET_INITRD -f usr/lib/dracut/build-parameter.txt) if [[ -z "$_dracut_args" ]];then From be578f6382ef6c25d5d76a8e371585461f243a36 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Mar 2020 13:52:55 +0800 Subject: [PATCH 224/806] kdump-lib.sh: add fstab failback helper for getting mount info This allows look up mount info even if target is not mounted. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index a5951ad..95162cd 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -236,7 +236,7 @@ get_bind_mount_source() echo $_mntpoint$_path } -# Return the real underlaying device of a path, ignore bind mounts +# Return the current underlaying device of a path, ignore bind mounts get_target_from_path() { local _target @@ -251,16 +251,31 @@ is_mounted() findmnt -k -n $1 &>/dev/null } +get_mount_info() +{ + local _info_type=$1 _src_type=$2 _src=$3; shift 3 + local _info=$(findmnt --real -k -n -r -o $_info_type --$_src_type $_src $@) + + [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt --real -s -n -r -o $_info_type --$_src_type $_src $@) + + echo $_info +} + get_fs_type_from_target() { - findmnt -k -f -n -r -o FSTYPE $1 + get_mount_info FSTYPE source $1 -f +} + +get_mntopt_from_target() +{ + get_mount_info OPTIONS source $1 -f } # Find the general mount point of a dump target, not the bind mount point get_mntpoint_from_target() { # Expcilitly specify --source to findmnt could ensure non-bind mount is returned - findmnt -k -f -n -r -o TARGET --source $1 + get_mount_info TARGET source $1 -f } # Get the path where the target will be mounted in kdump kernel From 61e016939c59f3011aea637aee7cec7d51471890 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Mar 2020 20:57:08 +0800 Subject: [PATCH 225/806] User get_mount_info to replace findmnt calls Use get_mount_info so that fstab is used as a failback when look for mount info. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 23 ++++++++++------------- kdump-lib.sh | 1 - kdumpctl | 4 ++-- mkdumprd | 38 +++++++++++++------------------------- 4 files changed, 25 insertions(+), 41 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c374c4b..ab78be3 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -94,19 +94,16 @@ get_kdump_confs() fi } -# dump_fs +# dump_fs dump_fs() { - local _dev=$(findmnt -k -f -n -r -o SOURCE $1) - local _mp=$(findmnt -k -f -n -r -o TARGET $1) - local _op=$(findmnt -k -f -n -r -o OPTIONS $1) + local _mp=$1 + local _dev=$(get_mount_info SOURCE target $_mp -f) + local _op=$(get_mount_info OPTIONS target $_mp -f) - if ! is_mounted "$_mp"; then - _dev=$(findmnt -s -f -n -r -o SOURCE $1) - _mp=$(findmnt -s -f -n -r -o TARGET $1) - _op=$(findmnt -s -f -n -r -o OPTIONS $1) - - if [ -n "$_dev" ] && [ -n "$_mp" ]; then + # If dump path have a corresponding device entry but not mounted, mount it. + if [ -n "$_dev" ]; then + if ! is_mounted "$_mp"; then echo "kdump: dump target $_dev is not mounted, trying to mount..." mkdir -p $_mp mount -o $_op $_dev $_mp @@ -115,11 +112,10 @@ dump_fs() echo "kdump: mounting failed (mount point: $_mp, option: $_op)" return 1 fi - else - echo "kdump: error: Dump target $_dev is not usable" fi else - echo "kdump: dump target is $_dev" + echo "kdump: failed to dump to \"$_mp\", it's not a mount point!" + return 1 fi # Remove -F in makedumpfile case. We don't want a flat format dump here. @@ -260,6 +256,7 @@ read_kdump_conf() [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" ;; ext[234]|xfs|btrfs|minix|nfs) + config_val=$(get_mntpoint_from_target "$config_val") add_dump_code "dump_fs $config_val" ;; raw) diff --git a/kdump-lib.sh b/kdump-lib.sh index 95162cd..691a14d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -270,7 +270,6 @@ get_mntopt_from_target() { get_mount_info OPTIONS source $1 -f } - # Find the general mount point of a dump target, not the bind mount point get_mntpoint_from_target() { diff --git a/kdumpctl b/kdumpctl index 23c0c38..4a674f2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -907,8 +907,8 @@ path_to_be_relabeled() _target=$(local_fs_dump_target) if [[ -n "$_target" ]]; then - _mnt=$(findmnt -k -f -n -r -o TARGET $_target) - if [ -z "$_mnt" ]; then + _mnt=$(get_mntpoint_from_target $_target) + if ! is_mounted "$_mnt"; then return fi else diff --git a/mkdumprd b/mkdumprd index d62746e..92f091b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -51,21 +51,18 @@ add_dracut_sshkey() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _dev=$1 _source _new_mntpoint _fstype _options _mntopts _pdev + local _target=$1 _new_mntpoint _fstype _options _mntopts _pdev - _source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev) - _new_mntpoint=$(get_kdump_mntpoint_from_target $_dev) + _fstype=$(get_fs_type_from_target $_target) + _options=$(get_mntopt_from_target $_target) + _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) - [[ -e /etc/fstab ]] && _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev) - if [ -z "$_options" ]; then - _options=$(findmnt -k -f -n -r -o OPTIONS $_dev) - if [[ $_fstype == "nfs"* ]]; then - _options=$(echo $_options | sed 's/,addr=[^,]*//') - _options=$(echo $_options | sed 's/,proto=[^,]*//') - _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') - fi + if [[ "$_fstype" == "nfs"* ]]; then + _options=$(echo $_options | sed 's/,addr=[^,]*//') + _options=$(echo $_options | sed 's/,proto=[^,]*//') + _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') fi + # mount fs target as rw in 2nd kernel _options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g') # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd @@ -79,28 +76,19 @@ to_mount() { _options="$_options,nofail,x-systemd.before=initrd-fs.target" _mntopts="$_new_mntpoint $_fstype $_options" - # for non-nfs _dev converting to use udev persistent name - if [ -b "$_source" ]; then - _pdev="$(get_persistent_dev $_source)" + # for non-nfs _target converting to use udev persistent name + if [ -b "$_target" ]; then + _pdev="$(get_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1 fi else - _pdev=$_dev + _pdev=$_target fi echo "$_pdev $_mntopts" } -is_readonly_mount() { - local _mnt - _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) - - #fs/proc_namespace.c: show_mountinfo(): - #seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw"); - [[ "$_mnt" =~ ^ro ]] -} - #Function: get_ssh_size #$1=dump target #called from while loop and shouldn't read from stdin, so we're using "ssh -n" From ca01cbdfd5c17e7a6134a1fcfef1a0ceb22476d9 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 12 May 2020 18:47:19 +0800 Subject: [PATCH 226/806] mkdumprd: generate usable kdump initramfs even target is not mounted Currently kexec-tools always depend on dump target to be mounted, which caused some inconvenience for setup. So for user configured target, allow kdump to start and build initramfs even if target is not mounted. When a mounted user configured target is used, the behavior is not changed. When a unmounted user configured target is used, mkdumprd will look for corresponding mount info in fstab, and a entry with noauto option is founded, mkdumprd will try to mount it inplace with optoins specified in fstab and do basic checks on the device, then umount it. If there is no fstab entry, mkdumprd will try to mount it in temporary path with defaults option, do same basic check and umount it. If there is a fstab entry but "noauto" option is not used, then there must be some reason that the target device is not mounted, mkdumprd will error out. When path based target is used, there is no behavior change. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 33 ++++++------------ mkdumprd | 94 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 92 insertions(+), 35 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 691a14d..74dac4c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -284,12 +284,17 @@ get_kdump_mntpoint_from_target() local _mntpoint=$(get_mntpoint_from_target $1) # mount under /sysroot if dump to root disk or mount under - # /kdumproot/$_mntpoint in other cases in 2nd kernel. systemd - # will be in charge to umount it. - if [ "$_mntpoint" = "/" ];then - _mntpoint="/sysroot" + # mount under /kdumproot if dump target is not mounted in first kernel + # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. + # systemd will be in charge to umount it. + if [ -z "$_mntpoint" ];then + _mntpoint="/kdumproot" else - _mntpoint="/kdumproot/$_mntpoint" + if [ "$_mntpoint" = "/" ];then + _mntpoint="/sysroot" + else + _mntpoint="/kdumproot/$_mntpoint" + fi fi # strip duplicated "/" @@ -302,24 +307,6 @@ get_option_value() { strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` } -check_save_path_fs() -{ - local _path=$1 - - if [ ! -d $_path ]; then - perror_exit "Dump path $_path does not exist." - fi -} - -# Check if path exists within dump target -check_save_path_user_configured() -{ - local _target=$1 _path=$2 - local _mnt=$(get_mntpoint_from_target $_target) - - check_save_path_fs "$_mnt/$_path" -} - is_atomic() { grep -q "ostree" /proc/cmdline diff --git a/mkdumprd b/mkdumprd index 92f091b..aa79541 100644 --- a/mkdumprd +++ b/mkdumprd @@ -19,6 +19,20 @@ OVERRIDE_RESETTABLE=0 extra_modules="" dracut_args="--quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" +readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" +[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." +readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target" + +trap ' + ret=$?; + is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT; + [[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKDUMPRD_TMPDIR"; + exit $ret; + ' EXIT + +# clean up after ourselves no matter how we die. +trap 'exit 1;' SIGINT + is_wdt_addition_needed() { local active @@ -51,11 +65,12 @@ add_dracut_sshkey() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _target=$1 _new_mntpoint _fstype _options _mntopts _pdev + local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _mntopts _pdev - _fstype=$(get_fs_type_from_target $_target) - _options=$(get_mntopt_from_target $_target) _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) + _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" + _options="${_options:-$(get_mntopt_from_target $_options)}" + _options="${_options:-defaults}" if [[ "$_fstype" == "nfs"* ]]; then _options=$(echo $_options | sed 's/,addr=[^,]*//') @@ -174,6 +189,67 @@ check_size() { fi } +check_save_path_fs() +{ + local _path=$1 + + if [ ! -d $_path ]; then + perror_exit "Dump path $_path does not exist." + fi +} + +check_user_configured_target() +{ + local _target=$1 _cfg_fs_type=$2 _mounted + local _mnt=$(get_mntpoint_from_target $_target) + local _opt=$(get_mntopt_from_target $_target) + local _fstype=$(get_fs_type_from_target $_target) + + if [ -n "$_fstype" ]; then + # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf + [[ $_fstype = "nfs"* ]] && _fstype=nfs + + if [ -n "$_cfg_fs_type" ] && [ "$_fstype" != "$_cfg_fs_type" ]; then + perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\"" + fi + else + _fstype="$_cfg_fs_type" + _fstype="$_cfg_fs_type" + fi + + # For noauto mount, mount it inplace with default value. + # Else use the temporary target directory + if [ -n "$_mnt" ]; then + if ! is_mounted "$_mnt"; then + if [[ $_opt = *",noauto"* ]]; then + mount $_mnt + [ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check." + _mounted=$_mnt + else + perror_exit "$_target is configured in fstab but not mounted, please check its usability." + fi + fi + else + _mnt=$MKDUMPRD_TMPMNT + mkdir -p $_mnt + mount $_target $_mnt -t $_fstype -o defaults + [ $? -ne 0 ] && perror_exit "Failed to mount $_target for kdump preflight check." + _mounted=$_mnt + fi + + # For user configured target, use $SAVE_PATH as the dump path within the target + if [ ! -d "$_mnt/$SAVE_PATH" ]; then + perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\"" + fi + + check_size fs "$_target" + + # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway + if [ -n "$_mounted" ]; then + umount -f -- $_mounted + fi +} + # $1: core_collector config value verify_core_collector() { local _cmd="${1%% *}" @@ -201,7 +277,7 @@ verify_core_collector() { } add_mount() { - local _mnt=$(to_mount "$1") + local _mnt=$(to_mount $@) if [ $? -ne 0 ]; then exit 1 @@ -354,14 +430,8 @@ do extra_modules="$extra_modules $config_val" ;; ext[234]|xfs|btrfs|minix|nfs) - if ! is_mounted $config_val; then - perror_exit "Dump target $config_val is probably not mounted." - fi - - # User configured target, use $SAVE_PATH as the dump path within the target - check_save_path_user_configured "$config_val" "$SAVE_PATH" - check_size fs "$config_val" - add_mount "$config_val" + check_user_configured_target "$config_val" "$config_opt" + add_mount "$config_val" "$config_opt" ;; raw) # checking raw disk writable From f2ffa3d34008ca553a3047a77453b20a60c2f992 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sat, 9 May 2020 18:25:23 +0800 Subject: [PATCH 227/806] kexec-kdump-howto.txt: Add some format to the document When adding doc for the non-mounted dump target support, I found the document are a bit uneasy to read due to lack of a proper format, this commit should it make looks better. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kexec-kdump-howto.txt | 210 +++++++++++++++++++++++++----------------- 1 file changed, 127 insertions(+), 83 deletions(-) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 8e6cc4c..0d2b6cb 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -1,15 +1,22 @@ +================= Kexec/Kdump HOWTO +================= + Introduction +============ Kexec and kdump are new features in the 2.6 mainstream kernel. These features are included in Red Hat Enterprise Linux 5. The purpose of these features is to ensure faster boot up and creation of reliable kernel vmcores for diagnostic purposes. + Overview +======== Kexec +----- Kexec is a fastboot mechanism which allows booting a Linux kernel from the context of already running kernel without going through BIOS. BIOS can be very @@ -17,6 +24,7 @@ time consuming especially on the big servers with lots of peripherals. This can save a lot of time for developers who end up booting a machine numerous times. Kdump +----- Kdump is a new kernel crash dumping mechanism and is very reliable because the crash dump is captured from the context of a freshly booted kernel and @@ -52,7 +60,8 @@ Now reboot your system, taking note that it should bypass the BIOS: # reboot -How to configure kdump: +How to configure kdump +====================== Again, we assume if you're reading this document, you should already have kexec-tools installed. If not, you install it via the following command: @@ -136,7 +145,9 @@ perform postmortem analysis: and so on... -Notes: + +Notes on kdump +============== When kdump starts, the kdump kernel is loaded together with the kdump initramfs. To save memory usage and disk space, the kdump initramfs is @@ -152,8 +163,10 @@ recommended to rebuild the initramfs manually with following command: # kdumpctl rebuild + Saving vmcore-dmesg.txt ----------------------- +======================= + Kernel log bufferes are one of the most important information available in vmcore. Now before saving vmcore, kernel log bufferes are extracted from /proc/vmcore and saved into a file vmcore-dmesg.txt. After @@ -161,7 +174,9 @@ vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will not be available if dump target is raw device. -Dump Triggering methods: + +Dump Triggering methods +======================= This section talks about the various ways, other than a Kernel Panic, in which Kdump can be triggered. The following methods assume that Kdump is configured @@ -268,7 +283,11 @@ to initate the dump and then click "Restart blade with NMI". This issues a system reset and invokes xmon debugger. -Advanced Setups: +Advanced Setups +=============== + +Dump targets +------------ In addition to being able to capture a vmcore to your system's local file system, kdump can be configured to capture a vmcore to a number of other @@ -295,7 +314,6 @@ which out of the box, is fairly well documented itself. Any alterations to the changes can be incorporated in the kdump initrd. Restarting the kdump service is as simple as '/sbin/systemctl restart kdump.service'. - Note that kdump.conf is used as a configuration mechanism for capturing dump files from the initramfs (in the interests of safety), the root file system is mounted, and the init process is started, only as a last resort if the @@ -314,7 +332,9 @@ someone uses the filesystem for something else other than dumping vmcore you can mount it as read-only. Mkdumprd will still remount it as read-write for creating dump directory and will move it back to read-only afterwards. -Raw partition +Followings are the available config options for dump targets. + +1) Raw partition Raw partition dumping requires that a disk partition in the system, at least as large as the amount of memory in the system, be left unformatted. Assuming @@ -325,7 +345,7 @@ onto partition /dev/vg/lv_kdump. Restart the kdump service via initrd. Dump target should be persistent device name, such as lvm or device mapper canonical name. -Dedicated file system +2) Dedicated file system Similar to raw partition dumping, you can format a partition with the file system of your choice, Again, it should be at least as large as the amount @@ -349,7 +369,7 @@ Be careful of your filesystem selection when using this target. It is recommended to use persistent device names or UUID/LABEL for file system dumps. One example of persistent device is /dev/vg/. -NFS mount +3) NFS mount Dumping over NFS requires an NFS server configured to export a file system with full read/write access for the root user. All operations done within @@ -367,7 +387,7 @@ mount the NFS mount and copy out the vmcore to your NFS server. Restart the kdump service via '/sbin/systemctl restart kdump.service' to commit this change to your kdump initrd. -Special mount via "dracut_args" +4) Special mount via "dracut_args" You can utilize "dracut_args" to pass "--mount" to kdump, see dracut manpage about the format of "--mount" for details. If there is any "--mount" specified @@ -385,7 +405,7 @@ dracut_args --mount "192.168.1.1:/share /mnt/test nfs4 defaults" NOTE: - must be specified as an absolute path. -Remote system via ssh/scp +5) Remote system via ssh/scp Dumping over ssh/scp requires setting up passwordless ssh keys for every machine you wish to have dump via this method. First up, configure kdump.conf @@ -404,7 +424,8 @@ to send over the necessary ssh key file. Restart the kdump service via '/sbin/systemctl restart kdump.service' to commit this change to your kdump initrd. Path -==== +---- + "path" represents the file system path in which vmcore will be saved. In fact kdump creates a directory $hostip-$date with-in "path" and saves vmcore there. So practically dump is saved in $path/$hostip-$date/. To @@ -427,25 +448,26 @@ at automatically depending on what's mounted in the current system. Following are few examples. -path /var/crash/ ----------------- -Assuming there is no disk mounted on /var/ or on /var/crash, dump will -be saved on disk backing rootfs in directory /var/crash. +- path /var/crash/ -path /var/crash/ (A separate disk mounted on /var) --------------------------------------------------- -Say a disk /dev/sdb is mouted on /var. In this case dump target will -become /dev/sdb and path will become "/crash" and dump will be saved -on "sdb:/crash/" directory. + Assuming there is no disk mounted on /var/ or on /var/crash, dump will + be saved on disk backing rootfs in directory /var/crash. -path /var/crash/ (NFS mounted on /var) -------------------------------------- -Say foo.com:/export/tmp is mounted on /var. In this case dump target is -nfs server and path will be adjusted to "/crash" and dump will be saved to -foo.com:/export/tmp/crash/ directory. +- path /var/crash/ (A separate disk mounted on /var) + + Say a disk /dev/sdb is mouted on /var. In this case dump target will + become /dev/sdb and path will become "/crash" and dump will be saved + on "sdb:/crash/" directory. + +- path /var/crash/ (NFS mounted on /var) + + Say foo.com:/export/tmp is mounted on /var. In this case dump target is + nfs server and path will be adjusted to "/crash" and dump will be saved to + foo.com:/export/tmp/crash/ directory. Kdump boot directory -==================== +-------------------- + Usually kdump kernel is the same as 1st kernel. So kdump will try to find kdump kernel under /boot according to /proc/cmdline. E.g we execute below command and get an output: @@ -456,6 +478,7 @@ However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to user if kdump kernel is put in a different directory. Kdump Post-Capture Executable +----------------------------- It is possible to specify a custom script or binary you wish to run following an attempt to capture a vmcore. The executable is passed an exit code from @@ -463,6 +486,7 @@ the capture process, which can be used to trigger different actions from within your post-capture executable. Kdump Pre-Capture Executable +---------------------------- It is possible to specify a custom script or binary you wish to run before capturing a vmcore. Exit status of this binary is interpreted: @@ -470,6 +494,7 @@ capturing a vmcore. Exit status of this binary is interpreted: non 0 - reboot the system Extra Binaries +-------------- If you have specific binaries or scripts you want to have made available within your kdump initrd, you can specify them by their full path, and they @@ -478,6 +503,7 @@ This may be particularly useful for those running post-capture scripts that rely on other binaries. Extra Modules +------------- By default, only the bare minimum of kernel modules will be included in your kdump initrd. Should you wish to capture your vmcore files to a non-boot-path @@ -486,7 +512,8 @@ need to manually specify additional kernel modules to load into your kdump initrd. Failure action -============== +-------------- + Failure action specifies what to do when dump to configured dump target fails. By default, failure action is "reboot" and that is system reboots if attempt to save dump to dump target fails. @@ -494,21 +521,24 @@ if attempt to save dump to dump target fails. There are other failure actions available though. - dump_to_rootfs - This option tries to mount root and save dump on root filesystem - in a path specified by "path". This option will generally make - sense when dump target is not root filesystem. For example, if - dump is being saved over network using "ssh" then one can specify - failure action to "dump_to_rootfs" to try saving dump to root - filesystem if dump over network fails. + This option tries to mount root and save dump on root filesystem + in a path specified by "path". This option will generally make + sense when dump target is not root filesystem. For example, if + dump is being saved over network using "ssh" then one can specify + failure action to "dump_to_rootfs" to try saving dump to root + filesystem if dump over network fails. - shell - Drop into a shell session inside initramfs. + Drop into a shell session inside initramfs. + - halt - Halt system after failure + Halt system after failure + - poweroff - Poweroff system after failure. + Poweroff system after failure. Compression and filtering +------------------------- The 'core_collector' parameter in kdump.conf allows you to specify a custom dump capture method. The most common alternate method is makedumpfile, which @@ -526,22 +556,21 @@ Core collector command format depends on dump target type. Typically for filesystem (local/remote), core_collector should accept two arguments. First one is source file and second one is target file. For ex. -ex1. ---- -core_collector "cp --sparse=always" +- ex1. -Above will effectively be translated to: + core_collector "cp --sparse=always" -cp --sparse=always /proc/vmcore /vmcore + Above will effectively be translated to: -ex2. ---- -core_collector "makedumpfile -l --message-level 1 -d 31" + cp --sparse=always /proc/vmcore /vmcore -Above will effectively be translated to: +- ex2. -makedumpfile -l --message-level 1 -d 31 /proc/vmcore /vmcore + core_collector "makedumpfile -l --message-level 1 -d 31" + Above will effectively be translated to: + + makedumpfile -l --message-level 1 -d 31 /proc/vmcore /vmcore For dump targets like raw and ssh, in general, core collector should expect one argument (source file) and should output the processed core on standard @@ -549,55 +578,56 @@ output (There is one exception of "scp", discussed later). This standard output will be saved to destination using appropriate commands. raw dumps core_collector examples: ---------- -ex3. ---- -core_collector "cat" -Above will effectively be translated to. +- ex3. -cat /proc/vmcore | dd of= + core_collector "cat" -ex4. ---- -core_collector "makedumpfile -F -l --message-level 1 -d 31" + Above will effectively be translated to. -Above will effectively be translated to. + cat /proc/vmcore | dd of= -makedumpfile -F -l --message-level 1 -d 31 | dd of= +- ex4. + + core_collector "makedumpfile -F -l --message-level 1 -d 31" + + Above will effectively be translated to. + + makedumpfile -F -l --message-level 1 -d 31 | dd of= ssh dumps core_collector examples: ---------- -ex5. ---- -core_collector "cat" -Above will effectively be translated to. +- ex5. -cat /proc/vmcore | ssh "dd of=path/vmcore" + core_collector "cat" -ex6. ---- -core_collector "makedumpfile -F -l --message-level 1 -d 31" + Above will effectively be translated to. -Above will effectively be translated to. + cat /proc/vmcore | ssh "dd of=path/vmcore" -makedumpfile -F -l --message-level 1 -d 31 | ssh "dd of=path/vmcore" +- ex6. + + core_collector "makedumpfile -F -l --message-level 1 -d 31" + + Above will effectively be translated to. + + makedumpfile -F -l --message-level 1 -d 31 | ssh "dd of=path/vmcore" There is one exception to standard output rule for ssh dumps. And that is scp. As scp can handle ssh destinations for file transfers, one can specify "scp" as core collector for ssh targets (no output on stdout). -ex7. ----- -core_collector "scp" +- ex7. -Above will effectively be translated to. + core_collector "scp" -scp /proc/vmcore :path/vmcore + Above will effectively be translated to. + + scp /proc/vmcore :path/vmcore About default core collector ---------------------------- + Default core_collector for ssh/raw dump is: "makedumpfile -F -l --message-level 1 -d 31". Default core_collector for other targets is: @@ -615,7 +645,9 @@ dump data from stdard input to a normal dumpfile (readable with analysis tools). For example: "makedumpfile -R vmcore < vmcore.flat" -Caveats: + +Caveats +======= Console frame-buffers and X are not properly supported. If you typically run with something along the lines of "vga=791" in your kernel config line or @@ -624,7 +656,11 @@ kexec. Note that the kdump kernel should still be able to create a dump, and when the system reboots, video should be restored to normal. +Notes +===== + Notes on resetting video: +------------------------- Video is a notoriously difficult issue with kexec. Video cards contain ROM code that controls their initial configuration and setup. This code is nominally @@ -646,7 +682,9 @@ Secondly, it may be worth trying to add vga15fb.ko to the extra_modules list in /etc/kdump.conf. This will attempt to use the video card in framebuffer mode, which can blank the screen prior to the start of a dump capture. -Notes on rootfs mount: +Notes on rootfs mount +--------------------- + Dracut is designed to mount rootfs by default. If rootfs mounting fails it will refuse to go on. So kdump leaves rootfs mounting to dracut currently. We make the assumtion that proper root= cmdline is being passed to dracut @@ -656,7 +694,8 @@ options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely. -Notes on watchdog module handling: +Notes on watchdog module handling +--------------------------------- If a watchdog is active in first kernel then, we must have it's module loaded in crash kernel, so that either watchdog is deactivated or started @@ -670,7 +709,8 @@ not been written in watchdog-core framework then this option will not have any effect and module will not be added. Please note that only systemd watchdog daemon is supported as watchdog kick application. -Notes for disk images: +Notes for disk images +--------------------- Kdump initramfs is a critical component for capturing the crash dump. But it's strictly generated for the machine it will run on, and have @@ -684,7 +724,8 @@ a machine with a disk image which have kdump initramfs embedded, you should rebuild the initramfs using "kdumpctl rebuild" command manually, or else kdump may not work as expeceted. -Notes on encrypted dump target: +Notes on encrypted dump target +------------------------------ Currently, kdump is not working well with encrypted dump target. First, user have to give the password manually in capture kernel, @@ -698,7 +739,8 @@ crash kernel according, or update your encryption setup. It's recommanded to use a non-encrypted target (eg. remote target) instead. -Notes on device dump: +Notes on device dump +-------------------- Device dump allows drivers to append dump data to vmcore, so you can collect driver specified debug info. The drivers could append the @@ -715,8 +757,10 @@ the dump target setup will be included. To ensure the device dump data will be included in the vmcore, you need to force include related device drivers by using "extra_modules" option in /etc/kdump.conf + Parallel Dumping Operation ========================== + Kexec allows kdump using multiple cpus. So parallel feature can accelerate dumping substantially, especially in executing compression and filter. For example: @@ -746,8 +790,10 @@ may lead to panic due to Out Of Memory. hang, system reset or power-off at boot, depending on your system and runtime situation at the time of crash. + Debugging Tips --------------- +============== + - One can drop into a shell before/after saving vmcore with the help of using kdump_pre/kdump_post hooks. Use following in one of the pre/post scripts to drop into a shell. @@ -772,5 +818,3 @@ Debugging Tips minicom -C /tmp/console-logs Now minicom should be logging serial console in file console-logs. - - From 846e23a2d57e51c47e1656cda57dd93380a5a8d6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 10 May 2020 00:45:29 +0800 Subject: [PATCH 228/806] Update docs for the new noauto dump target support Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kexec-kdump-howto.txt | 191 +++++++++++++++++++++++++++--------------- 1 file changed, 125 insertions(+), 66 deletions(-) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 0d2b6cb..78ebf69 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -283,11 +283,8 @@ to initate the dump and then click "Restart blade with NMI". This issues a system reset and invokes xmon debugger. -Advanced Setups -=============== - Dump targets ------------- +============ In addition to being able to capture a vmcore to your system's local file system, kdump can be configured to capture a vmcore to a number of other @@ -295,7 +292,8 @@ locations, including a raw disk partition, a dedicated file system, an NFS mounted file system, or a remote system via ssh/scp. Additional options exist for specifying the relative path under which the dump is captured, what to do if the capture fails, and for compressing and filtering the dump -(so as to produce smaller, more manageable, vmcore files). +(so as to produce smaller, more manageable, vmcore files, see "Advanced Setups" +for more detail on these options). In theory, dumping to a location other than the local file system should be safer than kdump's default setup, as its possible the default setup will try @@ -308,31 +306,131 @@ as allowing for the centralization of vmcore files, should you have several systems from which you'd like to obtain vmcore files. Of course, note that these configurations could present problems if your network is unreliable. -Advanced setups are configured via modifications to /etc/kdump.conf, -which out of the box, is fairly well documented itself. Any alterations to -/etc/kdump.conf should be followed by a restart of the kdump service, so -the changes can be incorporated in the kdump initrd. Restarting the kdump -service is as simple as '/sbin/systemctl restart kdump.service'. +Kdump target and advanced setups are configured via modifications to +/etc/kdump.conf, which out of the box, is fairly well documented itself. +Any alterations to /etc/kdump.conf should be followed by a restart of the +kdump service, so the changes can be incorporated in the kdump initrd. +Restarting the kdump service is as simple as '/sbin/systemctl restart kdump.service'. -Note that kdump.conf is used as a configuration mechanism for capturing dump -files from the initramfs (in the interests of safety), the root file system is -mounted, and the init process is started, only as a last resort if the -initramfs fails to capture the vmcore. As such, configuration made in -/etc/kdump.conf is only applicable to capture recorded in the initramfs. If -for any reason the init process is started on the root file system, only a -simple copying of the vmcore from /proc/vmcore to /var/crash/$DATE/vmcore will -be preformed. +There are two ways to config the dump target, config dump target only +using "path", and config dump target explicitly. Interpretation of "path" +also differs in two config styles. + +Config dump target only using "path" +------------------------------------ + +You can change the dump target by setting "path" to a mount point where +dump target is mounted. When there is no explicitly configured dump target, +"path" in kdump.conf represents the current file system path in which vmcore +will be saved. Kdump will automatically detect the underlying device of +"path" and use that as the dump target. + +In fact, upon dump, kdump creates a directory $hostip-$date with-in "path" +and saves vmcore there. So practically dump is saved in $path/$hostip-$date/. + +Kdump will only check current mount status for mount entry corresponding to +"path". So please ensure the dump target is mounted on "path" before kdump +service starts. + +NOTES: + +- It's strongly recommanded to put an mount entry for "path" in /etc/fstab + and have it auto mounted on boot. This make sure the dump target is + reachable from the machine and kdump's configuration is stable. + +EXAMPLES: + +- path /var/crash/ + + This is the default configuration. Assuming there is no disk mounted + on /var/ or on /var/crash, dump will be saved on disk backing rootfs + in directory /var/crash. + +- path /var/crash/ (A separate disk mounted on /var/crash) + + Say a disk /dev/sdb is mounted on /var. In this case dump target will + become /dev/sdb and path will become "/" and dump will be saved + on "sdb:/var/crash/" directory. + +- path /var/crash/ (NFS mounted on /var) + + Say foo.com:/export/tmp is mounted on /var. In this case dump target is + nfs server and path will be adjusted to "/crash" and dump will be saved to + foo.com:/export/tmp/crash/ directory. + +Config dump target explicitely +------------------------------ + +You can set the dump target explicitly in kdump.conf, and "path" will be +the relative path in the specified dump target. For example, if dump +target is "ext4 /dev/sda", then dump will be saved in "path" directory +on /dev/sda. + +Same is the case for nfs dump. If user specified "nfs foo.com:/export/tmp/" +as dump target, then dump will effectively be saved in +"foo.com:/export/tmp/var/crash/" directory. + +If the dump target is "raw", then "path" is ignored. + +If it's a filesystem target, kdump will need to know the right mount option. +Kdump will check current mount status, and then /etc/fstab for mount options +corresponding to the specified dump target and use it. If there are +special mount option required for the dump target, it could be set by put +an entry in fstab. + +If there are no related mount entry, mount option is set to "defaults". + +NOTES: + +- It's recommended to put an entry for the dump target in /etc/fstab + and have it auto mounted on boot. This make sure the dump target is + reachable from the machine and kdump won't fail. + +- Kdump ignores some mount options, including "noauto", "ro". This + make it possible to keep the dump target unmounted or read-only + when not used. + +EXAMPLES: + +- ext4 /dev/sda (mounted) + path /var/crash/ + + In this case dump target is set to /dev/sdb, path is the absolute path + "/var/crash" in /dev/sda, vmcore path will saved on + "sda:/var/crash" directory. + +- nfs foo.com:/export/tmp (mounted) + path /var/crash/ + + In this case dump target is nfs server, path is the absolute path + "/var/crash", vmcore path will saved on "foo.com:/export/tmp/crash/" directory. + +- nfs foo.com:/export/tmp (not mounted) + path /var/crash/ + + Same with above case, kdump will use "defaults" as the mount option + for the dump target. + +- nfs foo.com:/export/tmp (not mounted, entry with option "noauto,nolock" exists in /etc/fstab) + path /var/crash/ + + In this case dump target is nfs server, vmcore path will saved on + "foo.com:/export/tmp/crash/" directory, and kdump will inherit "nolock" option. + +Dump target and mkdumprd +------------------------ + +MKdumprd is the tool used to create kdump initramfs, and it may change +the mount status of the dump target in some condition. -For both local filesystem and nfs dump the dump target must be mounted before -building kdump initramfs. That means one needs to put an entry for the dump -file system in /etc/fstab so that after reboot when kdump service starts, -it can find the dump target and build initramfs instead of failing. Usually the dump target should be used only for kdump. If you worry about someone uses the filesystem for something else other than dumping vmcore -you can mount it as read-only. Mkdumprd will still remount it as read-write -for creating dump directory and will move it back to read-only afterwards. +you can mount it as read-only or make it a noauto mount. Mkdumprd will +mount/remount it as read-write for creating dump directory and will +move it back to it's original state afterwards. -Followings are the available config options for dump targets. +Supported dump target types and requirements +-------------------------------------------- 1) Raw partition @@ -423,47 +521,8 @@ you've connected to it, and then input the target system user's password to send over the necessary ssh key file. Restart the kdump service via '/sbin/systemctl restart kdump.service' to commit this change to your kdump initrd. -Path ----- - -"path" represents the file system path in which vmcore will be saved. In -fact kdump creates a directory $hostip-$date with-in "path" and saves -vmcore there. So practically dump is saved in $path/$hostip-$date/. To -simplify discussion further, if we say dump will be saved in $path, it -is implied that kdump will create another directory inside path and -save vmcore there. - -If a dump target is specified in kdump.conf, then "path" is relative to the -specified dump target. For example, if dump target is "ext4 /dev/sda", then -dump will be saved in "$path" directory on /dev/sda. - -Same is the case for nfs dump. If user specified "nfs foo.com:/export/tmp/" -as dump target, then dump will effectively be saved in -"foo.com:/export/tmp/var/crash/" directory. - -Interpretation of path changes a bit if user has not specified a dump -target explicitly in kdump.conf. In this case, "path" represents the -absolute path from root. And dump target and adjusted path are arrived -at automatically depending on what's mounted in the current system. - -Following are few examples. - -- path /var/crash/ - - Assuming there is no disk mounted on /var/ or on /var/crash, dump will - be saved on disk backing rootfs in directory /var/crash. - -- path /var/crash/ (A separate disk mounted on /var) - - Say a disk /dev/sdb is mouted on /var. In this case dump target will - become /dev/sdb and path will become "/crash" and dump will be saved - on "sdb:/crash/" directory. - -- path /var/crash/ (NFS mounted on /var) - - Say foo.com:/export/tmp is mounted on /var. In this case dump target is - nfs server and path will be adjusted to "/crash" and dump will be saved to - foo.com:/export/tmp/crash/ directory. +Advanced Setups +=============== Kdump boot directory -------------------- From 73da3224be0d6a682d91d2382228205510718b6c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 22 May 2020 17:18:06 +0800 Subject: [PATCH 229/806] Fix an error in commit ca01cbd Previous commit ca01cbd ('mkdumprd: generate usable kdump initramfs even target is not mounted') applied a wrong version of patch, let me just fix it. Signed-off-by: Kairui Song --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index aa79541..1bee98c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -69,7 +69,7 @@ to_mount() { _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" - _options="${_options:-$(get_mntopt_from_target $_options)}" + _options="${_options:-$(get_mntopt_from_target $_target)}" _options="${_options:-defaults}" if [[ "$_fstype" == "nfs"* ]]; then From 0094fb496dca9d5087ad3bbf193a394e467d32e5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 22 May 2020 17:01:42 +0800 Subject: [PATCH 230/806] Release 2.0.20-13 Add support for using unmounted device as dump target, update docs, and fix several known issue. Signed-off-by: Kairui Song --- kexec-tools.spec | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6bada4a..6889e8a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 12%{?dist} +Release: 13%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -350,6 +350,24 @@ done %endif %changelog +* Fri May 22 2020 Kairui Song - 2.0.20-13 +- Update docs for the new noauto dump target support +- kexec-kdump-howto.txt: Add some format to the document +- mkdumprd: generate usable kdump initramfs even target is not mounted +- User get_mount_info to replace findmnt calls +- kdump-lib.sh: add fstab failback helper for getting mount info +- Allow calling mkdumprd from kdumpctl even if targat not mounted +- Add a is_mounted helper +- Introduce get_kdump_mntpoint_from_target and fix duplicated / +- Append both nofail and x-systemd.before to kdump mount target +- Fix the problem that kdump prints redundant / +- Partially Revert "Don't mount the dump target unless needed" +- fadump: update fadump-howto.txt with some troubleshooting help +- Add a new option 'rd.znet_ifname' in order to use it in udev rules +- Don't unmount the dump target just after saving vmcore +- dracut-module-setup.sh: fix breakage in get_pcs_fence_kdump_nodes() +- dracut-module-setup.sh: ensure cluster info is ready before query + * Thu Apr 2 2020 Kairui Song - 2.0.20-12 - Remove adjust_bind_mount_path call - No longer treat atomic/silverblue specially From a81ec90ed81a75cacd67832738ec47db45a53c0a Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 22 May 2020 14:45:41 +0800 Subject: [PATCH 231/806] kdump.sysconfig: Remove the option 'log_buf_len' from kdump command line The option 'log_buf_len' in the kernel command line will make kernel dynamically allocate memory (system ram) from memblock and always hold the memory allocated. If the size of this option is misused such as 'log_buf_len=64M'. This may cause a short of memory for kdump kernel, because the size of memory is usually limited in kdump kernel. In order to avoid this problem, need to remove this option from the kdump kernel command line. Signed-off-by: Lianbo Jiang Acked-by: Pingfan Liu --- kdump.sysconfig | 2 +- kdump.sysconfig.aarch64 | 2 +- kdump.sysconfig.i386 | 2 +- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- kdump.sysconfig.s390x | 2 +- kdump.sysconfig.x86_64 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index df518d6..7c5641a 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index d5d7624..cbe6118 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index c31a8cb..61d9407 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 1f95452..6c091a7 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 1f95452..6c091a7 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index abd45a2..958eb8f 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index a43a970..95a26a4 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE From cfd93e2b7e407b19f32a408c562f31b4050d788c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 27 May 2020 18:32:26 +0800 Subject: [PATCH 232/806] Revert "Add a hook to wait for kdump target in initqueue" This reverts commit cee618593c35443f3cf5dbce85cf5b04cbeb34de. Upstream dracut have provided a parameter for adding mandantory network requirement by appending "rd.neednet" parameter, so we should use that instead. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-kdump-wait-for-target.sh | 23 ---------------- dracut-kdump.sh | 49 +++++++++++++++++++++++++++++++++ dracut-module-setup.sh | 2 -- kdump-lib-initramfs.sh | 49 --------------------------------- kexec-tools.spec | 2 -- 5 files changed, 49 insertions(+), 76 deletions(-) delete mode 100755 dracut-kdump-wait-for-target.sh diff --git a/dracut-kdump-wait-for-target.sh b/dracut-kdump-wait-for-target.sh deleted file mode 100755 index ce984d0..0000000 --- a/dracut-kdump-wait-for-target.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# only wait if it's kdump kernel -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ]; then - exit 0 -fi - -. /lib/dracut-lib.sh -. /lib/kdump-lib-initramfs.sh - -# For SSH/NFS target, need to wait for the network to setup -if is_nfs_dump_target; then - get_host_ip - exit $? -fi - -if is_ssh_dump_target; then - get_host_ip - exit $? -fi - -# No need to wait for dump target -exit 0 diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 0f54ddc..8752178 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -141,6 +141,55 @@ save_vmcore_dmesg_ssh() { fi } +get_host_ip() +{ + local _host + if is_nfs_dump_target || is_ssh_dump_target + then + kdumpnic=$(getarg kdumpnic=) + [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 + _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` + [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + _host=`echo $_host | head -n 1 | cut -d' ' -f2` + _host="${_host%%/*}" + [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + HOST_IP=$_host + fi + return 0 +} + +read_kdump_conf() +{ + if [ ! -f "$KDUMP_CONF" ]; then + echo "kdump: $KDUMP_CONF not found" + return + fi + + get_kdump_confs + + # rescan for add code for dump target + while read config_opt config_val; + do + # remove inline comments after the end of a directive. + case "$config_opt" in + dracut_args) + config_val=$(get_dracut_args_target "$config_val") + [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" + ;; + ext[234]|xfs|btrfs|minix|nfs) + config_val=$(get_mntpoint_from_target "$config_val") + add_dump_code "dump_fs $config_val" + ;; + raw) + add_dump_code "dump_raw $config_val" + ;; + ssh) + add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" + ;; + esac + done <<< "$(read_strip_comments $KDUMP_CONF)" +} + fence_kdump_notify() { if [ -n "$FENCE_KDUMP_NODES" ]; then diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 5397eb5..1794c2c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -811,9 +811,7 @@ install() { kdump_check_iscsi_targets # nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail - # also need to let initqueue wait for target to become ready if is_nfs_dump_target || is_ssh_dump_target; then - inst_hook initqueue/finished 01 $moddir/kdump-wait-for-target.sh inst "ip" fi diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index ab78be3..c98a43b 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -219,52 +219,3 @@ do_final_action() { eval $FINAL_ACTION } - -get_host_ip() -{ - local _host - if is_nfs_dump_target || is_ssh_dump_target - then - kdumpnic=$(getarg kdumpnic=) - [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 - _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` - [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - _host=`echo $_host | head -n 1 | cut -d' ' -f2` - _host="${_host%%/*}" - [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 - HOST_IP=$_host - fi - return 0 -} - -read_kdump_conf() -{ - if [ ! -f "$KDUMP_CONF" ]; then - echo "kdump: $KDUMP_CONF not found" - return - fi - - get_kdump_confs - - # rescan for add code for dump target - while read config_opt config_val; - do - # remove inline comments after the end of a directive. - case "$config_opt" in - dracut_args) - config_val=$(get_dracut_args_target "$config_val") - [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" - ;; - ext[234]|xfs|btrfs|minix|nfs) - config_val=$(get_mntpoint_from_target "$config_val") - add_dump_code "dump_fs $config_val" - ;; - raw) - add_dump_code "dump_raw $config_val" - ;; - ssh) - add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" - ;; - esac - done <<< "$(read_strip_comments $KDUMP_CONF)" -} diff --git a/kexec-tools.spec b/kexec-tools.spec index 6889e8a..2c9901e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -50,7 +50,6 @@ Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target Source108: dracut-early-kdump.sh Source109: dracut-early-kdump-module-setup.sh -Source110: dracut-kdump-wait-for-target.sh Requires(post): systemd-units Requires(preun): systemd-units @@ -223,7 +222,6 @@ cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} -cp %{SOURCE110} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE110}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump From 0cc3b85d0d4c88c11e48229a76eb24c7d49f9748 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 28 May 2020 02:20:20 +0800 Subject: [PATCH 233/806] module-setup.sh: Add "rd.neednet" parameter if network is needed Upstream dracut now use network-manager module by default and since upstream commit 3dcaa97, network-manager expects user to pass "rd.neednet" to indicate network is required. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1794c2c..d3a674e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -408,6 +408,11 @@ kdump_install_net() { kdump_setup_dns "$_netdev" + if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then + # network-manager module needs this parameter + echo "rd.neednet" >> ${initdir}/etc/cmdline.d/50neednet.conf + fi + # Save netdev used for kdump as cmdline # Whoever calling kdump_install_net() is setting up the default gateway, # ie. bootdev/kdumpnic. So don't override the setting if calling From 134c578463aface9543cba16532cbac3e3ff2da7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 17 May 2020 16:14:06 +0800 Subject: [PATCH 234/806] Don't inherit swiotlb parameter form 1st kernel by default Usually kdump kernel don't need a swiotlb. There are two cases known common case a swiotlb is needed: - SEV/SME is active. - crashkernel high reservation is used, or there are crashkernel memory above 4G. For both case, if swiotlb is set to a large value in first kernel, kdump kernel will likely to fail with OOM. So don't inherit swiotlb parameter by default. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump.sysconfig | 2 +- kdump.sysconfig.aarch64 | 2 +- kdump.sysconfig.i386 | 2 +- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- kdump.sysconfig.s390x | 2 +- kdump.sysconfig.x86_64 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index 7c5641a..ffc387a 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index cbe6118..6f55c03 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 61d9407..45f6d50 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 6c091a7..8dcbe60 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 6c091a7..8dcbe60 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 958eb8f..2a24688 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 95a26a4..e47e195 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE From 47bdeee35d35cec5e0e843aeb36bd0b5aec595c4 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 3 Jun 2020 10:53:25 +0800 Subject: [PATCH 235/806] fadump-howto.txt: source it in spec file Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kexec-tools.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2c9901e..8a470a5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -18,6 +18,7 @@ Source7: mkdumprd Source8: kdump.conf Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/%{mkdf_ver}/makedumpfile-%{mkdf_ver}.tar.gz Source10: kexec-kdump-howto.txt +Source11: fadump-howto.txt Source12: mkdumprd.8 Source13: 98-kexec.rules Source14: 98-kexec.rules.ppc64 @@ -141,6 +142,7 @@ autoreconf rm -f kexec-tools.spec.in # setup the docs cp %{SOURCE10} . +cp %{SOURCE11} . cp %{SOURCE21} . cp %{SOURCE26} . cp %{SOURCE27} . @@ -340,6 +342,7 @@ done %doc TODO %doc kexec-kdump-howto.txt %doc early-kdump-howto.txt +%doc fadump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 From 8fcbb4d265f6f7948081ecd88cccbb1d6548c449 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Tue, 19 May 2020 20:19:15 +0530 Subject: [PATCH 236/806] fadump: update fadump-howto.txt with some more troubleshooting help On journaling filesystems like XFS, bootloader is likely to pick up older initrd (without vmcore capture scripts) if system crashes right after initrd update, as the bootloader (read GRUB) may not replay filesystem log before reading the initrd from disk. Added steps to workaround that problem. Signed-off-by: Hari Bathini Acked-by: Pingfan Liu --- fadump-howto.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index 89675a1..c891e37 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -129,8 +129,24 @@ Then, start up kdump as well: This should turn on the firmware assisted functionality in kernel by echo'ing 1 to /sys/kernel/fadump_registered, leaving the system ready -to capture a vmcore upon crashing. To test this out, you can force-crash -your system by echo'ing a c into /proc/sysrq-trigger: +to capture a vmcore upon crashing. For journaling filesystems like XFS an +additional step is required to ensure bootloader does not pick the +older initrd (without vmcore capture scripts): + + * If /boot is a separate partition, run the below commands as the root user, + or as a user with CAP_SYS_ADMIN rights: + + # fsfreeze -f + # fsfreeze -u + + * If /boot is not a separate partition, reboot the system. + +After reboot check if the kdump service is up and running with: + + # systemctl status kdump.service + +To test out whether FADump is configured properly, you can force-crash your +system by echo'ing a 'c' into /proc/sysrq-trigger: # echo c > /proc/sysrq-trigger From e05c55014492958af48c885fab8f06c5090839af Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 17 May 2020 22:38:22 +0800 Subject: [PATCH 237/806] Drop switch root capability for non fadump initramfs Switch root is never used for kdump image, and this will be helpful to reduce the initramfs size. Also increase dracut dependency version and the function is dracut_no_switch_root is new introduced. This commit is applied to RHEL some time ago, but missing in Fedora as Fedora's Dracut didn't backport this feature at that time. Now apply this missing commit. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 3 +++ kexec-tools.spec | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d3a674e..faa918a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -846,5 +846,8 @@ install() { echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + + # Save more memory by dropping switch root capability + dracut_no_switch_root fi } diff --git a/kexec-tools.spec b/kexec-tools.spec index 8a470a5..c4b7c8d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -55,13 +55,13 @@ Source109: dracut-early-kdump-module-setup.sh Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units -Requires(pre): coreutils sed zlib -Requires: dracut >= 047-34.git20180604 -Requires: dracut-network >= 044-117 -Requires: dracut-squash >= 049-4 +Requires(pre): coreutils sed zlib +Requires: dracut >= 050 +Requires: dracut-network >= 050 +Requires: dracut-squash >= 050 Requires: ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel -BuildRequires: pkgconfig intltool gettext +BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units BuildRequires: automake autoconf libtool %ifarch %{ix86} x86_64 ppc64 ppc s390x ppc64le From 4246f26725b723e9d1ab6ec13659f1c95afd8336 Mon Sep 17 00:00:00 2001 From: "onitsuka.shinic@fujitsu.com" Date: Fri, 5 Jun 2020 02:22:35 +0000 Subject: [PATCH 238/806] dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d} into kdump initramfs This patch installs the binary and script files under /etc/kdump/{pre.d,post.d} into new initramfs of kdump. Signed-off-by: Shinichi Onitsuka Acked-by: Pingfan Liu --- dracut-module-setup.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index faa918a..90f3772 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -427,6 +427,29 @@ kdump_install_net() { fi } +# install etc/kdump/pre.d and /etc/kdump/post.d +kdump_install_pre_post_conf() { + if [ -d /etc/kdump/pre.d ]; then + for file in /etc/kdump/pre.d/*; do + if [ -x "$file" ]; then + dracut_install $file + else + echo "$file is not executable" + fi + done + fi + + if [ -d /etc/kdump/post.d ]; then + for file in /etc/kdump/post.d/*; do + if [ -x "$file" ]; then + dracut_install $file + else + echo "$file is not executable" + fi + done + fi +} + default_dump_target_install_conf() { local _target _fstype @@ -492,6 +515,8 @@ kdump_install_conf() { esac done <<< "$(read_strip_comments /etc/kdump.conf)" + kdump_install_pre_post_conf + default_dump_target_install_conf kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" From bdd57a58645c8b828bb5f8ab322cb83d67f4e9b9 Mon Sep 17 00:00:00 2001 From: "onitsuka.shinic@fujitsu.com" Date: Fri, 5 Jun 2020 02:24:07 +0000 Subject: [PATCH 239/806] kdumpctl: Check the update of the binary and script files in /etc/kdump/{pre.d,post.d} This patch adds the binary and script files in /etc/kdump/{pre.d,post.d} to modified checklist in order to update kdump initramfs when one adds new scripts or binaries or removes the existing ones under /etc/kdump/{pre.d, post.d}. Signed-off-by: Shinichi Onitsuka Acked-by: Pingfan Liu --- kdumpctl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 4a674f2..408b88a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -339,9 +339,23 @@ check_files_modified() EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` + if [ -d /etc/kdump/post.d ]; then + for file in /etc/kdump/post.d/*; do + if [ -x "$file" ]; then + POST_FILES="$POST_FILES $file" + fi + done + fi + if [ -d /etc/kdump/pre.d ]; then + for file in /etc/kdump/pre.d/*; do + if [ -x "$file" ]; then + PRE_FILES="$PRE_FILES $file" + fi + done + fi CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` CORE_COLLECTOR=`type -P $CORE_COLLECTOR` - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" + EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" From 45e02e73fa265452d90c552f82b95f1bde3ea45b Mon Sep 17 00:00:00 2001 From: "onitsuka.shinic@fujitsu.com" Date: Fri, 5 Jun 2020 02:25:12 +0000 Subject: [PATCH 240/806] dracut-kdump.sh: Execute the binary and script filesin /etc/kdump/{pre.d,post.d} This patch executes the binary and script files in /etc/kdump/{pre.d,post.d} just like kdump_pre or kdump_post directive written in /etc/kdump.conf. Signed-off-by: Shinichi Onitsuka Acked-by: Pingfan Liu --- dracut-kdump.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 8752178..9c8f3a9 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -30,15 +30,49 @@ do_dump() do_kdump_pre() { + local _ret + if [ -n "$KDUMP_PRE" ]; then "$KDUMP_PRE" + _ret=$? + if [ $_ret -ne 0 ]; then + echo "kdump: $KDUMP_PRE exited with $_ret status" + return $_ret + fi fi + + if [ -d /etc/kdump/pre.d ]; then + for file in /etc/kdump/pre.d/*; do + "$file" + _ret=$? + if [ $_ret -ne 0 ]; then + echo "kdump: $file exited with $_ret status" + fi + done + fi + return 0 } do_kdump_post() { + local _ret + + if [ -d /etc/kdump/post.d ]; then + for file in /etc/kdump/post.d/*; do + "$file" "$1" + _ret=$? + if [ $_ret -ne 0 ]; then + echo "kdump: $file exited with $_ret status" + fi + done + fi + if [ -n "$KDUMP_POST" ]; then "$KDUMP_POST" "$1" + _ret=$? + if [ $_ret -ne 0 ]; then + echo "kdump: $KDUMP_POST exited with $_ret status" + fi fi } From 077a7f19bb486fb695ee0a4f9ad4e59d1e582c1d Mon Sep 17 00:00:00 2001 From: "onitsuka.shinic@fujitsu.com" Date: Fri, 5 Jun 2020 02:28:45 +0000 Subject: [PATCH 241/806] kdump.conf: Specify /etc/kdump/{pre.d,post.d}interface This patch discribe /etc/kdump/{pre.d,post.d} interface. Signed-off-by: Shinichi Onitsuka Acked-by: Pingfan Liu --- kdump.conf | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kdump.conf b/kdump.conf index 1f0fc2d..4586ccd 100644 --- a/kdump.conf +++ b/kdump.conf @@ -79,13 +79,23 @@ # or script after the vmcore dump process terminates. # The exit status of the current dump process is fed to # the executable binary or script as its first argument. +# If /etc/kdump/post.d directory is exist, All files in +# the directory are collectively sorted and executed in +# lexical order, before binary or script specified +# kdump_post parameter is executed. # # kdump_pre # - Works like the "kdump_post" directive, but instead of running # after the dump process, runs immediately before it. # Exit status of this binary is interpreted as follows: -# 0 - continue with dump process as usual -# non 0 - reboot the system +# 0 - continue with dump process as usual +# non 0 - reboot the system +# If /etc/kdump/pre.d directory exists, all files in +# the directory are collectively sorted and executed in +# lexical order, after binary or script specified +# kdump_pre parameter is executed. +# Even if the binary or script in /etc/kdump/pre.d directory +# returns non 0 exit status, the processing is continued. # # extra_bins # - This directive allows you to specify additional binaries or From 1a5d44d7f45edd511fcb852901782bc497721281 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 11 Jun 2020 13:59:14 +0800 Subject: [PATCH 242/806] Fix kdump failure when mount target specified by dracut_args commit 61e0169 changed definition of dump_fs function, so need to do a mount target conversion before calling it. Signed-off-by: Kairui Song --- dracut-kdump.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 9c8f3a9..b71278d 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -208,7 +208,10 @@ read_kdump_conf() case "$config_opt" in dracut_args) config_val=$(get_dracut_args_target "$config_val") - [ -n "$config_val" ] && add_dump_code "dump_fs $config_val" + if [ -n "$config_val" ]; then + config_val=$(get_mntpoint_from_target "$config_val") + add_dump_code "dump_fs $config_val" + fi ;; ext[234]|xfs|btrfs|minix|nfs) config_val=$(get_mntpoint_from_target "$config_val") From 5d4a5896c94ec3c9af4c4e8a6bd099d8cb5ea2b8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 15 Jun 2020 16:34:51 +0800 Subject: [PATCH 243/806] mkdumprd: Fix dracut error on multiple extra_modules Dracut expects --add-drivers with a single parameter, so mkdumprd should quota the module list. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 1bee98c..7bc1bd1 100644 --- a/mkdumprd +++ b/mkdumprd @@ -471,7 +471,7 @@ handle_default_dump_target if [ -n "$extra_modules" ] then - add_dracut_arg "--add-drivers" "$extra_modules" + add_dracut_arg "--add-drivers" \"$extra_modules\" fi if ! is_fadump_capable; then From 66ff48ed6837961c2ebdd017195e6837136fdc4a Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 9 Apr 2020 16:25:03 +0800 Subject: [PATCH 244/806] s390x: add kdump sysconfig option to use the kexec_file_load() syscall Currently, kernel has supported the kexec_file_load() syscall on s390x, so I follow this commit: 6a20bd54473e ("kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default") And also enable the kexec_file_load() syscall for kdump on s390x by default. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump.sysconfig.s390x | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 2a24688..a0e5244 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -41,3 +41,9 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" + +# Using kexec file based syscall by default +# +# Here, the "on" is the only valid value to enable the kexec file load and +# anything else is equal to the "off"(disable). +KDUMP_FILE_LOAD="on" From a29de38da554ff4e67af6ba52e4739222146ddb8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 16 Jun 2020 11:25:26 +0800 Subject: [PATCH 245/806] Always wrap up call to dracut get_persistent_dev function Dracut get_persistent_dev function don't recognize UUID= or LABEL= format, so caller should conver it to the path to the block device before calling it. There is already such a helper "kdump_get_persistent_dev", just move it to kdump-lib.sh and rename it to reuse it, Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 14 -------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..2454463 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -48,20 +48,6 @@ depends() { return 0 } -kdump_get_persistent_dev() { - local dev="${1//\"/}" - - case "$dev" in - UUID=*) - dev=`blkid -U "${dev#UUID=}"` - ;; - LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` - ;; - esac - echo $(get_persistent_dev "$dev") -} - kdump_is_bridge() { [ -d /sys/class/net/"$1"/bridge ] } diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..6f250d4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,6 +307,20 @@ get_option_value() { strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` } +kdump_get_persistent_dev() { + local dev="${1//\"/}" + + case "$dev" in + UUID=*) + dev=`blkid -U "${dev#UUID=}"` + ;; + LABEL=*) + dev=`blkid -L "${dev#LABEL=}"` + ;; + esac + echo $(get_persistent_dev "$dev") +} + is_atomic() { grep -q "ostree" /proc/cmdline diff --git a/kdumpctl b/kdumpctl index 408b88a..70fb551 100755 --- a/kdumpctl +++ b/kdumpctl @@ -482,7 +482,7 @@ check_dump_fs_modified() if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then _new_dev=$_target else - _new_dev=$(get_persistent_dev $_target) + _new_dev=$(kdump_get_persistent_dev $_target) if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2 diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..4b1e11c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -93,7 +93,7 @@ to_mount() { _mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name if [ -b "$_target" ]; then - _pdev="$(get_persistent_dev $_target)" + _pdev="$(kdump_get_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1 fi @@ -438,7 +438,7 @@ do dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } - _praw=$(persistent_policy="by-id" get_persistent_dev $config_val) + _praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi From 807f0b5e48aa01bee07020e715b57be3577cc339 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 16 Jun 2020 11:33:39 +0800 Subject: [PATCH 246/806] mkdumprd: Fix nfs detection in to_mount If target is in format of UUID= or LABEL=, current code will fail as it expects target to be the absoluta path to the block device. Check for the fstype instead. Also simplify the code logic. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/mkdumprd b/mkdumprd index 4b1e11c..bf816fc 100644 --- a/mkdumprd +++ b/mkdumprd @@ -65,7 +65,7 @@ add_dracut_sshkey() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _mntopts _pdev + local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" @@ -73,9 +73,16 @@ to_mount() { _options="${_options:-defaults}" if [[ "$_fstype" == "nfs"* ]]; then + _pdev=$_target _options=$(echo $_options | sed 's/,addr=[^,]*//') _options=$(echo $_options | sed 's/,proto=[^,]*//') _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') + else + # for non-nfs _target converting to use udev persistent name + _pdev="$(kdump_get_persistent_dev $_target)" + if [ -z "$_pdev" ]; then + return 1 + fi fi # mount fs target as rw in 2nd kernel @@ -90,18 +97,7 @@ to_mount() { # mount it before kdump starts, this is an attempt to improve robustness _options="$_options,nofail,x-systemd.before=initrd-fs.target" - _mntopts="$_new_mntpoint $_fstype $_options" - # for non-nfs _target converting to use udev persistent name - if [ -b "$_target" ]; then - _pdev="$(kdump_get_persistent_dev $_target)" - if [ -z "$_pdev" ]; then - return 1 - fi - else - _pdev=$_target - fi - - echo "$_pdev $_mntopts" + echo "$_pdev $_new_mntpoint $_fstype $_options" } #Function: get_ssh_size From 61d4fa72b57433f3fc2509c9e1a25e4ac7a2c6f7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 24 Jun 2020 12:11:47 +0800 Subject: [PATCH 247/806] mkdumprd: Improve the error message for umounted dump target Since commit ca01cbd, mkdumprd can generate the initramfs even if dump target is not mounted. But it will refuse to work if the dump target is not marked as noauto, and not mounted. If a target is not marked as noauto in fstab, it should be mounted automatically on boot. If it's not mounted, most likely something is wrong and user should fix that. So mkdumprd will just show an error message and quit to avoid further failure. This commit make the error message more clear and less confusing. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index bf816fc..91ce3d5 100644 --- a/mkdumprd +++ b/mkdumprd @@ -222,7 +222,7 @@ check_user_configured_target() [ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check." _mounted=$_mnt else - perror_exit "$_target is configured in fstab but not mounted, please check its usability." + perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" fi fi else From 6dd2b9fb419966cfe23f3821993bd909b85d45a2 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 19 Jun 2020 11:37:02 +0800 Subject: [PATCH 248/806] man: improve description about /etc/kdump/{pre.d,post.d}interface The description is identical to the notes in kdump.conf Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump.conf.5 | 12 ++++++++++++ kexec-kdump-howto.txt | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/kdump.conf.5 b/kdump.conf.5 index 5a0952b..9f2b2b6 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -109,6 +109,11 @@ status of the current dump process is fed to the kdump_post executable as its first argument($1). Executable can modify it to indicate the new exit status of succeeding dump process, .PP +If /etc/kdump/post.d directory exists, All files in +the directory are collectively sorted and executed in +lexical order, before binary or script specified +kdump_post parameter is executed. +.PP Note that scripts written for use with this directive must use the /bin/bash interpreter. .RE @@ -124,6 +129,13 @@ as follows: .PP non 0 - reboot the system .PP +If /etc/kdump/pre.d directory exists, all files in +the directory are collectively sorted and executed in +lexical order, after binary or script specified +kdump_pre parameter is executed. +Even if the binary or script in /etc/kdump/pre.d directory +returns non 0 exit status, the processing is continued. +.PP Note that scripts written for this directive must use the /bin/bash interpreter. .RE diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 78ebf69..9b0fee2 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -543,6 +543,9 @@ It is possible to specify a custom script or binary you wish to run following an attempt to capture a vmcore. The executable is passed an exit code from the capture process, which can be used to trigger different actions from within your post-capture executable. +If /etc/kdump/post.d directory exist, All files in the directory are +collectively sorted and executed in lexical order, before binary or script +specified kdump_post parameter is executed. Kdump Pre-Capture Executable ---------------------------- @@ -551,6 +554,11 @@ It is possible to specify a custom script or binary you wish to run before capturing a vmcore. Exit status of this binary is interpreted: 0 - continue with dump process as usual non 0 - reboot the system +If /etc/kdump/pre.d directory exists, all files in the directory are collectively +sorted and executed in lexical order, after binary or script specified +kdump_pre parameter is executed. +Even if the binary or script in /etc/kdump/pre.d directory returns non 0 +exit status, the processing is continued. Extra Binaries -------------- From f2824e7b74a28ed6d78cb36156f4c7c6450f01d6 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 30 Jun 2020 11:05:51 +0800 Subject: [PATCH 249/806] kdump.conf: fix a grammar issue Signed-off-by: Pingfan Liu Acked-by: Dave Young --- kdump.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.conf b/kdump.conf index 4586ccd..ed78507 100644 --- a/kdump.conf +++ b/kdump.conf @@ -79,7 +79,7 @@ # or script after the vmcore dump process terminates. # The exit status of the current dump process is fed to # the executable binary or script as its first argument. -# If /etc/kdump/post.d directory is exist, All files in +# If /etc/kdump/post.d directory exists, all files in # the directory are collectively sorted and executed in # lexical order, before binary or script specified # kdump_post parameter is executed. From 073646998f5c7854bdacc8456a11d72314c7b4b1 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 29 Jun 2020 21:13:54 +0800 Subject: [PATCH 250/806] Revert "kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default" This reverts commit 6a20bd54473e11011bf2b47efb52d0759d412854. Let's restore the logic of secureboot status check, and remove the option 'KDUMP_FILE_LOAD=on|off'. We will use the option KEXEC_ARGS="-s" to enable the kexec file load later, which can avoid failures when the secureboot is enabled. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- dracut-early-kdump.sh | 5 ++--- kdump-lib.sh | 29 +++++++++++++++++++++++++++++ kdump.sysconfig.x86_64 | 6 ------ kdumpctl | 13 ++++++------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 6788a6b..69a34eb 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -2,7 +2,6 @@ KEXEC=/sbin/kexec standard_kexec_args="-p" -KDUMP_FILE_LOAD="" EARLY_KDUMP_INITRD="" EARLY_KDUMP_KERNEL="" @@ -44,8 +43,8 @@ early_kdump_load() EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") - if [ "$KDUMP_FILE_LOAD" == "on" ]; then - echo "Using kexec file based syscall." + if is_secure_boot_enforced; then + echo "Secure Boot is enabled. Using kexec file based syscall." EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" fi diff --git a/kdump-lib.sh b/kdump-lib.sh index 6f250d4..f78e064 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -597,6 +597,35 @@ need_64bit_headers() print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` } +# Check if secure boot is being enforced. +# +# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and +# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four +# bytes are the attributes associated with the variable and can safely be +# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot +# is 1 and SetupMode is 0, then secure boot is being enforced. +# +# Assume efivars is mounted at /sys/firmware/efi/efivars. +is_secure_boot_enforced() +{ + local secure_boot_file setup_mode_file + local secure_boot_byte setup_mode_byte + + secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) + setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) + + if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then + secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) + setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) + + if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then + return 0 + fi + fi + + return 1 +} + # # prepare_kexec_args # This function prepares kexec argument. diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index e47e195..f67d999 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -38,9 +38,3 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" - -# Using kexec file based syscall by default -# -# Here, the "on" is the only valid value to enable the kexec file load and -# anything else is equal to the "off"(disable). -KDUMP_FILE_LOAD="on" diff --git a/kdumpctl b/kdumpctl index 70fb551..d3ec4d7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -4,7 +4,6 @@ KEXEC=/sbin/kexec KDUMP_KERNELVER="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" -KDUMP_FILE_LOAD="" KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" @@ -686,8 +685,11 @@ load_kdump() KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - if [ "$KDUMP_FILE_LOAD" == "on" ]; then - echo "Using kexec file based syscall." + # For secureboot enabled machines, use new kexec file based syscall. + # Old syscall will always fail as it does not have capability to + # to kernel signature verification. + if is_secure_boot_enforced; then + echo "Secure Boot is enabled. Using kexec file based syscall." KEXEC_ARGS="$KEXEC_ARGS -s" fi @@ -699,9 +701,6 @@ load_kdump() return 0 else echo "kexec: failed to load kdump kernel" >&2 - if [ "$KDUMP_FILE_LOAD" == "on" ]; then - echo "kexec_file_load() failed, please try kexec_load()" >&2 - fi return 1 fi } @@ -1162,7 +1161,7 @@ stop_fadump() stop_kdump() { - if [ "$KDUMP_FILE_LOAD" == "on" ]; then + if is_secure_boot_enforced; then $KEXEC -s -p -u else $KEXEC -p -u From bf20a948efb97b0a16de6406c960ed541e9e410a Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 29 Jun 2020 21:13:55 +0800 Subject: [PATCH 251/806] Revert "s390x: add kdump sysconfig option to use the kexec_file_load() syscall" This reverts commit 66ff48ed6837961c2ebdd017195e6837136fdc4a. Since the code logic is changed(which related to the option 'KDUMP_FILE_LOAD=on|off'), accordingly, need to remove the option from the sysconfig file. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- kdump.sysconfig.s390x | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index a0e5244..2a24688 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -41,9 +41,3 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" - -# Using kexec file based syscall by default -# -# Here, the "on" is the only valid value to enable the kexec file load and -# anything else is equal to the "off"(disable). -KDUMP_FILE_LOAD="on" From e5cbf4d1ad5baa8797e2d5d012d59017bdfacb71 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 29 Jun 2020 21:13:56 +0800 Subject: [PATCH 252/806] x86_64: enable the kexec file load by default Let's use the option KEXEC_ARGS="-s" to enable the kexec file load by default. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- kdump.sysconfig.x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index f67d999..55f8b9b 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="-s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 8884af04b69d5dacee9416bbf9ae26845c4757dc Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 29 Jun 2020 21:13:57 +0800 Subject: [PATCH 253/806] s390x: enable the kexec file load by default Let's use the option KEXEC_ARGS="-s" to enable the kexec file load by default. Signed-off-by: Lianbo Jiang Acked-by: Dave Young --- kdump.sysconfig.s390x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 2a24688..25f7be5 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -31,7 +31,7 @@ MKDUMPRD_ARGS="" # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="-s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 070d362846acfdca5f7a8fd2573cc87cf8db7372 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 1 Jul 2020 17:15:17 +0800 Subject: [PATCH 254/806] Release 2.0.20-14 Also fix a timestamp issue. Signed-off-by: Kairui Song --- kexec-tools.spec | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c4b7c8d..4cd64c8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 13%{?dist} +Release: 14%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -351,6 +351,31 @@ done %endif %changelog +* Wed Jul 1 2020 Kairui Song - 2.0.20-14 +- s390x: enable the kexec file load by default +- x86_64: enable the kexec file load by default +- Revert "s390x: add kdump sysconfig option to use the kexec_file_load() syscall" +- Revert "kdump-lib: switch to the kexec_file_load() syscall on x86_64 by default" +- kdump.conf: fix a grammar issue +- man: improve description about /etc/kdump/{pre.d,post.d}interface +- mkdumprd: Improve the error message for umounted dump target +- mkdumprd: Fix nfs detection in to_mount +- Always wrap up call to dracut get_persistent_dev function +- s390x: add kdump sysconfig option to use the kexec_file_load() syscall +- mkdumprd: Fix dracut error on multiple extra_modules +- Fix kdump failure when mount target specified by dracut_args +- kdump.conf: Specify /etc/kdump/{pre.d,post.d}interface +- dracut-kdump.sh: Execute the binary and script filesin /etc/kdump/{pre.d,post.d} +- kdumpctl: Check the update of the binary and script files in /etc/kdump/{pre.d,post.d} +- dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d} into kdump initramfs +- Drop switch root capability for non fadump initramfs +- fadump: update fadump-howto.txt with some more troubleshooting help +- fadump-howto.txt: source it in spec file +- Don't inherit swiotlb parameter form 1st kernel by default +- module-setup.sh: Add "rd.neednet" parameter if network is needed +- Revert "Add a hook to wait for kdump target in initqueue" +- kdump.sysconfig: Remove the option 'log_buf_len' from kdump command line + * Fri May 22 2020 Kairui Song - 2.0.20-13 - Update docs for the new noauto dump target support - kexec-kdump-howto.txt: Add some format to the document @@ -377,7 +402,7 @@ done - Remove is_dump_target_configured - dracut-module-setup.sh: improve get_alias() -* Thu Mar 24 2020 Kairui Song - 2.0.20-11 +* Tue Mar 24 2020 Kairui Song - 2.0.20-11 - Fix a potential syntax error - Use read_strip_comments to filter the installed kdump.conf - kdumpctl: fix driver change detection on latest Fedora From 5521a70cc796f9006ad1c8a09fa31ee5c970a5b0 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 9 Jul 2020 20:46:55 +0530 Subject: [PATCH 255/806] ppc64/kdump: use kexec_file_load when secureboot is enabled In secure boot mode, kexec_load syscall is disabled. So, if in secure boot mode, load kdump kernel with kexec_file_load syscall instead. Signed-off-by: Hari Bathini Acked-by: Pingfan Liu --- kdump-lib.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index f78e064..f632f65 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -611,6 +611,12 @@ is_secure_boot_enforced() local secure_boot_file setup_mode_file local secure_boot_byte setup_mode_byte + # On powerpc, os-secureboot-enforcing DT property indicates whether secureboot + # is enforced. Return success, if it is found. + if [ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]; then + return 0 + fi + secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) From 8bef2d943b18768ab02c2b97b4399f7588f482a5 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 16 Jul 2020 16:50:13 +0800 Subject: [PATCH 256/806] kexec-tools.spec: make the existence of pre.d and post.d mandatory If the directory /etc/kdump/pre.d is optional, then it is hard to tell between the following cases: -1. no directory "/etc/kdump/pre.d" -2. "rm -rf /etc/kdump/pre.d", which removes all scripts under pre.d For the second case, kdump.img should be rebuilt. To bail out from this corner case, always creating pre.d and post.d during rpm installation. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kexec-tools.spec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 4cd64c8..0fd4853 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -157,6 +157,9 @@ make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libep %install mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/pre.d +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/post.d mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ @@ -327,6 +330,9 @@ done %endif %{dracutlibdir}/modules.d/* %dir %{_localstatedir}/crash +%dir %{_sysconfdir}/kdump +%dir %{_sysconfdir}/kdump/pre.d +%dir %{_sysconfdir}/kdump/post.d %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 From bdbddbff736e23a187098d4abde770bb617b270e Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 16 Jul 2020 16:50:14 +0800 Subject: [PATCH 257/806] module-setup.sh: suppress false alarm Even if the directory "/etc/kdump/pre.d/" is empty, the following false alarm can be observed during building kdump.initrd: "/etc/kdump/pre.d/* is not executable" Suppress it. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2454463..fbbd21a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -419,7 +419,7 @@ kdump_install_pre_post_conf() { for file in /etc/kdump/pre.d/*; do if [ -x "$file" ]; then dracut_install $file - else + elif [ $file != "/etc/kdump/pre.d/*" ]; then echo "$file is not executable" fi done @@ -429,7 +429,7 @@ kdump_install_pre_post_conf() { for file in /etc/kdump/post.d/*; do if [ -x "$file" ]; then dracut_install $file - else + elif [ $file != "/etc/kdump/post.d/*" ]; then echo "$file is not executable" fi done From 25824d64cdbe726286c2f1cc8c1255436cd5c973 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 16 Jul 2020 16:50:15 +0800 Subject: [PATCH 258/806] kdumpctl: detect modification of scripts by its directory's timestamp Checking modification against a file can not detect a removing file in "/etc/kdump/post.d/ /etc/kdump/pre.d/". Hence it also needs the modified time of directory to detect such changes. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index d3ec4d7..42c11d3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -338,6 +338,7 @@ check_files_modified() EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` + HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" if [ -d /etc/kdump/post.d ]; then for file in /etc/kdump/post.d/*; do if [ -x "$file" ]; then @@ -352,9 +353,11 @@ check_files_modified() fi done fi + HOOKS="$HOOKS $POST_FILES $PRE_FILES" CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` CORE_COLLECTOR=`type -P $CORE_COLLECTOR` - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES $POST_FILES $PRE_FILES" + # POST_FILES and PRE_FILES are already checked against executable, need not to check again. + EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" @@ -385,6 +388,8 @@ check_files_modified() check_exist "$files" && check_executable "$EXTRA_BINS" [ $? -ne 0 ] && return 2 + # HOOKS only need to check the modification here + files="$files $HOOKS" for file in $files; do if [ -e "$file" ]; then time_stamp=`stat -c "%Y" $file` From bda677c3d185ba6d0ce4f4c5019f0fac8e2dfbba Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 8 Jul 2020 10:05:25 +0800 Subject: [PATCH 259/806] dracut-kdump.sh: exit shell when machine reboot The following scenario is observed: kdump: kdump_pre script exited with non-zero status! [ 5.104841] systemd[1]: Shutting down. [ 5.122162] printk: systemd-shutdow: 27 output lines suppressed due to ratelimiting kdump: dump target is /dev/mapper/rhel_hpe--dl380pgen8--02--vm--12-root kdump: saving to /sysroot//var/crash/127.0.0.1-2020-06-27-03:55:01/ kdump: saving vmcore-dmesg.txt kdump: saving vmcore-dmesg.txt complete kdump: saving vmcore Checking for memory holes : [ 0.0 %] / Checking for memory holes : [100.0 %] | [ 5.516573] systemd-shutdown[1]: Syncing filesystems and block devices. [ 5.519515] systemd-shutdown[1]: Sending SIGTERM to remaining processes... It is caused by the following script if [ $? -ne 0 ]; then echo "kdump: kdump_pre script exited with non-zero status!" do_final_action fi When do_final_action runs, a systemd service is forked for reboot, then the subshell returns, and parent continues to execute. Place "exit 1" to stop executing and make kdump service failure. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-kdump.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b71278d..c74c4b7 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -251,6 +251,8 @@ do_kdump_pre if [ $? -ne 0 ]; then echo "kdump: kdump_pre script exited with non-zero status!" do_final_action + # During systemd service to reboot the machine, stop this shell script running + exit 1 fi make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' do_dump From bc67c13651de5e835666329604db26dd77f64850 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 15 Jul 2020 17:28:04 +0800 Subject: [PATCH 260/806] kdump_pre: make notes more precise Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-kdump.sh | 1 + kdump.conf | 2 +- kdump.conf.5 | 2 +- kexec-kdump-howto.txt | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index c74c4b7..6f948fc 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -41,6 +41,7 @@ do_kdump_pre() fi fi + # if any script fails, it just raises warning and continues if [ -d /etc/kdump/pre.d ]; then for file in /etc/kdump/pre.d/*; do "$file" diff --git a/kdump.conf b/kdump.conf index ed78507..9f35e31 100644 --- a/kdump.conf +++ b/kdump.conf @@ -89,7 +89,7 @@ # after the dump process, runs immediately before it. # Exit status of this binary is interpreted as follows: # 0 - continue with dump process as usual -# non 0 - reboot the system +# non 0 - run the final action (reboot/poweroff/halt) # If /etc/kdump/pre.d directory exists, all files in # the directory are collectively sorted and executed in # lexical order, after binary or script specified diff --git a/kdump.conf.5 b/kdump.conf.5 index 9f2b2b6..c362963 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -127,7 +127,7 @@ as follows: .PP 0 - continue with dump process as usual .PP -non 0 - reboot the system +non 0 - run the final action (reboot/poweroff/halt) .PP If /etc/kdump/pre.d directory exists, all files in the directory are collectively sorted and executed in diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 9b0fee2..2209e5a 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -553,7 +553,7 @@ Kdump Pre-Capture Executable It is possible to specify a custom script or binary you wish to run before capturing a vmcore. Exit status of this binary is interpreted: 0 - continue with dump process as usual -non 0 - reboot the system +non 0 - run the final action (reboot/poweroff/halt) If /etc/kdump/pre.d directory exists, all files in the directory are collectively sorted and executed in lexical order, after binary or script specified kdump_pre parameter is executed. From 1844d088f7371f482e3d9c0a3872ab2f81102a8c Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 28 Jul 2020 03:00:49 +0000 Subject: [PATCH 261/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 0fd4853..59b213b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 14%{?dist} +Release: 15%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -357,6 +357,9 @@ done %endif %changelog +* Tue Jul 28 2020 Fedora Release Engineering - 2.0.20-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Wed Jul 1 2020 Kairui Song - 2.0.20-14 - s390x: enable the kexec file load by default - x86_64: enable the kexec file load by default From f96172d3533c59571b04805c89f8fb1fa944adf1 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 29 Jul 2020 15:52:21 +0800 Subject: [PATCH 262/806] kdumpctl: exit if either pre.d or post.d is missing It is hard to detect the time that /etc/kdump is removed. And this failure may cause out-of-date kdump.initrd. To keep things simple, just exit if /etc/kdump/pre.d and post.d does not exist. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump.conf | 12 +++++------- kdump.conf.5 | 12 +++++------- kdumpctl | 6 +++--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/kdump.conf b/kdump.conf index 9f35e31..9fc0a4f 100644 --- a/kdump.conf +++ b/kdump.conf @@ -79,10 +79,9 @@ # or script after the vmcore dump process terminates. # The exit status of the current dump process is fed to # the executable binary or script as its first argument. -# If /etc/kdump/post.d directory exists, all files in -# the directory are collectively sorted and executed in -# lexical order, before binary or script specified -# kdump_post parameter is executed. +# All files under /etc/kdump/post.d are collectively sorted +# and executed in lexical order, before binary or script +# specified kdump_post parameter is executed. # # kdump_pre # - Works like the "kdump_post" directive, but instead of running @@ -90,9 +89,8 @@ # Exit status of this binary is interpreted as follows: # 0 - continue with dump process as usual # non 0 - run the final action (reboot/poweroff/halt) -# If /etc/kdump/pre.d directory exists, all files in -# the directory are collectively sorted and executed in -# lexical order, after binary or script specified +# All files under /etc/kdump/pre.d are collectively sorted and +# executed in lexical order, after binary or script specified # kdump_pre parameter is executed. # Even if the binary or script in /etc/kdump/pre.d directory # returns non 0 exit status, the processing is continued. diff --git a/kdump.conf.5 b/kdump.conf.5 index c362963..34c996c 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -109,10 +109,9 @@ status of the current dump process is fed to the kdump_post executable as its first argument($1). Executable can modify it to indicate the new exit status of succeeding dump process, .PP -If /etc/kdump/post.d directory exists, All files in -the directory are collectively sorted and executed in -lexical order, before binary or script specified -kdump_post parameter is executed. +All files under /etc/kdump/post.d are collectively sorted +and executed in lexical order, before binary or script +specified kdump_post parameter is executed. .PP Note that scripts written for use with this directive must use the /bin/bash interpreter. @@ -129,9 +128,8 @@ as follows: .PP non 0 - run the final action (reboot/poweroff/halt) .PP -If /etc/kdump/pre.d directory exists, all files in -the directory are collectively sorted and executed in -lexical order, after binary or script specified +All files under /etc/kdump/pre.d are collectively sorted and +executed in lexical order, after binary or script specified kdump_pre parameter is executed. Even if the binary or script in /etc/kdump/pre.d directory returns non 0 exit status, the processing is continued. diff --git a/kdumpctl b/kdumpctl index 42c11d3..122e065 100755 --- a/kdumpctl +++ b/kdumpctl @@ -151,7 +151,7 @@ rebuild_initrd() check_exist() { for file in $1; do - if [ ! -f "$file" ]; then + if [ ! -e "$file" ]; then echo -n "Error: $file not found."; echo return 1 fi @@ -385,11 +385,11 @@ check_files_modified() done fi + # HOOKS is mandatory and need to check the modification time + files="$files $HOOKS" check_exist "$files" && check_executable "$EXTRA_BINS" [ $? -ne 0 ] && return 2 - # HOOKS only need to check the modification here - files="$files $HOOKS" for file in $files; do if [ -e "$file" ]; then time_stamp=`stat -c "%Y" $file` From 21b4996e3a1117f7682d2b338d777c9eff54be88 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 1 Aug 2020 03:43:49 +0000 Subject: [PATCH 263/806] - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 59b213b..1da5844 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 15%{?dist} +Release: 16%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -357,6 +357,10 @@ done %endif %changelog +* Sat Aug 01 2020 Fedora Release Engineering - 2.0.20-16 +- Second attempt - Rebuilt for + https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Tue Jul 28 2020 Fedora Release Engineering - 2.0.20-15 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From fa8aa52d947edf86332c1194f86d70b6e0677a5c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 4 Aug 2020 10:14:52 +0800 Subject: [PATCH 264/806] Revert "s390x: enable the kexec file load by default" This reverts commit 8884af04b69d5dacee9416bbf9ae26845c4757dc. Currently the kernel image is being dual signed, but kexec_file_load can't handle multiple signature right, so it will always fail. Let's temporaryly revert "using '-s' by default", until upstream have fixed the real issue. Signed-off-by: Kairui Song --- kdump.sysconfig.s390x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 25f7be5..2a24688 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -31,7 +31,7 @@ MKDUMPRD_ARGS="" # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="-s" +KEXEC_ARGS="" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 073c30973cf45ce0cea7bfd2bb30c5449a041a54 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 4 Aug 2020 10:15:07 +0800 Subject: [PATCH 265/806] Revert "x86_64: enable the kexec file load by default" This reverts commit e5cbf4d1ad5baa8797e2d5d012d59017bdfacb71. Currently the kernel image is being dual signed, but kexec_file_load can't handle multiple signature right, so it will always fail. Let's temporaryly revert "using '-s' by default", until upstream have fixed the real issue. Signed-off-by: Kairui Song --- kdump.sysconfig.x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 55f8b9b..f67d999 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="-s" +KEXEC_ARGS="" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From d0d9ff1eb2ba9d4725d3459764a18a03ea220bb2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 22 Jul 2020 15:12:43 +0800 Subject: [PATCH 266/806] Drop static lib dependencies Signed-off-by: Kairui Song --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1da5844..37817ba 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -60,7 +60,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool -BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel +BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units BuildRequires: automake autoconf libtool From f8f8d79d7f67235d4237c90b9c5c092bfe6dc5b0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 4 Aug 2020 10:50:43 +0800 Subject: [PATCH 267/806] Release 2.0.20-17 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 37817ba..8505c78 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 16%{?dist} +Release: 17%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -357,6 +357,18 @@ done %endif %changelog +* Tue Aug 04 2020 Kairui Song - 2.0.20-16 +- Drop static lib dependencies +- Revert "x86_64: enable the kexec file load by default" +- Revert "s390x: enable the kexec file load by default" +- kdumpctl: exit if either pre.d or post.d is missing +- kdump_pre: make notes more precise +- dracut-kdump.sh: exit shell when machine reboot +- kdumpctl: detect modification of scripts by its directory's timestamp +- module-setup.sh: suppress false alarm +- kexec-tools.spec: make the existence of pre.d and post.d mandatory +- ppc64/kdump: use kexec_file_load when secureboot is enabled + * Sat Aug 01 2020 Fedora Release Engineering - 2.0.20-16 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From a7199c141cd75ffe2d25ea4ca2dfe7935d7f5f83 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 31 Jul 2020 16:47:11 +0800 Subject: [PATCH 268/806] Add a kernel install hook to clean up kdump initramfs Kdump service will create kdump initramfs when needed, but it won't clean up the kdump initramfs on kernel uninstall. So create a kernel install hook to do the clean up job. Signed-off-by: Kairui Song Acked-by: Dave Young --- 60-kdump.install | 30 ++++++++++++++++++++++++++++++ kexec-tools.spec | 3 +++ 2 files changed, 33 insertions(+) create mode 100755 60-kdump.install diff --git a/60-kdump.install b/60-kdump.install new file mode 100755 index 0000000..0a3b40e --- /dev/null +++ b/60-kdump.install @@ -0,0 +1,30 @@ +#!/usr/bin/bash + +COMMAND="$1" +KERNEL_VERSION="$2" +BOOT_DIR_ABS="$3" +KERNEL_IMAGE="$4" + +if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then + exit 0 +fi + +if [[ -d "$BOOT_DIR_ABS" ]]; then + KDUMP_INITRD="initrdkdump" +else + BOOT_DIR_ABS="/boot" + KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img" +fi + +ret=0 +case "$COMMAND" in + add) + # Do nothing, kdump initramfs is strictly host only + # and managed by kdump service + ;; + remove) + rm -f -- "$BOOT_DIR_ABS/$KDUMP_INITRD" + ret=$? + ;; +esac +exit $ret diff --git a/kexec-tools.spec b/kexec-tools.spec index 8505c78..5a14d48 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -36,6 +36,7 @@ Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler Source29: kdump.sysconfig.aarch64 +Source30: 60-kdump.install ####################################### # These are sources for mkdumpramfs @@ -203,6 +204,7 @@ install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh +install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile @@ -343,6 +345,7 @@ done %{_mandir}/man5/* %{_unitdir}/kdump.service %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh +%{_prefix}/lib/kernel/install.d/60-kdump.install %doc News %license COPYING %doc TODO From c76820bdddf965284344cf24ea60c0c69d4a9f8a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 27 Jul 2020 01:37:19 +0800 Subject: [PATCH 269/806] early-kdump: Use consistent symbol link for kernel and initramfs There is no need to follow user's configuration when installtion the kernel and initramfs for early kdump, just use a fixed a symbol link is enough, this help avoid a check_boot_dir call. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 4 ++-- dracut-early-kdump.sh | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index e069867..626ca0e 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -58,8 +58,8 @@ install() { inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" - ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" - ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img" + ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump" + ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump" chmod -x "${initdir}/$KDUMP_KERNEL" } diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 69a34eb..92913fb 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -16,10 +16,8 @@ EARLY_KEXEC_ARGS="" prepare_parameters() { EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") - - EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" - EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-earlykdump.img" + EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump" + EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump" } early_kdump_load() From a37f36ad4d6704b3a05723c3544cad4930f93bcd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 28 Jul 2020 02:40:20 +0800 Subject: [PATCH 270/806] Refactor kernel image and initrd detection code kernel installation is not always in a fixed location /boot, there are multiple different style of kernel installation, and initramfs location changes with kernel. The two files should be detected together and adapt to different style. To do so we use a list of known installation destinations, and a list of possible kernel image and initrd names. Iterate the two list to detect the installation location of the two files. If GRUB is in use, the BOOT_IMAGE= cmdline from GRUB will also be considered. And also prefers user specified config if given. Previous atomic workaround is no longer needed as the new detection method can cover that case. Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-early-kdump-module-setup.sh | 17 +++---- kdump-lib.sh | 72 ++++++++++++++++++++++++------ kdumpctl | 48 ++++++++++---------- 3 files changed, 88 insertions(+), 49 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 626ca0e..f30bd67 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -21,18 +21,13 @@ depends() { } prepare_kernel_initrd() { - KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") - if [ -z "$KDUMP_KERNELVER" ]; then - kdump_kver=`uname -r` - if [ "$kernel" != "$kdump_kver" ]; then - dwarn "Using current kernel version '$kdump_kver' for early kdump," \ - "but the initramfs is generated for kernel version '$kernel'" - fi - else - kdump_kver=$KDUMP_KERNELVER + prepare_kdump_bootinfo + + # $kernel is a variable from dracut + if [ "$KDUMP_KERNELVER" != $kernel ]; then + dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ + "but the initramfs is generated for kernel version '$kernel'" fi - KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" - KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" } install() { diff --git a/kdump-lib.sh b/kdump-lib.sh index f632f65..126104f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -666,24 +666,68 @@ prepare_kexec_args() echo $kexec_args } -check_boot_dir() +# +# Detect initrd and kernel location, results are stored in global enviromental variables: +# KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD +# +# Expectes KDUMP_BOOTDIR, KDUMP_IMG, KDUMP_IMG_EXT, KDUMP_KERNELVER to be loaded from config already +# and will prefer already set values so user can specify custom kernel/initramfs location +# +prepare_kdump_bootinfo() { - local kdump_bootdir=$1 - #If user specify a boot dir for kdump kernel, let's use it. Otherwise - #check whether it's a atomic host. If yes parse the subdirectory under - #/boot; If not just find it under /boot. - if [ -n "$kdump_bootdir" ]; then - echo "$kdump_bootdir" - return + local boot_imglist boot_dirlist boot_initrdlist curr_kver="$(uname -r)" + local machine_id + + if [ -z "$KDUMP_KERNELVER"]; then + KDUMP_KERNELVER="$(uname -r)" fi - if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then - kdump_bootdir="/boot" - else - eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) - kdump_bootdir="/boot"$(dirname ${BOOT_IMAGE#*)}) + read machine_id < /etc/machine-id + boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} + boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG" + + # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format + local boot_img="$(cat /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/")" + if [ -n "$boot_img" ]; then + boot_imglist="$boot_img $boot_imglist" + fi + + for dir in $boot_dirlist; do + for img in $boot_imglist; do + if [ -f "$dir/$img" ]; then + KDUMP_KERNEL=$(echo $dir/$img | tr -s '/') + break 2 + fi + done + done + + if ! [ -e "$KDUMP_KERNEL" ]; then + echo "Failed to detect kdump kernel location" + return 1 + fi + + # Set KDUMP_BOOTDIR to where kernel image is stored + KDUMP_BOOTDIR=$(dirname $KDUMP_KERNEL) + + # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR + boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" + for initrd in $boot_initrdlist; do + if [ -f "$KDUMP_BOOTDIR/$initrd" ]; then + DEFAULT_INITRD="$KDUMP_BOOTDIR/$initrd" + break + fi + done + + # Get kdump initrd from default initrd filename + # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img + # initrd => initrdkdump + if [[ -z "$DEFAULT_INITRD" ]]; then + KDUMP_INITRD=${KDUMP_BOOTDIR}/initramfs-${KDUMP_KERNELVER}kdump.img + elif [[ $(basename $DEFAULT_INITRD) == *.* ]]; then + KDUMP_INITRD=${DEFAULT_INITRD%.*}kdump.${DEFAULT_INITRD##*.} + else + KDUMP_INITRD=${DEFAULT_INITRD}kdump fi - echo $kdump_bootdir } # diff --git a/kdumpctl b/kdumpctl index 122e065..2248da4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -2,6 +2,7 @@ KEXEC=/sbin/kexec KDUMP_KERNELVER="" +KDUMP_KERNEL="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" KDUMP_CONFIG_FILE="/etc/kdump.conf" @@ -13,6 +14,7 @@ INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DUMP_TARGET="" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" +KDUMP_INITRD="" TARGET_INITRD="" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" #kdump shall be the default dump mode @@ -94,7 +96,7 @@ rebuild_fadump_initrd() # this file tells the initrd is fadump enabled touch /tmp/fadump.initramfs target_initrd_tmp="$TARGET_INITRD.tmp" - $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $kdump_kver \ + $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \ -i /tmp/fadump.initramfs /etc/fadump.initramfs if [ $? != 0 ]; then echo "mkdumprd: failed to rebuild initrd with fadump support" >&2 @@ -118,7 +120,7 @@ check_earlykdump_is_enabled() rebuild_kdump_initrd() { - $MKDUMPRD $TARGET_INITRD $kdump_kver + $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER if [ $? != 0 ]; then echo "mkdumprd: failed to make kdump initrd" >&2 return 1 @@ -189,6 +191,10 @@ backup_default_initrd() restore_default_initrd() { + if [ ! -f "$DEFAULT_INITRD" ]; then + return + fi + # If a backup initrd exists, we must be switching back from # fadump to kdump. Restore the original default initrd. if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then @@ -301,18 +307,12 @@ get_pcs_cluster_modified_files() setup_initrd() { - KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") - - if [ -z "$KDUMP_KERNELVER" ]; then - kdump_kver=`uname -r` - else - kdump_kver=$KDUMP_KERNELVER + prepare_kdump_bootinfo + if [ $? -ne 0 ]; then + return 1 fi - kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" - - DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img" - DEFAULT_INITRD_BAK="${KDUMP_BOOTDIR}/.initramfs-`uname -r`.img.default" + DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename $DEFAULT_INITRD).default" if [ $DEFAULT_DUMP_MODE == "fadump" ]; then TARGET_INITRD="$DEFAULT_INITRD" @@ -320,7 +320,7 @@ setup_initrd() # with fadump aware initrd backup_default_initrd else - TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img" + TARGET_INITRD="$KDUMP_INITRD" # check if a backup of default initrd exists. If yes, # it signifies a switch from fadump mode. So, restore @@ -360,25 +360,25 @@ check_files_modified() EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS $CORE_COLLECTOR" + files="$KDUMP_CONFIG_FILE $KDUMP_KERNEL $EXTRA_BINS $CORE_COLLECTOR" [[ -e /etc/fstab ]] && files="$files /etc/fstab" # Check for any updated extra module EXTRA_MODULES="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed 's/^extra_modules\s*//')" if [ -n "$EXTRA_MODULES" ]; then - if [ -e /lib/modules/$kdump_kver/modules.dep ]; then - files="$files /lib/modules/$kdump_kver/modules.dep" + if [ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]; then + files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" fi for _module in $EXTRA_MODULES; do - _module_file="$(modinfo --set-version "$kdump_kver" --filename "$_module" 2>/dev/null)" + _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2>/dev/null)" if [[ $? -eq 0 ]]; then files="$files $_module_file" for _dep_modules in $(modinfo -F depends $_module | tr ',' ' '); do - files="$files $(modinfo --set-version "$kdump_kver" --filename $_dep_modules 2>/dev/null)" + files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename $_dep_modules 2>/dev/null)" done else # If it's not a module nor builtin, give an error - if ! ( modprobe --set-version "$kdump_kver" --dry-run "$_module" &>/dev/null ); then + if ! ( modprobe --set-version "$KDUMP_KERNELVER" --dry-run "$_module" &>/dev/null ); then echo "Module $_module not found" fi fi @@ -472,8 +472,8 @@ check_dump_fs_modified() check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" for _driver in $_target_drivers; do # Skip deprecated/invalid driver name or built-in module - _module_name=$(modinfo --set-version "$kdump_kver" -F name $_driver 2>/dev/null) - _module_filename=$(modinfo --set-version "$kdump_kver" -n $_driver 2>/dev/null) + _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name $_driver 2>/dev/null) + _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n $_driver 2>/dev/null) if [ $? -ne 0 ] || [ -z "$_module_name" ] || [[ "$_module_filename" = *"(builtin)"* ]]; then continue fi @@ -540,7 +540,7 @@ check_wdt_modified() # modalias. Currently load all of them. # TODO: Need to find a way to avoid any unwanted module # represented by modalias - _wdtdrv=$(modprobe --set-version "$kdump_kver" -R $_wdtdrv 2>/dev/null) + _wdtdrv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_wdtdrv 2>/dev/null) if [[ $_wdtdrv ]]; then for i in $_wdtdrv; do _drivers[$i]=1 @@ -555,7 +555,7 @@ check_wdt_modified() [[ -f "$_wdtppath/modalias" ]] || continue _wdtdrv=$(< "$_wdtppath/modalias") - _wdtdrv=$(modprobe --set-version "$kdump_kver" -R $_wdtdrv 2>/dev/null) + _wdtdrv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_wdtdrv 2>/dev/null) if [[ $_wdtdrv ]]; then for i in $_wdtdrv; do _drivers[$i]=1 @@ -700,7 +700,7 @@ load_kdump() $KEXEC $KEXEC_ARGS $standard_kexec_args \ --command-line="$KDUMP_COMMANDLINE" \ - --initrd=$TARGET_INITRD $kdump_kernel + --initrd=$TARGET_INITRD $KDUMP_KERNEL if [ $? == 0 ]; then echo "kexec: loaded kdump kernel" return 0 From ff46cfb19e9bf944a114164e33203b1a532d35f6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 28 Jul 2020 02:30:47 +0800 Subject: [PATCH 271/806] kdump-lib.sh: Remove is_atomic Now all atomic special workaround is removed, we can remove the atomic detection function. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump-lib.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 126104f..e18c473 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -321,11 +321,6 @@ kdump_get_persistent_dev() { echo $(get_persistent_dev "$dev") } -is_atomic() -{ - grep -q "ostree" /proc/cmdline -} - is_ipv6_address() { echo $1 | grep -q ":" From 5ec98c2ec79d4babcfad9ea8f8db3bc62a492334 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 6 Aug 2020 13:39:10 +0800 Subject: [PATCH 272/806] mkdumprd: Improve the warning message when using encrypted target Encrypted target have many issues, so let user check kexec-kdump-howto.txt, which have more details. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 91ce3d5..36f71b7 100644 --- a/mkdumprd +++ b/mkdumprd @@ -400,7 +400,7 @@ if ! check_resettable; then fi if ! check_crypt; then - echo "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot." + echo "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." fi # firstly get right SSH_KEY_LOCATION From 3d5d9f0c0ff39b7c4262bd24a59a37ae1648628a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 27 Aug 2020 13:14:19 +0800 Subject: [PATCH 273/806] Release 2.0.20-18 Signed-off-by: Kairui Song --- kexec-tools.spec | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 5a14d48..669fd6c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 17%{?dist} +Release: 18%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -360,7 +360,14 @@ done %endif %changelog -* Tue Aug 04 2020 Kairui Song - 2.0.20-16 +* Thu Aug 27 2020 Kairui Song - 2.0.20-18 +- mkdumprd: Improve the warning message when using encrypted target +- kdump-lib.sh: Remove is_atomic +- Refactor kernel image and initrd detection code +- early-kdump: Use consistent symbol link for kernel and initramfs +- Add a kernel install hook to clean up kdump initramfs + +* Tue Aug 04 2020 Kairui Song - 2.0.20-17 - Drop static lib dependencies - Revert "x86_64: enable the kexec file load by default" - Revert "s390x: enable the kexec file load by default" From 2457f22baf3187351448f0c5c5d5d9bce432827d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 31 Jul 2020 15:34:39 +0800 Subject: [PATCH 274/806] selftest: Add basic infrastructure to build test image The Makefile In tests/ could help build a VM image using Fedora cloud image as base image, or, user can specify a base image using BASE_IMAGE=. The current repo will be packeged and installed in the image, so the image could be used as a test image to test kexec-tools. The image building is splited into two steps: The first step, it either convert the base image to qcow2 or create a snapshot on it, and install basic packages (dracut, grubby, ...) and do basic setups (setup crashkernel=, disable selinux, ...). See tests/scripts/build-scripts/base-image.sh for detail. The second step, it creates a snapshot on top of the image produced by the previous step, and install the packaged kexec-tools of current repo. See tests/scripts/build-scripts/test-base-image.sh for detail. In this way, if repo's content is changes, `make` will detect it and only rebuild the second snapshot which speed up the rebuild by a lot. The image will be located as tests/output/test-base-image, and in qcow2 format. And default user/password is set to root/fedora. Signed-off-by: Kairui Song Acked-by: Dave Young --- tests/Makefile | 80 ++++++ tests/scripts/build-image.sh | 57 ++++ tests/scripts/build-scripts/base-image.sh | 11 + .../scripts/build-scripts/test-base-image.sh | 15 ++ tests/scripts/image-init-lib.sh | 245 ++++++++++++++++++ 5 files changed, 408 insertions(+) create mode 100644 tests/Makefile create mode 100755 tests/scripts/build-image.sh create mode 100755 tests/scripts/build-scripts/base-image.sh create mode 100755 tests/scripts/build-scripts/test-base-image.sh create mode 100644 tests/scripts/image-init-lib.sh diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..a352ab3 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,80 @@ +BASE_IMAGE ?= + +TEST_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +BUILD_ROOT := $(TEST_ROOT)/build +REPO = $(shell realpath $(TEST_ROOT)/../) +ARCH ?= $(shell arch) +SPEC = kexec-tools.spec + +DIST ?= fedora +DIST_ABR ?= f +DIST_ABRL ?= fc +DIST_UNSET ?= rhel +RELEASE ?= 32 + +DEFAULT_BASE_IMAGE_VER ?= 1.6 +DEFAULT_BASE_IMAGE ?= Fedora-Cloud-Base-$(RELEASE)-$(DEFAULT_BASE_IMAGE_VER).$(ARCH).raw.xz +DEFAULT_BASE_IMAGE_URL ?= https://dl.fedoraproject.org/pub/fedora/linux/releases/$(RELEASE)/Cloud/$(ARCH)/images/$(DEFAULT_BASE_IMAGE) + +BUILD_ROOT = $(TEST_ROOT)/build +RPMDEFINE = --define '_sourcedir $(REPO)'\ + --define '_specdir $(REPO)'\ + --define '_builddir $(BUILD_ROOT)'\ + --define '_srcrpmdir $(BUILD_ROOT)'\ + --define '_rpmdir $(BUILD_ROOT)'\ + --define 'dist %{?distprefix}.$(DIST_ABRL)$(RELEASE)'\ + --define '$(DIST) $(RELEASE)'\ + --eval '%undefine $(DIST_UNSET)'\ + --define '$(DIST_ABRL)$(RELEASE) 1'\ + +KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*)) +KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*) +KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 .) +KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm + +all: $(TEST_ROOT)/output/test-base-image + +# Use either: +# fedpkg --release $(DIST_ABR)$(RELEASE) --path ../../ local +# or +# rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC) +# to rebuild the rpm, currently use rpmbuild to have better control over the rpm building process +# +$(KEXEC_TOOLS_RPM): $(KEXEC_TOOLS_SRC) + sh -c "cd .. && fedpkg sources" + @echo Rebuilding RPM due to modification of sources: $? + rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC) + +$(BUILD_ROOT)/base-image: + mkdir -p $(BUILD_ROOT) +ifeq ($(strip $(BASE_IMAGE)),) + wget $(DEFAULT_BASE_IMAGE_URL) -O $(BUILD_ROOT)/$(DEFAULT_BASE_IMAGE) + $(TEST_ROOT)/scripts/build-image.sh \ + $(BUILD_ROOT)/$(DEFAULT_BASE_IMAGE)\ + $(BUILD_ROOT)/base-image +else + $(TEST_ROOT)/scripts/build-image.sh \ + $(BASE_IMAGE)\ + $(BUILD_ROOT)/base-image +endif + +$(BUILD_ROOT)/inst-base-image: $(BUILD_ROOT)/base-image + @echo "Building installation base image" + echo $(KEXEC_TOOLS_NVR) + $(TEST_ROOT)/scripts/build-image.sh \ + $(BUILD_ROOT)/base-image \ + $(BUILD_ROOT)/inst-base-image \ + $(TEST_ROOT)/scripts/build-scripts/base-image.sh + +$(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS_RPM) $(KEXEC_TOOLS_TEST_SRC) + @echo "Building test base image" + mkdir -p $(TEST_ROOT)/output + $(TEST_ROOT)/scripts/build-image.sh \ + $(BUILD_ROOT)/inst-base-image \ + $(TEST_ROOT)/output/test-base-image \ + $(TEST_ROOT)/scripts/build-scripts/test-base-image.sh \ + $(KEXEC_TOOLS_RPM) + +clean: + rm -rf $(TEST_ROOT)/build + rm -rf $(TEST_ROOT)/output diff --git a/tests/scripts/build-image.sh b/tests/scripts/build-image.sh new file mode 100755 index 0000000..c196bfb --- /dev/null +++ b/tests/scripts/build-image.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +if [ $# -lt 2 ]; then + echo "Usage: $(basename $0) [] + Build a new on top of , and install + contents defined in . are directly passed + to . + + If is raw, will copy it and create + in qcow2 format. + + If is qcow2, will create as a snapshot + on top of " + exit 1 +fi + +BASEDIR=$(realpath $(dirname "$0")) +. $BASEDIR/image-init-lib.sh + +# Base image to build from +BASE_IMAGE=$1 && shift +if [[ ! -e $BASE_IMAGE ]]; then + perror_exit "Base image '$BASE_IMAGE' not found" +else + BASE_IMAGE=$(realpath "$BASE_IMAGE") +fi + +OUTPUT_IMAGE=$1 && shift +if [[ ! -d $(dirname $OUTPUT_IMAGE) ]]; then + perror_exit "Path '$(dirname $OUTPUT_IMAGE)' doesn't exists" +fi + +INST_SCRIPT=$1 && shift + +create_image_from_base_image $BASE_IMAGE $OUTPUT_IMAGE.building + +mount_image $OUTPUT_IMAGE.building + +img_inst() { + inst_in_image $OUTPUT_IMAGE.building $@ +} + +img_inst_pkg() { + inst_pkg_in_image $OUTPUT_IMAGE.building $@ +} + +img_run_cmd() { + run_in_image $OUTPUT_IMAGE.building "$@" +} + +img_add_qemu_cmd() { + QEMU_CMD+="$@" +} + +[ -e "$INST_SCRIPT" ] && source $INST_SCRIPT + +mv $OUTPUT_IMAGE.building $OUTPUT_IMAGE diff --git a/tests/scripts/build-scripts/base-image.sh b/tests/scripts/build-scripts/base-image.sh new file mode 100755 index 0000000..59f4574 --- /dev/null +++ b/tests/scripts/build-scripts/base-image.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +img_inst_pkg grubby\ + dnsmasq\ + openssh openssh-server\ + dracut-network dracut-squash squashfs-tools ethtool snappy + +img_run_cmd "grubby --args systemd.journald.forward_to_console=1 systemd.log_target=console --update-kernel ALL" +img_run_cmd "grubby --args selinux=0 --update-kernel ALL" +img_run_cmd "grubby --args crashkernel=224M --update-kernel ALL" +img_run_cmd "mkdir -p /kexec-kdump-test" diff --git a/tests/scripts/build-scripts/test-base-image.sh b/tests/scripts/build-scripts/test-base-image.sh new file mode 100755 index 0000000..a649306 --- /dev/null +++ b/tests/scripts/build-scripts/test-base-image.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test RPMs to be installed +TEST_RPMS= +for _rpm in $@; do + if [[ ! -e $_rpm ]]; then + perror_exit "'$_rpm' not found" + else + TEST_RPMS=$(realpath "$_rpm") + fi +done + +img_inst_pkg $TEST_RPMS +# Test script should start kdump manually to save time +img_run_cmd "systemctl disable kdump.service" diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh new file mode 100644 index 0000000..372e5e4 --- /dev/null +++ b/tests/scripts/image-init-lib.sh @@ -0,0 +1,245 @@ +#!/usr/bin/env bash +[ -z "$TESTDIR" ] && TESTDIR=$(realpath $(dirname "$0")/../) + +SUDO="sudo" + +declare -A MNTS=() +declare -A DEVS=() + +perror() { + echo $@>&2 +} + +perror_exit() { + echo $@>&2 + exit 1 +} + +is_mounted() +{ + findmnt -k -n $1 &>/dev/null +} + +clean_up() +{ + for _mnt in ${MNTS[@]}; do + is_mounted $_mnt && $SUDO umount -f $_mnt + done + + for _dev in ${DEVS[@]}; do + [ ! -e "$_dev" ] && continue + [[ "$_dev" == "/dev/loop"* ]] && $SUDO losetup -d "$_dev" + [[ "$_dev" == "/dev/nbd"* ]] && $SUDO qemu-nbd --disconnect "$_dev" + done + + [ -d "$TMPDIR" ] && $SUDO rm --one-file-system -rf -- "$TMPDIR"; + + sync +} + +trap ' +ret=$?; +clean_up +exit $ret; +' EXIT + +# clean up after ourselves no matter how we die. +trap 'exit 1;' SIGINT + +readonly TMPDIR="$(mktemp -d -t kexec-kdump-test.XXXXXX)" +[ -d "$TMPDIR" ] || perror_exit "mktemp failed." + +get_image_fmt() { + local image=$1 fmt + + [ ! -e "$image" ] && perror "image: $image doesn't exist" && return 1 + + fmt=$(qemu-img info $image | sed -n "s/file format:\s*\(.*\)/\1/p") + + [ $? -eq 0 ] && echo $fmt && return 0 + + return 1 +} + +# If it's partitioned, return the mountable partition, else return the dev +get_mountable_dev() { + local dev=$1 parts + + $SUDO partprobe $dev && sync + parts="$(ls -1 ${dev}p*)" + if [ -n "$parts" ]; then + if [ $(echo "$parts" | wc -l) -gt 1 ]; then + perror "It's a image with multiple partitions, using last partition as main partition" + fi + echo "$parts" | tail -1 + else + echo "$dev" + fi +} + +prepare_loop() { + [ -n "$(lsmod | grep "^loop")" ] && return + + $SUDO modprobe loop + + [ ! -e "/dev/loop-control" ] && perror_exit "failed to load loop driver" +} + +prepare_nbd() { + [ -n "$(lsmod | grep "^nbd")" ] && return + + $SUDO modprobe nbd max_part=4 + + [ ! -e "/dev/nbd0" ] && perror_exit "failed to load nbd driver" +} + +mount_nbd() { + local image=$1 size dev + for _dev in /sys/class/block/nbd* ; do + size=$(cat $_dev/size) + if [ "$size" -eq 0 ] ; then + dev=/dev/${_dev##*/} + $SUDO qemu-nbd --connect=$dev $image 1>&2 + [ $? -eq 0 ] && echo $dev && break + fi + done + + return 1 +} + +image_lock() +{ + local image=$1 timeout=5 fd + + eval "exec {fd}>$image.lock" + if [ $? -ne 0 ]; then + perror_exit "failed acquiring image lock" + exit 1 + fi + + flock -n $fd + rc=$? + while [ $rc -ne 0 ]; do + echo "Another instance is holding the image lock ..." + flock -w $timeout $fd + rc=$? + done +} + +# Mount a device, will umount it automatially when shell exits +mount_image() { + local image=$1 fmt + local dev mnt mnt_dev + + # Lock the image just in case user run this script in parrel + image_lock $image + + fmt=$(get_image_fmt $image) + [ $? -ne 0 ] || [ -z "$fmt" ] && perror_exit "failed to detect image format" + + if [ "$fmt" == "raw" ]; then + prepare_loop + + dev="$($SUDO losetup --show -f $image)" + [ $? -ne 0 ] || [ -z "$dev" ] && perror_exit "failed to setup loop device" + + elif [ "$fmt" == "qcow2" ]; then + prepare_nbd + + dev=$(mount_nbd $image) + [ $? -ne 0 ] || [ -z "$dev" ] perror_exit "failed to connect qemu to nbd device '$dev'" + else + perror_exit "Unrecognized image format '$fmt'" + fi + DEVS[$image]="$dev" + + mnt="$(mktemp -d -p $TMPDIR -t mount.XXXXXX)" + [ $? -ne 0 ] || [ -z "$mnt" ] && perror_exit "failed to create tmp mount dir" + MNTS[$image]="$mnt" + + mnt_dev=$(get_mountable_dev "$dev") + [ $? -ne 0 ] || [ -z "$mnt_dev" ] && perror_exit "failed to setup loop device" + + $SUDO mount $mnt_dev $mnt + [ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'" +} + +shell_in_image() { + local image=$1 && shift + local root=${MNTS[$image]} + + pushd $root + + $SHELL + + popd +} + +inst_pkg_in_image() { + local image=$1 && shift + local root=${MNTS[$image]} + + # LSB not available + # release_info=$($SUDO chroot $root /bin/bash -c "lsb_release -a") + # release=$(echo "$release_info" | sed -n "s/Release:\s*\(.*\)/\1/p") + # distro=$(echo "$release_info" | sed -n "s/Distributor ID:\s*\(.*\)/\1/p") + # if [ "$distro" != "Fedora" ]; then + # perror_exit "only Fedora image is supported" + # fi + release=$(cat $root/etc/fedora-release | sed -n "s/.*[Rr]elease\s*\([0-9]*\).*/\1/p") + [ $? -ne 0 ] || [ -z "$release" ] && perror_exit "only Fedora image is supported" + + $SUDO dnf --releasever=$release --installroot=$root install -y $@ +} + +run_in_image() { + local image=$1 && shift + local root=${MNTS[$image]} + + echo $SUDO chroot $root /bin/bash -c $@ > /dev/stderr + $SUDO chroot $root /bin/bash -c "$@" +} + +inst_in_image() { + local image=$1 src=$2 dst=$3 + local root=${MNTS[$image]} + + $SUDO cp $src $root/$dst +} + +# If source image is qcow2, create a snapshot +# If source image is raw, convert to raw +# If source image is xz, decompress then repeat the above logic +# +# Won't touch source image +create_image_from_base_image() { + local image=$1 + local output=$2 + local decompressed_image + + local ext="${image##*.}" + if [[ "$ext" == 'xz' ]]; then + echo "Decompressing base image..." + xz -d -k $image + decompressed_image=${image%.xz} + image=$decompressed_image + fi + + local image_fmt=$(qemu-img info $image | sed -n "s/file format:\s*\(.*\)/\1/p") + if [ "$image_fmt" != "raw" ]; then + if [ "$image_fmt" == "qcow2" ]; then + echo "Source image is qcow2, using snapshot..." + qemu-img create -f qcow2 -b $image $output + else + perror_exit "Unrecognized base image format $image_mnt" + fi + else + echo "Source image is raw, converting to qcow2..." + qemu-img convert -f raw -O qcow2 $image $output + fi + + # Clean up decompress temp image + if [ -n "$decompressed_image" ]; then + rm $decompressed_image + fi +} From a8dbd281f7db2f90892ad8d1184d474822a3a65b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 31 Jul 2020 15:34:40 +0800 Subject: [PATCH 275/806] selftest: Add basic test framework Now, by execute `make test-run` in tests/, kexec-tools sanity tests will be performed using VMs. There are currently 3 test cases, for local kdump, nfs kdump and ssh kdump. For each test VM, the selftest framework will create a snapshot layer, do setup as required by the test case, this ensure each test runs in a clean VM. This framework will install a custom systemd service that starts when system have finished booting, and the service will do basic routine (fetch and set boot counter, etc..), then call the test case which is installed in /kexec-kdump-test/test.sh in VM. Each VM will have two serial consoles, one for ordinary console usage, one for the test communication and log. The test script will watch the second test console to know the test status. The test cases are located in tests/scripts/testcases, documents about the test cases structure will be provided in following commits. Signed-off-by: Kairui Song Acked-by: Dave Young --- tests/Makefile | 8 + tests/scripts/build-scripts/base-image.sh | 1 - .../scripts/build-scripts/test-base-image.sh | 6 + tests/scripts/build-scripts/test-image.sh | 21 +++ tests/scripts/kexec-kdump-test/init.sh | 112 +++++++++++ .../kexec-kdump-test/kexec-kdump-test.service | 9 + tests/scripts/kexec-kdump-test/test.sh | 15 ++ tests/scripts/run-test.sh | 131 +++++++++++++ tests/scripts/spawn-image-shell.sh | 16 ++ tests/scripts/test-lib.sh | 177 ++++++++++++++++++ .../scripts/testcases/local-kdump/0-local.sh | 32 ++++ tests/scripts/testcases/nfs-kdump/0-server.sh | 38 ++++ tests/scripts/testcases/nfs-kdump/1-client.sh | 30 +++ tests/scripts/testcases/ssh-kdump/0-server.sh | 34 ++++ tests/scripts/testcases/ssh-kdump/1-client.sh | 40 ++++ 15 files changed, 669 insertions(+), 1 deletion(-) create mode 100755 tests/scripts/build-scripts/test-image.sh create mode 100755 tests/scripts/kexec-kdump-test/init.sh create mode 100644 tests/scripts/kexec-kdump-test/kexec-kdump-test.service create mode 100755 tests/scripts/kexec-kdump-test/test.sh create mode 100755 tests/scripts/run-test.sh create mode 100755 tests/scripts/spawn-image-shell.sh create mode 100644 tests/scripts/test-lib.sh create mode 100755 tests/scripts/testcases/local-kdump/0-local.sh create mode 100755 tests/scripts/testcases/nfs-kdump/0-server.sh create mode 100755 tests/scripts/testcases/nfs-kdump/1-client.sh create mode 100755 tests/scripts/testcases/ssh-kdump/0-server.sh create mode 100755 tests/scripts/testcases/ssh-kdump/1-client.sh diff --git a/tests/Makefile b/tests/Makefile index a352ab3..6144809 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,4 @@ +TEST_CASE ?= BASE_IMAGE ?= TEST_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -75,6 +76,13 @@ $(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS $(TEST_ROOT)/scripts/build-scripts/test-base-image.sh \ $(KEXEC_TOOLS_RPM) +test-run: $(TEST_ROOT)/output/test-base-image +ifeq ($(strip $(TEST_CASE)),) + $(TEST_ROOT)/scripts/run-test.sh +else + $(TEST_ROOT)/scripts/run-test.sh --console $(TEST_CASE) +endif + clean: rm -rf $(TEST_ROOT)/build rm -rf $(TEST_ROOT)/output diff --git a/tests/scripts/build-scripts/base-image.sh b/tests/scripts/build-scripts/base-image.sh index 59f4574..62624e4 100755 --- a/tests/scripts/build-scripts/base-image.sh +++ b/tests/scripts/build-scripts/base-image.sh @@ -8,4 +8,3 @@ img_inst_pkg grubby\ img_run_cmd "grubby --args systemd.journald.forward_to_console=1 systemd.log_target=console --update-kernel ALL" img_run_cmd "grubby --args selinux=0 --update-kernel ALL" img_run_cmd "grubby --args crashkernel=224M --update-kernel ALL" -img_run_cmd "mkdir -p /kexec-kdump-test" diff --git a/tests/scripts/build-scripts/test-base-image.sh b/tests/scripts/build-scripts/test-base-image.sh index a649306..5e2d86a 100755 --- a/tests/scripts/build-scripts/test-base-image.sh +++ b/tests/scripts/build-scripts/test-base-image.sh @@ -10,6 +10,12 @@ for _rpm in $@; do fi done +img_run_cmd "mkdir -p /kexec-kdump-test" +img_inst $TESTDIR/scripts/kexec-kdump-test/init.sh /kexec-kdump-test/init.sh +img_inst $TESTDIR/scripts/kexec-kdump-test/test.sh /kexec-kdump-test/test.sh +img_inst $TESTDIR/scripts/kexec-kdump-test/kexec-kdump-test.service /etc/systemd/system/kexec-kdump-test.service +img_run_cmd "systemctl enable kexec-kdump-test.service" + img_inst_pkg $TEST_RPMS # Test script should start kdump manually to save time img_run_cmd "systemctl disable kdump.service" diff --git a/tests/scripts/build-scripts/test-image.sh b/tests/scripts/build-scripts/test-image.sh new file mode 100755 index 0000000..d8e907e --- /dev/null +++ b/tests/scripts/build-scripts/test-image.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +. $TESTDIR/scripts/test-lib.sh +TEST_SCRIPT=$1 + +QEMU_CMD="$DEFAULT_QEMU_CMD \ +-serial stdio \ +-serial file:$(get_test_output_file $TEST_SCRIPT) \ +-monitor none \ +-hda $OUTPUT_IMAGE" + +img_add_qemu_cmd() { + QEMU_CMD+=" $@" +} + +source $TEST_SCRIPT + +on_build + +img_inst $TEST_SCRIPT /kexec-kdump-test/test.sh + +echo $QEMU_CMD > $(get_test_qemu_cmd_file $TEST_SCRIPT) diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh new file mode 100755 index 0000000..bc2a642 --- /dev/null +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env sh +BOOT_ARG="test_boot_count" +_YELLOW='\033[1;33m' +_GREEN='\033[0;32m' +_RED='\033[0;31m' +_NC='\033[0m' # No Color + +if [ -n "$(cat /proc/cmdline | grep "\bno_test\b")" ]; then + exit 0 +fi + +get_test_boot_count() { + local boot_count=$(cat /proc/cmdline | sed -n "s/.*$BOOT_ARG=\([0-9]*\).*/\1/p") + + if [ -z "$boot_count" ]; then + boot_count=1 + fi + + echo $boot_count +} + +test_output() { + echo $@ > /dev/ttyS1 + echo $@ > /dev/ttyS0 + + sync +} + +test_passed() { + echo -e "${_GREEN}TEST PASSED${_NC}" > /dev/ttyS1 + echo -e "${_GREEN}kexec-kdump-test: TEST PASSED${_NC}" > /dev/ttyS0 + + echo $@ > /dev/ttyS1 + echo $@ > /dev/ttyS0 + + sync + + shutdown -h 0 + + exit 0 +} + +test_failed() { + echo -e "${_RED}TEST FAILED${_NC}" > /dev/ttyS1 + echo -e "${_RED}kexec-kdump-test: TEST FAILED${_NC}" > /dev/ttyS0 + + echo $@ > /dev/ttyS1 + echo $@ > /dev/ttyS0 + + sync + + shutdown -h 0 + + exit 1 +} + +test_abort() { + echo -e "${_YELLOW}TEST ABORTED${_NC}" > /dev/ttyS1 + echo -e "${_YELLOW}kexec-kdump-test: TEST ABORTED${_NC}" > /dev/ttyS0 + + echo $@ > /dev/ttyS1 + echo $@ > /dev/ttyS0 + + sync + + shutdown -h 0 + + exit 2 +} + +has_valid_vmcore_dir() { + local path=$1 + local vmcore_dir=$path/$(ls -1 $path | tail -n 1) + local vmcore="" + + # Checking with `crash` is slow and consume a lot of memory/disk, + # just do a sanity check by check if log are available. + if [ -e $vmcore_dir/vmcore ]; then + vmcore=$vmcore_dir/vmcore + makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1 + elif [ -e $vmcore_dir/vmcore.flat ]; then + vmcore=$vmcore_dir/vmcore.flat + makedumpfile -R $vmcore_dir/vmcore < $vmcore || return 1 + makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1 + rm $vmcore_dir/vmcore + else + return 1 + fi + + if diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then + return 1 + fi + + test_output "Found a valid vmcore in \"$vmcore_dir\"" + + return 0 +} + +BOOT_COUNT=$(get_test_boot_count) +test_output "Kexec-Kdump-Test Boot #$BOOT_COUNT" + +echo 'fedora' | passwd --stdin root + +test_output "Updating kernel cmdline" +grubby --update-kernel ALL --args $BOOT_ARG=$(expr $BOOT_COUNT + 1) && sync + +test_output "Executing test hook" +source /kexec-kdump-test/test.sh + +on_test; + +test_output "Test exited, system hang for inspect" diff --git a/tests/scripts/kexec-kdump-test/kexec-kdump-test.service b/tests/scripts/kexec-kdump-test/kexec-kdump-test.service new file mode 100644 index 0000000..ba7b11e --- /dev/null +++ b/tests/scripts/kexec-kdump-test/kexec-kdump-test.service @@ -0,0 +1,9 @@ +[Unit] +Description=Kexec Kdump Test Service + +[Service] +ExecStart=/kexec-kdump-test/init.sh +Type=idle + +[Install] +WantedBy=multi-user.target diff --git a/tests/scripts/kexec-kdump-test/test.sh b/tests/scripts/kexec-kdump-test/test.sh new file mode 100755 index 0000000..66ac15d --- /dev/null +++ b/tests/scripts/kexec-kdump-test/test.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +# A test example that do nothing + +# Executed before VM starts +on_build() { + : +} + +# Executed when VM boots +on_test() { + : + # call get_test_boot_count to get boot cound + # call test_passed if test passed + # call test_failed if test passed +} diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh new file mode 100755 index 0000000..cdba7f4 --- /dev/null +++ b/tests/scripts/run-test.sh @@ -0,0 +1,131 @@ +#!/bin/bash + +_kill_all_jobs() { + local _jobs=$(jobs -r -p) + + [ -n "$_jobs" ] && kill $_jobs +} + +trap ' +ret=$?; +_kill_all_jobs +exit $ret; +' EXIT + +trap 'exit 1;' SIGINT + +BASEDIR=$(realpath $(dirname "$0")) +. $BASEDIR/test-lib.sh +TESTCASEDIR="$BASEDIR/testcases" + +console=0 +testcases="" + +while [ $# -gt 0 ]; do + case $1 in + '') + break + ;; + --console ) + console=1 + ;; + -*) + echo "Invalid option $1" + ;; + *) + testcases+=" $1" + ;; + esac + shift; +done + +if [ -z "$testcases" ]; then + echo "==== Starting all tests: ====" + testcases=$(ls -1 $TESTCASEDIR) +else + echo "==== Starting specified tests: ====" +fi +echo ${testcases##*/} +echo + +declare -A results +ret=0 + +for test_case in $testcases; do + echo "======== Running Test Case $test_case ========" + results[$test_case]="" + + testdir=$TESTCASEDIR/$test_case + script_num=$(ls -1 $testdir | wc -l) + scripts=$(ls -r -1 $testdir | tr '\n' ' ') + test_outputs="" + read main_script aux_script <<< "$scripts" + + if [ -z "$main_script" ]; then + echo "ERROR: Empty testcase dir $testdir" + continue + fi + + for script in $scripts; do + echo "---- Building image for: $script ----" + echo "-------- Output image is: $(get_test_image $testdir/$script)" + echo "-------- Building log is: $(get_test_image $testdir/$script).log" + + mkdir -p $(dirname $(get_test_image $testdir/$script)) + build_test_image $testdir/$script &> $(get_test_image $testdir/$script).log + + if [ $? -ne 0 ]; then + echo "Failing building image!" + continue 2 + fi + done + + for script in $aux_script; do + echo "---- Starting VM: $script ----" + + script="$testdir/$script" + echo "-------- Qemu cmdline: $(get_test_qemu_cmd_file $script)" + echo "-------- Console log: $(get_test_console_file $script)" + echo "-------- Test log: $(get_test_output_file $script)" + test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) + rm -f $(get_test_output_file $script) + + $(run_test_sync $script > $(get_test_console_file $script)) & + + sleep 3 + done + + script="$main_script" + echo "---- Starting test VM: $(basename $script) ----" + script="$testdir/$script" + + echo "-------- Qemu cmdline: $(get_test_qemu_cmd_file $script)" + echo "-------- Console log: $(get_test_console_file $script)" + echo "-------- Test log: $(get_test_output_file $script)" + test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) + rm -f $(get_test_output_file $script) + + if [ $console -eq 1 ]; then + run_test_sync $script | tee $(get_test_console_file $script) + [ -n "$(jobs -p)" ] && kill $(jobs -p) + else + $(run_test_sync $script > $(get_test_console_file $script)) & + watch_test_outputs $test_outputs + fi + + res="$(gather_test_result $test_outputs)" + [ $? -ne 0 ] && ret=$(expr $ret + 1) + results[$test_case]="$res" + + echo -e "-------- Test finished: $test_case $res --------" +done + +echo "======== Test results ========" +for i in ${!results[@]}; do + echo "----------------" + echo -e "$i:\t\t${results[$i]}" +done + +exit $ret diff --git a/tests/scripts/spawn-image-shell.sh b/tests/scripts/spawn-image-shell.sh new file mode 100755 index 0000000..ccfb655 --- /dev/null +++ b/tests/scripts/spawn-image-shell.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +BASEDIR=$(realpath $(dirname "$0")) +. $BASEDIR/image-init-lib.sh + +# Base image to build from +BOOT_IMAGE=$1 +if [[ ! -e $BOOT_IMAGE ]]; then + perror_exit "Image '$BOOT_IMAGE' not found" +else + BOOT_IMAGE=$(realpath "$BOOT_IMAGE") +fi + +mount_image $BOOT_IMAGE + +shell_in_image $BOOT_IMAGE diff --git a/tests/scripts/test-lib.sh b/tests/scripts/test-lib.sh new file mode 100644 index 0000000..aff5cd3 --- /dev/null +++ b/tests/scripts/test-lib.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env sh +[ -z "$BASEDIR" ] && BASEDIR=$(realpath $(dirname "$0")) +[ -z "$TESTDIR" ] && TESTDIR=$(realpath $BASEDIR/../) +[ -z "$TEST_BASE_IMAGE" ] && TEST_BASE_IMAGE=$TESTDIR/output/test-base-image + +[[ ! -e $TEST_BASE_IMAGE ]] && echo "Test base image not found." && exit 1 + +DEFAULT_QEMU_CMD="-nodefaults \ +-nographic \ +-smp 2 \ +-m 768M \ +-monitor none" + +_YELLOW='\033[1;33m' +_GREEN='\033[0;32m' +_RED='\033[0;31m' +_NC='\033[0m' # No Color + +get_test_path() { + local script=$1 + local testname=$(basename $(dirname $script)) + local output=$TESTDIR/output/$testname + + echo $output +} + +get_test_entry_name() { + echo $(basename ${1%.*}) +} + +get_test_image() { + local script=$1 + local testout=$(get_test_path $script) + local entry=$(get_test_entry_name $script) + + echo $testout/$entry.img +} + +get_test_qemu_cmd_file() { + local script=$1 + local testout=$(get_test_path $script) + local entry=$(get_test_entry_name $script) + + echo $testout/$entry.qemu_cmd +} + +get_test_qemu_cmd() { + cat $(get_test_qemu_cmd_file $1) +} + +get_test_output_file() { + local script=$1 + local testout=$(get_test_path $script) + local entry=$(get_test_entry_name $script) + + echo $testout/$entry.output +} + +get_test_console_file() { + local script=$1 + local testout=$(get_test_path $script) + local entry=$(get_test_entry_name $script) + + echo $testout/$entry.console +} + +get_test_output() { + local output=$(get_test_output_file $1) + if [ -e "$output" ]; then + cat $(get_test_output_file $1) + else + echo "" + fi +} + +build_test_image() { + local script=$1 + local test_image=$(get_test_image $script) + mkdir -p $(dirname $test_image) + + $BASEDIR/build-image.sh \ + $TEST_BASE_IMAGE \ + $test_image \ + $BASEDIR/build-scripts/test-image.sh \ + $script +} + +run_test_sync() { + local qemu_cmd=$(get_test_qemu_cmd $1) + + if [ -n "$qemu_cmd" ]; then + timeout --foreground 10m qemu-kvm $(get_test_qemu_cmd $1) + else + echo "error: test qemu command line is not configured" > /dev/stderr + return 1 + fi +} + +_check_test_result() { + grep "TEST PASSED" $1 2>/dev/null + [ $? -eq 0 ] && return 0 + + grep "TEST FAILED" $1 2>/dev/null + [ $? -eq 0 ] && return 1 + + grep "TEST ABORTED" $1 2>/dev/null + [ $? -eq 0 ] && return 2 + + return 255 +} + +# Print test result and return below value: +# 0: Test passed +# 1: Test failed +# 2: Test aborted, test scripts errored out +# 3: Test exited unexpectely, VM got killed early, or time out +gather_test_result() { + local ret=255 + local res="" + + for i in $@; do + res=$(_check_test_result $i) + ret=$? + + if [ $ret -ne 255 ]; then + echo $res + return $ret + fi + done + + echo "${_RED}TEST RESULT NOT FOUND!${_NC}" + return 3 +} + +# Wait and watch for test result +watch_test_outputs() { + local ret=255 + local res="" + # If VMs are still running, check for test result, if + # test finished, kill remaining VMs + while true; do + if [ -n "$(jobs -r)" ]; then + # VMs still running + for i in $@; do + res=$(_check_test_result $i) + ret=$? + + if [ $ret -ne 255 ]; then + # Test finished, kill VMs + kill $(jobs -p) + break 2 + fi + done + else + # VMs exited + ret=255 + + for i in $@; do + res=$(_check_test_result $i) + ret=$? + + if [ $ret -ne 255 ]; then + break 2 + fi + done + + if [ $ret -eq 255 ]; then + ret=3 + break + fi + fi + + sleep 1 + done + + return $ret +} diff --git a/tests/scripts/testcases/local-kdump/0-local.sh b/tests/scripts/testcases/local-kdump/0-local.sh new file mode 100755 index 0000000..d09c6f0 --- /dev/null +++ b/tests/scripts/testcases/local-kdump/0-local.sh @@ -0,0 +1,32 @@ +on_build() { + : +} + +on_test() { + local boot_count=$(get_test_boot_count) + + if [ $boot_count -eq 1 ]; then + cat << EOF > /etc/kdump.conf +path /var/crash +core_collector makedumpfile -l --message-level 1 -d 31 +EOF + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + + elif [ $boot_count -eq 2 ]; then + + if has_valid_vmcore_dir /var/crash; then + test_passed + else + test_failed + fi + + shutdown -h 0 + else + test_failed "Unexpected reboot" + fi +} diff --git a/tests/scripts/testcases/nfs-kdump/0-server.sh b/tests/scripts/testcases/nfs-kdump/0-server.sh new file mode 100755 index 0000000..04f102e --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump/0-server.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils dnsmasq" + + img_run_cmd "mkdir -p /srv/nfs/var/crash" + img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports" + img_run_cmd "systemctl enable nfs-server" + + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" + img_run_cmd "systemctl enable dnsmasq" + + img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo BOOTPROTO="none >> /etc/sysconfig/network-scripts/ifcfg-eth0"' + img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + + img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56" +} + +# Executed when VM boots +on_test() { + while true; do + if has_valid_vmcore_dir /srv/nfs/var/crash; then + # Wait a few seconds so client finish it's work to generate a full log + sleep 5 + + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/nfs-kdump/1-client.sh b/tests/scripts/testcases/nfs-kdump/1-client.sh new file mode 100755 index 0000000..df62463 --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump/1-client.sh @@ -0,0 +1,30 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57" +} + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.77.1 + + if [ "$boot_count" -eq 1 ]; then + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 1 -d 31 +EOF + + while ! ping -c 1 $nfs_server -W 1; do + : + done + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +} diff --git a/tests/scripts/testcases/ssh-kdump/0-server.sh b/tests/scripts/testcases/ssh-kdump/0-server.sh new file mode 100755 index 0000000..f1e5073 --- /dev/null +++ b/tests/scripts/testcases/ssh-kdump/0-server.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56" + + img_run_cmd "echo root:fedora | chpasswd" + img_run_cmd 'sed -i "s/^.*PasswordAuthentication .*\$/PasswordAuthentication yes/" /etc/ssh/sshd_config' + img_run_cmd 'sed -i "s/^.*PermitRootLogin .*\$/PermitRootLogin yes/" /etc/ssh/sshd_config' + img_run_cmd "systemctl enable sshd" + + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" + img_run_cmd "systemctl enable dnsmasq" + + img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo BOOTPROTO="none >> /etc/sysconfig/network-scripts/ifcfg-eth0"' + img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' +} + +# Executed when VM boots +on_test() { + while true; do + if has_valid_vmcore_dir /var/crash; then + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/ssh-kdump/1-client.sh b/tests/scripts/testcases/ssh-kdump/1-client.sh new file mode 100755 index 0000000..d79f00f --- /dev/null +++ b/tests/scripts/testcases/ssh-kdump/1-client.sh @@ -0,0 +1,40 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "sshpass" + img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57" +} + +on_test() { + local boot_count=$(get_test_boot_count) + local ssh_server=192.168.77.1 + + if [ "$boot_count" -eq 1 ]; then +cat << EOF > /etc/kdump.conf +ssh root@192.168.77.1 +core_collector makedumpfile -l --message-level 1 -d 31 -F +EOF + + ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y &>/dev/ttyS1 + + while ! ping -c 1 $ssh_server -W 1; do + sleep 1 + done + + while [ -z "$(cat /root/.ssh/known_hosts)" ]; do + ssh-keyscan -H 192.168.77.1 > /root/.ssh/known_hosts + done + + sshpass -p fedora ssh-copy-id root@$ssh_server -f &>/dev/ttyS1 + + sshpass -p fedora kdumpctl propagate &>/dev/ttyS1 + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +} From 978a84976593985c1d91b396fe5dcc762c0c685c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 31 Jul 2020 15:34:41 +0800 Subject: [PATCH 276/806] selftest: Add document for selftests Acked-by: Dave Young --- tests/README | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/README diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..6ab63a8 --- /dev/null +++ b/tests/README @@ -0,0 +1,65 @@ +===================== +Kexec Kdump Self-test +===================== + + +Introduction +============ +The self-tests here are useful for quick sanity tests for new patches, and also helpful for debugging issues. + + +How it works +============ +All tests are run within VMs using qemu. By default, VM images are based on Fedora Cloud image, and the image for each test run is a layered qcow2 snapshot on top of the base image. +Test images are managed by Makefile, so if there are any code change in the kexec-tools repository, `make` command will detect that and only rebuild the top image layer. This makes the test runs boot fast and each test run is clean. + + +Basic usage +=========== +Before you start, you can make the self-tests use your own base image by running following command: + +`make clean && make BASE_IMAGE=` + +This is helpful if you have a slow network, else self-test will try to download the cloud image from Fedora's official website using `wget`. + +- Use the following command to run all tests: + $ make test-run + + All available tests will be executed. + + Test artifacts are stored in output/ + +- For easier debugging, you can run only on test with the following command: + $ make TEST_CASE= test-run + + This way, VM's console is directly connected to stdin/out so debugging will be easier. + If there are multiple VMs used in a test case, the VM performing actual kdump/kexec operation will be connected to stdin/out. + +Test Cases +========== +Each test case is a folder under scripts/testcases/, a test case folder will contain at least one executable shell script, and each script should contain two functions: "on_build" and "on_test". + +"on_build" is called when building the test image, which can instruct the self-test framework to install packages or create files, etc. +"on_test" is called when VM finished booting, which can get the boot count by calling "get_test_boot_count" and determine what to do. It should call "test_passed" on success, and call "test_failed" on failure. "test_aborted" is called when unexpected behavior occurs. + +When there are multiple scripts in a single test case folder, they will spawn VMs in lexical order, and the last VM is considered the VM performing the actual test. Other VMs could be hosting test required service. This is useful for the network dump test. However, "test_passed" or "test_failed" or "test_aborted" could be called in any of these VMs, so during network kdump test, the dump target can also terminate the test and mark it passed when a valid vmcore is detected. + + +Debugging +========= + +- When the test VM boots, you can append "no_test" to kernel args in grub, which tells the test services to quit early. + +- You can launch the VMs manually or inspect the image after ran a test. + + Test images are located as: + + output//.img + + Test images' corresponding qemu command are located as: + + output//.qemu_cmd + + To repeat/debug a test manually, you should launch all VMs in output/ menu in lexical order, and append 'no_test' in the last VM's grub cmdline, then VM will hang on login prompt, login with root/fedora. Test script is located as /kexec-kdump-test/test.sh + +- If you just want to inspect the images file content, you can also use scripts/spawn-image-shell.sh to spawn a shell in the image quickly. From c44cdb67031f0fed225a348fe8695e17932541b3 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 31 Jul 2020 15:34:42 +0800 Subject: [PATCH 277/806] selftest: Show the path of dumped vmcore on test end Make the test script print following line when the test is finished and vmcore is successfully dumped: You can retrive the verify the vmcore file using following command: ./scripts/copy-from-image.sh \ /home/kasong/fedpkg/kexec-tools/tests/output/ssh-kdump/0-server.img \ /var/crash/192.168.77.62-2020-09-02-05:16:26/vmcore.flat ./ Kernel package verion is: kernel-core-5.6.6-300.fc32.x86_64 Also add a helper to copy files out of the VM image. Signed-off-by: Kairui Song Acked-by: Dave Young --- tests/scripts/copy-from-image.sh | 25 +++++++++++++++++++++++++ tests/scripts/image-init-lib.sh | 21 ++++++++++++++------- tests/scripts/kexec-kdump-test/init.sh | 2 ++ tests/scripts/run-test.sh | 17 +++++++++++++++++ 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100755 tests/scripts/copy-from-image.sh diff --git a/tests/scripts/copy-from-image.sh b/tests/scripts/copy-from-image.sh new file mode 100755 index 0000000..9b71054 --- /dev/null +++ b/tests/scripts/copy-from-image.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +BASEDIR=$(realpath $(dirname "$0")) +. $BASEDIR/image-init-lib.sh + +# Base image to copy from +BOOT_IMAGE=$1 && shift +if [ ! -e "$BOOT_IMAGE" ]; then + perror_exit "Image '$BOOT_IMAGE' not found" +else + BOOT_IMAGE=$(realpath "$BOOT_IMAGE") +fi + +mount_image $BOOT_IMAGE + +IMAGE_MNT=$(get_image_mount_root $BOOT_IMAGE) + +SRC= +while [ $# -gt 1 ]; do + SRC="$SRC $IMAGE_MNT/$1" + shift +done +DST=$1 + +cp -rv $SRC $DST diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 372e5e4..7be55d1 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -164,10 +164,20 @@ mount_image() { [ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'" } -shell_in_image() { - local image=$1 && shift +get_image_mount_root() { + local image=$1 local root=${MNTS[$image]} + echo $root + + if [ -z "$root" ]; then + return 1 + fi +} + +shell_in_image() { + local root=$(get_image_mount_root $1) && shift + pushd $root $SHELL @@ -176,8 +186,7 @@ shell_in_image() { } inst_pkg_in_image() { - local image=$1 && shift - local root=${MNTS[$image]} + local root=$(get_image_mount_root $1) && shift # LSB not available # release_info=$($SUDO chroot $root /bin/bash -c "lsb_release -a") @@ -193,10 +202,8 @@ inst_pkg_in_image() { } run_in_image() { - local image=$1 && shift - local root=${MNTS[$image]} + local root=$(get_image_mount_root $1) && shift - echo $SUDO chroot $root /bin/bash -c $@ > /dev/stderr $SUDO chroot $root /bin/bash -c "$@" } diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh index bc2a642..5737810 100755 --- a/tests/scripts/kexec-kdump-test/init.sh +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -92,6 +92,8 @@ has_valid_vmcore_dir() { fi test_output "Found a valid vmcore in \"$vmcore_dir\"" + test_output "VMCORE: $vmcore" + test_output "KERNEL VERSION: $(rpm -q kernel-core)" return 0 } diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index cdba7f4..ef628aa 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -88,6 +88,7 @@ for test_case in $testcases; do echo "-------- Console log: $(get_test_console_file $script)" echo "-------- Test log: $(get_test_output_file $script)" test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) rm -f $(get_test_output_file $script) @@ -104,6 +105,7 @@ for test_case in $testcases; do echo "-------- Console log: $(get_test_console_file $script)" echo "-------- Test log: $(get_test_output_file $script)" test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) rm -f $(get_test_output_file $script) @@ -116,10 +118,25 @@ for test_case in $testcases; do fi res="$(gather_test_result $test_outputs)" + [ $? -ne 0 ] && ret=$(expr $ret + 1) results[$test_case]="$res" echo -e "-------- Test finished: $test_case $res --------" + for script in $scripts; do + script="$testdir/$script" + output="$(get_test_output_file $script) " + image="$(get_test_image $script)" + vmcore="$(sed -n 's/^VMCORE: \(\S*\).*/\1/p' $output)" + kernel="$(sed -n 's/^KERNEL VERSION: \(\S*\).*/\1/p' $output)" + if [ -n "$vmcore" ]; then + echo "You can retrive the verify the vmcore file using following command:" + echo "./scripts/copy-from-image.sh \\" + echo " $image \\" + echo " $vmcore ./" + echo "Kernel package verion is: $kernel" + fi + done done echo "======== Test results ========" From bcaa4358b117c496cd4aaeadd0bdc2b1aef886cf Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 11 Aug 2020 17:50:07 +0800 Subject: [PATCH 278/806] dracut-module-install: Move systemd conf install code to a function No feature change. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index fbbd21a..3c35aa2 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -787,6 +787,27 @@ kdump_install_random_seed() { bs=$poolsize count=1 2> /dev/null } +kdump_install_systemd_conf() { + # Kdump turns out to require longer default systemd mount timeout + # than 1st kernel(90s by default), we use default 300s for kdump. + grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null + if [ $? -ne 0 ]; then + mkdir -p ${initdir}/etc/systemd/system.conf.d + echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf + echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf + fi + + # Forward logs to console directly, this avoids unneccessary memory + # consumption and make console output more useful. + # Only do so for non fadump image. + if ! is_fadump_capable; then + mkdir -p ${initdir}/etc/systemd/journald.conf.d + echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + fi +} + install() { kdump_install_conf overwrite_sysctl_conf @@ -826,6 +847,8 @@ install() { # at some point of time. kdump_check_iscsi_targets + kdump_install_systemd_conf + # nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail if is_nfs_dump_target || is_ssh_dump_target; then inst "ip" @@ -840,25 +863,8 @@ install() { 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ ${initdir}/etc/lvm/lvm.conf &>/dev/null - # Kdump turns out to require longer default systemd mount timeout - # than 1st kernel(90s by default), we use default 300s for kdump. - grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null - if [ $? -ne 0 ]; then - mkdir -p ${initdir}/etc/systemd/system.conf.d - echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf - echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf - fi - - # Forward logs to console directly, this avoids unneccessary memory - # consumption and make console output more useful. - # Only do so for non fadump image. + # Save more memory by dropping switch root capability if ! is_fadump_capable; then - mkdir -p ${initdir}/etc/systemd/journald.conf.d - echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - - # Save more memory by dropping switch root capability dracut_no_switch_root fi } From 041ba89902961b5490a7143d9596dc00d732cba0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 11 Aug 2020 17:50:08 +0800 Subject: [PATCH 279/806] Don't drop journalctl content if failure action is "shell" If failure action is set to "shell", user will need more debug info available in kdump kernel. Especially when serial console is not available, manually retrieve the log from journalctl is very useful for debugging kdump issue. Else, we can still drop journalctl content to save memory assuming nothing will use it. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3c35aa2..a186570 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -788,6 +788,8 @@ kdump_install_random_seed() { } kdump_install_systemd_conf() { + local failure_action=$(get_option_value "failure_action") + # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null @@ -800,7 +802,7 @@ kdump_install_systemd_conf() { # Forward logs to console directly, this avoids unneccessary memory # consumption and make console output more useful. # Only do so for non fadump image. - if ! is_fadump_capable; then + if ! is_fadump_capable && [ "$failure_action" != "shell" ]; then mkdir -p ${initdir}/etc/systemd/journald.conf.d echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf From 21f5f95b06811c5c73392be513f0eabef355248e Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 15 Sep 2020 21:21:28 +0800 Subject: [PATCH 280/806] kdump-lib.sh: detect secure boot on s390 On s390, if Secure-IPL is enabled, then "kexec -s -l" is required. Otherwise kdump kernel can not be loaded. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index e18c473..6b9ac20 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -612,6 +612,7 @@ is_secure_boot_enforced() return 0 fi + # Detect secure boot on x86 and arm64 secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) @@ -624,6 +625,11 @@ is_secure_boot_enforced() fi fi + # Detect secure boot on s390x + if [[ -e "/sys/firmware/ipl/secure" && "$(cat /sys/firmware/ipl/secure)" == "1" ]]; then + return 0 + fi + return 1 } From 08276e9f7ab258918fa440f23cf8c26e6be7527f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 21 Aug 2020 01:35:20 +0800 Subject: [PATCH 281/806] Rework check_config and warn on any duplicated option Instead of read and parse the kdump.conf multiple times, only read once and use a single loop to handle the error check, which is faster. Also check for any duplicated config otion, and error out if there are duplicated ones. Now it checks for following errors, most are unchanged from before: - Any duplicated config options. (New added) - Deprecated/Invalid kdump config option. - Duplicated kdump target, will have a different error message of other duplicated config options. - Duplicated --mount options in dracut_args. - Empty config values. All kdump configs should be in " " format. - Check If raw target is used in fadump mode. And removed detect of lines start with space, it will not break kdump anyway. The performance is measurable better than before for the check_config function. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdumpctl | 76 +++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/kdumpctl b/kdumpctl index 2248da4..f191d9a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -217,62 +217,58 @@ restore_default_initrd() check_config() { - local nr - - nr=$(awk 'BEGIN{cnt=0} /^raw|^ssh[[:blank:]]|^nfs|^ext[234]|^xfs|^btrfs|^minix|^dracut_args .*\-\-mount/{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) - [ $nr -gt 1 ] && { - echo "More than one dump targets specified." - return 1 - } - - # Check if path option is set more than once. - nr=$(awk 'BEGIN{cnt=0} /^path /{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) - [ $nr -gt 1 ] && { - echo "Mutiple paths specifed in $KDUMP_CONFIG_FILE" - return 1 - } - - nr=$(grep "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE | grep -o "\-\-mount" | wc -l) - [ $nr -gt 1 ] && { - echo "Multiple mount targets specified in one \"dracut_args\"." - return 1 - } - - # Check if we have any leading spaces (or tabs) before the - # variable name in the kdump conf file - if grep -E -q '^[[:blank:]]+[a-z]' $KDUMP_CONFIG_FILE; then - echo "No whitespaces are allowed before a kdump option name in $KDUMP_CONFIG_FILE" - return 1 - fi - + local -A _opt_rec while read config_opt config_val; do + if [ -z "$config_val" ]; then + echo "Invalid kdump config value for option $config_opt" + return 1 + fi + case "$config_opt" in - \#* | "") - ;; - raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) - # remove inline comments after the end of a directive. - [ -z "$config_val" ] && { - echo "Invalid kdump config value for option $config_opt." - return 1; - } - if [ -d "/proc/device-tree/ibm,opal/dump" ] && [ "$config_opt" == "raw" ]; then - echo "WARNING: Won't capture opalcore when 'raw' dump target is used." + dracut_args) + if [[ $config_val == *--mount* ]]; then + if [ $(echo $config_val | grep -o "\-\-mount" | wc -l) -ne 1 ]; then + echo "Multiple mount targets specified in one \"dracut_args\"." + return 1 + fi + config_opt=_target fi ;; + raw) + if [ -d "/proc/device-tree/ibm,opal/dump" ]; then + echo "WARNING: Won't capture opalcore when 'raw' dump target is used." + return 1 + fi + config_opt=_target + ;; + ext[234]|minix|btrfs|xfs|nfs|ssh) + config_opt=_target + ;; + sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|fence_kdump_args|fence_kdump_nodes) + ;; net|options|link_delay|disk_timeout|debug_mem_level|blacklist) echo "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." return 1 ;; *) echo "Invalid kdump config option $config_opt" - return 1; + return 1 ;; esac + + if [ -n "${_opt_rec[$config_opt]}" ]; then + if [ $config_opt == _target ]; then + echo "More than one dump targets specified" + else + echo "Duplicated kdump config value of option $config_opt" + fi + return 1 + fi + _opt_rec[$config_opt]="$config_val" done <<< "$(read_strip_comments $KDUMP_CONFIG_FILE)" check_failure_action_config || return 1 check_final_action_config || return 1 - check_fence_kdump_config || return 1 return 0 From 41b3da399682c6b72d4e609d334f078a7dd10ed8 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:21 +0800 Subject: [PATCH 282/806] introduce the kdump logger from the dracut Currently, all messages are directly printed to the console, sometimes, we also need to output these messages to the journal log according to the log level. In view of this, introduce the kdump logger from the dracut module. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-logger.sh | 334 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100755 kdump-logger.sh diff --git a/kdump-logger.sh b/kdump-logger.sh new file mode 100755 index 0000000..c7afa34 --- /dev/null +++ b/kdump-logger.sh @@ -0,0 +1,334 @@ +#!/bin/bash +# +# This comes from the dracut-logger.sh +# +# The logger defined 6 logging levels: +# - dtrace() (6) +# The TRACE Level designates finer-grained informational events than the +# DEBUG. +# - ddebug (5) +# The DEBUG Level designates fine-grained informational events that are most +# useful to debug an application. +# - dinfo (4) +# The INFO level designates informational messages that highlight the +# progress of the application at coarse-grained level. +# - dwarn (3) +# The WARN level designates potentially harmful situations. +# - derror (2) +# The ERROR level designates error events that might still allow the +# application to continue running. +# - dfatal (1) +# The FATAL level designates very severe error events that will presumably +# lead the application to abort. +# +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl = 4 (info) +# - @var kdump_sysloglvl = 4 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) +# +# First of all you have to start with dlog_init() function which initializes +# required variables. Don't call any other logging function before that one! +# +# @brief Initializes Logger. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +dlog_init() { + local ret=0; local errmsg + [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4 + [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4 + [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 + # Skip initialization if it's already done. + [ -n "$kdump_maxloglvl" ] && return 0 + + if [[ $UID -ne 0 ]]; then + kdump_kmsgloglvl=0 + kdump_sysloglvl=0 + fi + + if [[ $kdump_sysloglvl -gt 0 ]]; then + if [[ -d /run/systemd/journal ]] \ + && type -P systemd-cat &>/dev/null \ + && systemctl --quiet is-active systemd-journald.socket &>/dev/null; then + readonly _systemdcatfile="/var/tmp/systemd-cat" + mkfifo "$_systemdcatfile" &>/dev/null + readonly _dlogfd=15 + systemd-cat -t 'kdump' --level-prefix=true <"$_systemdcatfile" & + exec 15>"$_systemdcatfile" + elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then + # We cannot log to syslog, so turn this facility off. + kdump_kmsgloglvl=$kdump_sysloglvl + kdump_sysloglvl=0 + ret=1 + errmsg="No '/dev/log' or 'logger' included for syslog logging" + fi + fi + + local lvl; local maxloglvl_l=0 + for lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do + [[ $lvl -gt $maxloglvl_l ]] && maxloglvl_l=$lvl + done + readonly kdump_maxloglvl=$maxloglvl_l + export kdump_maxloglvl + + + if [[ $kdump_stdloglvl -lt 6 ]] && [[ $kdump_kmsgloglvl -lt 6 ]] && [[ $kdump_sysloglvl -lt 6 ]]; then + unset dtrace + dtrace() { :; }; + fi + + if [[ $kdump_stdloglvl -lt 5 ]] && [[ $kdump_kmsgloglvl -lt 5 ]] && [[ $kdump_sysloglvl -lt 5 ]]; then + unset ddebug + ddebug() { :; }; + fi + + if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then + unset dinfo + dinfo() { :; }; + fi + + if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then + unset dwarn + dwarn() { :; }; + unset dwarning + dwarning() { :; }; + fi + + if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then + unset derror + derror() { :; }; + fi + + if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then + unset dfatal + dfatal() { :; }; + fi + + [ -n "$errmsg" ] && derror "$errmsg" + + return $ret +} + +## @brief Converts numeric logging level to the first letter of level name. +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes first letter of level name. +_lvl2char() { + case "$1" in + 1) echo F;; + 2) echo E;; + 3) echo W;; + 4) echo I;; + 5) echo D;; + 6) echo T;; + *) return 1;; + esac +} + +## @brief Converts numeric level to logger priority defined by POSIX.2. +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes logger priority. +_lvl2syspri() { + case "$1" in + 1) echo crit;; + 2) echo error;; + 3) echo warning;; + 4) echo info;; + 5) echo debug;; + 6) echo debug;; + *) return 1;; + esac +} + +## @brief Converts logger numeric level to syslog log level +# +# @param lvl Numeric logging level in range from 1 to 6. +# @retval 1 if @a lvl is out of range. +# @retval 0 if @a lvl is correct. +# @result Echoes kernel console numeric log level +# +# Conversion is done as follows: +# +# +# none -> LOG_EMERG (0) +# none -> LOG_ALERT (1) +# FATAL(1) -> LOG_CRIT (2) +# ERROR(2) -> LOG_ERR (3) +# WARN(3) -> LOG_WARNING (4) +# none -> LOG_NOTICE (5) +# INFO(4) -> LOG_INFO (6) +# DEBUG(5) -> LOG_DEBUG (7) +# TRACE(6) / +# +# +# @see /usr/include/sys/syslog.h +_dlvl2syslvl() { + local lvl + + case "$1" in + 1) lvl=2;; + 2) lvl=3;; + 3) lvl=4;; + 4) lvl=6;; + 5) lvl=7;; + 6) lvl=7;; + *) return 1;; + esac + + [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl)) +} + +## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg +# given message with given level (priority). +# +# @param lvl Numeric logging level. +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +# +# @note This function is not supposed to be called manually. Please use +# dtrace(), ddebug(), or others instead which wrap this one. +# +# This is core logging function which logs given message to standard error, file +# and/or syslog (with POSIX shell command logger) and/or to /dev/kmsg. +# The format is following: +# +# X: some message +# +# where @c X is the first letter of logging level. See module description for +# details on that. +# +# Message to syslog is sent with tag @c kdump. Priorities are mapped as +# following: +# - @c FATAL to @c crit +# - @c ERROR to @c error +# - @c WARN to @c warning +# - @c INFO to @c info +# - @c DEBUG and @c TRACE both to @c debug +_do_dlog() { + local lvl="$1"; shift + local lvlc=$(_lvl2char "$lvl") || return 0 + local msg="$*" + local lmsg="$lvlc: $*" + + [[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2 + + if [[ $lvl -le $kdump_sysloglvl ]]; then + if [[ "$_dlogfd" ]]; then + printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd + else + logger -t "kdump[$$]" -p $(_lvl2syspri $lvl) -- "$msg" + fi + fi + + [[ $lvl -le $kdump_kmsgloglvl ]] && \ + echo "<$(_dlvl2syslvl $lvl)>kdump[$$] $msg" >/dev/kmsg +} + +## @brief Internal helper function for _do_dlog() +# +# @param lvl Numeric logging level. +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +# +# @note This function is not supposed to be called manually. Please use +# dtrace(), ddebug(), or others instead which wrap this one. +# +# This function calls _do_dlog() either with parameter msg, or if +# none is given, it will read standard input and will use every line as +# a message. +# +# This enables: +# dwarn "This is a warning" +# echo "This is a warning" | dwarn +dlog() { + [ -z "$kdump_maxloglvl" ] && return 0 + [[ $1 -le $kdump_maxloglvl ]] || return 0 + + if [[ $# -gt 1 ]]; then + _do_dlog "$@" + else + while read line || [ -n "$line" ]; do + _do_dlog "$1" "$line" + done + fi +} + +## @brief Logs message at TRACE level (6) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dtrace() { + set +x + dlog 6 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at DEBUG level (5) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +ddebug() { + set +x + dlog 5 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at INFO level (4) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dinfo() { + set +x + dlog 4 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at WARN level (3) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dwarn() { + set +x + dlog 3 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief It's an alias to dwarn() function. +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dwarning() { + set +x + dwarn "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at ERROR level (2) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +derror() { + set +x + dlog 2 "$@" + [ -n "$debug" ] && set -x || : +} + +## @brief Logs message at FATAL level (1) +# +# @param msg Message. +# @retval 0 It's always returned, even if logging failed. +dfatal() { + set +x + dlog 1 "$@" + [ -n "$debug" ] && set -x || : +} From 3b743ae6aee36921800629b0fe9e80acc2e6f59f Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:22 +0800 Subject: [PATCH 283/806] enable the logger for kdump Since the logger was introduced into kdump, let's enable it for kdump so that we can output kdump messages according the log level and save these messages for debugging. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-early-kdump-module-setup.sh | 3 + dracut-early-kdump.sh | 23 ++- kdump-lib.sh | 23 +-- kdumpctl | 221 ++++++++++++++++------------- kexec-tools.spec | 2 + mkdumprd | 23 ++- 6 files changed, 173 insertions(+), 122 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index f30bd67..3b23383 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -48,7 +48,10 @@ install() { inst_simple "/etc/sysconfig/kdump" inst_binary "/usr/sbin/kexec" inst_binary "/usr/bin/gawk" "/usr/bin/awk" + inst_binary "/usr/bin/logger" "/usr/bin/logger" + inst_binary "/usr/bin/printf" "/usr/bin/printf" inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" + inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" inst_hook cmdline 00 "$moddir/early-kdump.sh" inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 92913fb..23bb369 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -13,6 +13,13 @@ EARLY_KEXEC_ARGS="" . /lib/dracut-lib.sh . /lib/kdump-lib.sh +#initiate the kdump logger +dlog_init +if [ $? -ne 0 ]; then + echo "failed to initiate the kdump logger." + exit 1 +fi + prepare_parameters() { EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") @@ -28,7 +35,7 @@ early_kdump_load() fi if is_fadump_capable; then - echo "WARNING: early kdump doesn't support fadump." + dwarn "WARNING: early kdump doesn't support fadump." return 1 fi @@ -42,18 +49,22 @@ early_kdump_load() EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") if is_secure_boot_enforced; then - echo "Secure Boot is enabled. Using kexec file based syscall." + dinfo "Secure Boot is enabled. Using kexec file based syscall." EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" fi + ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ + --command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \ + $EARLY_KDUMP_KERNEL" + $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ --command-line="$EARLY_KDUMP_CMDLINE" \ --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL if [ $? == 0 ]; then - echo "kexec: loaded early-kdump kernel" + dinfo "kexec: loaded early-kdump kernel" return 0 else - echo "kexec: failed to load early-kdump kernel" + derror "kexec: failed to load early-kdump kernel" return 1 fi } @@ -61,10 +72,10 @@ early_kdump_load() set_early_kdump() { if getargbool 0 rd.earlykdump; then - echo "early-kdump is enabled." + dinfo "early-kdump is enabled." early_kdump_load else - echo "early-kdump is disabled." + dinfo "early-kdump is disabled." fi return 0 diff --git a/kdump-lib.sh b/kdump-lib.sh index 6b9ac20..b55d987 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -8,6 +8,12 @@ FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" +if [ -f /lib/kdump/kdump-logger.sh ]; then + . /lib/kdump/kdump-logger.sh +elif [ -f /lib/kdump-logger.sh ]; then + . /lib/kdump-logger.sh +fi + is_fadump_capable() { # Check if firmware-assisted dump is enabled @@ -20,14 +26,10 @@ is_fadump_capable() } perror_exit() { - echo $@ >&2 + derror "$@" exit 1 } -perror() { - echo $@ >&2 -} - is_fs_type_nfs() { [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] @@ -503,7 +505,7 @@ check_crash_mem_reserved() mem_reserved=$(cat /sys/kernel/kexec_crash_size) if [ $mem_reserved -eq 0 ]; then - echo "No memory reserved for crash kernel" + derror "No memory reserved for crash kernel" return 1 fi @@ -513,7 +515,7 @@ check_crash_mem_reserved() check_kdump_feasibility() { if [ ! -e /sys/kernel/kexec_crash_loaded ]; then - echo "Kdump is not supported on this kernel" + derror "Kdump is not supported on this kernel" return 1 fi check_crash_mem_reserved @@ -523,7 +525,7 @@ check_kdump_feasibility() check_current_kdump_status() { if [ ! -f /sys/kernel/kexec_crash_loaded ];then - echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" + derror "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" return 1 fi @@ -651,8 +653,7 @@ prepare_kexec_args() found_elf_args=`echo $kexec_args | grep elf32-core-headers` if [ -n "$found_elf_args" ] then - echo -n "Warning: elf32-core-headers overrides correct elf64 setting" - echo + dwarn "Warning: elf32-core-headers overrides correct elf64 setting" else kexec_args="$kexec_args --elf64-core-headers" fi @@ -703,7 +704,7 @@ prepare_kdump_bootinfo() done if ! [ -e "$KDUMP_KERNEL" ]; then - echo "Failed to detect kdump kernel location" + derror "Failed to detect kdump kernel location" return 1 fi diff --git a/kdumpctl b/kdumpctl index f191d9a..8032c09 100755 --- a/kdumpctl +++ b/kdumpctl @@ -21,10 +21,6 @@ FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" DEFAULT_DUMP_MODE="kdump" image_time=0 -[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut -. $dracutbasedir/dracut-functions.sh -. /lib/kdump/kdump-lib.sh - standard_kexec_args="-p" # Some default values in case /etc/sysconfig/kdump doesn't include @@ -34,13 +30,24 @@ if [ -f /etc/sysconfig/kdump ]; then . /etc/sysconfig/kdump fi +[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut +. $dracutbasedir/dracut-functions.sh +. /lib/kdump/kdump-lib.sh + +#initiate the kdump logger +dlog_init +if [ $? -ne 0 ]; then + echo "failed to initiate the kdump logger." + exit 1 +fi + single_instance_lock() { local rc timeout=5 exec 9>/var/lock/kdump if [ $? -ne 0 ]; then - echo "Create file lock failed" + derror "Create file lock failed" exit 1 fi @@ -48,7 +55,7 @@ single_instance_lock() rc=$? while [ $rc -ne 0 ]; do - echo "Another app is currently holding the kdump lock; waiting for it to exit..." + dinfo "Another app is currently holding the kdump lock; waiting for it to exit..." flock -w $timeout 9 rc=$? done @@ -59,9 +66,10 @@ determine_dump_mode() # Check if firmware-assisted dump is enabled # if yes, set the dump mode as fadump if is_fadump_capable; then - echo "Dump mode is fadump" + dinfo "Dump mode is fadump" DEFAULT_DUMP_MODE="fadump" fi + ddebug "DEFAULT_DUMP_MODE=$DEFAULT_DUMP_MODE" } save_core() @@ -69,22 +77,25 @@ save_core() coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" mkdir -p $coredir + ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete if [ $? == 0 ]; then mv $coredir/vmcore-incomplete $coredir/vmcore - echo "saved a vmcore to $coredir" + dinfo "saved a vmcore to $coredir" else - echo "failed to save a vmcore to $coredir" >&2 + derror "failed to save a vmcore to $coredir" fi # pass the dmesg to Abrt tool if exists, in order # to collect the kernel oops message. # https://fedorahosted.org/abrt/ if [ -x /usr/bin/dumpoops ]; then + ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg >/dev/null 2>&1 + ddebug "dumpoops -d $coredir/dmesg" dumpoops -d $coredir/dmesg >/dev/null 2>&1 if [ $? == 0 ]; then - echo "kernel oops has been collected by abrt tool" + dinfo "kernel oops has been collected by abrt tool" fi fi } @@ -96,16 +107,18 @@ rebuild_fadump_initrd() # this file tells the initrd is fadump enabled touch /tmp/fadump.initramfs target_initrd_tmp="$TARGET_INITRD.tmp" + ddebug "rebuild fadump initrd: $target_initrd_tmp $DEFAULT_INITRD_BAK $KDUMP_KERNELVER" $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \ -i /tmp/fadump.initramfs /etc/fadump.initramfs if [ $? != 0 ]; then - echo "mkdumprd: failed to rebuild initrd with fadump support" >&2 + derror "mkdumprd: failed to rebuild initrd with fadump support" rm -f /tmp/fadump.initramfs return 1 fi rm -f /tmp/fadump.initramfs # updating fadump initrd + ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD" mv $target_initrd_tmp $TARGET_INITRD sync @@ -120,14 +133,15 @@ check_earlykdump_is_enabled() rebuild_kdump_initrd() { + ddebug "rebuild kdump initrd: $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER" $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER if [ $? != 0 ]; then - echo "mkdumprd: failed to make kdump initrd" >&2 + derror "mkdumprd: failed to make kdump initrd" return 1 fi if check_earlykdump_is_enabled; then - echo "Tips: If early kdump is enabled, also require rebuilding the system initramfs to make the changes take effect for early kdump." + dwarn "Tips: If early kdump is enabled, also require rebuilding the system initramfs to make the changes take effect for early kdump." fi return 0 @@ -136,7 +150,7 @@ rebuild_kdump_initrd() rebuild_initrd() { if [[ ! -w "$KDUMP_BOOTDIR" ]];then - echo "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" + derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" return 1 fi @@ -154,7 +168,7 @@ check_exist() { for file in $1; do if [ ! -e "$file" ]; then - echo -n "Error: $file not found."; echo + derror "Error: $file not found." return 1 fi done @@ -165,7 +179,7 @@ check_executable() { for file in $1; do if [ ! -x "$file" ]; then - echo -n "Error: $file is not executable."; echo + derror "Error: $file is not executable." return 1 fi done @@ -173,17 +187,19 @@ check_executable() backup_default_initrd() { + ddebug "backup default initrd: $DEFAULT_INITRD" + if [ ! -f "$DEFAULT_INITRD" ]; then return fi if [ ! -e $DEFAULT_INITRD_BAK ]; then - echo "Backing up $DEFAULT_INITRD before rebuild." + dinfo "Backing up $DEFAULT_INITRD before rebuild." # save checksum to verify before restoring sha1sum $DEFAULT_INITRD > $INITRD_CHECKSUM_LOCATION cp $DEFAULT_INITRD $DEFAULT_INITRD_BAK if [ $? -ne 0 ]; then - echo "WARNING: failed to backup $DEFAULT_INITRD." + dwarn "WARNING: failed to backup $DEFAULT_INITRD." rm -f $DEFAULT_INITRD_BAK fi fi @@ -191,6 +207,8 @@ backup_default_initrd() restore_default_initrd() { + ddebug "restore default initrd: $DEFAULT_INITRD" + if [ ! -f "$DEFAULT_INITRD" ]; then return fi @@ -202,13 +220,12 @@ restore_default_initrd() backup_checksum=`sha1sum $DEFAULT_INITRD_BAK | awk '{ print $1 }'` default_checksum=`cat $INITRD_CHECKSUM_LOCATION | awk '{ print $1 }'` if [ "$default_checksum" != "$backup_checksum" ]; then - echo "WARNING: checksum mismatch! Can't restore original initrd.." + dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else rm -f $INITRD_CHECKSUM_LOCATION mv $DEFAULT_INITRD_BAK $DEFAULT_INITRD if [[ $? -eq 0 ]]; then - echo -n "Restoring original initrd as fadump mode " - echo "is disabled." + derror "Restoring original initrd as fadump mode is disabled." sync fi fi @@ -220,7 +237,7 @@ check_config() local -A _opt_rec while read config_opt config_val; do if [ -z "$config_val" ]; then - echo "Invalid kdump config value for option $config_opt" + derror "Invalid kdump config value for option $config_opt" return 1 fi @@ -228,7 +245,7 @@ check_config() dracut_args) if [[ $config_val == *--mount* ]]; then if [ $(echo $config_val | grep -o "\-\-mount" | wc -l) -ne 1 ]; then - echo "Multiple mount targets specified in one \"dracut_args\"." + derror "Multiple mount targets specified in one \"dracut_args\"." return 1 fi config_opt=_target @@ -236,7 +253,7 @@ check_config() ;; raw) if [ -d "/proc/device-tree/ibm,opal/dump" ]; then - echo "WARNING: Won't capture opalcore when 'raw' dump target is used." + derror "WARNING: Won't capture opalcore when 'raw' dump target is used." return 1 fi config_opt=_target @@ -247,20 +264,20 @@ check_config() sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|fence_kdump_args|fence_kdump_nodes) ;; net|options|link_delay|disk_timeout|debug_mem_level|blacklist) - echo "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." + derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." return 1 ;; *) - echo "Invalid kdump config option $config_opt" + derror "Invalid kdump config option $config_opt" return 1 ;; esac if [ -n "${_opt_rec[$config_opt]}" ]; then if [ $config_opt == _target ]; then - echo "More than one dump targets specified" + derror "More than one dump targets specified" else - echo "Duplicated kdump config value of option $config_opt" + derror "Duplicated kdump config value of option $config_opt" fi return 1 fi @@ -305,6 +322,7 @@ setup_initrd() { prepare_kdump_bootinfo if [ $? -ne 0 ]; then + derror "failed to prepare for kdump bootinfo." return 1 fi @@ -375,7 +393,7 @@ check_files_modified() else # If it's not a module nor builtin, give an error if ! ( modprobe --set-version "$KDUMP_KERNELVER" --dry-run "$_module" &>/dev/null ); then - echo "Module $_module not found" + dwarn "Module $_module not found" fi fi done @@ -400,13 +418,12 @@ check_files_modified() fi fi else - echo "$file doesn't exist" + dwarn "$file doesn't exist" fi done if [ -n "$modified_files" ]; then - echo "Detected change(s) in the following file(s):" - echo -n " "; echo "$modified_files" | sed 's/\s/\n /g' + dinfo "Detected change(s) in the following file(s): $modified_files" return 1 fi @@ -444,13 +461,16 @@ check_dump_fs_modified() _target=$(to_dev_name $_target) _new_fstype=$(get_fs_type_from_target $_target) if [[ -z "$_target" || -z "$_new_fstype" ]];then - echo "Dump path $_path does not exist" + derror "Dump path $_path does not exist" return 2 fi fi + ddebug "_target=$_target _path=$_path _new_fstype=$_new_fstype" + _record_block_drivers() { local _drivers + if [[ -b /dev/block/$1 ]]; then _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') fi @@ -462,6 +482,7 @@ check_dump_fs_modified() _target_drivers="$_target_drivers $_driver" fi done + ddebug "MAJ:MIN=$1 _drivers=$_drivers _target_drivers=$_targer_drivers" return 1 } @@ -474,7 +495,7 @@ check_dump_fs_modified() continue fi if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then - echo "Detected change in block device driver, new loaded module: $_module_name" + dinfo "Detected change in block device driver, new loaded module: $_module_name" return 1 fi done @@ -484,7 +505,7 @@ check_dump_fs_modified() else _new_dev=$(kdump_get_persistent_dev $_target) if [ -z "$_new_dev" ]; then - echo "Get persistent device name failed" + derror "Get persistent device name failed" return 2 fi fi @@ -492,7 +513,7 @@ check_dump_fs_modified() _new_mntpoint="$(get_kdump_mntpoint_from_target $_target)" _dracut_args=$(lsinitrd $TARGET_INITRD -f usr/lib/dracut/build-parameter.txt) if [[ -z "$_dracut_args" ]];then - echo "Warning: No dracut arguments found in initrd" + dwarn "Warning: No dracut arguments found in initrd" return 0 fi @@ -510,7 +531,7 @@ check_dump_fs_modified() [[ "$_target" = "$(get_root_fs_device)" ]] && return 0 fi - echo "Detected change in File System" + dinfo "Detected change in File System" return 1 } @@ -593,7 +614,7 @@ check_system_modified() check_wdt_modified if [ $? -ne 0 ]; then - echo "Detected change in watchdog state" + dinfo "Detected change in watchdog state" return 1 fi @@ -617,7 +638,7 @@ check_rebuild() if [ $? -eq 0 ]; then force_no_rebuild=`echo $_force_no_rebuild | cut -d' ' -f2` if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then - echo "Error: force_no_rebuild value is invalid" + derror "Error: force_no_rebuild value is invalid" return 1 fi fi @@ -626,13 +647,13 @@ check_rebuild() if [ $? -eq 0 ]; then force_rebuild=`echo $_force_rebuild | cut -d' ' -f2` if [ "$force_rebuild" != "0" ] && [ "$force_rebuild" != "1" ];then - echo "Error: force_rebuild value is invalid" + derror "Error: force_rebuild value is invalid" return 1 fi fi if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then - echo "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf" + derror "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf" return 1 fi @@ -662,18 +683,18 @@ check_rebuild() fi if [ $image_time -eq 0 ]; then - echo -n "No kdump initial ramdisk found."; echo + dinfo "No kdump initial ramdisk found." elif [ "$capture_capable_initrd" == "0" ]; then - echo -n "Rebuild $TARGET_INITRD with dump capture support"; echo + dinfo "Rebuild $TARGET_INITRD with dump capture support" elif [ "$force_rebuild" != "0" ]; then - echo -n "Force rebuild $TARGET_INITRD"; echo + dinfo "Force rebuild $TARGET_INITRD" elif [ "$system_modified" != "0" ]; then : else return 0 fi - echo "Rebuilding $TARGET_INITRD" + dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd return $? } @@ -690,18 +711,20 @@ load_kdump() # Old syscall will always fail as it does not have capability to # to kernel signature verification. if is_secure_boot_enforced; then - echo "Secure Boot is enabled. Using kexec file based syscall." + dinfo "Secure Boot is enabled. Using kexec file based syscall." KEXEC_ARGS="$KEXEC_ARGS -s" fi + ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL" + $KEXEC $KEXEC_ARGS $standard_kexec_args \ --command-line="$KDUMP_COMMANDLINE" \ --initrd=$TARGET_INITRD $KDUMP_KERNEL if [ $? == 0 ]; then - echo "kexec: loaded kdump kernel" + dinfo "kexec: loaded kdump kernel" return 0 else - echo "kexec: failed to load kdump kernel" >&2 + derror "kexec: failed to load kdump kernel" return 1 fi } @@ -716,7 +739,7 @@ check_ssh_config() # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m $config_val) else - echo "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" + dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" fi ;; path) @@ -758,22 +781,22 @@ check_and_wait_network_ready() if [ $retval -eq 0 ]; then return 0 elif [ $retval -ne 255 ]; then - echo "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" >&2 + derror "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" return 1 fi # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa - echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" + ddebug "$errmsg" + echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" &> /dev/null if [ $? -eq 0 ]; then - echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2 + derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" return 1 fi if [ $warn_once -eq 1 ]; then - echo "Network dump target is not usable, waiting for it to be ready" + dwarn "Network dump target is not usable, waiting for it to be ready..." warn_once=0 fi - echo -n . cur=$(date +%s) let "diff = $cur - $start_time" @@ -784,7 +807,7 @@ check_and_wait_network_ready() sleep 1 done - echo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" >&2 + dinfo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" return 1 } @@ -801,7 +824,7 @@ propagate_ssh_key() { check_ssh_config if [ $? -ne 0 ]; then - echo "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate" >&2 + derror "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate" exit 1 fi @@ -810,11 +833,11 @@ propagate_ssh_key() #Check to see if we already created key, if not, create it. if [ -f $KEYFILE ]; then - echo "Using existing keys..." + dinfo "Using existing keys..." else - echo -n "Generating new ssh keys... " + dinfo "Generating new ssh keys... " /usr/bin/ssh-keygen -t rsa -f $KEYFILE -N "" 2>&1 > /dev/null - echo "done." + dinfo "done." fi #now find the target ssh user and server to contact. @@ -825,10 +848,10 @@ propagate_ssh_key() ssh-copy-id -i $KEYFILE $SSH_USER@$SSH_SERVER RET=$? if [ $RET == 0 ]; then - echo $KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER + dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER" return 0 else - echo $errmsg, $KEYFILE failed in transfer to $SSH_SERVER >&2 + derror "$errmsg, $KEYFILE failed in transfer to $SSH_SERVER" exit 1 fi } @@ -838,7 +861,7 @@ show_reserved_mem() local mem=$(cat /sys/kernel/kexec_crash_size) local mem_mb=$(expr $mem / 1024 / 1024) - echo "Reserved "$mem_mb"MB memory for crash kernel" + dinfo "Reserved "$mem_mb"MB memory for crash kernel" } check_current_fadump_status() @@ -868,12 +891,12 @@ save_raw() raw_target=$(awk '$1 ~ /^raw$/ { print $2; }' $KDUMP_CONFIG_FILE) [ -z "$raw_target" ] && return 0 [ -b "$raw_target" ] || { - echo "raw partition $raw_target not found" + derror "raw partition $raw_target not found" return 1 } check_fs=$(lsblk --nodeps -npo FSTYPE $raw_target) if [[ $(echo $check_fs | wc -w) -ne 0 ]]; then - echo "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." + dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." return 0 fi kdump_dir=`grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2-` @@ -885,12 +908,12 @@ save_raw() mkdir -p "$coredir" [ -d "$coredir" ] || { - echo "failed to create $coredir" + derror "failed to create $coredir" return 1 } if makedumpfile -R $coredir/vmcore <$raw_target >/dev/null 2>&1; then # dump found - echo "Dump saved to $coredir/vmcore" + dinfo "Dump saved to $coredir/vmcore" # wipe makedumpfile header dd if=/dev/zero of=$raw_target bs=1b count=1 2>/dev/null else @@ -963,13 +986,13 @@ check_fence_kdump_config() for node in $nodes; do if [ "$node" = "$hostname" ]; then - echo "Option fence_kdump_nodes cannot contain $hostname" + derror "Option fence_kdump_nodes cannot contain $hostname" return 1 fi # node can be ipaddr echo $ipaddrs | grep $node > /dev/null if [ $? -eq 0 ]; then - echo "Option fence_kdump_nodes cannot contain $node" + derror "Option fence_kdump_nodes cannot contain $node" return 1 fi done @@ -991,11 +1014,11 @@ start_fadump() { echo 1 > $FADUMP_REGISTER_SYS_NODE if ! check_current_fadump_status; then - echo "fadump: failed to register" + derror "fadump: failed to register" return 1 fi - echo "fadump: registered successfully" + dinfo "fadump: registered successfully" return 0 } @@ -1022,7 +1045,7 @@ check_failure_action_config() if [ -z "$failure_action" -a -z "$default_option" ]; then return 0 elif [ -n "$failure_action" -a -n "$default_option" ]; then - echo "Cannot specify 'failure_action' and 'default' option together" + derror "Cannot specify 'failure_action' and 'default' option together" return 1 fi @@ -1036,7 +1059,7 @@ check_failure_action_config() return 0 ;; *) - echo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" + dinfo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" return 1 esac } @@ -1054,7 +1077,7 @@ check_final_action_config() return 0 ;; *) - echo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" + dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" return 1 esac fi @@ -1064,13 +1087,13 @@ start() { check_dump_feasibility if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi check_config if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi @@ -1080,43 +1103,43 @@ start() save_raw if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi check_current_status if [ $? == 0 ]; then - echo "Kdump already running: [WARNING]" + dwarn "Kdump already running: [WARNING]" return 0 fi if check_ssh_config; then if ! check_ssh_target; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi fi check_rebuild if [ $? != 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi start_dump if [ $? != 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi - echo "Starting kdump: [OK]" + dinfo "Starting kdump: [OK]" } reload() { check_current_status if [ $? -ne 0 ]; then - echo "Kdump was not running: [WARNING]" + dwarn "Kdump was not running: [WARNING]" fi if [ $DEFAULT_DUMP_MODE == "fadump" ]; then @@ -1127,36 +1150,36 @@ reload() fi if [ $? -ne 0 ]; then - echo "Stopping kdump: [FAILED]" + derror "Stopping kdump: [FAILED]" return 1 fi - echo "Stopping kdump: [OK]" + dinfo "Stopping kdump: [OK]" setup_initrd if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi start_dump if [ $? -ne 0 ]; then - echo "Starting kdump: [FAILED]" + derror "Starting kdump: [FAILED]" return 1 fi - echo "Starting kdump: [OK]" + dinfo "Starting kdump: [OK]" } stop_fadump() { echo 0 > $FADUMP_REGISTER_SYS_NODE if check_current_fadump_status; then - echo "fadump: failed to unregister" + derror "fadump: failed to unregister" return 1 fi - echo "fadump: unregistered successfully" + dinfo "fadump: unregistered successfully" return 0 } @@ -1169,11 +1192,11 @@ stop_kdump() fi if [ $? != 0 ]; then - echo "kexec: failed to unload kdump kernel" + derror "kexec: failed to unload kdump kernel" return 1 fi - echo "kexec: unloaded kdump kernel" + dinfo "kexec: unloaded kdump kernel" return 0 } @@ -1181,7 +1204,7 @@ reload_fadump() { echo 1 > $FADUMP_REGISTER_SYS_NODE if [ $? == 0 ]; then - echo "fadump: re-registered successfully" + dinfo "fadump: re-registered successfully" return 0 else # FADump could fail on older kernel where re-register @@ -1206,11 +1229,11 @@ stop() fi if [ $? != 0 ]; then - echo "Stopping kdump: [FAILED]" + derror "Stopping kdump: [FAILED]" return 1 fi - echo "Stopping kdump: [OK]" + dinfo "Stopping kdump: [OK]" return 0 } @@ -1231,13 +1254,13 @@ rebuild() { return 1 fi - echo "Rebuilding $TARGET_INITRD" + dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd return $? } if [ ! -f "$KDUMP_CONFIG_FILE" ]; then - echo "Error: No kdump config file found!" >&2 + derror "Error: No kdump config file found!" exit 1 fi @@ -1263,11 +1286,11 @@ main () check_current_status case "$?" in 0) - echo "Kdump is operational" + dinfo "Kdump is operational" EXIT_CODE=0 ;; 1) - echo "Kdump is not operational" + dinfo "Kdump is not operational" EXIT_CODE=3 ;; esac @@ -1292,7 +1315,7 @@ main () show_reserved_mem ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem}" + dinfo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem}" exit 1 esac } diff --git a/kexec-tools.spec b/kexec-tools.spec index 669fd6c..f6c0129 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -37,6 +37,7 @@ Source27: early-kdump-howto.txt Source28: kdump-udev-throttler Source29: kdump.sysconfig.aarch64 Source30: 60-kdump.install +Source31: kdump-logger.sh ####################################### # These are sources for mkdumpramfs @@ -190,6 +191,7 @@ install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh +install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh %ifnarch s390x install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler %endif diff --git a/mkdumprd b/mkdumprd index 36f71b7..2f3e7f7 100644 --- a/mkdumprd +++ b/mkdumprd @@ -6,11 +6,22 @@ # Written by Cong Wang # +if [ -f /etc/sysconfig/kdump ]; then + . /etc/sysconfig/kdump +fi + [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh . /lib/kdump/kdump-lib.sh export IN_KDUMP=1 +#initiate the kdump logger +dlog_init +if [ $? -ne 0 ]; then + echo "failed to initiate the kdump logger." + exit 1 +fi + conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" SAVE_PATH=$(get_save_path) @@ -180,8 +191,8 @@ check_size() { fi if [ $avail -lt $memtotal ]; then - echo "Warning: There might not be enough space to save a vmcore." - echo " The size of $2 should be greater than $memtotal kilo bytes." + dwarn "Warning: There might not be enough space to save a vmcore." + dwarn " The size of $2 should be greater than $memtotal kilo bytes." fi } @@ -253,7 +264,7 @@ verify_core_collector() { 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." + dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." fi return fi @@ -343,7 +354,7 @@ is_unresettable() resettable="$(cat $path)" [ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && { local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}') - echo "Error: Can not save vmcore because device $device is unresettable" + derror "Error: Can not save vmcore because device $device is unresettable" return 0 } fi @@ -377,7 +388,7 @@ is_crypt() eval "$line" [[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && { dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}') - echo "Device $dev is encrypted." + derror "Device $dev is encrypted." return 0 } return 1 @@ -400,7 +411,7 @@ if ! check_resettable; then fi if ! check_crypt; then - echo "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." + dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." fi # firstly get right SSH_KEY_LOCATION From d001bd177fc6903fb5ac010d8fbbe97cbacf93ff Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:23 +0800 Subject: [PATCH 284/806] kdump.sysconfig: add the kdump logger configurations The kdump logger has the default values of the log levels, but sometimes, need to change the value of log level in order to get more debugging messages for troubleshooting. Here, user will have a chance to reconfigure it. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump.sysconfig | 16 ++++++++++++++++ kdump.sysconfig.aarch64 | 16 ++++++++++++++++ kdump.sysconfig.i386 | 16 ++++++++++++++++ kdump.sysconfig.ppc64 | 16 ++++++++++++++++ kdump.sysconfig.ppc64le | 16 ++++++++++++++++ kdump.sysconfig.s390x | 16 ++++++++++++++++ kdump.sysconfig.x86_64 | 16 ++++++++++++++++ 7 files changed, 112 insertions(+) diff --git a/kdump.sysconfig b/kdump.sysconfig index ffc387a..52a0b92 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -35,3 +35,19 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz" + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 6f55c03..1d75979 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -35,3 +35,19 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz" + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 45f6d50..2eb9705 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -38,3 +38,19 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 8dcbe60..24279ff 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -40,3 +40,19 @@ KDUMP_IMG="vmlinuz" KDUMP_IMG_EXT="" #Specify the action after failure + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 8dcbe60..24279ff 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -40,3 +40,19 @@ KDUMP_IMG="vmlinuz" KDUMP_IMG_EXT="" #Specify the action after failure + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 2a24688..232d7d4 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -41,3 +41,19 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index f67d999..eb1c538 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -38,3 +38,19 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" + +# Logging is controlled by following global variables: +# - @var kdump_stdloglvl - logging level to standard error (console output) +# - @var kdump_sysloglvl - logging level to syslog (by logger command) +# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) +# If any of the variables is not set, this function set it to default: +# - @var kdump_stdloglvl=4 (info) +# - @var kdump_sysloglvl=4 (info) +# - @var kdump_kmsgloglvl=0 (no logging) +# +# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# +# For example: the following configurations indicate that kdump messages will be printed +# to console and journald for debugging case. +# kdump_sysloglvl=5 +# kdump_stdloglvl=5 From 88a8b94de9994264f1520441656300d6658801da Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:24 +0800 Subject: [PATCH 285/806] kdumpctl: add the '-d' option to enable the kexec loading debugging messages Currently, the kexec option '--debug/-d' is not enabled by default, which means that users need to set it manually and wait for the next failure to capture the additional information. Therefore, let's enable the option '-d' for kexec loading by default. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdumpctl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 8032c09..344c096 100755 --- a/kdumpctl +++ b/kdumpctl @@ -6,6 +6,7 @@ KDUMP_KERNEL="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" KDUMP_CONFIG_FILE="/etc/kdump.conf" +KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" SAVE_PATH=/var/crash @@ -21,7 +22,7 @@ FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" DEFAULT_DUMP_MODE="kdump" image_time=0 -standard_kexec_args="-p" +standard_kexec_args="-d -p" # Some default values in case /etc/sysconfig/kdump doesn't include KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug" @@ -704,6 +705,8 @@ check_rebuild() # as the currently running kernel. load_kdump() { + local ret + KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") @@ -717,10 +720,20 @@ load_kdump() ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL" + exec 12>&2 + exec 2>> $KDUMP_LOG_PATH/kdump.log + PS4='+ $(date "+%Y-%m-%d %H:%M:%S") ${BASH_SOURCE}@${LINENO}: ' + set -x + $KEXEC $KEXEC_ARGS $standard_kexec_args \ --command-line="$KDUMP_COMMANDLINE" \ --initrd=$TARGET_INITRD $KDUMP_KERNEL - if [ $? == 0 ]; then + + ret=$? + set +x + exec 2>&12 12>&- + + if [ $ret == 0 ]; then dinfo "kexec: loaded kdump kernel" return 0 else From d7054f4cd8e964572a37b78e60f1ed10a0f003ef Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:25 +0800 Subject: [PATCH 286/806] Improve debugging in the kdump kernel Let's use the logger in the second kernel and collect the kernel ring buffer(dmesg) of the second kernel. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-kdump.sh | 68 +++++++++++++++++++++++++----------------- dracut-module-setup.sh | 4 +++ kdump-lib-initramfs.sh | 66 +++++++++++++++++++++++++++++----------- 3 files changed, 94 insertions(+), 44 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 6f948fc..c2627c2 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -5,7 +5,6 @@ if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump exit 0 fi -exec &> /dev/console . /lib/dracut-lib.sh . /lib/kdump-lib-initramfs.sh @@ -22,7 +21,7 @@ do_dump() _ret=$? if [ $_ret -ne 0 ]; then - echo "kdump: saving vmcore failed" + derror "saving vmcore failed" fi return $_ret @@ -36,7 +35,7 @@ do_kdump_pre() "$KDUMP_PRE" _ret=$? if [ $_ret -ne 0 ]; then - echo "kdump: $KDUMP_PRE exited with $_ret status" + derror "$KDUMP_PRE exited with $_ret status" return $_ret fi fi @@ -47,7 +46,7 @@ do_kdump_pre() "$file" _ret=$? if [ $_ret -ne 0 ]; then - echo "kdump: $file exited with $_ret status" + derror "$file exited with $_ret status" fi done fi @@ -63,7 +62,7 @@ do_kdump_post() "$file" "$1" _ret=$? if [ $_ret -ne 0 ]; then - echo "kdump: $file exited with $_ret status" + derror "$file exited with $_ret status" fi done fi @@ -72,7 +71,7 @@ do_kdump_post() "$KDUMP_POST" "$1" _ret=$? if [ $_ret -ne 0 ]; then - echo "kdump: $KDUMP_POST exited with $_ret status" + derror "$KDUMP_POST exited with $_ret status" fi fi } @@ -88,7 +87,7 @@ dump_raw() [ -b "$_raw" ] || return 1 - echo "kdump: saving to raw disk $_raw" + dinfo "saving to raw disk $_raw" if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then _src_size=`ls -l /proc/vmcore | cut -d' ' -f5` @@ -96,21 +95,22 @@ dump_raw() monitor_dd_progress $_src_size_mb & fi - echo "kdump: saving vmcore" + dinfo "saving vmcore" $CORE_COLLECTOR /proc/vmcore | dd of=$_raw bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 sync - echo "kdump: saving vmcore complete" + dinfo "saving vmcore complete" return 0 } dump_ssh() { + local ret local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" local _host=$2 - echo "kdump: saving to $_host:$_dir" + dinfo "saving to $_host:$_dir" cat /var/lib/random-seed > /dev/urandom ssh -q $_opt $_host mkdir -p $_dir || return 1 @@ -118,17 +118,29 @@ dump_ssh() save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host save_opalcore_ssh ${_dir} "${_opt}" $_host - echo "kdump: saving vmcore" + dinfo "saving vmcore" if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" || return 1 + scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" + ret=$? + save_log + scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" + if [ $ret -ne 0 ]; then + return 1 + fi ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1 else - $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" || return 1 + $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" + ret=$? + save_log + scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" + if [ $ret -ne 0 ]; then + return 1 + fi ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore.flat" || return 1 fi - echo "kdump: saving vmcore complete" + dinfo "saving vmcore complete" return 0 } @@ -137,6 +149,8 @@ save_opalcore_ssh() { local _opts="$2" local _location=$3 + ddebug "_path=$_path _opts=$_opts _location=$_location" + if [ ! -f $OPALCORE ]; then # Check if we are on an old kernel that uses a different path if [ -f /sys/firmware/opal/core ]; then @@ -146,15 +160,15 @@ save_opalcore_ssh() { fi fi - echo "kdump: saving opalcore" + dinfo "saving opalcore:$OPALCORE to $_location:$_path" scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete if [ $? -ne 0 ]; then - echo "kdump: saving opalcore failed" + derror "saving opalcore failed" return 1 fi ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore - echo "kdump: saving opalcore complete" + dinfo "saving opalcore complete" return 0 } @@ -164,15 +178,15 @@ save_vmcore_dmesg_ssh() { local _opts="$3" local _location=$4 - echo "kdump: saving vmcore-dmesg.txt" + dinfo "saving vmcore-dmesg.txt to $_location:$_path" $_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt" _exitcode=$? if [ $_exitcode -eq 0 ]; then ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt - echo "kdump: saving vmcore-dmesg.txt complete" + dinfo "saving vmcore-dmesg.txt complete" else - echo "kdump: saving vmcore-dmesg.txt failed" + derror "saving vmcore-dmesg.txt failed" fi } @@ -182,12 +196,12 @@ get_host_ip() if is_nfs_dump_target || is_ssh_dump_target then kdumpnic=$(getarg kdumpnic=) - [ -z "$kdumpnic" ] && echo "kdump: failed to get kdumpnic!" && return 1 + [ -z "$kdumpnic" ] && derror "failed to get kdumpnic!" && return 1 _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` - [ $? -ne 0 ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + [ $? -ne 0 ] && derror "wrong kdumpnic: $kdumpnic" && return 1 _host=`echo $_host | head -n 1 | cut -d' ' -f2` _host="${_host%%/*}" - [ -z "$_host" ] && echo "kdump: wrong kdumpnic: $kdumpnic" && return 1 + [ -z "$_host" ] && derror "wrong kdumpnic: $kdumpnic" && return 1 HOST_IP=$_host fi return 0 @@ -196,7 +210,7 @@ get_host_ip() read_kdump_conf() { if [ ! -f "$KDUMP_CONF" ]; then - echo "kdump: $KDUMP_CONF not found" + derror "$KDUMP_CONF not found" return fi @@ -240,7 +254,7 @@ fence_kdump_notify get_host_ip if [ $? -ne 0 ]; then - echo "kdump: get_host_ip exited with non-zero status!" + derror "get_host_ip exited with non-zero status!" exit 1 fi @@ -250,7 +264,7 @@ fi do_kdump_pre if [ $? -ne 0 ]; then - echo "kdump: kdump_pre script exited with non-zero status!" + derror "kdump_pre script exited with non-zero status!" do_final_action # During systemd service to reboot the machine, stop this shell script running exit 1 @@ -261,7 +275,7 @@ DUMP_RETVAL=$? do_kdump_post $DUMP_RETVAL if [ $? -ne 0 ]; then - echo "kdump: kdump_post script exited with non-zero status!" + derror "kdump_post script exited with non-zero status!" fi if [ $DUMP_RETVAL -ne 0 ]; then diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a186570..b0b30af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -818,6 +818,7 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime + inst_simple "/etc/sysconfig/kdump" inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/dd" "/bin/dd" @@ -830,8 +831,11 @@ install() { inst "/bin/sed" "/bin/sed" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" + inst "/usr/bin/printf" "/sbin/printf" + inst "/usr/bin/logger" "/sbin/logger" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" + inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" mkdir -p "$initdir/$systemdsystemunitdir/initrd.target.wants" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c98a43b..1adcca1 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,8 +1,10 @@ # These variables and functions are useful in 2nd kernel +. /etc/sysconfig/kdump . /lib/kdump-lib.sh KDUMP_PATH="/var/crash" +KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" CORE_COLLECTOR="" DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" DMESG_COLLECTOR="/sbin/vmcore-dmesg" @@ -20,6 +22,13 @@ KDUMP_POST="" NEWROOT="/sysroot" OPALCORE="/sys/firmware/opal/mpipl/core" +#initiate the kdump logger +dlog_init +if [ $? -ne 0 ]; then + echo "failed to initiate the kdump logger." + exit 1 +fi + get_kdump_confs() { local config_opt config_val @@ -94,27 +103,40 @@ get_kdump_confs() fi } +# store the kexec kernel log to a file. +save_log() +{ + dmesg -T > $KDUMP_LOG_FILE + + if command -v journalctl > /dev/null; then + journalctl -ab >> $KDUMP_LOG_FILE + fi +} + # dump_fs dump_fs() { + local ret local _mp=$1 local _dev=$(get_mount_info SOURCE target $_mp -f) local _op=$(get_mount_info OPTIONS target $_mp -f) + ddebug "_mp=$_mp _dev=$_dev _op=$_op" + # If dump path have a corresponding device entry but not mounted, mount it. if [ -n "$_dev" ]; then if ! is_mounted "$_mp"; then - echo "kdump: dump target $_dev is not mounted, trying to mount..." + dinfo "dump target $_dev is not mounted, trying to mount..." mkdir -p $_mp mount -o $_op $_dev $_mp if [ $? -ne 0 ]; then - echo "kdump: mounting failed (mount point: $_mp, option: $_op)" + derror "mounting failed (mount point: $_mp, option: $_op)" return 1 fi fi else - echo "kdump: failed to dump to \"$_mp\", it's not a mount point!" + derror "failed to dump to \"$_mp\", it's not a mount point!" return 1 fi @@ -123,11 +145,11 @@ dump_fs() local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) - echo "kdump: saving to $_dump_path" + dinfo "saving to $_dump_path" # Only remount to read-write mode if the dump target is mounted read-only. if [[ "$_op" = "ro"* ]]; then - echo "kdump: Mounting Dump target $_dev in rw mode." + dinfo "Mounting Dump target $_dev in rw mode." mount -o remount,rw $_dev $_mp || return 1 fi @@ -136,12 +158,18 @@ dump_fs() save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path" save_opalcore_fs "$_dump_path" - echo "kdump: saving vmcore" - $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete || return 1 + dinfo "saving vmcore" + $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete + ret=$? + save_log + mv $KDUMP_LOG_FILE $_dump_path/ + if [ $ret -ne 0 ]; then + return 1 + fi mv $_dump_path/vmcore-incomplete $_dump_path/vmcore sync - echo "kdump: saving vmcore complete" + dinfo "saving vmcore complete" # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure return 0 @@ -151,7 +179,7 @@ save_vmcore_dmesg_fs() { local _dmesg_collector=$1 local _path=$2 - echo "kdump: saving vmcore-dmesg.txt" + dinfo "saving vmcore-dmesg.txt to ${_path}" $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt _exitcode=$? if [ $_exitcode -eq 0 ]; then @@ -161,9 +189,9 @@ save_vmcore_dmesg_fs() { # saving vmcore failed and system rebooted without sync and there # was no vmcore-dmesg.txt available. sync - echo "kdump: saving vmcore-dmesg.txt complete" + dinfo "saving vmcore-dmesg.txt complete" else - echo "kdump: saving vmcore-dmesg.txt failed" + derror "saving vmcore-dmesg.txt failed" fi } @@ -179,43 +207,47 @@ save_opalcore_fs() { fi fi - echo "kdump: saving opalcore" + dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore" cp $OPALCORE ${_path}/opalcore if [ $? -ne 0 ]; then - echo "kdump: saving opalcore failed" + derror "saving opalcore failed" return 1 fi sync - echo "kdump: saving opalcore complete" + dinfo "saving opalcore complete" return 0 } dump_to_rootfs() { - echo "Kdump: trying to bring up rootfs device" + dinfo "Trying to bring up rootfs device" systemctl start dracut-initqueue - echo "Kdump: waiting for rootfs mount, will timeout after 90 seconds" + dinfo "Waiting for rootfs mount, will timeout after 90 seconds" systemctl start sysroot.mount + ddebug "NEWROOT=$NEWROOT" + dump_fs $NEWROOT } kdump_emergency_shell() { echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile + ddebug "Switching to dracut emergency..." /bin/dracut-emergency rm -f /etc/profile } do_failure_action() { - echo "Kdump: Executing failure action $FAILURE_ACTION" + dinfo "Executing failure action $FAILURE_ACTION" eval $FAILURE_ACTION } do_final_action() { + dinfo "Executing final action $FINAL_ACTION" eval $FINAL_ACTION } From d4c6f5645654e3e40bbaa7afee9f58470c6c6af7 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 27 Oct 2020 17:04:26 +0800 Subject: [PATCH 287/806] Doc: add a documentation for the usage of logger Because the logger is introduced to output the kdump logs, need to add a documentation for this change and describe how to use it. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kexec-kdump-howto.txt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 2209e5a..1e97ca7 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -885,3 +885,38 @@ Debugging Tips minicom -C /tmp/console-logs Now minicom should be logging serial console in file console-logs. + +- Using the logger to output kdump log messages + + Currently, kdump messages are printed with the 'echo' command or redirect + to console, and which does not support to output kdump messages according + to the log level. + + That is not convenient to debug kdump issues, we usually need to capture + additional debugging information via the modification of the options or the + scripts like kdumpctl, mkdumprd, etc. Because there is no complete debugging + messages, which could waste valuable time. + + To cope with this challenging, we introduce the logger to output the kdump + messages according to the log level, and provide a chance to save logs to + the journald if the journald service is available, and then dump all logs + to a file, otherwise dump the logs with the dmesg to a file. + + Logging is controlled by following global variables: + - @var kdump_stdloglvl - logging level to standard error (console output) + - @var kdump_sysloglvl - logging level to syslog (by logger command) + - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) + If any of the variables is not set, this function set it to default: + - @var kdump_stdloglvl=4 (info) + - @var kdump_sysloglvl=4 (info) + - @var kdump_kmsgloglvl=0 (no logging) + + Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) + + We can easily configure the above variables in the /etc/sysconfig/kdump. For + example: + kdump_sysloglvl=5 + kdump_stdloglvl=5 + + The above configurations indicate that kdump messages will be printed to the + console and journald if the journald service is enabled. From 46cc7f46b2840399fe653049c4893f16285f7c81 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 27 Oct 2020 15:00:45 +0800 Subject: [PATCH 288/806] module-setup.sh: Instead of drop journalctl log, just don't read kmsg Previously journalctl logs are directly dropped to save memory, but this make journalctl unusable in kdump kernel and diffcult to debug. So instead just don't let it read kmsg but keep other logs stored as volatile. Kernel message are already stored in the kernel log ring buffer, no need to let journalctl make a copy, especially when in kdump kernel, ususlly there won't be too much kernel log overlapping the old ring buffer. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b0b30af..911a8b8 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -799,13 +799,14 @@ kdump_install_systemd_conf() { echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf fi - # Forward logs to console directly, this avoids unneccessary memory - # consumption and make console output more useful. + # Forward logs to console directly, and don't read Kmsg, this avoids + # unneccessary memory consumption and make console output more useful. # Only do so for non fadump image. - if ! is_fadump_capable && [ "$failure_action" != "shell" ]; then + if ! is_fadump_capable; then mkdir -p ${initdir}/etc/systemd/journald.conf.d echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "Storage=none" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf fi } From b9a1f461a8f01e1622201e6c39a2a679c79e4f1a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 27 Oct 2020 17:34:48 +0800 Subject: [PATCH 289/806] Fix error when using raw target with opalcore Commit 08276e9 wrongly raise this warning message to error level, fix this. Fixes: 08276e9 ('Rework check_config and warn on any duplicated option') Signed-off-by: Kairui Song --- kdumpctl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 344c096..e816719 100755 --- a/kdumpctl +++ b/kdumpctl @@ -254,8 +254,7 @@ check_config() ;; raw) if [ -d "/proc/device-tree/ibm,opal/dump" ]; then - derror "WARNING: Won't capture opalcore when 'raw' dump target is used." - return 1 + dwarn "WARNING: Won't capture opalcore when 'raw' dump target is used." fi config_opt=_target ;; From 3221f4e91fa95ac89dd86dd0e2f1145540575de0 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 26 Oct 2020 16:27:05 +0800 Subject: [PATCH 290/806] increase makdumpfile default message level to 7 Currently, the makedumpfile option '--message-level' is set to 1 when dumping the vmcore, it only displays the progress indicator message, but there are no common message and error message, it is important to report some additional messages, especially for the error message, which is very useful for the debugging. In view of this, let's change the message level to 7 by default. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 2 +- kdump.conf | 6 +++--- kdump.conf.5 | 16 ++++++++-------- kexec-kdump-howto.txt | 18 +++++++++--------- tests/scripts/testcases/local-kdump/0-local.sh | 2 +- tests/scripts/testcases/nfs-kdump/1-client.sh | 2 +- tests/scripts/testcases/ssh-kdump/1-client.sh | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 1adcca1..14aac7b 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -6,7 +6,7 @@ KDUMP_PATH="/var/crash" KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" CORE_COLLECTOR="" -DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" +DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31" DMESG_COLLECTOR="/sbin/vmcore-dmesg" FAILURE_ACTION="systemctl reboot -f" DATEDIR=`date +%Y-%m-%d-%T` diff --git a/kdump.conf b/kdump.conf index 9fc0a4f..e4db52e 100644 --- a/kdump.conf +++ b/kdump.conf @@ -62,9 +62,9 @@ # as the initrd will automatically be populated with a # config file appropriate for the running kernel. # The default core_collector for raw/ssh dump is: -# "makedumpfile -F -l --message-level 1 -d 31". +# "makedumpfile -F -l --message-level 7 -d 31". # The default core_collector for other targets is: -# "makedumpfile -l --message-level 1 -d 31". +# "makedumpfile -l --message-level 7 -d 31". # # "makedumpfile -F" will create a flattened vmcore. # You need to use "makedumpfile -R" to rearrange the dump data to @@ -169,7 +169,7 @@ #ssh user@my.server.com #sshkey /root/.ssh/kdump_id_rsa path /var/crash -core_collector makedumpfile -l --message-level 1 -d 31 +core_collector makedumpfile -l --message-level 7 -d 31 #core_collector scp #kdump_post /var/crash/scripts/kdump-post.sh #kdump_pre /var/crash/scripts/kdump-pre.sh diff --git a/kdump.conf.5 b/kdump.conf.5 index 34c996c..4be3c77 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -85,9 +85,9 @@ for the running kernel. .PP Note 1: About default core collector: The default core_collector for raw/ssh dump is: -"makedumpfile -F -l --message-level 1 -d 31". +"makedumpfile -F -l --message-level 7 -d 31". The default core_collector for other targets is: -"makedumpfile -l --message-level 1 -d 31". +"makedumpfile -l --message-level 7 -d 31". Even if core_collector option is commented out in kdump.conf, makedumpfile is the default core collector and kdump uses it internally. If one does not want makedumpfile as default core_collector, then they @@ -307,11 +307,11 @@ Above will effectively be translated to: cp --sparse=always /proc/vmcore /vmcore .TP ex2. -core_collector "makedumpfile -l --message-level 1 -d 31" +core_collector "makedumpfile -l --message-level 7 -d 31" Above will effectively be translated to: -makedumpfile -l --message-level 1 -d 31 /proc/vmcore /vmcore +makedumpfile -l --message-level 7 -d 31 /proc/vmcore /vmcore .PP For dump targets like raw and ssh, in general, core collector should expect one argument (source file) and should output the processed core on standard @@ -328,11 +328,11 @@ Above will effectively be translated to. cat /proc/vmcore | dd of= .TP ex4. -core_collector "makedumpfile -F -l --message-level 1 -d 31" +core_collector "makedumpfile -F -l --message-level 7 -d 31" Above will effectively be translated to. -makedumpfile -F -l --message-level 1 -d 31 | dd of= +makedumpfile -F -l --message-level 7 -d 31 | dd of= .PP ssh dumps examples .TP @@ -344,11 +344,11 @@ Above will effectively be translated to. cat /proc/vmcore | ssh "dd of=path/vmcore" .TP ex6. -core_collector "makedumpfile -F -l --message-level 1 -d 31" +core_collector "makedumpfile -F -l --message-level 7 -d 31" Above will effectively be translated to. -makedumpfile -F -l --message-level 1 -d 31 | ssh "dd of=path/vmcore" +makedumpfile -F -l --message-level 7 -d 31 | ssh "dd of=path/vmcore" There is one exception to standard output rule for ssh dumps. And that is scp. As scp can handle ssh destinations for file transfers, one can diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 1e97ca7..5f57a84 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -613,7 +613,7 @@ is a dump filtering and compression utility provided with kexec-tools. On some architectures, it can drastically reduce the size of your vmcore files, which becomes very useful on systems with large amounts of memory. -A typical setup is 'core_collector makedumpfile -F -l --message-level 1 -d 31', +A typical setup is 'core_collector makedumpfile -F -l --message-level 7 -d 31', but check the output of '/sbin/makedumpfile --help' for a list of all available options (-i and -g don't need to be specified, they're automatically taken care of). Note that use of makedumpfile requires that the kernel-debuginfo package @@ -633,11 +633,11 @@ First one is source file and second one is target file. For ex. - ex2. - core_collector "makedumpfile -l --message-level 1 -d 31" + core_collector "makedumpfile -l --message-level 7 -d 31" Above will effectively be translated to: - makedumpfile -l --message-level 1 -d 31 /proc/vmcore /vmcore + makedumpfile -l --message-level 7 -d 31 /proc/vmcore /vmcore For dump targets like raw and ssh, in general, core collector should expect one argument (source file) and should output the processed core on standard @@ -656,11 +656,11 @@ raw dumps core_collector examples: - ex4. - core_collector "makedumpfile -F -l --message-level 1 -d 31" + core_collector "makedumpfile -F -l --message-level 7 -d 31" Above will effectively be translated to. - makedumpfile -F -l --message-level 1 -d 31 | dd of= + makedumpfile -F -l --message-level 7 -d 31 | dd of= ssh dumps core_collector examples: @@ -674,11 +674,11 @@ ssh dumps core_collector examples: - ex6. - core_collector "makedumpfile -F -l --message-level 1 -d 31" + core_collector "makedumpfile -F -l --message-level 7 -d 31" Above will effectively be translated to. - makedumpfile -F -l --message-level 1 -d 31 | ssh "dd of=path/vmcore" + makedumpfile -F -l --message-level 7 -d 31 | ssh "dd of=path/vmcore" There is one exception to standard output rule for ssh dumps. And that is scp. As scp can handle ssh destinations for file transfers, one can @@ -696,9 +696,9 @@ About default core collector ---------------------------- Default core_collector for ssh/raw dump is: -"makedumpfile -F -l --message-level 1 -d 31". +"makedumpfile -F -l --message-level 7 -d 31". Default core_collector for other targets is: -"makedumpfile -l --message-level 1 -d 31". +"makedumpfile -l --message-level 7 -d 31". Even if core_collector option is commented out in kdump.conf, makedumpfile is default core collector and kdump uses it internally. diff --git a/tests/scripts/testcases/local-kdump/0-local.sh b/tests/scripts/testcases/local-kdump/0-local.sh index d09c6f0..948cfa1 100755 --- a/tests/scripts/testcases/local-kdump/0-local.sh +++ b/tests/scripts/testcases/local-kdump/0-local.sh @@ -8,7 +8,7 @@ on_test() { if [ $boot_count -eq 1 ]; then cat << EOF > /etc/kdump.conf path /var/crash -core_collector makedumpfile -l --message-level 1 -d 31 +core_collector makedumpfile -l --message-level 7 -d 31 EOF kdumpctl start || test_failed "Failed to start kdump" diff --git a/tests/scripts/testcases/nfs-kdump/1-client.sh b/tests/scripts/testcases/nfs-kdump/1-client.sh index df62463..4122bb8 100755 --- a/tests/scripts/testcases/nfs-kdump/1-client.sh +++ b/tests/scripts/testcases/nfs-kdump/1-client.sh @@ -11,7 +11,7 @@ on_test() { if [ "$boot_count" -eq 1 ]; then cat << EOF > /etc/kdump.conf nfs $nfs_server:/srv/nfs -core_collector makedumpfile -l --message-level 1 -d 31 +core_collector makedumpfile -l --message-level 7 -d 31 EOF while ! ping -c 1 $nfs_server -W 1; do diff --git a/tests/scripts/testcases/ssh-kdump/1-client.sh b/tests/scripts/testcases/ssh-kdump/1-client.sh index d79f00f..bd03eff 100755 --- a/tests/scripts/testcases/ssh-kdump/1-client.sh +++ b/tests/scripts/testcases/ssh-kdump/1-client.sh @@ -11,7 +11,7 @@ on_test() { if [ "$boot_count" -eq 1 ]; then cat << EOF > /etc/kdump.conf ssh root@192.168.77.1 -core_collector makedumpfile -l --message-level 1 -d 31 -F +core_collector makedumpfile -l --message-level 7 -d 31 -F EOF ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y &>/dev/ttyS1 From 12e72b9dd68775483e92516ef02050d9edce896c Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 23 Oct 2020 17:17:48 +0800 Subject: [PATCH 291/806] Revert "Revert "s390x: enable the kexec file load by default"" This reverts commit fa8aa52d947edf86332c1194f86d70b6e0677a5c. For the s390x, the vmlinuz image has only single signature according to the kernel.spec. The dual signature issue doesn't happens on s390x, therefore, let's restore it in order to enable the file load on s390x by default. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump.sysconfig.s390x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 232d7d4..5e1cb5a 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -31,7 +31,7 @@ MKDUMPRD_ARGS="" # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="-s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 0084806493d01d14dc7148b2dd5fc46e07b42c96 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 27 Oct 2020 12:22:36 -0400 Subject: [PATCH 292/806] kdump.service: use ConditionKernelCommandLine=crashkernel Because otherwise, `kdumpctl start` will fail anyway. This makes it easier to enable kdump by simply adding the mandatory karg and leaving the service enabled. --- kdump.service | 1 + 1 file changed, 1 insertion(+) diff --git a/kdump.service b/kdump.service index f888dd6..99feed8 100644 --- a/kdump.service +++ b/kdump.service @@ -2,6 +2,7 @@ Description=Crash recovery kernel arming After=network.target network-online.target remote-fs.target basic.target DefaultDependencies=no +ConditionKernelCommandLine=crashkernel [Service] Type=oneshot From c9a0df1ccbd35807753ed99343eb53129f5191c3 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 27 Oct 2020 10:46:50 -0400 Subject: [PATCH 293/806] Make dracut-squash a weak dep The dracut module is opportunistic about using the built-in squashfs support only when available, but the spec file hard requires it. Demote it to a weak dep to truly make it optional. This caters to environments which strive to stay minimal, like FCOS and RHCOS. See https://github.com/coreos/fedora-coreos-config/pull/708 for details. --- dracut-module-setup.sh | 3 +++ kexec-tools.spec | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index fbbd21a..474847d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -28,6 +28,9 @@ depends() { modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 fi done + + # check that the dracut squash module is available + [ -d "$(dracut_module_path squash)" ] || return 1 } if is_squash_available && ! is_fadump_capable; then diff --git a/kexec-tools.spec b/kexec-tools.spec index 8505c78..dcf99ed 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -58,7 +58,7 @@ Requires(postun): systemd-units Requires(pre): coreutils sed zlib Requires: dracut >= 050 Requires: dracut-network >= 050 -Requires: dracut-squash >= 050 +Recommends: dracut-squash >= 050 Requires: ethtool BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext From a1664c63d06ac90ae4ead36fb20ce8bb22dfd44c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 13:00:21 +0800 Subject: [PATCH 294/806] mkdumprd: Ensure kdumpbase is added Dracut only check if a module failed installtion if the module is listed in --add params. Without this param, if kdumpbase failed to install due to any reason, dracut will still build the initramfs only print a warning. Add this param to ensure it fail early. Signed-off-by: Kairui Song Acked-by: Dave Young --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 2f3e7f7..1c361d6 100644 --- a/mkdumprd +++ b/mkdumprd @@ -28,7 +28,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args="--quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" +dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." From 1b8e0325f28062b81ca0cf84489a286aced29e77 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 14 Oct 2020 15:29:17 +0800 Subject: [PATCH 295/806] Fix comment about ssh dump target When using ssh dump target, scp is always used, correct the comment. Signed-off-by: Kairui Song Acked-by: Dave Young --- kdump.conf.5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.conf.5 b/kdump.conf.5 index 4be3c77..ae07466 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -41,7 +41,7 @@ mount point. .B ssh .RS -Will scp /proc/vmcore to :/%HOST-%DATE/, +Will save /proc/vmcore through ssh pipe to :/%HOST-%DATE/, supports DNS. NOTE: make sure user has necessary write permissions on server and that a fqdn is used as the server name. .RE From bfd06661e81465d077bac435c90b4082134adf19 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Nov 2020 01:10:56 +0800 Subject: [PATCH 296/806] Release 2.0.20-19 Signed-off-by: Kairui Song --- kexec-tools.spec | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f6c0129..623274c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 18%{?dist} +Release: 19%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -362,6 +362,28 @@ done %endif %changelog +- Fix comment about ssh dump target +- mkdumprd: Ensure kdumpbase is added +- kdump.service: use ConditionKernelCommandLine=crashkernel +- Revert "Revert "s390x: enable the kexec file load by def +- increase makdumpfile default message level to 7 +- Fix error when using raw target with opalcore +- module-setup.sh: Instead of drop journalctl log, just don't read kmsg +- Doc: add a documentation for the usage of logger +- Improve debugging in the kdump kernel +- kdumpctl: add the '-d' option to enable the kexec loading debugging messages +- kdump.sysconfig: add the kdump logger configurations +- enable the logger for kdump +- introduce the kdump logger from the dracut +- Rework check_config and warn on any duplicated option +- (watchdog) kdump-lib.sh: detect secure boot on s390 +- Don't drop journalctl content if failure action is "shell" +- dracut-module-install: Move systemd conf install code to a function +- selftest: Show the path of dumped vmcore on test end +- selftest: Add document for selftests +- selftest: Add basic test framework +- selftest: Add basic infrastructure to build test image + * Thu Aug 27 2020 Kairui Song - 2.0.20-18 - mkdumprd: Improve the warning message when using encrypted target - kdump-lib.sh: Remove is_atomic From cd85fe9165623cc83edda36f5107fb4d850211fc Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 29 Oct 2020 10:21:09 +0800 Subject: [PATCH 297/806] Add code comments to help better understanding Let's add some code comments to help better understanding, and no code changes. Signed-off-by: Lianbo Jiang Acked-by: Baoquan He --- dracut-early-kdump.sh | 3 +++ kdumpctl | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 23bb369..a4e14a4 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -53,6 +53,9 @@ early_kdump_load() EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" fi + # Here, only output the messages, but do not save these messages + # to a file because the target disk may not be mounted yet, the + # earlykdump is too early. ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ --command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \ $EARLY_KDUMP_KERNEL" diff --git a/kdumpctl b/kdumpctl index e816719..94e4f5a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -719,6 +719,10 @@ load_kdump() ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL" + # The '12' represents an intermediate temporary file descriptor + # to store the standard error file descriptor '2', and later + # restore the error file descriptor with the file descriptor '12' + # and release it. exec 12>&2 exec 2>> $KDUMP_LOG_PATH/kdump.log PS4='+ $(date "+%Y-%m-%d %H:%M:%S") ${BASH_SOURCE}@${LINENO}: ' From 08de71252814354375323fd1b5142168e930093c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:16:42 +0800 Subject: [PATCH 298/806] Move some dracut module dependencies checks to module-setup.sh depend() in module-setup.sh is a better place to setup dracut module dependency, it will do early check, and fail early if needed module is missing. Also remove a unneeded helper add_dracut_module. Also remove the unnecessary return in depend() function. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 9 ++++++++- mkdumprd | 9 --------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 911a8b8..ae7af4e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -36,6 +36,14 @@ depends() { dwarning "Required modules to build a squashed kdump image is missing!" fi + if is_ssh_dump_target; then + _dep="$_dep ssh-client" + fi + + if [ "$(uname -m)" = "s390x" ]; then + _dep="$_dep znet" + fi + if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then _dep="$_dep drm" fi @@ -45,7 +53,6 @@ depends() { fi echo $_dep - return 0 } kdump_is_bridge() { diff --git a/mkdumprd b/mkdumprd index 1c361d6..4c4cd0b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -62,10 +62,6 @@ add_dracut_arg() { dracut_args="$dracut_args $@" } -add_dracut_module() { - add_dracut_arg "--add" "\"$1\"" -} - add_dracut_mount() { add_dracut_arg "--mount" "\"$1\"" } @@ -421,10 +417,6 @@ if [ -f "$keyfile" ]; then SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi -if [ "$(uname -m)" = "s390x" ]; then - add_dracut_module "znet" -fi - if is_wdt_addition_needed; then add_dracut_arg "-a" "watchdog" fi @@ -457,7 +449,6 @@ do then mkdir_save_path_ssh $config_val check_size ssh $config_val - add_dracut_module "ssh-client" add_dracut_sshkey "$SSH_KEY_LOCATION" else perror_exit "Bad ssh dump target $config_val" From bc639c976358c77ea6b5cce51dceffa3485055ce Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:16:43 +0800 Subject: [PATCH 299/806] Add a helper to omit non-mandatory dracut module Use dracut_args to omit some non-mandatory modules. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ae7af4e..b54447b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -20,6 +20,10 @@ check() { depends() { local _dep="base shutdown" + add_opt_module() { + [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" + } + is_squash_available() { for kmodule in squashfs overlay loop; do if [ -z "$KDUMP_KERNELVER" ]; then @@ -31,7 +35,7 @@ depends() { } if is_squash_available && ! is_fadump_capable; then - _dep="$_dep squash" + add_opt_module squash else dwarning "Required modules to build a squashed kdump image is missing!" fi @@ -45,7 +49,7 @@ depends() { fi if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then - _dep="$_dep drm" + add_opt_module drm fi if is_generic_fence_kdump || is_pcs_fence_kdump; then From 69bf81bc8bbc0a0562a59a4cd294361c32caa9ad Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:16:44 +0800 Subject: [PATCH 300/806] Move watchdog detect and install code to module-setup.sh Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 4 ++++ kdump-lib.sh | 12 ++++++++++++ mkdumprd | 18 ------------------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b54447b..850c6f6 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -40,6 +40,10 @@ depends() { dwarning "Required modules to build a squashed kdump image is missing!" fi + if is_wdt_active; then + add_opt_module watchdog + fi + if is_ssh_dump_target; then _dep="$_dep ssh-client" fi diff --git a/kdump-lib.sh b/kdump-lib.sh index b55d987..748419f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -479,6 +479,18 @@ is_wdt_mod_omitted() { return $ret } +is_wdt_active() { + local active + + [ -d /sys/class/watchdog ] || return 1 + for dir in /sys/class/watchdog/*; do + [ -f "$dir/state" ] || continue + active=$(< "$dir/state") + [ "$active" = "active" ] && return 0 + done + return 1 +} + # If "dracut_args" contains "--mount" information, use it # directly without any check(users are expected to ensure # its correctness). diff --git a/mkdumprd b/mkdumprd index 4c4cd0b..0623940 100644 --- a/mkdumprd +++ b/mkdumprd @@ -44,20 +44,6 @@ trap ' # clean up after ourselves no matter how we die. trap 'exit 1;' SIGINT -is_wdt_addition_needed() { - local active - - is_wdt_mod_omitted - [[ $? -eq 0 ]] && return 1 - [[ -d /sys/class/watchdog/ ]] || return 1 - for dir in /sys/class/watchdog/*; do - [[ -f "$dir/state" ]] || continue - active=$(< "$dir/state") - [[ "$active" = "active" ]] && return 0 - done - return 1 -} - add_dracut_arg() { dracut_args="$dracut_args $@" } @@ -417,10 +403,6 @@ if [ -f "$keyfile" ]; then SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi -if is_wdt_addition_needed; then - add_dracut_arg "-a" "watchdog" -fi - while read config_opt config_val; do # remove inline comments after the end of a directive. From 2dea15c4fd897bc60c415a0d44d40a5284aae772 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:37 +0800 Subject: [PATCH 301/806] Add sanity checks for the log levels Let's add sanity checks for the log levels in order to avoid passing illegal log levels to the logger. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-logger.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/kdump-logger.sh b/kdump-logger.sh index c7afa34..25fc24b 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -34,15 +34,42 @@ # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! # + +# @brief Check the log level. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +check_loglvl() +{ + case "$1" in + 0|1|2|3|4|5|6) + return 0 + ;; + *) + return 1 + ;; + esac +} + # @brief Initializes Logger. # @retval 1 if something has gone wrong # @retval 0 on success. # dlog_init() { local ret=0; local errmsg + [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4 [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 + + for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do + check_loglvl "$loglvl" + if [ $? -ne 0 ]; then + echo "Illegal log level: $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl" + return 1 + fi + done + # Skip initialization if it's already done. [ -n "$kdump_maxloglvl" ] && return 0 From 5b2b7ec08bf31a7627ddcfd16e4371e49c1b44c2 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:38 +0800 Subject: [PATCH 302/806] Remove unused log levels for kdump logger Previously, the range of log level is from 1 to 6, and the TRACE level and FATAL level are not used, therefore, let's remove these unused log levels. Now it has only four log levels: error(1), warn(2), info(3) and debug(4). We have to remap the numeric log level to the logger priority or syslog log level, which is finished in kdump-logger.sh module, it is invisible for user. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-logger.sh | 147 ++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 105 deletions(-) diff --git a/kdump-logger.sh b/kdump-logger.sh index 25fc24b..cf4d810 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -2,24 +2,18 @@ # # This comes from the dracut-logger.sh # -# The logger defined 6 logging levels: -# - dtrace() (6) -# The TRACE Level designates finer-grained informational events than the -# DEBUG. -# - ddebug (5) +# The logger defined 4 logging levels: +# - ddebug (4) # The DEBUG Level designates fine-grained informational events that are most # useful to debug an application. -# - dinfo (4) +# - dinfo (3) # The INFO level designates informational messages that highlight the # progress of the application at coarse-grained level. -# - dwarn (3) +# - dwarn (2) # The WARN level designates potentially harmful situations. -# - derror (2) +# - derror (1) # The ERROR level designates error events that might still allow the # application to continue running. -# - dfatal (1) -# The FATAL level designates very severe error events that will presumably -# lead the application to abort. # # Logging is controlled by following global variables: # - @var kdump_stdloglvl - logging level to standard error (console output) @@ -27,8 +21,8 @@ # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # # If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl = 4 (info) -# - @var kdump_sysloglvl = 4 (info) +# - @var kdump_stdloglvl = 3 (info) +# - @var kdump_sysloglvl = 3 (info) # - @var kdump_kmsgloglvl = 0 (no logging) # # First of all you have to start with dlog_init() function which initializes @@ -42,7 +36,7 @@ check_loglvl() { case "$1" in - 0|1|2|3|4|5|6) + 0|1|2|3|4) return 0 ;; *) @@ -58,8 +52,8 @@ check_loglvl() dlog_init() { local ret=0; local errmsg - [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=4 - [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=4 + [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3 + [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=3 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do @@ -103,83 +97,52 @@ dlog_init() { readonly kdump_maxloglvl=$maxloglvl_l export kdump_maxloglvl - - if [[ $kdump_stdloglvl -lt 6 ]] && [[ $kdump_kmsgloglvl -lt 6 ]] && [[ $kdump_sysloglvl -lt 6 ]]; then - unset dtrace - dtrace() { :; }; - fi - - if [[ $kdump_stdloglvl -lt 5 ]] && [[ $kdump_kmsgloglvl -lt 5 ]] && [[ $kdump_sysloglvl -lt 5 ]]; then + if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then unset ddebug ddebug() { :; }; fi - if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then + if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then unset dinfo dinfo() { :; }; fi - if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then + if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then unset dwarn dwarn() { :; }; unset dwarning dwarning() { :; }; fi - if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then + if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then unset derror derror() { :; }; fi - if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then - unset dfatal - dfatal() { :; }; - fi - [ -n "$errmsg" ] && derror "$errmsg" return $ret } -## @brief Converts numeric logging level to the first letter of level name. -# -# @param lvl Numeric logging level in range from 1 to 6. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes first letter of level name. -_lvl2char() { - case "$1" in - 1) echo F;; - 2) echo E;; - 3) echo W;; - 4) echo I;; - 5) echo D;; - 6) echo T;; - *) return 1;; - esac -} - ## @brief Converts numeric level to logger priority defined by POSIX.2. # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. _lvl2syspri() { case "$1" in - 1) echo crit;; - 2) echo error;; - 3) echo warning;; - 4) echo info;; - 5) echo debug;; - 6) echo debug;; + 1) echo error;; + 2) echo warning;; + 3) echo info;; + 4) echo debug;; *) return 1;; esac } ## @brief Converts logger numeric level to syslog log level # -# @param lvl Numeric logging level in range from 1 to 6. +# @param lvl Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level @@ -189,13 +152,12 @@ _lvl2syspri() { # # none -> LOG_EMERG (0) # none -> LOG_ALERT (1) -# FATAL(1) -> LOG_CRIT (2) -# ERROR(2) -> LOG_ERR (3) -# WARN(3) -> LOG_WARNING (4) +# none -> LOG_CRIT (2) +# ERROR(1) -> LOG_ERR (3) +# WARN(2) -> LOG_WARNING (4) # none -> LOG_NOTICE (5) -# INFO(4) -> LOG_INFO (6) -# DEBUG(5) -> LOG_DEBUG (7) -# TRACE(6) / +# INFO(3) -> LOG_INFO (6) +# DEBUG(4) -> LOG_DEBUG (7) # # # @see /usr/include/sys/syslog.h @@ -203,29 +165,27 @@ _dlvl2syslvl() { local lvl case "$1" in - 1) lvl=2;; - 2) lvl=3;; - 3) lvl=4;; - 4) lvl=6;; - 5) lvl=7;; - 6) lvl=7;; + 1) lvl=3;; + 2) lvl=4;; + 3) lvl=6;; + 4) lvl=7;; *) return 1;; esac [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl)) } -## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg -# given message with given level (priority). +## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with +# given level (priority). # # @param lvl Numeric logging level. # @param msg Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # -# This is core logging function which logs given message to standard error, file +# This is core logging function which logs given message to standard error # and/or syslog (with POSIX shell command logger) and/or to /dev/kmsg. # The format is following: # @@ -236,16 +196,13 @@ _dlvl2syslvl() { # # Message to syslog is sent with tag @c kdump. Priorities are mapped as # following: -# - @c FATAL to @c crit # - @c ERROR to @c error # - @c WARN to @c warning # - @c INFO to @c info -# - @c DEBUG and @c TRACE both to @c debug +# - @c DEBUG to @c debug _do_dlog() { local lvl="$1"; shift - local lvlc=$(_lvl2char "$lvl") || return 0 local msg="$*" - local lmsg="$lvlc: $*" [[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2 @@ -268,7 +225,7 @@ _do_dlog() { # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use -# dtrace(), ddebug(), or others instead which wrap this one. +# dinfo(), ddebug(), or others instead which wrap this one. # # This function calls _do_dlog() either with parameter msg, or if # none is given, it will read standard input and will use every line as @@ -290,43 +247,33 @@ dlog() { fi } -## @brief Logs message at TRACE level (6) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dtrace() { - set +x - dlog 6 "$@" - [ -n "$debug" ] && set -x || : -} - -## @brief Logs message at DEBUG level (5) +## @brief Logs message at DEBUG level (4) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. ddebug() { set +x - dlog 5 "$@" + dlog 4 "$@" [ -n "$debug" ] && set -x || : } -## @brief Logs message at INFO level (4) +## @brief Logs message at INFO level (3) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dinfo() { set +x - dlog 4 "$@" + dlog 3 "$@" [ -n "$debug" ] && set -x || : } -## @brief Logs message at WARN level (3) +## @brief Logs message at WARN level (2) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. dwarn() { set +x - dlog 3 "$@" + dlog 2 "$@" [ -n "$debug" ] && set -x || : } @@ -340,21 +287,11 @@ dwarning() { [ -n "$debug" ] && set -x || : } -## @brief Logs message at ERROR level (2) +## @brief Logs message at ERROR level (1) # # @param msg Message. # @retval 0 It's always returned, even if logging failed. derror() { - set +x - dlog 2 "$@" - [ -n "$debug" ] && set -x || : -} - -## @brief Logs message at FATAL level (1) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dfatal() { set +x dlog 1 "$@" [ -n "$debug" ] && set -x || : From 239d64f6da09d633d37330359b5e7e6b6badf6d8 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:39 +0800 Subject: [PATCH 303/806] Appropriately converts logger numeric level to syslog log level The kdump-logger will be used by the system service(daemons), so let's appropriately convert the logger numeric level to syslog level with the facility(daemon). The number is constructed by multiplying the facility by 8 and then adding the level. About The Syslog Protocol, please refer to the RFC5424 for more details. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-logger.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kdump-logger.sh b/kdump-logger.sh index cf4d810..c81e614 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -172,7 +172,10 @@ _dlvl2syslvl() { *) return 1;; esac - [ -s /proc/vmcore ] && echo $((24+$lvl)) || echo $((8+$lvl)) + # The number is constructed by multiplying the facility by 8 and then + # adding the level. + # About The Syslog Protocol, please refer to the RFC5424 for more details. + echo $((24+$lvl)) } ## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with From e345ed18e229695fb75800508787945eaeca16ca Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:40 +0800 Subject: [PATCH 304/806] Add the rd.kdumploglvl option to control log level in the second kernel Let's add the rd.kdumploglvl option to control log level in the second kernel, which can make us avoid rebuilding the kdump initramfs after we change the log level in /etc/sysconfig/kdump. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-module-setup.sh | 1 - kdump-lib-initramfs.sh | 1 - kdump-logger.sh | 48 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 850c6f6..1750c6c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -834,7 +834,6 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime - inst_simple "/etc/sysconfig/kdump" inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" chmod +x ${initdir}/kdumpscripts/monitor_dd_progress inst "/bin/dd" "/bin/dd" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 14aac7b..d8d4893 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,5 @@ # These variables and functions are useful in 2nd kernel -. /etc/sysconfig/kdump . /lib/kdump-lib.sh KDUMP_PATH="/var/crash" diff --git a/kdump-logger.sh b/kdump-logger.sh index c81e614..6d214af 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -20,15 +20,43 @@ # - @var kdump_sysloglvl - logging level to syslog (by logger command) # - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) # -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl = 3 (info) -# - @var kdump_sysloglvl = 3 (info) -# - @var kdump_kmsgloglvl = 0 (no logging) +# If any of the variables is not set, the function dlog_init() sets it to default: +# - In the first kernel: +# - @var kdump_stdloglvl = 3 (info) +# - @var kdump_sysloglvl = 0 (no logging) +# - @var kdump_kmsgloglvl = 0 (no logging) +# +# -In the second kernel: +# - @var kdump_stdloglvl = 0 (no logging) +# - @var kdump_sysloglvl = 3 (info) +# - @var kdump_kmsgloglvl = 0 (no logging) # # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! # +# The dracut-lib.sh is only available in the second kernel, and it won't +# be used in the first kernel because the dracut-lib.sh is invisible in +# the first kernel. +if [ -f /lib/dracut-lib.sh ]; then + . /lib/dracut-lib.sh +fi + +# @brief Get the log level from kernel command line. +# @retval 1 if something has gone wrong +# @retval 0 on success. +# +get_kdump_loglvl() +{ + (type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl) + [ -z "$kdump_sysloglvl" ] && return 1; + + (type -p isdigit) && isdigit $kdump_sysloglvl + [ $? -ne 0 ] && return 1; + + return 0 +} + # @brief Check the log level. # @retval 1 if something has gone wrong # @retval 0 on success. @@ -52,8 +80,18 @@ check_loglvl() dlog_init() { local ret=0; local errmsg + if [ -s /proc/vmcore ];then + get_kdump_loglvl + if [ $? -ne 0 ];then + logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)." + kdump_sysloglvl=3 + fi + kdump_stdloglvl=0 + kdump_kmsgloglvl=0 + fi + [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3 - [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=3 + [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=0 [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do From 0098b5d9f30f9611557e61f2b75914ea3322b880 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:41 +0800 Subject: [PATCH 305/806] Capitalize the configuration name of log level In the /etc/sysconfig/kdump, we usually use the uppercase configuration name for all options. So let's use the same method to handle this. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump-logger.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kdump-logger.sh b/kdump-logger.sh index 6d214af..370e5e8 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -35,6 +35,11 @@ # required variables. Don't call any other logging function before that one! # +# Define vairables for the log levels in this module. +kdump_stdloglvl="" +kdump_sysloglvl="" +kdump_kmsgloglvl="" + # The dracut-lib.sh is only available in the second kernel, and it won't # be used in the first kernel because the dracut-lib.sh is invisible in # the first kernel. @@ -88,6 +93,10 @@ dlog_init() { fi kdump_stdloglvl=0 kdump_kmsgloglvl=0 + else + kdump_stdloglvl=$KDUMP_STDLOGLVL + kdump_sysloglvl=$KDUMP_SYSLOGLVL + kdump_kmsgloglvl=$KDUMP_KMSGLOGLVL fi [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3 From 8b0a755b8221a2f58007153568fc692d33805ee1 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:42 +0800 Subject: [PATCH 306/806] Update the kdump sysconfig Some unused log levels have been removed, and kdump has used the different options to control the log levels for the first kernel and the second kernel. Therefore, let's update the kdump sysconfig accordingly. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kdump.sysconfig | 26 +++++++++++++------------- kdump.sysconfig.aarch64 | 26 +++++++++++++------------- kdump.sysconfig.i386 | 26 +++++++++++++------------- kdump.sysconfig.ppc64 | 26 +++++++++++++------------- kdump.sysconfig.ppc64le | 26 +++++++++++++------------- kdump.sysconfig.s390x | 26 +++++++++++++------------- kdump.sysconfig.x86_64 | 26 +++++++++++++------------- 7 files changed, 91 insertions(+), 91 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index 52a0b92..30f0c63 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -36,18 +36,18 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz" -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 1d75979..6f7830a 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -36,18 +36,18 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz" -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 2eb9705..d2de7d6 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -39,18 +39,18 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 24279ff..39b69bb 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -41,18 +41,18 @@ KDUMP_IMG_EXT="" #Specify the action after failure -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 24279ff..39b69bb 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -41,18 +41,18 @@ KDUMP_IMG_EXT="" #Specify the action after failure -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 5e1cb5a..f9218e5 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -42,18 +42,18 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index eb1c538..0521893 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -39,18 +39,18 @@ KDUMP_IMG="vmlinuz" #What is the images extension. Relocatable kernels don't have one KDUMP_IMG_EXT="" -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# If any of the variables is not set, this function set it to default: -# - @var kdump_stdloglvl=4 (info) -# - @var kdump_sysloglvl=4 (info) -# - @var kdump_kmsgloglvl=0 (no logging) +# Logging is controlled by following variables in the first kernel: +# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) +# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) +# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) # -# Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) +# In the second kernel, kdump will use the rd.kdumploglvl option to set the +# log level in the above KDUMP_COMMANDLINE_APPEND. +# - @var rd.kdumploglvl - logging level to syslog (by logger command) +# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND # -# For example: the following configurations indicate that kdump messages will be printed -# to console and journald for debugging case. -# kdump_sysloglvl=5 -# kdump_stdloglvl=5 +# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) +# +# KDUMP_STDLOGLVL=3 +# KDUMP_SYSLOGLVL=0 +# KDUMP_KMSGLOGLVL=0 From 638167358f75599384a452979900cd10e7585dee Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 12 Nov 2020 23:55:43 +0800 Subject: [PATCH 307/806] Doc: improve the usage documentation of the logger Let's remove some redundant descriptions in the usage documentation of the logger, and make it clear. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kexec-kdump-howto.txt | 97 +++++++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 26 deletions(-) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 5f57a84..447bc54 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -888,35 +888,80 @@ Debugging Tips - Using the logger to output kdump log messages - Currently, kdump messages are printed with the 'echo' command or redirect - to console, and which does not support to output kdump messages according - to the log level. + You can configure the kdump log level for the first kernel in the + /etc/sysconfig/kdump. For example: - That is not convenient to debug kdump issues, we usually need to capture - additional debugging information via the modification of the options or the - scripts like kdumpctl, mkdumprd, etc. Because there is no complete debugging - messages, which could waste valuable time. + KDUMP_STDLOGLVL=3 + KDUMP_SYSLOGLVL=0 + KDUMP_KMSGLOGLVL=0 - To cope with this challenging, we introduce the logger to output the kdump - messages according to the log level, and provide a chance to save logs to - the journald if the journald service is available, and then dump all logs - to a file, otherwise dump the logs with the dmesg to a file. + The above configurations indicate that kdump messages will be printed + to the console, and the KDUMP_STDLOGLVL is set to 3(info), but the + KDUMP_SYSLOGLVL and KDUMP_KMSGLOGLVL are set to 0(no logging). This + is also the current default log levels in the first kernel. - Logging is controlled by following global variables: - - @var kdump_stdloglvl - logging level to standard error (console output) - - @var kdump_sysloglvl - logging level to syslog (by logger command) - - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) - If any of the variables is not set, this function set it to default: - - @var kdump_stdloglvl=4 (info) - - @var kdump_sysloglvl=4 (info) - - @var kdump_kmsgloglvl=0 (no logging) + In the second kernel, you can add the 'rd.kdumploglvl=X' option to the + KDUMP_COMMANDLINE_APPEND in the /etc/sysconfig/kdump so that you can also + set the log levels for the second kernel. The 'X' represents the logging + levels, the default log level is 3(info) in the second kernel, for example: - Logging levels: fatal(1),error(2),warn(3),info(4),debug(5),trace(6) + # cat /etc/sysconfig/kdump |grep rd.kdumploglvl + KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd rd.kdumploglvl=3" - We can easily configure the above variables in the /etc/sysconfig/kdump. For - example: - kdump_sysloglvl=5 - kdump_stdloglvl=5 + Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) - The above configurations indicate that kdump messages will be printed to the - console and journald if the journald service is enabled. + The ERROR level designates error events that might still allow the application + to continue running. + + The WARN level designates potentially harmful situations. + + The INFO level designates informational messages that highlight the progress + of the application at coarse-grained level. + + The DEBUG level designates fine-grained informational events that are most + useful to debug an application. + + Note: if you set the log level to 0, that will disable the logs at the + corresponding log level, which indicates that it has no log output. + + At present, the logger works in both the first kernel(kdump service debugging) + and the second kernel. + + In the first kernel, you can find the historical logs with the journalctl + command and check kdump service debugging information. In addition, the + 'kexec -d' debugging messages are also saved to /var/log/kdump.log in the + first kernel. For example: + + [root@ibm-z-109 ~]# ls -al /var/log/kdump.log + -rw-r--r--. 1 root root 63238 Oct 28 06:40 /var/log/kdump.log + + If you want to get the debugging information of building kdump initramfs, you + can enable the '--debug' option for the dracut_args in the /etc/kdump.conf, and + then rebuild the kdump initramfs as below: + + # systemctl restart kdump.service + + That will rebuild the kdump initramfs and gerenate some logs to journald, you + can find the dracut logs with the journalctl command. + + In the second kernel, kdump will automatically put the kexec-dmesg.log to a same + directory with the vmcore, the log file includes the debugging messages like dmesg + and journald logs. For example: + + [root@ibm-z-109 ~]# ls -al /var/crash/127.0.0.1-2020-10-28-02\:01\:23/ + drwxr-xr-x. 2 root root 67 Oct 28 02:02 . + drwxr-xr-x. 6 root root 154 Oct 28 02:01 .. + -rw-r--r--. 1 root root 21164 Oct 28 02:01 kexec-dmesg.log + -rw-------. 1 root root 74238698 Oct 28 02:01 vmcore + -rw-r--r--. 1 root root 17532 Oct 28 02:01 vmcore-dmesg.txt + + If you want to get more debugging information in the second kernel, you can add + the 'rd.debug' option to the KDUMP_COMMANDLINE_APPEND in the /etc/sysconfig/kdump, + and then reload them in order to make the changes take effect. + + In addition, you can also add the 'rd.memdebug=X' option to the KDUMP_COMMANDLINE_APPEND + in the /etc/sysconfig/kdump in order to output the additional information about + kernel module memory consumption during loading. + + For more details, please refer to the /etc/sysconfig/kdump, or the man page of + dracut.cmdline and kdump.conf. From aced2c06a0aa95e1401fe821b60996303b76d571 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 14 Oct 2020 16:29:45 +0800 Subject: [PATCH 308/806] selftest: Always use the get_image_fmt helper Avoid code duplication. --- tests/scripts/image-init-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 7be55d1..09ad940 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -232,7 +232,7 @@ create_image_from_base_image() { image=$decompressed_image fi - local image_fmt=$(qemu-img info $image | sed -n "s/file format:\s*\(.*\)/\1/p") + local image_fmt=$(get_image_fmt $image) if [ "$image_fmt" != "raw" ]; then if [ "$image_fmt" == "qcow2" ]; then echo "Source image is qcow2, using snapshot..." From f85a291fcb70c744549e0dcb6d5c8c744480ed6a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 14 Oct 2020 16:34:35 +0800 Subject: [PATCH 309/806] selftest: Fix qcow2 image format detect qemu-img will report "qcow2" or "qcow2 backing qcow2" for qcow2 image, cover both case. Signed-off-by: Kairui Song --- tests/scripts/image-init-lib.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 09ad940..0a1524b 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -61,6 +61,10 @@ get_image_fmt() { return 1 } +fmt_is_qcow2() { + [ "$1" == "qcow2" ] || [ "$1" == "qcow2 backing qcow2" ] +} + # If it's partitioned, return the mountable partition, else return the dev get_mountable_dev() { local dev=$1 parts @@ -143,7 +147,7 @@ mount_image() { dev="$($SUDO losetup --show -f $image)" [ $? -ne 0 ] || [ -z "$dev" ] && perror_exit "failed to setup loop device" - elif [ "$fmt" == "qcow2" ]; then + elif fmt_is_qcow2 "$fmt"; then prepare_nbd dev=$(mount_nbd $image) @@ -234,11 +238,11 @@ create_image_from_base_image() { local image_fmt=$(get_image_fmt $image) if [ "$image_fmt" != "raw" ]; then - if [ "$image_fmt" == "qcow2" ]; then + if fmt_is_qcow2 "$image_fmt"; then echo "Source image is qcow2, using snapshot..." qemu-img create -f qcow2 -b $image $output else - perror_exit "Unrecognized base image format $image_mnt" + perror_exit "Unrecognized base image format '$image_mnt'" fi else echo "Source image is raw, converting to qcow2..." From 13ac2446302de2e242d08decb5b5ce9fce1fff04 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Nov 2020 17:15:18 +0800 Subject: [PATCH 310/806] selftest: Update test base image to Fedora 33 --- tests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 6144809..71b329b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,9 +11,9 @@ DIST ?= fedora DIST_ABR ?= f DIST_ABRL ?= fc DIST_UNSET ?= rhel -RELEASE ?= 32 +RELEASE ?= 33 -DEFAULT_BASE_IMAGE_VER ?= 1.6 +DEFAULT_BASE_IMAGE_VER ?= 1.2 DEFAULT_BASE_IMAGE ?= Fedora-Cloud-Base-$(RELEASE)-$(DEFAULT_BASE_IMAGE_VER).$(ARCH).raw.xz DEFAULT_BASE_IMAGE_URL ?= https://dl.fedoraproject.org/pub/fedora/linux/releases/$(RELEASE)/Cloud/$(ARCH)/images/$(DEFAULT_BASE_IMAGE) From 616d359c5e8b8aa1f62924a22b1688167c33d021 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Nov 2020 17:15:37 +0800 Subject: [PATCH 311/806] selftest: add more detailed log and fix a test failure issue Signed-off-by: Kairui Song --- tests/scripts/kexec-kdump-test/init.sh | 16 ++++++++++++---- tests/scripts/testcases/local-kdump/0-local.sh | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh index 5737810..f427905 100755 --- a/tests/scripts/kexec-kdump-test/init.sh +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -73,25 +73,33 @@ has_valid_vmcore_dir() { local vmcore_dir=$path/$(ls -1 $path | tail -n 1) local vmcore="" + test_output "Found a vmcore dir \"$vmcore_dir\":" # Checking with `crash` is slow and consume a lot of memory/disk, # just do a sanity check by check if log are available. if [ -e $vmcore_dir/vmcore ]; then vmcore=$vmcore_dir/vmcore - makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1 + makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || { + test_output "Failed to retrive dmesg from vmcore!" + return 1 + } elif [ -e $vmcore_dir/vmcore.flat ]; then vmcore=$vmcore_dir/vmcore.flat makedumpfile -R $vmcore_dir/vmcore < $vmcore || return 1 - makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1 + makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || { + test_output "Failed to retrive dmesg from vmcore!" + return 1 + } rm $vmcore_dir/vmcore else + test_output "The vmcore dir is empty!" return 1 fi - if diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then + if ! diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then + test_output "Dmesg retrived from vmcore is different from dump version!" return 1 fi - test_output "Found a valid vmcore in \"$vmcore_dir\"" test_output "VMCORE: $vmcore" test_output "KERNEL VERSION: $(rpm -q kernel-core)" diff --git a/tests/scripts/testcases/local-kdump/0-local.sh b/tests/scripts/testcases/local-kdump/0-local.sh index 948cfa1..e5c1ff0 100755 --- a/tests/scripts/testcases/local-kdump/0-local.sh +++ b/tests/scripts/testcases/local-kdump/0-local.sh @@ -22,7 +22,7 @@ EOF if has_valid_vmcore_dir /var/crash; then test_passed else - test_failed + test_failed "Vmcore missing" fi shutdown -h 0 From 7b7e5d07433f8f178d9899d77faff991b100d2f3 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Nov 2020 23:33:06 +0800 Subject: [PATCH 312/806] selftest: Fix several test issue with Fedora 33 - ssh-copy-id is bugged and not working, use a more robust way to sync ssh keys - systemd-resolvd will bind on port 53 so DHCP server won't work, disable systemd-resolvd's builtin DNS server Signed-off-by: Kairui Song --- tests/scripts/run-test.sh | 2 +- tests/scripts/testcases/nfs-kdump/0-server.sh | 3 +++ tests/scripts/testcases/nfs-kdump/1-client.sh | 2 +- tests/scripts/testcases/ssh-kdump/0-server.sh | 3 +++ tests/scripts/testcases/ssh-kdump/1-client.sh | 8 +++++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index ef628aa..a68504d 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -94,7 +94,7 @@ for test_case in $testcases; do $(run_test_sync $script > $(get_test_console_file $script)) & - sleep 3 + sleep 5 done script="$main_script" diff --git a/tests/scripts/testcases/nfs-kdump/0-server.sh b/tests/scripts/testcases/nfs-kdump/0-server.sh index 04f102e..41a0212 100755 --- a/tests/scripts/testcases/nfs-kdump/0-server.sh +++ b/tests/scripts/testcases/nfs-kdump/0-server.sh @@ -8,6 +8,9 @@ on_build() { img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports" img_run_cmd "systemctl enable nfs-server" + img_run_cmd "touch /etc/systemd/resolved.conf" + img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf" + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" diff --git a/tests/scripts/testcases/nfs-kdump/1-client.sh b/tests/scripts/testcases/nfs-kdump/1-client.sh index 4122bb8..184c795 100755 --- a/tests/scripts/testcases/nfs-kdump/1-client.sh +++ b/tests/scripts/testcases/nfs-kdump/1-client.sh @@ -15,7 +15,7 @@ core_collector makedumpfile -l --message-level 7 -d 31 EOF while ! ping -c 1 $nfs_server -W 1; do - : + sleep 1 done kdumpctl start || test_failed "Failed to start kdump" diff --git a/tests/scripts/testcases/ssh-kdump/0-server.sh b/tests/scripts/testcases/ssh-kdump/0-server.sh index f1e5073..6dfcc91 100755 --- a/tests/scripts/testcases/ssh-kdump/0-server.sh +++ b/tests/scripts/testcases/ssh-kdump/0-server.sh @@ -9,6 +9,9 @@ on_build() { img_run_cmd 'sed -i "s/^.*PermitRootLogin .*\$/PermitRootLogin yes/" /etc/ssh/sshd_config' img_run_cmd "systemctl enable sshd" + img_run_cmd "touch /etc/systemd/resolved.conf" + img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf" + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" diff --git a/tests/scripts/testcases/ssh-kdump/1-client.sh b/tests/scripts/testcases/ssh-kdump/1-client.sh index bd03eff..be549c3 100755 --- a/tests/scripts/testcases/ssh-kdump/1-client.sh +++ b/tests/scripts/testcases/ssh-kdump/1-client.sh @@ -14,7 +14,7 @@ ssh root@192.168.77.1 core_collector makedumpfile -l --message-level 7 -d 31 -F EOF - ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y &>/dev/ttyS1 + ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa <<< y while ! ping -c 1 $ssh_server -W 1; do sleep 1 @@ -24,9 +24,11 @@ EOF ssh-keyscan -H 192.168.77.1 > /root/.ssh/known_hosts done - sshpass -p fedora ssh-copy-id root@$ssh_server -f &>/dev/ttyS1 + sshpass -p fedora ssh $ssh_server "mkdir /root/.ssh" + cat /root/.ssh/id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys" - sshpass -p fedora kdumpctl propagate &>/dev/ttyS1 + sshpass -p fedora kdumpctl propagate + cat /root/.ssh/kdump_id_rsa.pub | sshpass -p fedora ssh $ssh_server "cat >> /root/.ssh/authorized_keys" kdumpctl start || test_failed "Failed to start kdump" From 4f492cf73ea11ff74f5b062e18fcea45cb5e7eeb Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 19 Nov 2020 00:38:00 +0800 Subject: [PATCH 313/806] Release 2.0.20-20 Also fix some changelog issue. Signed-off-by: Kairui Song --- kexec-tools.spec | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 623274c..53d1ff1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,7 +4,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 19%{?dist} +Release: 20%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -362,6 +362,25 @@ done %endif %changelog +* Thu Nov 19 2020 Kairui Song - 2.0.20-20 +- selftest: Fix several test issue with Fedora 33 +- selftest: add more detailed log and fix a test failure issue +- selftest: Update test base image to Fedora 33 +- selftest: Fix qcow2 image format detect +- selftest: Always use the get_image_fmt helper +- Doc: improve the usage documentation of the logger +- Update the kdump sysconfig +- Capitalize the configuration name of log level +- Add the rd.kdumploglvl option to control log level in the second kernel +- Appropriately converts logger numeric level to syslog log level +- Remove unused log levels for kdump logger +- Add sanity checks for the log levels +- Move watchdog detect and install code to module-setup.sh +- Add a helper to omit non-mandatory dracut module +- Move some dracut module dependencies checks to module-setup.sh +- Add code comments to help better understanding + +* Thu Nov 05 2020 Kairui Song - 2.0.20-19 - Fix comment about ssh dump target - mkdumprd: Ensure kdumpbase is added - kdump.service: use ConditionKernelCommandLine=crashkernel From d54e5bab0f7f352e35d874816f61a0c9c2a94a01 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:22:12 +0800 Subject: [PATCH 314/806] kdumpctl: split the driver detection from fs dection function The driver detection have nothing to do with fs detection, and currently if the dump target is raw, the block driver detection is skipped which is wrong. Just split it out and run the block driver detection when dump target is fs or raw. Also simplfied the code a bit. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdumpctl | 109 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/kdumpctl b/kdumpctl index 94e4f5a..af24971 100755 --- a/kdumpctl +++ b/kdumpctl @@ -430,14 +430,51 @@ check_files_modified() return 0 } -check_dump_fs_modified() +check_drivers_modified() +{ + local _target _new_drivers _old_drivers _module_name _module_filename + + # If it's dump target is on block device, detect the block driver + _target=$(get_block_dump_target) + if [[ -n "$_target" ]]; then + _record_block_drivers() { + local _drivers + _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') + for _driver in $_drivers; do + if ! [[ " $_new_drivers " == *" $_driver "* ]]; then + _new_drivers="$_new_drivers $_driver" + fi + done + + ddebug "MAJ:MIN=$1 drivers='$_drivers'" + } + check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" + fi + + [ -z "$_new_drivers" ] && return 0 + _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" + + ddebug "Modules required for dump target: '$_new_drivers'" + ddebug "Modules included in old initramfs: '$_old_drivers'" + for _driver in $_new_drivers; do + # Skip deprecated/invalid driver name or built-in module + _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name $_driver 2>/dev/null) + _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n $_driver 2>/dev/null) + if [ $? -ne 0 ] || [ -z "$_module_name" ] || [[ "$_module_filename" = *"(builtin)"* ]]; then + continue + fi + if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then + dinfo "Detected change in block device driver, new loaded module: $_module_name" + return 1 + fi + done +} + +check_fs_modified() { local _old_dev _old_mntpoint _old_fstype local _new_dev _new_mntpoint _new_fstype - local _target _path _dracut_args - local _target_drivers _module_name _module_filename - - local _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" + local _target _dracut_args # No need to check in case of mount target specified via "dracut_args". if is_mount_in_dracut_args; then @@ -450,56 +487,14 @@ check_dump_fs_modified() return 0 fi - _target=$(get_user_configured_dump_disk) - - if [[ -n "$_target" ]]; then - _target=$(to_dev_name $_target) - _new_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2) - else - _path=$(get_save_path) - _target=$(get_target_from_path $_path) - _target=$(to_dev_name $_target) - _new_fstype=$(get_fs_type_from_target $_target) - if [[ -z "$_target" || -z "$_new_fstype" ]];then - derror "Dump path $_path does not exist" - return 2 - fi + _target=$(get_block_dump_target) + _new_fstype=$(get_fs_type_from_target $_target) + if [[ -z "$_target" ]] || [[ -z "$_new_fstype" ]];then + derror "Dump target is invalid" + return 2 fi - ddebug "_target=$_target _path=$_path _new_fstype=$_new_fstype" - - _record_block_drivers() { - local _drivers - - if [[ -b /dev/block/$1 ]]; then - _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') - fi - if [[ -b $1 ]]; then - _drivers=$(udevadm info -a "$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') - fi - for _driver in $_drivers; do - if ! [[ " $_target_drivers " == *" $_driver "* ]]; then - _target_drivers="$_target_drivers $_driver" - fi - done - ddebug "MAJ:MIN=$1 _drivers=$_drivers _target_drivers=$_targer_drivers" - return 1 - } - - check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" - for _driver in $_target_drivers; do - # Skip deprecated/invalid driver name or built-in module - _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name $_driver 2>/dev/null) - _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n $_driver 2>/dev/null) - if [ $? -ne 0 ] || [ -z "$_module_name" ] || [[ "$_module_filename" = *"(builtin)"* ]]; then - continue - fi - if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then - dinfo "Detected change in block device driver, new loaded module: $_module_name" - return 1 - fi - done - + ddebug "_target=$_target _new_fstype=$_new_fstype" if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then _new_dev=$_target else @@ -606,7 +601,13 @@ check_system_modified() return $ret fi - check_dump_fs_modified + check_fs_modified + ret=$? + if [ $ret -ne 0 ]; then + return $ret + fi + + check_drivers_modified ret=$? if [ $ret -ne 0 ]; then return $ret From 276de0f810235802cd9951e9d38d2258cc69330d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 30 Nov 2020 15:16:57 +0800 Subject: [PATCH 315/806] Remove a redundant nfs check In check_fs_modified, is_nfs_dump_target is already called, the dump target can't be nfs. No need to check here. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdumpctl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/kdumpctl b/kdumpctl index af24971..fe41ef8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -495,14 +495,10 @@ check_fs_modified() fi ddebug "_target=$_target _new_fstype=$_new_fstype" - if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then - _new_dev=$_target - else - _new_dev=$(kdump_get_persistent_dev $_target) - if [ -z "$_new_dev" ]; then - derror "Get persistent device name failed" - return 2 - fi + _new_dev=$(kdump_get_persistent_dev $_target) + if [ -z "$_new_dev" ]; then + perror "Get persistent device name failed" + return 2 fi _new_mntpoint="$(get_kdump_mntpoint_from_target $_target)" From 320bd209fe2ffdd9649ce4e4e7b8d910dd29c297 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 19 Nov 2020 17:06:58 +0800 Subject: [PATCH 316/806] Add a helper for detecting watchdog drivers Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 748419f..43116a9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -744,6 +744,25 @@ prepare_kdump_bootinfo() fi } +get_watchdog_drvs() +{ + local _wdtdrvs _drv _dir + + for _dir in /sys/class/watchdog/*; do + # device/modalias will return driver of this device + [[ -f "$_dir/device/modalias" ]] || continue + _drv=$(< "$_dir/device/modalias") + _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_drv 2>/dev/null) + for i in $_drv; do + if ! [[ " $_wdtdrvs " == *" $i "* ]]; then + _wdtdrvs="$_wdtdrvs $i" + fi + done + done + + echo $_wdtdrvs +} + # # prepare_cmdline # This function performs a series of edits on the command line. From 647aa56b532770693affc3778f57e28875406cc6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:22:14 +0800 Subject: [PATCH 317/806] Fix the watchdog drivers detection code Currently the watchdog detection code is broken already, it get the list of active watchdog drivers, then check if they are set in the /etc/cmdline.d/* as preload module. But after we switched to use squash module, /etc/cmdline.d/* is not directly visible. So just detect whether current needed driver is installed. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdumpctl | 67 ++++---------------------------------------------------- 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/kdumpctl b/kdumpctl index fe41ef8..14e99d7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -451,10 +451,13 @@ check_drivers_modified() check_block_and_slaves_all _record_block_drivers "$(get_maj_min "$_target")" fi + # Include watchdog drivers if watchdog module is not omitted + is_wdt_mod_omitted || _new_drivers+=" $(get_watchdog_drvs)" + [ -z "$_new_drivers" ] && return 0 _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" - ddebug "Modules required for dump target: '$_new_drivers'" + ddebug "Modules required for kdump: '$_new_drivers'" ddebug "Modules included in old initramfs: '$_old_drivers'" for _driver in $_new_drivers; do # Skip deprecated/invalid driver name or built-in module @@ -526,62 +529,6 @@ check_fs_modified() return 1 } -check_wdt_modified() -{ - local -A _drivers - local _alldrivers _active _wdtdrv _wdtppath _dir - local wd_old wd_new - - is_wdt_mod_omitted - [[ $? -eq 0 ]] && return 0 - [[ -d /sys/class/watchdog/ ]] || return 0 - - # Copied logic from dracut 04watchdog/module-setup.sh::installkernel() - for _dir in /sys/class/watchdog/*; do - [[ -d "$_dir" ]] || continue - [[ -f "$_dir/state" ]] || continue - _active=$(< "$_dir/state") - [[ "$_active" = "active" ]] || continue - # device/modalias will return driver of this device - _wdtdrv=$(< "$_dir/device/modalias") - # There can be more than one module represented by same - # modalias. Currently load all of them. - # TODO: Need to find a way to avoid any unwanted module - # represented by modalias - _wdtdrv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_wdtdrv 2>/dev/null) - if [[ $_wdtdrv ]]; then - for i in $_wdtdrv; do - _drivers[$i]=1 - done - fi - # however in some cases, we also need to check that if there is - # a specific driver for the parent bus/device. In such cases - # we also need to enable driver for parent bus/device. - _wdtppath=$(readlink -f "$_dir/device") - while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do - _wdtppath=$(readlink -f "$_wdtppath/..") - [[ -f "$_wdtppath/modalias" ]] || continue - - _wdtdrv=$(< "$_wdtppath/modalias") - _wdtdrv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_wdtdrv 2>/dev/null) - if [[ $_wdtdrv ]]; then - for i in $_wdtdrv; do - _drivers[$i]=1 - done - fi - done - done - - # ensure that watchdog module is loaded as early as possible - _alldrivers="${!_drivers[*]}" - [[ $_alldrivers ]] && wd_new="rd.driver.pre=${_alldrivers// /,}" - wd_old=$(lsinitrd $TARGET_INITRD -f etc/cmdline.d/00-watchdog.conf) - - [[ "$wd_old" = "$wd_new" ]] && return 0 - - return 1 -} - # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -609,12 +556,6 @@ check_system_modified() return $ret fi - check_wdt_modified - if [ $? -ne 0 ]; then - dinfo "Detected change in watchdog state" - return 1 - fi - return 0 } From 4464bcf8f3e7a8bdc4ea96d49223552f1003163b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Oct 2020 18:22:15 +0800 Subject: [PATCH 318/806] kdump-lib.sh: Use a more generic helper to detect omitted dracut module Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 31 ++++++++++++------------------- kdumpctl | 2 +- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 43116a9..6475f52 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -455,28 +455,21 @@ get_ifcfg_filename() { echo -n "${ifcfg_file}" } -# returns 0 when omission of watchdog module is desired in dracut_args +# returns 0 when omission of a module is desired in dracut_args # returns 1 otherwise -is_wdt_mod_omitted() { - local dracut_args - local ret=1 +is_dracut_mod_omitted() { + local dracut_args dracut_mod=$1 - dracut_args=$(grep "^dracut_args" /etc/kdump.conf) - [[ -z $dracut_args ]] && return $ret + set -- $(grep "^dracut_args" /etc/kdump.conf) + while [ $# -gt 0 ]; do + case $1 in + -o|--omit) + [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 + esac + shift + done - eval set -- $dracut_args - while :; do - [[ -z $1 ]] && break - case $1 in - -o|--omit) - echo $2 | grep -qw "watchdog" - [[ $? == 0 ]] && ret=0 - break - esac - shift - done - - return $ret + return 1 } is_wdt_active() { diff --git a/kdumpctl b/kdumpctl index 14e99d7..3f6a9be 100755 --- a/kdumpctl +++ b/kdumpctl @@ -452,7 +452,7 @@ check_drivers_modified() fi # Include watchdog drivers if watchdog module is not omitted - is_wdt_mod_omitted || _new_drivers+=" $(get_watchdog_drvs)" + is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)" [ -z "$_new_drivers" ] && return 0 _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" From d551516f521e449db114cffb4d5ad426edf5eea2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 19 Nov 2020 22:07:09 +0800 Subject: [PATCH 319/806] Set watchdog's pretimeout to zero in kdump kernel Most watchdogs have a parameter pretimeout, if set to non-zero, it means before the watchdog really reset the system, it will try to panic the kernel first, so kdump could kick in, or, just print a panic stacktrace and then kernel should reset it self. If we are already in kdump kernel, this is not really helpful, only increase kernel hanging chance. And it also make thing become complex as some watchdog triggers the kernel panic in NMI context, which could also hang the kernel in strange ways, and fail the watchdog it self. So just disable this parameter. Also for hpwdt, it have another parameter kdumptimeout, which is just designed for first kernel. The default behaviour is the watchdog will simply stop working if timeouted, trigger a panic, and leave the kernel to kdump. Again, if we are already in kdump this is not helpful. So also disable that. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- kdump-lib.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 6475f52..98ff27c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -797,5 +797,21 @@ prepare_cmdline() if [ ! -z ${id} ] ; then cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) fi + + # If any watchdog is used, set it's pretimeout to 0. pretimeout let + # watchdog panic the kernel first, and reset the system after the + # panic. If the system is already in kdump, panic is not helpful + # and only increase the chance of watchdog failure. + for i in $(get_watchdog_drvs); do + cmdline+=" $i.pretimeout=0" + + if [[ $i == hpwdt ]]; then + # hpwdt have a special parameter kdumptimeout, is's only suppose + # to be set to non-zero in first kernel. In kdump, non-zero + # value could prevent the watchdog from resetting the system. + cmdline+=" $i.kdumptimeout=0" + fi + done + echo ${cmdline} } From 08d9846ebad3ce210cfa5388ac7286e30c36d233 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 23 Nov 2020 21:41:51 +0800 Subject: [PATCH 320/806] Make get_mount_info work with bind mount Remove the --real when calling findmnt. The option is only useful in capture kernel, to avoid `findmnt` returning the pseudo 'rootfs' for non mounted path. example, when /kdumproot/mnt/ is not mounted: kdump:/# findmnt --target /kdumproot/mnt TARGET SOURCE FSTYPE OPTIONS / rootfs rootfs rw,size=61368k,nr_inodes=15342 kdump:/# findmnt --target /kdumproot/mnt But this function will make findmnt also return empty value for bind mount. So remove it and add an extra if statement for second kernel. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 2 +- kdump-lib.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index d8d4893..9275c83 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -123,7 +123,7 @@ dump_fs() ddebug "_mp=$_mp _dev=$_dev _op=$_op" # If dump path have a corresponding device entry but not mounted, mount it. - if [ -n "$_dev" ]; then + if [ -n "$_dev" ] && [ "$_dev" != "rootfs" ]; then if ! is_mounted "$_mp"; then dinfo "dump target $_dev is not mounted, trying to mount..." mkdir -p $_mp diff --git a/kdump-lib.sh b/kdump-lib.sh index 98ff27c..f04095a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -256,9 +256,9 @@ is_mounted() get_mount_info() { local _info_type=$1 _src_type=$2 _src=$3; shift 3 - local _info=$(findmnt --real -k -n -r -o $_info_type --$_src_type $_src $@) + local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@) - [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt --real -s -n -r -o $_info_type --$_src_type $_src $@) + [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@) echo $_info } From 9966b0a12e775f7446a6810647201451af700655 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 25 Nov 2020 17:06:12 +0800 Subject: [PATCH 321/806] kdump-lib: Fix get_bind_mount_source to support btrfs and fstab Currently get_bind_mount_source will not work on btrfs, that's because this function relies on findmnt to detect bind mount. For a bind mount, findmnt will return different value with "-v" option. For example, we have /dev/sdc mounted on /mnt/source, and then bind mount /mnt/source/sub/path to /mnt/bind: $ findmnt /mnt/bind TARGET SOURCE FSTYPE OPTIONS /mnt/bind /dev/sdc[/sub/path] ext4 rw,relatime,seclabel $ findmnt -v /mnt/bind TARGET SOURCE FSTYPE OPTIONS /mnt/bind /dev/sdc ext4 rw,relatime,seclabel But findmnt also return similiar result for btrfs, on a fresh installed Fedora 33: $ findmnt / TARGET SOURCE FSTYPE OPTIONS / /dev/sdb7[/root] btrfs rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/root $ findmnt -v / TARGET SOURCE FSTYPE OPTIONS / /dev/sdb7 btrfs rw,relatime,seclabel,ssd,space_cache,subvolid=256,subvol=/root The [...] indicator will contain the subvol of btrfs as well. And if it's bind mounted under btrfs, it will contain a mixup of btrfs subvol and the actuall fsroot. And also, if the bind mount source device is not mounted on /, get_bind_mount_source will also not work. So rewrite the get_bind_mount_source function, make it work in every cases. Tested with: - Silverblue's bind mount - Bind mount with source device mounted not under / - Btrfs - Bind mount and source device is Btrfs Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index f04095a..0e38580 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -211,8 +211,8 @@ get_kdump_targets() # /mnt/bind -> /path/to/src, /mnt/bind/dump -> /path/to/src/dump # # findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] -# in the SOURCE column for bind-mounts, then if $_mntpoint equals to -# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory. +# in the SOURCE column for bind-mounts, then if $_src equals to +# $_src_nofsroot, the mountpoint is not bind mounted directory. # # Below is just an example for mount info # /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the @@ -220,22 +220,36 @@ get_kdump_targets() # part is the bind mounted directory which quotes by bracket "[]". get_bind_mount_source() { - local _path=$1 - # In case it's a sub path in a mount point, get the mount point first - local _mnt_top=$(df $_path | tail -1 | awk '{print $NF}') - local _mntpoint=$(findmnt $_mnt_top | tail -n 1 | awk '{print $2}') - local _mntpoint_nofsroot=$(findmnt -v $_mnt_top | tail -n 1 | awk '{print $2}') + local _mnt=$(df $1 | tail -1 | awk '{print $NF}') + local _path=${1#$_mnt} - if [[ "$_mntpoint" = $_mntpoint_nofsroot ]]; then - echo $_path && return + local _src=$(get_mount_info SOURCE target $_mnt -f) + local _opt=$(get_mount_info OPTIONS target $_mnt -f) + local _fstype=$(get_mount_info FSTYPE target $_mnt -f) + + # bind mount in fstab + if [[ -d "$_src" ]] && [[ "$_fstype" = none ]] && (echo "$_opt" | grep -q "\bbind\b"); then + echo $_src$_path && return fi - _mntpoint=${_mntpoint#*$_mntpoint_nofsroot} - _mntpoint=${_mntpoint#[} - _mntpoint=${_mntpoint%]} - _path=${_path#$_mnt_top} + # direct mount + local _src_nofsroot=$(get_mount_info SOURCE target $_mnt -v -f) + if [[ $_src_nofsroot = $_src ]]; then + echo $_mnt$_path && return + fi - echo $_mntpoint$_path + local _fsroot=${_src#$_src_nofsroot[} + _fsroot=${_fsroot%]} + _mnt=$(get_mount_info TARGET source $_src_nofsroot -f) + + # for btrfs, _fsroot will also contain the subvol value as well, strip it + if [[ "$_fstype" = btrfs ]]; then + local _subvol + _subvol=${_opt#*subvol=} + _subvol=${_subvol%,*} + _fsroot=${_fsroot#$_subvol} + fi + echo $_mnt$_fsroot$_path } # Return the current underlaying device of a path, ignore bind mounts From 6f9235887f7817085aabfcc67bf4a6d68e474264 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 16 Nov 2020 18:55:24 +0800 Subject: [PATCH 322/806] module-setup.sh: enable vlan on team interface Dracut has switch network-legacy to network-manager by default, which makes vlan on team easy. So it can be enabled. Testing network topology with two VMs. VM1 ens2-\ /----> VLAN8 (192.168.120.50) ---> team0 ens3-/ (192.168.122.10) VM2 ens2-\ /----> VLAN8 (192.168.120.100) ---> team0 ens3-/ (192.168.122.20) Both of ens2/ens3 in VM1/VM2 are connected to virbr0. During test, dump target is set as root@192.168.120.100:/var/crash then crashing in VM1 Signed-off-by: Pingfan Liu Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1750c6c..5c41e63 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -298,14 +298,10 @@ kdump_setup_vlan() { local _netmac="$(kdump_get_mac_addr $_phydev)" local _kdumpdev - #Just support vlan over bond, it is not easy - #to support all other complex setup + #Just support vlan over bond and team if kdump_is_bridge "$_phydev"; then derror "Vlan over bridge is not supported!" exit 1 - elif kdump_is_team "$_phydev"; then - derror "Vlan over team is not supported!" - exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf From 7a77d5a267234fc1854b6fefb3c4147555fa04ba Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Wed, 25 Nov 2020 11:25:18 +0530 Subject: [PATCH 323/806] fadump-howto: update about 'nocma' and 'off' options for 'fadump=' parameter Along with 'on' option, 'fadump=' kernel parameter also supports 'nocma' & 'off' options. Update about these missing options in the fadump-howto.txt document. Signed-off-by: Hari Bathini Acked-by: Pingfan Liu --- fadump-howto.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index c891e37..5360f3d 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -104,6 +104,11 @@ For the recommended value of X, see 'FADump Memory Requirements' section. # grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r` +By default, FADump reserved memory will be initialized as CMA area to make the +memory available through CMA allocator on the production kernel. We can opt out +of this, making reserved memory unavailable to production kernel, by booting the +linux kernel with 'fadump=nocma' instead of 'fadump=on'. + The term 'boot memory' means size of the low memory chunk that is required for a kernel to boot successfully when booted with restricted memory. By default, the boot memory size will be the larger of 5% of system RAM or 256MB. @@ -326,9 +331,14 @@ the original command line completely. How to disable FADump: -Remove "fadump=on" from kernel cmdline parameters: +Remove "fadump=on"/"fadump=nocma" from kernel cmdline parameters OR replace +it with "fadump=off" kernel cmdline parameter: # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=on" +or + # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=nocma" +OR + # grubby --update-kernel=/boot/vmlinuz-`uname -r` --args="fadump=off" If KDump is to be used as the dump capturing mechanism, update the crashkernel parameter (Else, remove "crashkernel=" parameter too, using grubby): From 7d861422fa6cba022d325c36163dc42fcbf6ed12 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 30 Nov 2020 16:48:02 +0800 Subject: [PATCH 324/806] Rebase makedumpfile to 1.6.8 makedumpfile have moved to Github, so update the upstream URLs. --- ...mpfile-Introduce-check-params-option.patch | 255 ------------------ ...ove-duplicated-variable-declarations.patch | 76 ------ kexec-tools.spec | 11 +- 3 files changed, 4 insertions(+), 338 deletions(-) delete mode 100644 kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch b/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch deleted file mode 100644 index 5314ad9..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch +++ /dev/null @@ -1,255 +0,0 @@ -From 989152e113bfcb4fbfbad6f3aed6f43be4455919 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 25 Feb 2020 16:04:55 -0500 -Subject: [PATCH] Introduce --check-params option - -Currently it's difficult to check whether a makedumpfile command-line -is valid or not without an actual panic. This is inefficient and if -a wrong configuration is not tested, you will miss the vmcore when an -actual panic occurs. - -In order for kdump facilities like kexec-tools to be able to check -the specified command-line parameters in advance, introduce the ---check-params option that only checks them and exits immediately. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.8 | 5 ++++ - makedumpfile.c | 75 ++++++++++++++++++++++++++++++++++++++------------ - print_info.c | 4 +++ - 4 files changed, 69 insertions(+), 17 deletions(-) - -diff --git a/makedumpfile-1.6.7/makedumpfile.8 b/makedumpfile-1.6.7/makedumpfile.8 -index bf156a8..c5d4806 100644 ---- a/makedumpfile-1.6.7/makedumpfile.8 -+++ b/makedumpfile-1.6.7/makedumpfile.8 -@@ -632,6 +632,11 @@ Show help message and LZO/snappy support status (enabled/disabled). - \fB\-v\fR - Show the version of makedumpfile. - -+.TP -+\fB\-\-check-params\fR -+Only check whether the command-line parameters are valid or not, and exit. -+Preferable to be given as the first parameter. -+ - .SH ENVIRONMENT VARIABLES - - .TP 8 -diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c -index 607e07f..f5860a1 100644 ---- a/makedumpfile-1.6.7/makedumpfile.c -+++ b/makedumpfile-1.6.7/makedumpfile.c -@@ -10978,12 +10978,6 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) - if (info->flag_generate_vmcoreinfo || info->flag_rearrange) - return FALSE; - -- if ((message_level < MIN_MSG_LEVEL) -- || (MAX_MSG_LEVEL < message_level)) { -- message_level = DEFAULT_MSG_LEVEL; -- MSG("Message_level is invalid.\n"); -- return FALSE; -- } - if ((info->flag_compress && info->flag_elf_dumpfile) - || (info->flag_read_vmcoreinfo && info->name_vmlinux) - || (info->flag_read_vmcoreinfo && info->name_xen_syms)) -@@ -11013,6 +11007,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) - if (info->flag_partial_dmesg && !info->flag_dmesg) - return FALSE; - -+ if (info->flag_excludevm && !info->working_dir) { -+ MSG("-%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); -+ return FALSE; -+ } -+ - if ((argc == optind + 2) && !info->flag_flatten - && !info->flag_split - && !info->flag_sadump_diskset) { -@@ -11408,6 +11407,23 @@ int show_mem_usage(void) - return TRUE; - } - -+static int set_message_level(char *str_ml) -+{ -+ int ml; -+ -+ ml = atoi(str_ml); -+ if ((ml < MIN_MSG_LEVEL) || (MAX_MSG_LEVEL < ml)) { -+ message_level = DEFAULT_MSG_LEVEL; -+ MSG("Message_level(%d) is invalid.\n", ml); -+ return FALSE; -+ } -+ -+ if (info->flag_check_params) -+ return TRUE; -+ -+ message_level = ml; -+ return TRUE; -+} - - static struct option longopts[] = { - {"split", no_argument, NULL, OPT_SPLIT}, -@@ -11429,6 +11445,7 @@ static struct option longopts[] = { - {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, - {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, - {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, -+ {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, - {0, 0, 0, 0} - }; - -@@ -11527,7 +11544,8 @@ main(int argc, char *argv[]) - info->flag_compress = DUMP_DH_COMPRESSED_LZO; - break; - case OPT_MESSAGE_LEVEL: -- message_level = atoi(optarg); -+ if (!set_message_level(optarg)) -+ goto out; - break; - case OPT_DUMP_DMESG: - info->flag_dmesg = 1; -@@ -11590,6 +11608,10 @@ main(int argc, char *argv[]) - case OPT_NUM_THREADS: - info->num_threads = MAX(atoi(optarg), 0); - break; -+ case OPT_CHECK_PARAMS: -+ info->flag_check_params = TRUE; -+ message_level = DEFAULT_MSG_LEVEL; -+ break; - case '?': - MSG("Commandline parameter is invalid.\n"); - MSG("Try `makedumpfile --help' for more information.\n"); -@@ -11599,11 +11621,9 @@ main(int argc, char *argv[]) - if (flag_debug) - message_level |= ML_PRINT_DEBUG_MSG; - -- if (info->flag_excludevm && !info->working_dir) { -- ERRMSG("Error: -%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); -- ERRMSG("Try `makedumpfile --help' for more information\n"); -- return COMPLETED; -- } -+ if (info->flag_check_params) -+ /* suppress debugging messages */ -+ message_level = DEFAULT_MSG_LEVEL; - - if (info->flag_show_usage) { - print_usage(); -@@ -11634,6 +11654,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (!open_files_for_generating_vmcoreinfo()) - goto out; - -@@ -11657,6 +11680,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (!check_dump_file(info->name_dumpfile)) - goto out; - -@@ -11677,6 +11703,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (!check_dump_file(info->name_dumpfile)) - goto out; - -@@ -11690,6 +11719,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (!check_dump_file(info->name_dumpfile)) - goto out; - if (!dump_dmesg()) -@@ -11703,6 +11735,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (!populate_kernel_version()) - goto out; - -@@ -11721,6 +11756,9 @@ main(int argc, char *argv[]) - MSG("Try `makedumpfile --help' for more information.\n"); - goto out; - } -+ if (info->flag_check_params) -+ goto check_ok; -+ - if (info->flag_split) { - for (i = 0; i < info->num_dumpfile; i++) { - SPLITTING_FD_BITMAP(i) = -1; -@@ -11748,13 +11786,16 @@ main(int argc, char *argv[]) - MSG("The dumpfile is saved to %s.\n", info->name_dumpfile); - } - } -+check_ok: - retcd = COMPLETED; - out: -- MSG("\n"); -- if (retcd != COMPLETED) -- MSG("makedumpfile Failed.\n"); -- else if (!info->flag_mem_usage) -- MSG("makedumpfile Completed.\n"); -+ if (!info->flag_check_params) { -+ MSG("\n"); -+ if (retcd != COMPLETED) -+ MSG("makedumpfile Failed.\n"); -+ else if (!info->flag_mem_usage) -+ MSG("makedumpfile Completed.\n"); -+ } - - free_for_parallel(); - -diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h -index 7217407..03fb4ce 100644 ---- a/makedumpfile-1.6.7/makedumpfile.h -+++ b/makedumpfile-1.6.7/makedumpfile.h -@@ -1303,6 +1303,7 @@ struct DumpInfo { - int flag_read_vmcoreinfo; /* flag of reading vmcoreinfo file */ - int flag_show_usage; /* flag of showing usage */ - int flag_show_version; /* flag of showing version */ -+ int flag_check_params; /* only check parameters */ - int flag_flatten; /* flag of outputting flattened - format to a standard out */ - int flag_rearrange; /* flag of creating dumpfile from -@@ -2364,6 +2365,7 @@ struct elf_prstatus { - #define OPT_WORKING_DIR OPT_START+15 - #define OPT_NUM_THREADS OPT_START+16 - #define OPT_PARTIAL_DMESG OPT_START+17 -+#define OPT_CHECK_PARAMS OPT_START+18 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.6.7/print_info.c b/makedumpfile-1.6.7/print_info.c -index 0be12ea..e0c38b4 100644 ---- a/makedumpfile-1.6.7/print_info.c -+++ b/makedumpfile-1.6.7/print_info.c -@@ -321,6 +321,10 @@ print_usage(void) - MSG(" [-v]:\n"); - MSG(" Show the version of makedumpfile.\n"); - MSG("\n"); -+ MSG(" [--check-params]:\n"); -+ MSG(" Only check whether the command-line parameters are valid or not, and exit.\n"); -+ MSG(" Preferable to be given as the first parameter.\n"); -+ MSG("\n"); - MSG(" VMLINUX:\n"); - MSG(" This is a pathname to the first kernel's vmlinux.\n"); - MSG(" This file must have the debug information of the first kernel to analyze\n"); --- -2.24.1 - - diff --git a/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch b/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch deleted file mode 100644 index f240e8c..0000000 --- a/kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch +++ /dev/null @@ -1,76 +0,0 @@ -From efa29d476996a20052be80878767cfe09e4b6224 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Wed, 29 Jan 2020 10:59:08 +0800 -Subject: [PATCH] makedumpfile: Remove duplicated variable declarations - -When building on Fedora 32, following error is observed: - -/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010: -multiple definition of `crash_reserved_mem_nr'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2010: first defined here -/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009: -multiple definition of `crash_reserved_mem'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:2009: first defined here -/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278: -multiple definition of `parallel_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1278: first defined here -/usr/bin/ld: erase_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265: -multiple definition of `splitting_info_t'; elf_info.o:/builddir/build/BUILD/kexec-tools-2.0.20/makedumpfile-1.6.7/makedumpfile.h:1265: first defined here - -And apparently, these variables are wrongly declared multiple times. So -remove duplicated declaration. - -Signed-off-by: Kairui Song ---- - makedumpfile.c | 2 ++ - makedumpfile.h | 10 ++++++---- - 2 files changed, 8 insertions(+), 4 deletions(-) - -diff --git a/makedumpfile.c b/makedumpfile.c -index e290fbd..9aad77b 100644 ---- a/makedumpfile-1.6.7/makedumpfile.c -+++ b/makedumpfile-1.6.7/makedumpfile.c -@@ -34,6 +34,8 @@ struct array_table array_table; - struct number_table number_table; - struct srcfile_table srcfile_table; - struct save_control sc; -+struct parallel_info parallel_info_t; -+struct splitting_info splitting_info_t; - - struct vm_table vt = { 0 }; - struct DumpInfo *info = NULL; -diff --git a/makedumpfile.h b/makedumpfile.h -index 68d9691..614764c 100644 ---- a/makedumpfile-1.6.7/makedumpfile.h -+++ b/makedumpfile-1.6.7/makedumpfile.h -@@ -1262,7 +1262,8 @@ struct splitting_info { - mdf_pfn_t end_pfn; - off_t offset_eraseinfo; - unsigned long size_eraseinfo; --} splitting_info_t; -+}; -+extern struct splitting_info splitting_info_t; - - struct parallel_info { - int fd_memory; -@@ -1275,7 +1276,8 @@ struct parallel_info { - #ifdef USELZO - lzo_bytep wrkmem; - #endif --} parallel_info_t; -+}; -+extern struct parallel_info parallel_info_t; - - struct ppc64_vmemmap { - unsigned long phys; -@@ -2006,8 +2008,8 @@ struct memory_range { - }; - - #define CRASH_RESERVED_MEM_NR 8 --struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; --int crash_reserved_mem_nr; -+extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; -+extern int crash_reserved_mem_nr; - - unsigned long read_vmcoreinfo_symbol(char *str_symbol); - int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size); --- -2.24.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 53d1ff1..66465fd 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,7 @@ %global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.6.7 +%global mkdf_ver 1.6.8 +%global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools Version: 2.0.20 @@ -16,7 +17,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/%{mkdf_ver}/makedumpfile-%{mkdf_ver}.tar.gz +Source9: https://github.com/makedumpfile/makedumpfile/archive/%{mkdf_ver}/makedumpfile-%{mkdf_shortver}.tar.gz Source10: kexec-kdump-howto.txt Source11: fadump-howto.txt Source12: mkdumprd.8 @@ -100,9 +101,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # Patches 601 onward are generic patches # Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch -Patch602: ./kexec-tools-2.0.20-makedumpfile-Remove-duplicated-variable-declarations.patch -Patch603: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch -Patch604: ./kexec-tools-2.0.20-makedumpfile-Introduce-check-params-option.patch +Patch602: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -122,8 +121,6 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 -%patch603 -p1 -%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc From 6be14c2bcde068b97e9eb2aeed5aac2d6a4790bd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 30 Nov 2020 17:02:20 +0800 Subject: [PATCH 325/806] Release 2.0.20-21 Signed-off-by: Kairui Song --- kexec-tools.spec | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 66465fd..11743a4 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.20 -Release: 20%{?dist} +Release: 21%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -359,6 +359,19 @@ done %endif %changelog +* Mon Nov 30 2020 Kairui Song - 2.0.20-21 +- Rebase makedumpfile to 1.6.8 +- fadump-howto: update about 'nocma' and 'off' options for 'fadump=' parameter +- module-setup.sh: enable vlan on team interface +- kdump-lib: Fix get_bind_mount_source to support btrfs and fstab +- Make get_mount_info work with bind mount +- Set watchdog's pretimeout to zero in kdump kernel +- kdump-lib.sh: Use a more generic helper to detect omitted dracut module +- Fix the watchdog drivers detection code +- Add a helper for detecting watchdog drivers +- Remove a redundant nfs check +- kdumpctl: split the driver detection from fs dection function + * Thu Nov 19 2020 Kairui Song - 2.0.20-20 - selftest: Fix several test issue with Fedora 33 - selftest: add more detailed log and fix a test failure issue From d5e39c9f7b721b80d2aa1afa85c38754a5be074e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 30 Nov 2020 19:37:18 +0800 Subject: [PATCH 326/806] Upload missing source file --- sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources b/sources index 574d13c..cc14d5b 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d SHA512 (kexec-tools-2.0.20.tar.xz) = 3112b6202c1030705c53e3f65a2b58aec14d65333a35aad681d48b9f2bd1c51a2e05c985a1e5e867ab02f8a9c97708483d9d225619db7c6993676f1a242e2d99 -SHA512 (makedumpfile-1.6.7.tar.gz) = fdd78bfea5f96eda094269480ebbceead6ae8d9d2bb1184ffa1e18c6effda5c6df296fbcecc25735109194c0690d6f9ca684c37da1825d7d65568ba18a71a940 +SHA512 (makedumpfile-1.6.8.tar.gz) = 15e60688b06013bf86e339ec855774ea2c904d425371ea867101704ba0611c69da891eb3cc96f67eb10197d8c42d217ea28bf11bcaa93ddc2495cbf984c0b7ec From eaf0e813a20bf5ecf2b481a57d6e728ae6732630 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 7 Dec 2020 12:53:47 +0800 Subject: [PATCH 327/806] dracut-module-setup.sh: use auto6 for ipv6 The parameter either6 is introduced to dracut by commit 67354eebbcd4c358b8194ba5fd1ab1cf7dbd42aa Author: Pingfan Liu Date: Tue Apr 24 16:41:21 2018 +0800 40network: introduce ip=either6 option But it turns out needless. On a sensible ipv6 network environment, DHCPv6 can not work properly alone, because DHCPv6 protocol has no info about the gateway. An reasonalbe process of ipv6 address set up should look like host send: Router Solicitation router reply: Router Advertisements "Router Advertisements" carries many info like gateway, and if it has other-config flag set, it carries DNS info etc. As for DHCPv6 address allocation, it will only start if "Router Advertisements" has the 'managed' flag set, which directs the host to start a stateful address allocation from DHCPv6 server. For more info: rfc4861: Neighbor Discovery for IP version 6 (IPv6) rfc5175: IPv6 Router Advertisement Flags Option Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 5c41e63..ec1ccc5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -373,7 +373,7 @@ kdump_install_net() { if [ -n "$_static" ]; then _proto=none elif is_ipv6_address $_srcaddr; then - _proto=either6 + _proto=auto6 else _proto=dhcp fi From ad6a93b00d85a85702bb59d15ecc81a5382a9a31 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 2 Dec 2020 00:36:47 +0800 Subject: [PATCH 328/806] Don's try to restart dracut-initqueue if it's already failed If dracut-initqueue failed in kdump kernel and failure action is set to dump_to_rootfs, there is no point try again to start the initqueue. It will also slow down the dump process, and the initqueue will most like still not work if first attemp failed. So just try to start sysroot.mount, if it failed, there is no luck. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 9275c83..791d141 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -222,7 +222,8 @@ dump_to_rootfs() { dinfo "Trying to bring up rootfs device" - systemctl start dracut-initqueue + systemctl is-failed dracut-initqueue || systemctl start dracut-initqueue + dinfo "Waiting for rootfs mount, will timeout after 90 seconds" systemctl start sysroot.mount From cd7264705d2ce59c9a8a2982d9c744faaa3dc490 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 11 Dec 2020 11:37:29 +0800 Subject: [PATCH 329/806] Doc: improve mkdumprd man page Currently, when generating a kdump initramfs, mkdumprd will determine how much disk space is available, if the dump target's available space is not greater than the total system memory, mkdumprd will print a warning to remind that there might not be enough space to save a vmcore. Some users are complaining that mkdumprd overestimates the needed size. But actually, the warning covers extreme scenarios such as the slab explodes with non-zero data or a full vmcore, etc. Therefore, need to prevent users from having minimum disk space for crash dump. In view of this, add some descriptions to clarify it in mkdumprd man page. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- mkdumprd.8 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mkdumprd.8 b/mkdumprd.8 index 7faae57..2ac3d5a 100644 --- a/mkdumprd.8 +++ b/mkdumprd.8 @@ -15,7 +15,13 @@ be loaded in the initramfs (based on configuration retrieved from \fI/etc/kdump.conf)\fR \fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR -utility to generate the initramfs. +utility to generate the initramfs. When generating a kdump initramfs, \fBmkdumprd\fR +will determine how much disk space is available, if the dump target's available +space is not greater than the total system memory, \fBmkdumprd\fR will print a +warning to remind that there might not be enough space to save a vmcore. The +warning covers extreme scenarios such as the slab explodes with non-zero data or +a full vmcore, etc. Therefore, need to prevent users from having minimum disk +space for crash dump. \fBmkdumprd\fR was not intended for casual use outside of the service initialization script for the kdump utility, and should not be run manually. If From fa9797ec9d269f1509725a72c6ea312e37808fb5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 14 Dec 2020 15:10:28 +0800 Subject: [PATCH 330/806] dracut-module-setup.sh: Use systemctl call to replace ln_r systemctl -q --root "$initdir" add-wants X.target X.service is the recommanded way to add service dependency, and it covers more corner cases. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ec1ccc5..21f7105 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -849,8 +849,7 @@ install() { inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" - mkdir -p "$initdir/$systemdsystemunitdir/initrd.target.wants" - ln_r "$systemdsystemunitdir/kdump-capture.service" "$systemdsystemunitdir/initrd.target.wants/kdump-capture.service" + systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service" # Replace existing emergency service and emergency target From 71e1c651ddb820808b10c4a7a6a093c3d56e9634 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 23 Dec 2020 17:25:30 +0800 Subject: [PATCH 331/806] makedumpfile: printk: add support for lockless ringbuffer Backports: commit c617ec63339222f3a44d73e36677a9acc8954ccd Author: John Ogness Date: Thu Nov 19 02:41:21 2020 +0000 [PATCH 1/2] printk: add support for lockless ringbuffer * Required for kernel 5.10 Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer is structured completely different to the previous iterations. Add support for retrieving the ringbuffer from debug information and/or using vmcoreinfo. The new ringbuffer is detected based on the availability of the "prb" symbol. Signed-off-by: John Ogness Signed-off-by: Kazuhito Hagio Signed-off-by: Kairui Song --- ...-add-support-for-lockless-ringbuffer.patch | 587 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 589 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch diff --git a/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch b/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch new file mode 100644 index 0000000..c445e76 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch @@ -0,0 +1,587 @@ +From c617ec63339222f3a44d73e36677a9acc8954ccd Mon Sep 17 00:00:00 2001 +From: John Ogness +Date: Thu, 19 Nov 2020 02:41:21 +0000 +Subject: [PATCH 1/2] [PATCH 1/2] printk: add support for lockless ringbuffer + +* Required for kernel 5.10 + +Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer +is structured completely different to the previous iterations. +Add support for retrieving the ringbuffer from debug information +and/or using vmcoreinfo. The new ringbuffer is detected based on +the availability of the "prb" symbol. + +Signed-off-by: John Ogness +Signed-off-by: Kazuhito Hagio +--- + Makefile | 2 +- + dwarf_info.c | 36 ++++++++- + makedumpfile.c | 103 +++++++++++++++++++++++- + makedumpfile.h | 58 ++++++++++++++ + printk.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 399 insertions(+), 7 deletions(-) + create mode 100644 printk.c + +diff --git a/makedumpfile-1.6.8/Makefile b/makedumpfile-1.6.8/Makefile +index e5ac71a..cb6bd42 100644 +--- a/makedumpfile-1.6.8/Makefile ++++ b/makedumpfile-1.6.8/Makefile +@@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32 + endif + + SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h +-SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c ++SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c + OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) + SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c + OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) +diff --git a/makedumpfile-1.6.8/dwarf_info.c b/makedumpfile-1.6.8/dwarf_info.c +index e42a9f5..543588b 100644 +--- a/makedumpfile-1.6.8/dwarf_info.c ++++ b/makedumpfile-1.6.8/dwarf_info.c +@@ -614,6 +614,7 @@ search_structure(Dwarf_Die *die, int *found) + { + int tag; + const char *name; ++ Dwarf_Die die_type; + + /* + * If we get to here then we don't have any more +@@ -622,9 +623,31 @@ search_structure(Dwarf_Die *die, int *found) + do { + tag = dwarf_tag(die); + name = dwarf_diename(die); +- if ((tag != DW_TAG_structure_type) || (!name) +- || strcmp(name, dwarf_info.struct_name)) ++ if ((!name) || strcmp(name, dwarf_info.struct_name)) ++ continue; ++ ++ if (tag == DW_TAG_typedef) { ++ if (!get_die_type(die, &die_type)) { ++ ERRMSG("Can't get CU die of DW_AT_type.\n"); ++ break; ++ } ++ ++ /* Resolve typedefs of typedefs. */ ++ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { ++ if (!get_die_type(&die_type, &die_type)) { ++ ERRMSG("Can't get CU die of DW_AT_type.\n"); ++ return; ++ } ++ } ++ ++ if (tag != DW_TAG_structure_type) ++ continue; ++ die = &die_type; ++ ++ } else if (tag != DW_TAG_structure_type) { + continue; ++ } ++ + /* + * Skip if DW_AT_byte_size is not included. + */ +@@ -740,6 +763,15 @@ search_typedef(Dwarf_Die *die, int *found) + ERRMSG("Can't get CU die of DW_AT_type.\n"); + break; + } ++ ++ /* Resolve typedefs of typedefs. */ ++ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { ++ if (!get_die_type(&die_type, &die_type)) { ++ ERRMSG("Can't get CU die of DW_AT_type.\n"); ++ return; ++ } ++ } ++ + dwarf_info.struct_size = dwarf_bytesize(&die_type); + if (dwarf_info.struct_size <= 0) + continue; +diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c +index cdde040..061741f 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -1555,6 +1555,7 @@ get_symbol_info(void) + SYMBOL_INIT(node_data, "node_data"); + SYMBOL_INIT(pgdat_list, "pgdat_list"); + SYMBOL_INIT(contig_page_data, "contig_page_data"); ++ SYMBOL_INIT(prb, "prb"); + SYMBOL_INIT(log_buf, "log_buf"); + SYMBOL_INIT(log_buf_len, "log_buf_len"); + SYMBOL_INIT(log_end, "log_end"); +@@ -1971,16 +1972,47 @@ get_structure_info(void) + OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz"); + + SIZE_INIT(printk_log, "printk_log"); +- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { ++ SIZE_INIT(printk_ringbuffer, "printk_ringbuffer"); ++ if ((SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE)) { ++ info->flag_use_printk_ringbuffer = TRUE; ++ info->flag_use_printk_log = FALSE; ++ ++ OFFSET_INIT(printk_ringbuffer.desc_ring, "printk_ringbuffer", "desc_ring"); ++ OFFSET_INIT(printk_ringbuffer.text_data_ring, "printk_ringbuffer", "text_data_ring"); ++ ++ OFFSET_INIT(prb_desc_ring.count_bits, "prb_desc_ring", "count_bits"); ++ OFFSET_INIT(prb_desc_ring.descs, "prb_desc_ring", "descs"); ++ OFFSET_INIT(prb_desc_ring.infos, "prb_desc_ring", "infos"); ++ OFFSET_INIT(prb_desc_ring.head_id, "prb_desc_ring", "head_id"); ++ OFFSET_INIT(prb_desc_ring.tail_id, "prb_desc_ring", "tail_id"); ++ ++ SIZE_INIT(prb_desc, "prb_desc"); ++ OFFSET_INIT(prb_desc.state_var, "prb_desc", "state_var"); ++ OFFSET_INIT(prb_desc.text_blk_lpos, "prb_desc", "text_blk_lpos"); ++ ++ OFFSET_INIT(prb_data_blk_lpos.begin, "prb_data_blk_lpos", "begin"); ++ OFFSET_INIT(prb_data_blk_lpos.next, "prb_data_blk_lpos", "next"); ++ ++ OFFSET_INIT(prb_data_ring.size_bits, "prb_data_ring", "size_bits"); ++ OFFSET_INIT(prb_data_ring.data, "prb_data_ring", "data"); ++ ++ SIZE_INIT(printk_info, "printk_info"); ++ OFFSET_INIT(printk_info.ts_nsec, "printk_info", "ts_nsec"); ++ OFFSET_INIT(printk_info.text_len, "printk_info", "text_len"); ++ ++ OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter"); ++ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { + /* + * In kernel 3.11-rc4 the log structure name was renamed + * to "printk_log". + */ ++ info->flag_use_printk_ringbuffer = FALSE; + info->flag_use_printk_log = TRUE; + OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec"); + OFFSET_INIT(printk_log.len, "printk_log", "len"); + OFFSET_INIT(printk_log.text_len, "printk_log", "text_len"); + } else { ++ info->flag_use_printk_ringbuffer = FALSE; + info->flag_use_printk_log = FALSE; + SIZE_INIT(printk_log, "log"); + OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec"); +@@ -2191,6 +2223,7 @@ write_vmcoreinfo_data(void) + WRITE_SYMBOL("node_data", node_data); + WRITE_SYMBOL("pgdat_list", pgdat_list); + WRITE_SYMBOL("contig_page_data", contig_page_data); ++ WRITE_SYMBOL("prb", prb); + WRITE_SYMBOL("log_buf", log_buf); + WRITE_SYMBOL("log_buf_len", log_buf_len); + WRITE_SYMBOL("log_end", log_end); +@@ -2222,7 +2255,11 @@ write_vmcoreinfo_data(void) + WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); + WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t); + WRITE_STRUCTURE_SIZE("pageflags", pageflags); +- if (info->flag_use_printk_log) ++ if (info->flag_use_printk_ringbuffer) { ++ WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); ++ WRITE_STRUCTURE_SIZE("prb_desc", prb_desc); ++ WRITE_STRUCTURE_SIZE("printk_info", printk_info); ++ } else if (info->flag_use_printk_log) + WRITE_STRUCTURE_SIZE("printk_log", printk_log); + else + WRITE_STRUCTURE_SIZE("log", printk_log); +@@ -2268,7 +2305,30 @@ write_vmcoreinfo_data(void) + WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); + WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); + WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list); +- if (info->flag_use_printk_log) { ++ if (info->flag_use_printk_ringbuffer) { ++ WRITE_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); ++ WRITE_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); ++ ++ WRITE_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); ++ WRITE_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); ++ WRITE_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); ++ WRITE_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); ++ WRITE_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); ++ ++ WRITE_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); ++ WRITE_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); ++ ++ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); ++ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); ++ ++ WRITE_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); ++ WRITE_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); ++ ++ WRITE_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); ++ WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); ++ ++ WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); ++ } else if (info->flag_use_printk_log) { + WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); + WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len); + WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); +@@ -2606,6 +2666,7 @@ read_vmcoreinfo(void) + READ_SYMBOL("node_data", node_data); + READ_SYMBOL("pgdat_list", pgdat_list); + READ_SYMBOL("contig_page_data", contig_page_data); ++ READ_SYMBOL("prb", prb); + READ_SYMBOL("log_buf", log_buf); + READ_SYMBOL("log_buf_len", log_buf_len); + READ_SYMBOL("log_end", log_end); +@@ -2684,12 +2745,43 @@ read_vmcoreinfo(void) + READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); + + READ_STRUCTURE_SIZE("printk_log", printk_log); +- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { ++ READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); ++ if (SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE) { ++ info->flag_use_printk_ringbuffer = TRUE; ++ info->flag_use_printk_log = FALSE; ++ ++ READ_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); ++ READ_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); ++ ++ READ_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); ++ READ_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); ++ READ_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); ++ READ_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); ++ READ_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); ++ ++ READ_STRUCTURE_SIZE("prb_desc", prb_desc); ++ READ_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); ++ READ_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); ++ ++ READ_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); ++ READ_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); ++ ++ READ_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); ++ READ_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); ++ ++ READ_STRUCTURE_SIZE("printk_info", printk_info); ++ READ_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); ++ READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); ++ ++ READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); ++ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { ++ info->flag_use_printk_ringbuffer = FALSE; + info->flag_use_printk_log = TRUE; + READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); + READ_MEMBER_OFFSET("printk_log.len", printk_log.len); + READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); + } else { ++ info->flag_use_printk_ringbuffer = FALSE; + info->flag_use_printk_log = FALSE; + READ_STRUCTURE_SIZE("log", printk_log); + READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec); +@@ -5286,6 +5378,9 @@ dump_dmesg() + if (!initial()) + return FALSE; + ++ if ((SYMBOL(prb) != NOT_FOUND_SYMBOL)) ++ return dump_lockless_dmesg(); ++ + if ((SYMBOL(log_buf) == NOT_FOUND_SYMBOL) + || (SYMBOL(log_buf_len) == NOT_FOUND_SYMBOL)) { + ERRMSG("Can't find some symbols for log_buf.\n"); +diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h +index 698c054..47f7e79 100644 +--- a/makedumpfile-1.6.8/makedumpfile.h ++++ b/makedumpfile-1.6.8/makedumpfile.h +@@ -1317,6 +1317,7 @@ struct DumpInfo { + int flag_partial_dmesg; /* dmesg dump only from the last cleared index*/ + int flag_mem_usage; /*show the page number of memory in different use*/ + int flag_use_printk_log; /* did we read printk_log symbol name? */ ++ int flag_use_printk_ringbuffer; /* using lockless printk ringbuffer? */ + int flag_nospace; /* the flag of "No space on device" error */ + int flag_vmemmap; /* kernel supports vmemmap address space */ + int flag_excludevm; /* -e - excluding unused vmemmap pages */ +@@ -1602,6 +1603,7 @@ struct symbol_table { + unsigned long long node_data; + unsigned long long pgdat_list; + unsigned long long contig_page_data; ++ unsigned long long prb; + unsigned long long log_buf; + unsigned long long log_buf_len; + unsigned long long log_end; +@@ -1689,6 +1691,13 @@ struct size_table { + long nodemask_t; + long printk_log; + ++ /* ++ * for lockless printk ringbuffer ++ */ ++ long printk_ringbuffer; ++ long prb_desc; ++ long printk_info; ++ + /* + * for Xen extraction + */ +@@ -1864,6 +1873,52 @@ struct offset_table { + long text_len; + } printk_log; + ++ /* ++ * for lockless printk ringbuffer ++ */ ++ struct printk_ringbuffer_s { ++ long desc_ring; ++ long text_data_ring; ++ long fail; ++ } printk_ringbuffer; ++ ++ struct prb_desc_ring_s { ++ long count_bits; ++ long descs; ++ long infos; ++ long head_id; ++ long tail_id; ++ } prb_desc_ring; ++ ++ struct prb_desc_s { ++ long state_var; ++ long text_blk_lpos; ++ } prb_desc; ++ ++ struct prb_data_blk_lpos_s { ++ long begin; ++ long next; ++ } prb_data_blk_lpos; ++ ++ struct printk_info_s { ++ long seq; ++ long ts_nsec; ++ long text_len; ++ long caller_id; ++ long dev_info; ++ } printk_info; ++ ++ struct prb_data_ring_s { ++ long size_bits; ++ long data; ++ long head_lpos; ++ long tail_lpos; ++ } prb_data_ring; ++ ++ struct atomic_long_t_s { ++ long counter; ++ } atomic_long_t; ++ + /* + * symbols on ppc64 arch + */ +@@ -2390,4 +2445,7 @@ int hexadecimal(char *s, int count); + int decimal(char *s, int count); + int file_exists(char *file); + ++int open_dump_file(void); ++int dump_lockless_dmesg(void); ++ + #endif /* MAKEDUMPFILE_H */ +diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c +new file mode 100644 +index 0000000..acffb6c +--- /dev/null ++++ b/makedumpfile-1.6.8/printk.c +@@ -0,0 +1,207 @@ ++#include "makedumpfile.h" ++#include ++ ++#define DESC_SV_BITS (sizeof(unsigned long) * 8) ++#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) ++#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) ++#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) ++#define DESC_ID_MASK (~DESC_FLAGS_MASK) ++ ++/* convenience struct for passing many values to helper functions */ ++struct prb_map { ++ char *prb; ++ ++ char *desc_ring; ++ unsigned long desc_ring_count; ++ char *descs; ++ char *infos; ++ ++ char *text_data_ring; ++ unsigned long text_data_ring_size; ++ char *text_data; ++}; ++ ++static void ++dump_record(struct prb_map *m, unsigned long id) ++{ ++ unsigned long long ts_nsec; ++ unsigned long state_var; ++ unsigned short text_len; ++ unsigned long begin; ++ unsigned long next; ++ char buf[BUFSIZE]; ++ ulonglong nanos; ++ int indent_len; ++ int buf_need; ++ char *bufp; ++ char *text; ++ char *desc; ++ char *inf; ++ ulong rem; ++ char *p; ++ int i; ++ ++ desc = m->descs + ((id % m->desc_ring_count) * SIZE(prb_desc)); ++ ++ /* skip non-committed record */ ++ state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); ++ if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) ++ return; ++ ++ begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % ++ m->text_data_ring_size; ++ next = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.next)) % ++ m->text_data_ring_size; ++ ++ /* skip data-less text blocks */ ++ if (begin == next) ++ return; ++ ++ inf = m->infos + ((id % m->desc_ring_count) * SIZE(printk_info)); ++ ++ text_len = USHORT(inf + OFFSET(printk_info.text_len)); ++ ++ /* handle wrapping data block */ ++ if (begin > next) ++ begin = 0; ++ ++ /* skip over descriptor ID */ ++ begin += sizeof(unsigned long); ++ ++ /* handle truncated messages */ ++ if (next - begin < text_len) ++ text_len = next - begin; ++ ++ text = m->text_data + begin; ++ ++ ts_nsec = ULONGLONG(inf + OFFSET(printk_info.ts_nsec)); ++ nanos = (ulonglong)ts_nsec / (ulonglong)1000000000; ++ rem = (ulonglong)ts_nsec % (ulonglong)1000000000; ++ ++ bufp = buf; ++ bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000); ++ indent_len = strlen(buf); ++ ++ /* How much buffer space is needed in the worst case */ ++ buf_need = MAX(sizeof("\\xXX\n"), sizeof("\n") + indent_len); ++ ++ for (i = 0, p = text; i < text_len; i++, p++) { ++ if (bufp - buf >= sizeof(buf) - buf_need) { ++ if (write(info->fd_dumpfile, buf, bufp - buf) < 0) ++ return; ++ bufp = buf; ++ } ++ ++ if (*p == '\n') ++ bufp += sprintf(bufp, "\n%-*s", indent_len, ""); ++ else if (isprint(*p) || isspace(*p)) ++ *bufp++ = *p; ++ else ++ bufp += sprintf(bufp, "\\x%02x", *p); ++ } ++ ++ *bufp++ = '\n'; ++ ++ write(info->fd_dumpfile, buf, bufp - buf); ++} ++ ++int ++dump_lockless_dmesg(void) ++{ ++ unsigned long head_id; ++ unsigned long tail_id; ++ unsigned long kaddr; ++ unsigned long id; ++ struct prb_map m; ++ int ret = FALSE; ++ ++ /* setup printk_ringbuffer */ ++ if (!readmem(VADDR, SYMBOL(prb), &kaddr, sizeof(kaddr))) { ++ ERRMSG("Can't get the prb address.\n"); ++ return ret; ++ } ++ ++ m.prb = malloc(SIZE(printk_ringbuffer)); ++ if (!m.prb) { ++ ERRMSG("Can't allocate memory for prb.\n"); ++ return ret; ++ } ++ if (!readmem(VADDR, kaddr, m.prb, SIZE(printk_ringbuffer))) { ++ ERRMSG("Can't get prb.\n"); ++ goto out_prb; ++ } ++ ++ /* setup descriptor ring */ ++ m.desc_ring = m.prb + OFFSET(printk_ringbuffer.desc_ring); ++ m.desc_ring_count = 1 << UINT(m.desc_ring + OFFSET(prb_desc_ring.count_bits)); ++ ++ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.descs)); ++ m.descs = malloc(SIZE(prb_desc) * m.desc_ring_count); ++ if (!m.descs) { ++ ERRMSG("Can't allocate memory for prb.desc_ring.descs.\n"); ++ goto out_prb; ++ } ++ if (!readmem(VADDR, kaddr, m.descs, ++ SIZE(prb_desc) * m.desc_ring_count)) { ++ ERRMSG("Can't get prb.desc_ring.descs.\n"); ++ goto out_descs; ++ } ++ ++ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.infos)); ++ m.infos = malloc(SIZE(printk_info) * m.desc_ring_count); ++ if (!m.infos) { ++ ERRMSG("Can't allocate memory for prb.desc_ring.infos.\n"); ++ goto out_descs; ++ } ++ if (!readmem(VADDR, kaddr, m.infos, SIZE(printk_info) * m.desc_ring_count)) { ++ ERRMSG("Can't get prb.desc_ring.infos.\n"); ++ goto out_infos; ++ } ++ ++ /* setup text data ring */ ++ m.text_data_ring = m.prb + OFFSET(printk_ringbuffer.text_data_ring); ++ m.text_data_ring_size = 1 << UINT(m.text_data_ring + OFFSET(prb_data_ring.size_bits)); ++ ++ kaddr = ULONG(m.text_data_ring + OFFSET(prb_data_ring.data)); ++ m.text_data = malloc(m.text_data_ring_size); ++ if (!m.text_data) { ++ ERRMSG("Can't allocate memory for prb.text_data_ring.data.\n"); ++ goto out_infos; ++ } ++ if (!readmem(VADDR, kaddr, m.text_data, m.text_data_ring_size)) { ++ ERRMSG("Can't get prb.text_data_ring.\n"); ++ goto out_text_data; ++ } ++ ++ /* ready to go */ ++ ++ tail_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.tail_id) + ++ OFFSET(atomic_long_t.counter)); ++ head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) + ++ OFFSET(atomic_long_t.counter)); ++ ++ if (!open_dump_file()) { ++ ERRMSG("Can't open output file.\n"); ++ goto out_text_data; ++ } ++ ++ for (id = tail_id; id != head_id; id = (id + 1) & DESC_ID_MASK) ++ dump_record(&m, id); ++ ++ /* dump head record */ ++ dump_record(&m, id); ++ ++ if (!close_files_for_creating_dumpfile()) ++ goto out_text_data; ++ ++ ret = TRUE; ++out_text_data: ++ free(m.text_data); ++out_infos: ++ free(m.infos); ++out_descs: ++ free(m.descs); ++out_prb: ++ free(m.prb); ++ return ret; ++} +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 11743a4..9140751 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -102,6 +102,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch Patch602: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch +Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -121,6 +122,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 +%patch603 -p1 %ifarch ppc %define archdef ARCH=ppc From 1d5d39f3d4ff19978d350251f118fe71bfdfb98d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 23 Dec 2020 17:26:24 +0800 Subject: [PATCH 332/806] makedumpfile: printk: use committed/finalized state values commit 44b073b7ec467aee0d7de381d455b8ace1199184 Author: John Ogness Date: Wed Nov 25 10:10:31 2020 +0106 [PATCH 2/2] printk: use committed/finalized state values * Required for kernel 5.10 The ringbuffer entries use 2 state values (committed and finalized) rather than a single flag to represent being available for reading. Copy the definitions and state lookup function directly from the kernel source and use the new states. Signed-off-by: John Ogness Signed-off-by: Kairui Song --- ...-use-committed-finalized-state-value.patch | 99 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 101 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch diff --git a/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch b/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch new file mode 100644 index 0000000..8ec27bf --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch @@ -0,0 +1,99 @@ +From 44b073b7ec467aee0d7de381d455b8ace1199184 Mon Sep 17 00:00:00 2001 +From: John Ogness +Date: Wed, 25 Nov 2020 10:10:31 +0106 +Subject: [PATCH 2/2] [PATCH 2/2] printk: use committed/finalized state values + +* Required for kernel 5.10 + +The ringbuffer entries use 2 state values (committed and finalized) +rather than a single flag to represent being available for reading. +Copy the definitions and state lookup function directly from the +kernel source and use the new states. + +Signed-off-by: John Ogness +--- + printk.c | 48 +++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 41 insertions(+), 7 deletions(-) + +diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c +index acffb6c..2af8562 100644 +--- a/makedumpfile-1.6.8/printk.c ++++ b/makedumpfile-1.6.8/printk.c +@@ -1,12 +1,6 @@ + #include "makedumpfile.h" + #include + +-#define DESC_SV_BITS (sizeof(unsigned long) * 8) +-#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) +-#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) +-#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) +-#define DESC_ID_MASK (~DESC_FLAGS_MASK) +- + /* convenience struct for passing many values to helper functions */ + struct prb_map { + char *prb; +@@ -21,12 +15,51 @@ struct prb_map { + char *text_data; + }; + ++/* ++ * desc_state and DESC_* definitions taken from kernel source: ++ * ++ * kernel/printk/printk_ringbuffer.h ++ */ ++ ++/* The possible responses of a descriptor state-query. */ ++enum desc_state { ++ desc_miss = -1, /* ID mismatch (pseudo state) */ ++ desc_reserved = 0x0, /* reserved, in use by writer */ ++ desc_committed = 0x1, /* committed by writer, could get reopened */ ++ desc_finalized = 0x2, /* committed, no further modification allowed */ ++ desc_reusable = 0x3, /* free, not yet used by any writer */ ++}; ++ ++#define DESC_SV_BITS (sizeof(unsigned long) * 8) ++#define DESC_FLAGS_SHIFT (DESC_SV_BITS - 2) ++#define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) ++#define DESC_STATE(sv) (3UL & (sv >> DESC_FLAGS_SHIFT)) ++#define DESC_ID_MASK (~DESC_FLAGS_MASK) ++#define DESC_ID(sv) ((sv) & DESC_ID_MASK) ++ ++/* ++ * get_desc_state() taken from kernel source: ++ * ++ * kernel/printk/printk_ringbuffer.c ++ */ ++ ++/* Query the state of a descriptor. */ ++static enum desc_state get_desc_state(unsigned long id, ++ unsigned long state_val) ++{ ++ if (id != DESC_ID(state_val)) ++ return desc_miss; ++ ++ return DESC_STATE(state_val); ++} ++ + static void + dump_record(struct prb_map *m, unsigned long id) + { + unsigned long long ts_nsec; + unsigned long state_var; + unsigned short text_len; ++ enum desc_state state; + unsigned long begin; + unsigned long next; + char buf[BUFSIZE]; +@@ -45,7 +78,8 @@ dump_record(struct prb_map *m, unsigned long id) + + /* skip non-committed record */ + state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); +- if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) ++ state = get_desc_state(id, state_var); ++ if (state != desc_committed && state != desc_finalized) + return; + + begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 9140751..f71bc55 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -103,6 +103,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch Patch602: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch +Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -123,6 +124,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 %patch603 -p1 +%patch604 -p1 %ifarch ppc %define archdef ARCH=ppc From 7cb4be80cdaaf85b7dcbdf8f15b113192159026b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 23 Dec 2020 17:40:57 +0800 Subject: [PATCH 333/806] Release 2.0.20-1 Signed-off-by: Kairui Song --- ...-broken-multiboot2-buliding-for-i386.patch | 88 ------------------- kexec-tools.spec | 17 ++-- sources | 2 +- 3 files changed, 11 insertions(+), 96 deletions(-) delete mode 100644 kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch diff --git a/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch b/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch deleted file mode 100644 index 3f0fb33..0000000 --- a/kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 940c3a1e1a304fbecc850c593a272215b0f52eab Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Wed, 31 Jul 2019 16:30:47 +0800 -Subject: [PATCH] x86: Fix broken multiboot2 buliding for i386 - -When building for i386, an error occured: - -kexec/arch/i386/kexec-x86.c:39:22: error: 'multiboot2_x86_probe' -undeclared here (not in a function); did you mean 'multiboot_x86_probe'? -39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, - | ^~~~~~~~~~~~~~~~~~~~ - | multiboot_x86_probe - -kexec/arch/i386/kexec-x86.c:39:44: error: 'multiboot2_x86_load' -undeclared here (not in a function); did you mean 'multiboot_x86_load'? -39 | { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load, - | ^~~~~~~~~~~~~~~~~~~ - | multiboot_x86_load -kexec/arch/i386/kexec-x86.c:40:4: error: 'multiboot2_x86_usage' - undeclared here (not in a function); did you mean 'multiboot_x86_usage'? -40 | multiboot2_x86_usage }, - | ^~~~~~~~~~~~~~~~~~~~ - | multiboot_x86_usage - -Fix this issue by putting the definition in the right header, also tidy -up Makefile. - -Fixes: 22a2ed55132e ("x86: Support multiboot2 images") -Signed-off-by: Kairui Song ---- - kexec/arch/i386/Makefile | 2 +- - kexec/arch/i386/kexec-x86.h | 5 +++++ - kexec/arch/x86_64/kexec-x86_64.h | 5 ----- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/kexec/arch/i386/Makefile b/kexec/arch/i386/Makefile -index 105cefd..f486103 100644 ---- a/kexec/arch/i386/Makefile -+++ b/kexec/arch/i386/Makefile -@@ -7,6 +7,7 @@ i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c - i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c - i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c - i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c -+i386_KEXEC_SRCS += kexec/arch/i386/kexec-mb2-x86.c - i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c - i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c - i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c -@@ -14,7 +15,6 @@ i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c - - dist += kexec/arch/i386/Makefile $(i386_KEXEC_SRCS) \ - kexec/arch/i386/crashdump-x86.h \ -- kexec/arch/i386/kexec-mb2-x86.c \ - kexec/arch/i386/kexec-x86.h \ - kexec/arch/i386/x86-linux-setup.h \ - kexec/arch/i386/include/arch/options.h -diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h -index 1b58c3b..16d0f6c 100644 ---- a/kexec/arch/i386/kexec-x86.h -+++ b/kexec/arch/i386/kexec-x86.h -@@ -60,6 +60,11 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info); - void multiboot_x86_usage(void); - -+int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info); -+void multiboot2_x86_usage(void); -+int multiboot2_x86_probe(const char *buf, off_t buf_len); -+ - int elf_x86_probe(const char *buf, off_t len); - int elf_x86_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info); -diff --git a/kexec/arch/x86_64/kexec-x86_64.h b/kexec/arch/x86_64/kexec-x86_64.h -index 21c3a73..4cdeffb 100644 ---- a/kexec/arch/x86_64/kexec-x86_64.h -+++ b/kexec/arch/x86_64/kexec-x86_64.h -@@ -33,9 +33,4 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info); - void bzImage64_usage(void); - --int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len, -- struct kexec_info *info); --void multiboot2_x86_usage(void); --int multiboot2_x86_probe(const char *buf, off_t buf_len); -- - #endif /* KEXEC_X86_64_H */ --- -2.21.0 - diff --git a/kexec-tools.spec b/kexec-tools.spec index f71bc55..3f94bcb 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.20 -Release: 21%{?dist} +Version: 2.0.21 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -80,7 +80,6 @@ Requires: systemd-udev%{?_isa} # # Patches 0 through 100 are meant for x86 kexec-tools enablement # -Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement @@ -101,7 +100,6 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # Patches 601 onward are generic patches # Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch -Patch602: ./kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch @@ -119,10 +117,7 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch0 -p1 - %patch601 -p1 -%patch602 -p1 %patch603 -p1 %patch604 -p1 @@ -363,6 +358,14 @@ done %endif %changelog +* Wed Dec 23 2020 Kairui Song - 2.0.21-1 +- makedumpfile: printk: use committed/finalized state values +- makedumpfile: printk: add support for lockless ringbuffer +- dracut-module-setup.sh: Use systemctl call to replace ln_r +- Doc: improve mkdumprd man page +- Don's try to restart dracut-initqueue if it's already failed +- dracut-module-setup.sh: use auto6 for ipv6 + * Mon Nov 30 2020 Kairui Song - 2.0.20-21 - Rebase makedumpfile to 1.6.8 - fadump-howto: update about 'nocma' and 'off' options for 'fadump=' parameter diff --git a/sources b/sources index cc14d5b..58d314e 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d -SHA512 (kexec-tools-2.0.20.tar.xz) = 3112b6202c1030705c53e3f65a2b58aec14d65333a35aad681d48b9f2bd1c51a2e05c985a1e5e867ab02f8a9c97708483d9d225619db7c6993676f1a242e2d99 SHA512 (makedumpfile-1.6.8.tar.gz) = 15e60688b06013bf86e339ec855774ea2c904d425371ea867101704ba0611c69da891eb3cc96f67eb10197d8c42d217ea28bf11bcaa93ddc2495cbf984c0b7ec +SHA512 (kexec-tools-2.0.21.tar.xz) = f487d2e243c2c4f29fbc9da7d06806f65210f717904655fc84d8d162b9c4614c3dd62e1bb47104a79f0dc2af04e462baf764fb309b5d7e6d287264cb48fd2a3e From cd8614880498258d05907a05c45b75854ce288c5 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Mon, 14 Dec 2020 17:01:42 +0800 Subject: [PATCH 334/806] Save the final failure information to log file if saving vmcore failed Currently, if saving vmcore failed, the final failure information won't be saved to the kexec-dmesg.log, because the action of saving the log occurs before the final log is printed, it has no chance to save the log(marked it with the '^^^' below) to the log file(kexec-dmesg.log). For example: [1] console log: [ 3.589967] kdump[453]: saving vmcore-dmesg.txt to /sysroot//var/crash/127.0.0.1-2020-11-26-14:19:17/ [ 3.627261] kdump[458]: saving vmcore-dmesg.txt complete [ 3.633923] kdump[460]: saving vmcore [ 3.661020] kdump[465]: saving vmcore failed ^^^^^^^^^^^^^^^^^^^^ [2] kexec-dmesg.log: Nov 26 14:19:17 kvm-06-guest25.hv2.lab.eng.bos.redhat.com kdump[453]: saving vmcore-dmesg.txt to /sysroot//var/crash/127.0.0.1-2020-11-26-14:19:17/ Nov 26 14:19:17 kvm-06-guest25.hv2.lab.eng.bos.redhat.com kdump[458]: saving vmcore-dmesg.txt complete Nov 26 14:19:17 kvm-06-guest25.hv2.lab.eng.bos.redhat.com kdump[460]: saving vmcore Let's improve it in order to avoid the loss of important information. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- dracut-kdump.sh | 45 +++++++++++++++++++++++++++--------------- kdump-lib-initramfs.sh | 20 +++++++++++-------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index c2627c2..370d217 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -105,10 +105,12 @@ dump_raw() dump_ssh() { - local ret + local _ret=0 + local _exitcode=0 _exitcode2=0 local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" local _host=$2 + local _vmcore="vmcore" dinfo "saving to $_host:$_dir" @@ -122,25 +124,36 @@ dump_ssh() if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" - ret=$? - save_log - scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" - if [ $ret -ne 0 ]; then - return 1 - fi - ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1 + _exitcode=$? else $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" - ret=$? - save_log - scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" - if [ $ret -ne 0 ]; then - return 1 - fi - ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/vmcore.flat" || return 1 + _exitcode=$? + _vmcore="vmcore.flat" + fi + + if [ $_exitcode -eq 0 ]; then + ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/$_vmcore" + _exitcode2=$? + if [ $_exitcode2 -ne 0 ]; then + derror "moving vmcore failed, _exitcode:$_exitcode2" + else + dinfo "saving vmcore complete" + fi + else + derror "saving vmcore failed, _exitcode:$_exitcode" + fi + + save_log + scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "saving log file failed, _exitcode:$_ret" + fi + + if [ $_exitcode -ne 0 ] || [ $_exitcode2 -ne 0 ];then + return 1 fi - dinfo "saving vmcore complete" return 0 } diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 791d141..e766f95 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -115,7 +115,7 @@ save_log() # dump_fs dump_fs() { - local ret + local _exitcode local _mp=$1 local _dev=$(get_mount_info SOURCE target $_mp -f) local _op=$(get_mount_info OPTIONS target $_mp -f) @@ -159,16 +159,20 @@ dump_fs() dinfo "saving vmcore" $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete - ret=$? + _exitcode=$? + if [ $_exitcode -eq 0 ]; then + mv $_dump_path/vmcore-incomplete $_dump_path/vmcore + sync + dinfo "saving vmcore complete" + else + derror "saving vmcore failed, _exitcode:$_exitcode" + fi + save_log mv $KDUMP_LOG_FILE $_dump_path/ - if [ $ret -ne 0 ]; then - return 1 + if [ $_exitcode -ne 0 ]; then + return 1 fi - mv $_dump_path/vmcore-incomplete $_dump_path/vmcore - sync - - dinfo "saving vmcore complete" # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure return 0 From 872d6b36de34048e97438b3519310731861bde1c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 5 Jan 2021 22:46:03 +0000 Subject: [PATCH 335/806] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3f94bcb..1a9e77b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -63,6 +63,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool +BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units From 0bd0c5b9f11add0addb3af8e62aa423995e1722b Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 11 Dec 2020 09:20:00 +0800 Subject: [PATCH 336/806] kdumpctl: fix a variable expansion in check_fence_kdump_config() Both $ipaddrs and $node can hold multiple strings, so use "" to brace them. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 3f6a9be..2e7f842 100755 --- a/kdumpctl +++ b/kdumpctl @@ -944,7 +944,7 @@ check_fence_kdump_config() return 1 fi # node can be ipaddr - echo $ipaddrs | grep $node > /dev/null + echo "$ipaddrs " | grep "$node " > /dev/null if [ $? -eq 0 ]; then derror "Option fence_kdump_nodes cannot contain $node" return 1 From 0e540f732888f46d55267a5de28bdb4812f982fa Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 8 Jan 2021 11:03:43 +0800 Subject: [PATCH 337/806] makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO Backports: commit 54aec3878b3f91341e6bc735eda158cca5c54ec9 Author: Alexander Egorenkov Date: Fri Sep 18 13:55:56 2020 +0200 [PATCH] make use of 'uts_namespace.name' offset in VMCOREINFO * Required for kernel 5.11 The offset of the field 'init_uts_ns.name' has changed since kernel commit 9a56493f6942 ("uts: Use generic ns_common::count"). Make use of the offset 'uts_namespace.name' if available in VMCOREINFO. Signed-off-by: Alexander Egorenkov Signed-off-by: Kairui Song --- ...f-uts_namespace.name-offset-in-VMCOR.patch | 101 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 103 insertions(+) create mode 100644 kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch diff --git a/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch b/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch new file mode 100644 index 0000000..0c29723 --- /dev/null +++ b/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch @@ -0,0 +1,101 @@ +From 54aec3878b3f91341e6bc735eda158cca5c54ec9 Mon Sep 17 00:00:00 2001 +From: Alexander Egorenkov +Date: Fri, 18 Sep 2020 13:55:56 +0200 +Subject: [PATCH] [PATCH] make use of 'uts_namespace.name' offset in VMCOREINFO + +* Required for kernel 5.11 + +The offset of the field 'init_uts_ns.name' has changed since +kernel commit 9a56493f6942 ("uts: Use generic ns_common::count"). +Make use of the offset 'uts_namespace.name' if available in +VMCOREINFO. + +Signed-off-by: Alexander Egorenkov +--- + makedumpfile.c | 17 +++++++++++++++-- + makedumpfile.h | 6 ++++++ + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index 061741f..ecd63fa 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -1159,7 +1159,10 @@ check_release(void) + if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) { + utsname = SYMBOL(system_utsname); + } else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) { +- utsname = SYMBOL(init_uts_ns) + sizeof(int); ++ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE) ++ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name); ++ else ++ utsname = SYMBOL(init_uts_ns) + sizeof(int); + } else { + ERRMSG("Can't get the symbol of system_utsname.\n"); + return FALSE; +@@ -2040,6 +2043,11 @@ get_structure_info(void) + SIZE_INIT(cpu_spec, "cpu_spec"); + OFFSET_INIT(cpu_spec.mmu_features, "cpu_spec", "mmu_features"); + ++ /* ++ * Get offsets of the uts_namespace's members. ++ */ ++ OFFSET_INIT(uts_namespace.name, "uts_namespace", "name"); ++ + return TRUE; + } + +@@ -2109,7 +2117,10 @@ get_str_osrelease_from_vmlinux(void) + if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) { + utsname = SYMBOL(system_utsname); + } else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) { +- utsname = SYMBOL(init_uts_ns) + sizeof(int); ++ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE) ++ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name); ++ else ++ utsname = SYMBOL(init_uts_ns) + sizeof(int); + } else { + ERRMSG("Can't get the symbol of system_utsname.\n"); + return FALSE; +@@ -2344,6 +2355,7 @@ write_vmcoreinfo_data(void) + WRITE_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); + WRITE_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); + WRITE_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); ++ WRITE_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name); + + if (SYMBOL(node_data) != NOT_FOUND_SYMBOL) + WRITE_ARRAY_LENGTH("node_data", node_data); +@@ -2743,6 +2755,7 @@ read_vmcoreinfo(void) + READ_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); + READ_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); + READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); ++ READ_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name); + + READ_STRUCTURE_SIZE("printk_log", printk_log); + READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); +diff --git a/makedumpfile.h b/makedumpfile.h +index 47f7e79..5f50080 100644 +--- a/makedumpfile-1.6.8/makedumpfile.h ++++ b/makedumpfile-1.6.8/makedumpfile.h +@@ -1728,6 +1728,8 @@ struct size_table { + long cpu_spec; + + long pageflags; ++ ++ long uts_namespace; + }; + + struct offset_table { +@@ -1935,6 +1937,10 @@ struct offset_table { + struct cpu_spec_s { + long mmu_features; + } cpu_spec; ++ ++ struct uts_namespace_s { ++ long name; ++ } uts_namespace; + }; + + /* +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 1a9e77b..fffb72e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -103,6 +103,7 @@ Requires: systemd-udev%{?_isa} Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch +Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -121,6 +122,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch603 -p1 %patch604 -p1 +%patch605 -p1 %ifarch ppc %define archdef ARCH=ppc From ae142da0a6eccedafc1fb4b0e5346d2ddc276b4b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 8 Jan 2021 11:07:51 +0800 Subject: [PATCH 338/806] Release 2.0.20-2 Signed-off-by: Kairui Song --- kexec-tools.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index fffb72e..6791395 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -361,6 +361,12 @@ done %endif %changelog +* Fri Jan 08 2020 Kairui Song - 2.0.21-2 +- makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO +- kdumpctl: fix a variable expansion in check_fence_kdump_config() +- Add BuildRequires: make +- Save the final failure information to log file if saving vmcore failed + * Wed Dec 23 2020 Kairui Song - 2.0.21-1 - makedumpfile: printk: use committed/finalized state values - makedumpfile: printk: add support for lockless ringbuffer From fc703518525dc85b88873120f2bcf7bffa682735 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 8 Jan 2021 11:15:24 +0800 Subject: [PATCH 339/806] Fix a date error in the change log --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6791395..d7497e0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -361,7 +361,7 @@ done %endif %changelog -* Fri Jan 08 2020 Kairui Song - 2.0.21-2 +* Fri Jan 08 2021 Kairui Song - 2.0.21-2 - makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO - kdumpctl: fix a variable expansion in check_fence_kdump_config() - Add BuildRequires: make From 85c3d6643dd404e2a3d891a08d007da73f3c9c1d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 11 Jan 2021 10:03:12 +0800 Subject: [PATCH 340/806] kdump.conf: Update doc about core_collector for ssh target The current inline comment is a bit misleading, ssh dump target don't need to use scp as core_collector, and when using scp as core_collector, the vmcore could be huge. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump.conf | 2 +- kdump.conf.5 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kdump.conf b/kdump.conf index e4db52e..bd98b79 100644 --- a/kdump.conf +++ b/kdump.conf @@ -21,7 +21,7 @@ # //%HOST-%DATE/, supports DNS. # # ssh -# - Will scp /proc/vmcore to :/%HOST-%DATE/, +# - Will save /proc/vmcore to :/%HOST-%DATE/, # supports DNS. # NOTE: make sure the user has write permissions on the server. # diff --git a/kdump.conf.5 b/kdump.conf.5 index ae07466..2c5a2bc 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -98,6 +98,11 @@ vmcore.flat, you will need to use "makedumpfile -R" to rearrange the dump data from standard input to a normal dumpfile (readable with analysis tools). ie. "makedumpfile -R vmcore < vmcore.flat" +.PP +Note 3: If specified core_collector simply copy the vmcore file to the +dump target (eg: cp, scp), the vmcore could be significantly large. +Please make sure the dump target has enough space, at leaset larger +than the system's RAM. .RE From 50b3b4cb93fb59e1640c01b578f56f1eca0cc2c2 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Wed, 30 Dec 2020 15:08:33 +0800 Subject: [PATCH 341/806] Doc: Improve the kdump sysconfig document Currently, the kdump sysconfig document is missed, let's add it to the kexec-kdump-howto.txt as a document in order to help users better understand these options in the /etc/sysconfig/kdump. Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- kexec-kdump-howto.txt | 84 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 447bc54..88af607 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -524,17 +524,91 @@ to send over the necessary ssh key file. Restart the kdump service via Advanced Setups =============== -Kdump boot directory --------------------- +About /etc/sysconfig/kdump +------------------------------ + +Currently, there are a few options in /etc/sysconfig/kdump, which are +usually used to control the behavior of kdump kernel. Basically, all of +these options have default values, usually we do not need to change them, +but sometimes, we may modify them in order to better control the behavior +of kdump kernel such as debug, etc. + +-KDUMP_BOOTDIR Usually kdump kernel is the same as 1st kernel. So kdump will try to find kdump kernel under /boot according to /proc/cmdline. E.g we execute below command and get an output: cat /proc/cmdline BOOT_IMAGE=/xxx/vmlinuz-3.yyy.zzz root=xxxx ..... -Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz. -However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to -user if kdump kernel is put in a different directory. + +Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz. However, this option +is provided to user if kdump kernel is put in a different directory. + +-KDUMP_IMG + +This represents the image type used for kdump. The default value is "vmlinuz". + +-KDUMP_IMG_EXT + +This represents the images extension. Relocatable kernels don't have one. +Currently, it is a null string by default. + +-KEXEC_ARGS + +Any additional kexec arguments required. For example: +KEXEC_ARGS="--elf32-core-headers". + +In most situations, this should be left empty. But, sometimes we hope to get +additional kexec loading debugging information, we can add the '-d' option +for the debugging. + +-KDUMP_KERNELVER + +This is a kernel version string for the kdump kernel. If the version is not +specified, the init script will try to find a kdump kernel with the same +version number as the running kernel. + +-KDUMP_COMMANDLINE + +The value of 'KDUMP_COMMANDLINE' will be passed to kdump kernel as command +line parameters, this will likely match the contents of the grub kernel line. + +In general, if a command line is not specified, which means that it is a null +string such as KDUMP_COMMANDLINE="", the default will be taken automatically +from the '/proc/cmdline'. + +-KDUMP_COMMANDLINE_REMOVE + +This option allows us to remove arguments from the current kdump command line. +If we don't specify any parameters for the KDUMP_COMMANDLINE, it will inherit +all values from the '/proc/cmdline', which is not expected. As you know, some +default kernel parameters could affect kdump, furthermore, that could cause +the failure of kdump kernel boot. + +In addition, the option is also helpful to debug the kdump kernel, we can use +this option to change kdump kernel command line. + +For more kernel parameters, please refer to kernel document. + +-KDUMP_COMMANDLINE_APPEND + +This option allows us to append arguments to the current kdump command line +after processed by the KDUMP_COMMANDLINE_REMOVE. For kdump kernel, some +specific modules require to be disabled like the mce, cgroup, numa, hest_disable, +etc. Those modules may waste memory or kdump kernel doesn't need them, +furthermore, there may affect kdump kernel boot. + +Just like above option, it can be used to disable or enable some kernel +modules so that we can exclude any errors for kdump kernel, this is very +meaningful for debugging. + +-KDUMP_STDLOGLVL | KDUMP_SYSLOGLVL | KDUMP_KMSGLOGLVL + +These variables are used to control the kdump log level in the first kernel. +In the second kernel, kdump will use the rd.kdumploglvl option to set the log +level in the above KDUMP_COMMANDLINE_APPEND. + +Logging levels: no logging(0), error(1), warn(2), info(3), debug(4) Kdump Post-Capture Executable ----------------------------- From 0843c706723b825653ba4a5d6b1106332d5ed4c8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 13 Jan 2021 17:12:18 +0800 Subject: [PATCH 342/806] Revert "Append both nofail and x-systemd.before to kdump mount target" That commit is trying to workaround a kernel VFS bug. Now, the VFS issue should have been fixed in all recent releases, so remove this workaround. This reverts commit 539bff40830e961d7ef85248e39bff0e40b23c91. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 3 --- 1 file changed, 3 deletions(-) diff --git a/mkdumprd b/mkdumprd index 0623940..8ba8e2a 100644 --- a/mkdumprd +++ b/mkdumprd @@ -86,9 +86,6 @@ to_mount() { # drop nofail or nobootwait _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') - # use both nofail and x-systemd.before to ensure systemd will try best to - # mount it before kdump starts, this is an attempt to improve robustness - _options="$_options,nofail,x-systemd.before=initrd-fs.target" echo "$_pdev $_new_mntpoint $_fstype $_options" } From 7f1f8f229f546818a891400ac7961e485dcd6f3c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 4 Jan 2021 15:24:29 +0800 Subject: [PATCH 343/806] Revert "Don's try to restart dracut-initqueue if it's already failed" systemctl is-failed will not work after dracut isolated to the emergency target, so this judgement is invalid. And the restart is basically harmless, so just revert this commit. This reverts commit ad6a93b00d85a85702bb59d15ecc81a5382a9a31. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e766f95..a60a52a 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -226,8 +226,7 @@ dump_to_rootfs() { dinfo "Trying to bring up rootfs device" - systemctl is-failed dracut-initqueue || systemctl start dracut-initqueue - + systemctl start dracut-initqueue dinfo "Waiting for rootfs mount, will timeout after 90 seconds" systemctl start sysroot.mount From e8ef4db8ff91c57d499677873762c3524e786aa5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 5 Jan 2021 00:35:58 +0800 Subject: [PATCH 344/806] Fix dump_fs mount point detection and fallback mount Simplify the code and fix mount point detection. The code logic is now much simpler: if $1 is not a mount point, call "mount --target $1" again to try mount it. "mount --target" cmd itself can handle all the /etc/fstab parsing job, so drop the buggy and complex bash code. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index a60a52a..cd9d512 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -117,26 +117,15 @@ dump_fs() { local _exitcode local _mp=$1 - local _dev=$(get_mount_info SOURCE target $_mp -f) - local _op=$(get_mount_info OPTIONS target $_mp -f) + ddebug "dump_fs _mp=$_mp" - ddebug "_mp=$_mp _dev=$_dev _op=$_op" - - # If dump path have a corresponding device entry but not mounted, mount it. - if [ -n "$_dev" ] && [ "$_dev" != "rootfs" ]; then - if ! is_mounted "$_mp"; then - dinfo "dump target $_dev is not mounted, trying to mount..." - mkdir -p $_mp - mount -o $_op $_dev $_mp - - if [ $? -ne 0 ]; then - derror "mounting failed (mount point: $_mp, option: $_op)" - return 1 - fi + if ! is_mounted "$_mp"; then + dinfo "dump path \"$_mp\" is not mounted, trying to mount..." + mount --target $_mp + if [ $? -ne 0 ]; then + derror "failed to dump to \"$_mp\", it's not a mount point!" + return 1 fi - else - derror "failed to dump to \"$_mp\", it's not a mount point!" - return 1 fi # Remove -F in makedumpfile case. We don't want a flat format dump here. From 02202aa70fb5230660348882f0466a6f3b9809c2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Jan 2021 20:10:28 +0800 Subject: [PATCH 345/806] logger: source the logger file individually Sourcing logger file in kdump-lib.sh will leak kdump helper to dracut, because module-setup.sh will source kdump-lib.sh. This will make kdump's function override dracut's ones, and lead to unexpected behaviours. So include kdump-logger.sh individually and only source it where it really needed. for module-setup.sh, simply use dracut's logger helper is good enough so just source kdump-logger.sh in kdump only scripts. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-early-kdump.sh | 1 + kdump-dep-generator.sh | 1 + kdump-lib-initramfs.sh | 1 + kdump-lib.sh | 6 ------ kdumpctl | 1 + mkdumprd | 1 + 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index a4e14a4..129841e 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -12,6 +12,7 @@ EARLY_KEXEC_ARGS="" . /etc/sysconfig/kdump . /lib/dracut-lib.sh . /lib/kdump-lib.sh +. /lib/kdump-logger.sh #initiate the kdump logger dlog_init diff --git a/kdump-dep-generator.sh b/kdump-dep-generator.sh index b6fab2d..f48c8f6 100644 --- a/kdump-dep-generator.sh +++ b/kdump-dep-generator.sh @@ -4,6 +4,7 @@ # http://www.freedesktop.org/wiki/Software/systemd/Generators/ . /usr/lib/kdump/kdump-lib.sh +. /usr/lib/kdump/kdump-logger.sh # If invokded with no arguments for testing purpose, output to /tmp to # avoid overriding the existing. diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index cd9d512..059ff20 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,6 +1,7 @@ # These variables and functions are useful in 2nd kernel . /lib/kdump-lib.sh +. /lib/kdump-logger.sh KDUMP_PATH="/var/crash" KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" diff --git a/kdump-lib.sh b/kdump-lib.sh index 0e38580..d2801da 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -8,12 +8,6 @@ FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" -if [ -f /lib/kdump/kdump-logger.sh ]; then - . /lib/kdump/kdump-logger.sh -elif [ -f /lib/kdump-logger.sh ]; then - . /lib/kdump-logger.sh -fi - is_fadump_capable() { # Check if firmware-assisted dump is enabled diff --git a/kdumpctl b/kdumpctl index 2e7f842..24f5cf7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -34,6 +34,7 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh . /lib/kdump/kdump-lib.sh +. /lib/kdump/kdump-logger.sh #initiate the kdump logger dlog_init diff --git a/mkdumprd b/mkdumprd index 8ba8e2a..c34b79c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,6 +13,7 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh . /lib/kdump/kdump-lib.sh +. /lib/kdump/kdump-logger.sh export IN_KDUMP=1 #initiate the kdump logger From d49a5015d8b277a5db51bfa48eb576e5438344c9 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Jan 2021 22:16:27 +0800 Subject: [PATCH 346/806] module-setup.sh: don't source $dracutfunctions There is no need to source the file manually, dracut will always prepare the dracut lib before calling a module-setup.sh Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-module-setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a6edc84..5d1f203 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1,6 +1,5 @@ #!/bin/bash -. $dracutfunctions . /lib/kdump/kdump-lib.sh if ! [[ -d "${initdir}/tmp" ]]; then From 88f787e1f591e4b0411279fd0ffa620266dfb3ef Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 19 Jan 2021 22:23:16 +0800 Subject: [PATCH 347/806] module-setup.sh: don't polute the namespace unnecessarily Only source kdump libs when building a kdump initramfs. Signed-off-by: Kairui Song Acked-by: Lianbo Jiang --- dracut-early-kdump-module-setup.sh | 3 ++- dracut-module-setup.sh | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 3b23383..b25d6b5 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -1,7 +1,6 @@ #!/bin/bash . /etc/sysconfig/kdump -. /lib/kdump/kdump-lib.sh KDUMP_KERNEL="" KDUMP_INITRD="" @@ -21,6 +20,8 @@ depends() { } prepare_kernel_initrd() { + . /lib/kdump/kdump-lib.sh + prepare_kdump_bootinfo # $kernel is a variable from dracut diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 5d1f203..9f9220b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1,10 +1,12 @@ #!/bin/bash -. /lib/kdump/kdump-lib.sh +kdump_module_init() { + if ! [[ -d "${initdir}/tmp" ]]; then + mkdir -p "${initdir}/tmp" + fi -if ! [[ -d "${initdir}/tmp" ]]; then - mkdir -p "${initdir}/tmp" -fi + . /lib/kdump/kdump-lib.sh +} check() { [[ $debug ]] && set -x @@ -19,6 +21,8 @@ check() { depends() { local _dep="base shutdown" + kdump_module_init + add_opt_module() { [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" } @@ -825,6 +829,7 @@ kdump_install_systemd_conf() { } install() { + kdump_module_init kdump_install_conf overwrite_sysctl_conf From 550f1c42851e716daaf403f509c4113ee0bd33a0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 20 Jan 2021 14:37:31 +0800 Subject: [PATCH 348/806] Release 2.0.21-3 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 7cd9dfc..bedc8be 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -361,6 +361,18 @@ done %endif %changelog +* Wed Jan 20 2021 Kairui Song - 2.0.21-3 +- module-setup.sh: don't polute the namespace unnecessarily +- module-setup.sh: don't source $dracutfunctions +- logger: source the logger file individually +- Fix dump_fs mount point detection and fallback mount +- Revert "Don's try to restart dracut-initqueue if it's already failed" +- Revert "Append both nofail and x-systemd.before to kdump mount target" +- Doc: Improve the kdump sysconfig document +- kdump.conf: Update doc about core_collector for ssh target +- Merge #4 `Make dracut-squash a weak dep` +- Fix a date error in the change log + * Fri Jan 08 2021 Kairui Song - 2.0.21-2 - makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO - kdumpctl: fix a variable expansion in check_fence_kdump_config() From a571b0da9ff06d75eb0bb99d38b75a648941de7d Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 14 Jan 2021 11:42:01 +0800 Subject: [PATCH 349/806] fix kdump failure of saving vmcore with the scp + ipv6 method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, kdump will fail to save vmcore when using the scp and ipv6. The reason is that the scp requires IPv6 addresses to be enclosed in square brackets, but ssh doesn’t require this. Let's enclose the ipv6 address in square brackets for scp dump. Signed-off-by: Lianbo Jiang Acked-by: Pingfan Liu --- dracut-kdump.sh | 32 +++++++++++++++++++++++++++++--- kdump-lib-initramfs.sh | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 370d217..3367bc5 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -111,6 +111,7 @@ dump_ssh() local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" local _host=$2 local _vmcore="vmcore" + local _ipv6_addr="" _username="" dinfo "saving to $_host:$_dir" @@ -122,8 +123,17 @@ dump_ssh() dinfo "saving vmcore" + if is_ipv6_address "$_host"; then + _username=${_host%@*} + _ipv6_addr="[${_host#*@}]" + fi + if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" + if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then + scp -q $_opt /proc/vmcore "$_username@$_ipv6_addr:$_dir/vmcore-incomplete" + else + scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" + fi _exitcode=$? else $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" @@ -143,8 +153,13 @@ dump_ssh() derror "saving vmcore failed, _exitcode:$_exitcode" fi + dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/" save_log - scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" + if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then + scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/" + else + scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" + fi _ret=$? if [ $_ret -ne 0 ]; then derror "saving log file failed, _exitcode:$_ret" @@ -161,6 +176,7 @@ save_opalcore_ssh() { local _path=$1 local _opts="$2" local _location=$3 + local _user_name="" _ipv6addr="" ddebug "_path=$_path _opts=$_opts _location=$_location" @@ -173,8 +189,18 @@ save_opalcore_ssh() { fi fi + if is_ipv6_address "$_host"; then + _user_name=${_location%@*} + _ipv6addr="[${_location#*@}]" + fi + dinfo "saving opalcore:$OPALCORE to $_location:$_path" - scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete + + if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then + scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete + else + scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete + fi if [ $? -ne 0 ]; then derror "saving opalcore failed" return 1 diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 059ff20..86065be 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -158,6 +158,7 @@ dump_fs() derror "saving vmcore failed, _exitcode:$_exitcode" fi + dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/" save_log mv $KDUMP_LOG_FILE $_dump_path/ if [ $_exitcode -ne 0 ]; then From 9462a7d5546c48f218248365586c2e818200b81b Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Thu, 14 Jan 2021 11:43:55 +0800 Subject: [PATCH 350/806] kdump.conf: add ipv6 example for nfs and ssh dump At present, there is no ipv6 example for nfs and ssh dump, let's add an example to the kdump.conf. Signed-off-by: Lianbo Jiang Acked-by: Pingfan Liu --- kdump.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kdump.conf b/kdump.conf index bd98b79..dea2e94 100644 --- a/kdump.conf +++ b/kdump.conf @@ -166,7 +166,9 @@ #ext4 LABEL=/boot #ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 #nfs my.server.com:/export/tmp +#nfs [2001:db8::1:2:3:4]:/export/tmp #ssh user@my.server.com +#ssh user@2001:db8::1:2:3:4 #sshkey /root/.ssh/kdump_id_rsa path /var/crash core_collector makedumpfile -l --message-level 7 -d 31 From 24bbe9c05ed7cb8636f2a1bc8f23cbde1c53d51b Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 19 Jan 2021 18:14:20 +0800 Subject: [PATCH 351/806] dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode In fadump mode, it is also useful to observe kdump message through console. Hence enable it. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 9f9220b..21143b4 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -819,13 +819,11 @@ kdump_install_systemd_conf() { # Forward logs to console directly, and don't read Kmsg, this avoids # unneccessary memory consumption and make console output more useful. # Only do so for non fadump image. - if ! is_fadump_capable; then - mkdir -p ${initdir}/etc/systemd/journald.conf.d - echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - fi + mkdir -p ${initdir}/etc/systemd/journald.conf.d + echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf } install() { From 33108ef524ff033295711f888ce2c67d457951aa Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 22 Jan 2021 15:53:52 +0800 Subject: [PATCH 352/806] Release 2.0.21-4 Signed-off-by: Kairui Song --- kexec-tools.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index bedc8be..91bc0f3 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -361,6 +361,11 @@ done %endif %changelog +* Fri Jan 22 2021 Kairui Song - 2.0.21-4 +- dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode +- kdump.conf: add ipv6 example for nfs and ssh dump +- fix kdump failure of saving vmcore with the scp + ipv6 method + * Wed Jan 20 2021 Kairui Song - 2.0.21-3 - module-setup.sh: don't polute the namespace unnecessarily - module-setup.sh: don't source $dracutfunctions From 7a0d2aaed53dc0500860691320a90bc1e695b795 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 15:28:37 +0000 Subject: [PATCH 353/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 91bc0f3..378058e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -361,6 +361,9 @@ done %endif %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 2.0.21-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Fri Jan 22 2021 Kairui Song - 2.0.21-4 - dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode - kdump.conf: add ipv6 example for nfs and ssh dump From 18131894b609eb233496af81d034d65c96d4d0e6 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 4 Feb 2021 09:45:36 +0800 Subject: [PATCH 354/806] kdump-lib.sh: introduce functions to return recommened mem size There is requirement to decide the recommended memory size for the current system. And the algorithm is based on /proc/iomem, so it can align with the algorithm used by reserve_crashkernel() in kernel. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index d2801da..46e5e03 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -823,3 +823,71 @@ prepare_cmdline() echo ${cmdline} } + +#get system memory size in the unit of GB +get_system_size() +{ + result=$(cat /proc/iomem | grep "System RAM" | awk -F ":" '{ print $1 }' | tr [:lower:] [:upper:] | paste -sd+) + result="+$result" + # replace '-' with '+0x' and '+' with '-0x' + sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' ) + size=$(printf "%d\n" $(($sum))) + let size=$size/1024/1024/1024 + + echo $size +} + +get_recommend_size() +{ + local mem_size=$1 + local _ck_cmdline=$2 + local OLDIFS="$IFS" + + last_sz="" + last_unit="" + + IFS=',' + for i in $_ck_cmdline; do + end=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $1 }') + recommend=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $2 }') + size=${end: : -1} + unit=${end: -1} + if [ $unit == 'T' ]; then + let size=$size*1024 + fi + if [ $mem_size -lt $size ]; then + echo $recommend + IFS="$OLDIFS" + return + fi + done + IFS="$OLDIFS" +} + +# return recommended size based on current system RAM size +kdump_get_arch_recommend_size() +{ + if ! [[ -r "/proc/iomem" ]] ; then + echo "Error, can not access /proc/iomem." + return 1 + fi + arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:]) + + if [ $arch == "X86_64" ] || [ $arch == "S390" ]; then + ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" + elif [ $arch == "ARM64" ]; then + ck_cmdline="2G-:448M" + elif [ $arch == "PPC64LE" ]; then + if is_fadump_capable; then + ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" + else + ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + fi + fi + + ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g') + sys_mem=$(get_system_size) + result=$(get_recommend_size $sys_mem "$ck_cmdline") + echo $result + return 0 +} From f39000f5240e577347d2cdae8fd9bcb710fe7325 Mon Sep 17 00:00:00 2001 From: "fj1508ic@fujitsu.com" Date: Tue, 26 Jan 2021 06:37:28 +0000 Subject: [PATCH 355/806] Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel The kdump kernel uses resources for ftrace because trace_buf_size, which specifies the ring buffer size for ftrace, and trace_event, which specifies a valid trace event, are not removed, but the kdump kernel does not require ftrace. trace_buf_size is ignored if the specified size is 0, so specify 1. Signed-off-by: Hisashi Nagaoka Acked-by: Kairui Song --- kdump-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 46e5e03..537d5f8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -821,6 +821,10 @@ prepare_cmdline() fi done + # Remove trace_buf_size, trace_event + cmdline=$(remove_cmdline_param "$cmdline" trace_buf_size trace_event) + cmdline="${cmdline} trace_buf_size=1" + echo ${cmdline} } From 7232f5bff204d4271c02bfd421aef2e8974bd888 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 8 Feb 2021 23:21:25 +0800 Subject: [PATCH 356/806] Release 2.0.21-6 Signed-off-by: Kairui Song --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 378058e..30266da 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -361,6 +361,10 @@ done %endif %changelog +* Mon Feb 08 2021 Kairui Song - 2.0.21-6 +- Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel +- kdump-lib.sh: introduce functions to return recommened mem size + * Tue Jan 26 2021 Fedora Release Engineering - 2.0.21-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild From 2721f323a9fb105471727de3093dda459326aba4 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 8 Feb 2021 14:13:54 +0800 Subject: [PATCH 357/806] add dependency on ipcalc ipcalc is needed for generating 45route-static.conf. However, on newer Fedora, e.g. 34, dracut-network drops dependency on dhcp-client which requires ipcalc. Make kexec-tools explicitly depends on ipcalc. Reported-by: Jie Li Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 30266da..3cbecb5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -63,6 +63,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Recommends: dracut-squash >= 050 Requires: ethtool +Requires: ipcalc BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext From 596fa0a07f089a9dd54cf631124d88653b4d77ec Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 18 Feb 2021 14:01:18 +0800 Subject: [PATCH 358/806] kdumpctl: enable secure boot on ppc64le LPARs On ppc64le LPAR, secure-boot is a little different from bare metal, Where host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists while guest secure boot: /ibm,secure-boot >= 2 Make kexec-tools adapt to LPAR Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib.sh | 9 +++++++-- kdumpctl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 537d5f8..21271cf 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -621,11 +621,16 @@ is_secure_boot_enforced() local secure_boot_file setup_mode_file local secure_boot_byte setup_mode_byte - # On powerpc, os-secureboot-enforcing DT property indicates whether secureboot - # is enforced. Return success, if it is found. + # On powerpc, secure boot is enforced if: + # host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists + # guest secure boot: /ibm,secure-boot >= 2 if [ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]; then return 0 fi + if [ -f /proc/device-tree/ibm,secure-boot ] && \ + [ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]; then + return 0 + fi # Detect secure boot on x86 and arm64 secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) diff --git a/kdumpctl b/kdumpctl index 24f5cf7..c3311ad 100755 --- a/kdumpctl +++ b/kdumpctl @@ -638,6 +638,35 @@ check_rebuild() return $? } +# On ppc64le LPARs, the keys trusted by firmware do not end up in +# .builtin_trusted_keys. So instead, add the key to the .ima keyring +function load_kdump_kernel_key() +{ + # this is only called inside is_secure_boot_enforced, + # no need to retest + + # this is only required if DT /ibm,secure-boot is a file. + # if it is a dir, we are on OpenPower and don't need this. + if ! [ -f /proc/device-tree/ibm,secure-boot ]; then + return + fi + + KDUMP_KEY_ID=$(cat /usr/share/doc/kernel-keys/$KDUMP_KERNELVER/kernel-signing-ppc.cer | + keyctl padd asymmetric kernelkey-$RANDOM %:.ima) +} + +# remove a previously loaded key. There's no real security implication +# to leaving it around, we choose to do this because it makes it easier +# to be idempotent and so as to reduce the potential for confusion. +function remove_kdump_kernel_key() +{ + if [ -z "$KDUMP_KEY_ID" ]; then + return + fi + + keyctl unlink $KDUMP_KEY_ID %:.ima +} + # Load the kdump kernel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. @@ -654,6 +683,7 @@ load_kdump() if is_secure_boot_enforced; then dinfo "Secure Boot is enabled. Using kexec file based syscall." KEXEC_ARGS="$KEXEC_ARGS -s" + load_kdump_kernel_key fi ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL" @@ -675,6 +705,8 @@ load_kdump() set +x exec 2>&12 12>&- + remove_kdump_kernel_key + if [ $ret == 0 ]; then dinfo "kexec: loaded kdump kernel" return 0 From da6f381b081469fccf12110a398d03d1c0810b3f Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 18 Feb 2021 14:12:00 +0530 Subject: [PATCH 359/806] fadump: improve fadump-howto.txt about remote dump target setup While fadump-howto.txt talks about what happens to network interface name on setting up a remote dump target in FADump mode, it doesn't explicitly specify the negative consequences of it. Make it explicit and provide a recommendation to overcome the same. Signed-off-by: Hari Bathini Acked-by: Kairui Song --- fadump-howto.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index 5360f3d..433e9a6 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -224,12 +224,16 @@ Things to remember: dracut_args --add "network" 4) If FADump is configured to capture vmcore to a remote dump target using SSH - or NFS protocol, the network interface is renamed to kdump- - if is generic, for example, *eth#, or net#. This problem - occurs because the vmcore capture scripts in the initial RAM disk (initrd) - add the kdump- prefix to the network interface name to secure persistent - naming. As the same initrd is used for production kernel boot, the interface - name is changed for the production kernel too. + or NFS protocol, the corresponding network interface '' is + renamed to 'kdump-', if it is generic (like *eth# or net#). + It happens because vmcore capture scripts in the initial RAM disk (initrd) + add the 'kdump-' prefix to the network interface name to secure persistent + naming. And as capture kernel and production kernel use the same initrd in + case of FADump, the interface name is changed for the production kernel too. + This is likely to impact network configuration setup for production kernel. + So, it is recommended to use a non-generic name for a network interface, + before setting up FADump to capture vmcore to a remote dump target based on + that network interface, to avoid running into network configuration issues. Dump Triggering methods: From 4b7ff283f5efb4c6e007ef56e4dec74c8a4fbd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 2 Mar 2021 16:13:34 +0100 Subject: [PATCH 360/806] Rebuilt for updated systemd-rpm-macros See https://pagure.io/fesco/issue/2583. --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 3cbecb5..00cf64c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -362,6 +362,10 @@ done %endif %changelog +* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek - 2.0.21-7 +- Rebuilt for updated systemd-rpm-macros + See https://pagure.io/fesco/issue/2583. + * Mon Feb 08 2021 Kairui Song - 2.0.21-6 - Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel - kdump-lib.sh: introduce functions to return recommened mem size From 6a2e820d87106592678391c2cb7befa7033a3cb0 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Sun, 21 Feb 2021 17:23:37 +0530 Subject: [PATCH 361/806] Stop reloading kdump service on CPU hotplug event for FADump As FADump does not require an explicit elfcorehdr update whenever there is CPU hotplug event so let's stop kdump service reload for FADump when CPU hotplug event is triggered. A new label is added to handle CPU and memory hotplug events separately. The updated CPU hotplug event handler make sure that kdump service should not be reloaded when FADump is configured. Signed-off-by: Sourabh Jain Reviewed-by: Pingfan Liu Acked-by: Baoquan He --- 98-kexec.rules.ppc64 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/98-kexec.rules.ppc64 b/98-kexec.rules.ppc64 index 1a91220..a1c00a9 100644 --- a/98-kexec.rules.ppc64 +++ b/98-kexec.rules.ppc64 @@ -1,15 +1,22 @@ -SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload" -SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload" -SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload" +SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload_cpu" +SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload_mem" +SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload_mem" GOTO="kdump_reload_end" -LABEL="kdump_reload" - # If kdump is not loaded, calling kdump-udev-throttle will end up # doing nothing, but systemd-run will always generate extra logs for # each call, so trigger the kdump-udev-throttler only if kdump # service is active to avoid unnecessary logs + +LABEL="kdump_reload_mem" + RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" +GOTO="kdump_reload_end" + +LABEL="kdump_reload_cpu" + +RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump_enabled || cat /sys/kernel/fadump_enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" + LABEL="kdump_reload_end" From 00785873ef364dcbca8765ba22a48a01bdd4fca5 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Fri, 19 Mar 2021 18:07:51 +0800 Subject: [PATCH 362/806] Fix incorrect vmcore permissions when dumped through ssh Previously when dumping vmcore to a remote machine through ssh, the files are created remotely and file permissions are taken from the default umask value, which making the files accessible to anyone on the remote machine. This patch fixed the security issue by setting a customized umask value before the file creation on the remote machine. Signed-off-by: Tao Liu Acked-by: Kairui Song --- dracut-kdump.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 3367bc5..3e65c44 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -136,7 +136,7 @@ dump_ssh() fi _exitcode=$? else - $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512 of=$_dir/vmcore-incomplete" + $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "umask 0077 && dd bs=512 of=$_dir/vmcore-incomplete" _exitcode=$? _vmcore="vmcore.flat" fi @@ -218,7 +218,7 @@ save_vmcore_dmesg_ssh() { local _location=$4 dinfo "saving vmcore-dmesg.txt to $_location:$_path" - $_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt" + $_dmesg_collector /proc/vmcore | ssh $_opts $_location "umask 0077 && dd of=$_path/vmcore-dmesg-incomplete.txt" _exitcode=$? if [ $_exitcode -eq 0 ]; then From 91c802ff526a0aa0618f6d5c282a9b9b8e41bff8 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 18 Mar 2021 16:52:46 +0800 Subject: [PATCH 363/806] Fix incorrect permissions on kdump dmesg file Also known as CVE-2021-20269. The kdump dmesg log files(kexec-dmesg.log, vmcore-dmesg.txt) are generated by shell redirection, which take the default umask value, making the files readable for group and others. This patch chmod these files, making them only accessible to owner. Signed-off-by: Tao Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 1 + kdump-lib-initramfs.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 21143b4..8316589 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -849,6 +849,7 @@ install() { inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/usr/bin/printf" "/sbin/printf" inst "/usr/bin/logger" "/sbin/logger" + inst "/usr/bin/chmod" "/sbin/chmod" inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 86065be..5cb0223 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -111,6 +111,7 @@ save_log() if command -v journalctl > /dev/null; then journalctl -ab >> $KDUMP_LOG_FILE fi + chmod 600 $KDUMP_LOG_FILE } # dump_fs @@ -178,6 +179,7 @@ save_vmcore_dmesg_fs() { _exitcode=$? if [ $_exitcode -eq 0 ]; then mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt + chmod 600 ${_path}/vmcore-dmesg.txt # Make sure file is on disk. There have been instances where later # saving vmcore failed and system rebooted without sync and there From e5a745ce776dd19d617c2025acb3e510585d4e82 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 20 Feb 2021 11:55:52 +0800 Subject: [PATCH 364/806] mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed When nfs-utils is not installed, mounting as NFS fs would fail. Currently, the error message is not user-friendly, mount: /tmp/mkdumprd.HyPGpS/target: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program. kdump: Failed to mount on xxx for kdump preflight check. kdump: mkdumprd: failed to make kdump initrd Prompt the user to install nfs-utilsa in the error message, kdump: Failed to mount on xxx for kdump preflight check. Please make sure nfs-utils has been installed. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- mkdumprd | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index c34b79c..50ebdc8 100644 --- a/mkdumprd +++ b/mkdumprd @@ -185,6 +185,26 @@ check_save_path_fs() fi } +mount_failure() +{ + local _target=$1 + local _mnt=$2 + local _fstype=$3 + local msg="Failed to mount $_target" + + if [ -n "$_mnt" ]; then + msg="$msg on $_mnt" + fi + + msg="$msg for kdump preflight check." + + if [[ $_fstype = "nfs" ]]; then + msg="$msg Please make sure nfs-utils has been installed." + fi + + perror_exit "$msg" +} + check_user_configured_target() { local _target=$1 _cfg_fs_type=$2 _mounted @@ -210,7 +230,7 @@ check_user_configured_target() if ! is_mounted "$_mnt"; then if [[ $_opt = *",noauto"* ]]; then mount $_mnt - [ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check." + [ $? -ne 0 ] && mount_failure "$_target" "$_mnt" "$_fstype" _mounted=$_mnt else perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" @@ -220,7 +240,7 @@ check_user_configured_target() _mnt=$MKDUMPRD_TMPMNT mkdir -p $_mnt mount $_target $_mnt -t $_fstype -o defaults - [ $? -ne 0 ] && perror_exit "Failed to mount $_target for kdump preflight check." + [ $? -ne 0 ] && mount_failure "$_target" "" "$_fstype" _mounted=$_mnt fi From 0dedb2c91a3ae2f377a5b368240a293a4c3bd516 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 24 Mar 2021 11:10:34 +0800 Subject: [PATCH 365/806] selftest: Fix bug of collecting test RPMs from argument Currently, TEST_RPMS would be only using the last RPM. Append each RPM path to TEST_RPMs instead, Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/scripts/build-scripts/test-base-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/build-scripts/test-base-image.sh b/tests/scripts/build-scripts/test-base-image.sh index 5e2d86a..afe1a97 100755 --- a/tests/scripts/build-scripts/test-base-image.sh +++ b/tests/scripts/build-scripts/test-base-image.sh @@ -6,7 +6,7 @@ for _rpm in $@; do if [[ ! -e $_rpm ]]; then perror_exit "'$_rpm' not found" else - TEST_RPMS=$(realpath "$_rpm") + TEST_RPMS="$TEST_RPMS $(realpath "$_rpm")" fi done From bbc064f9582080124a4acc41f7e33e21c4f18a4f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 24 Mar 2021 11:10:35 +0800 Subject: [PATCH 366/806] selftest: add EXTRA_RPMs so dracut RPMs can be installed onto the image to run the tests dracut will build the PRMs which will be installed onto the image to run the tests. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 71b329b..4e9c55f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -74,7 +74,7 @@ $(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS $(BUILD_ROOT)/inst-base-image \ $(TEST_ROOT)/output/test-base-image \ $(TEST_ROOT)/scripts/build-scripts/test-base-image.sh \ - $(KEXEC_TOOLS_RPM) + $(KEXEC_TOOLS_RPM) $(EXTRA_RPMS) test-run: $(TEST_ROOT)/output/test-base-image ifeq ($(strip $(TEST_CASE)),) From 8619f585387d022fd45b1fa153102f3409d9f144 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 24 Mar 2021 11:10:36 +0800 Subject: [PATCH 367/806] selftest: replace qemu-kvm with one based on dracut's run-qemu Dracut's run-qemu could find which virtualization technology to the user in the order of kvm, kqemu, userspace. Using run-qemu could allow running tests where qemu-kvm doesn't exist. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/scripts/run-qemu | 23 +++++++++++++++++++++++ tests/scripts/test-lib.sh | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 tests/scripts/run-qemu diff --git a/tests/scripts/run-qemu b/tests/scripts/run-qemu new file mode 100755 index 0000000..836387a --- /dev/null +++ b/tests/scripts/run-qemu @@ -0,0 +1,23 @@ +#!/bin/bash +# Check which virtualization technology to use +# We prefer kvm, kqemu, userspace in that order. + +# This script is based on https://github.com/dracutdevs/dracut/blob/master/test/run-qemu + +export PATH=/sbin:/bin:/usr/sbin:/usr/bin + +[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS="-cpu max" +$(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu host" +[[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS="-cpu host" +[[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS="-cpu host" +[[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS="-cpu host" +[[ -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-cpu max" +[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-enable-kvm -cpu host" + +[[ $BIN ]] || { + echo "Could not find a working KVM or QEMU to test with!" >&2 + echo "Please install kvm or qemu." >&2 + exit 1 +} + +exec $BIN $ARGS "$@" diff --git a/tests/scripts/test-lib.sh b/tests/scripts/test-lib.sh index aff5cd3..f8a2249 100644 --- a/tests/scripts/test-lib.sh +++ b/tests/scripts/test-lib.sh @@ -89,7 +89,7 @@ run_test_sync() { local qemu_cmd=$(get_test_qemu_cmd $1) if [ -n "$qemu_cmd" ]; then - timeout --foreground 10m qemu-kvm $(get_test_qemu_cmd $1) + timeout --foreground 10m $BASEDIR/run-qemu $(get_test_qemu_cmd $1) else echo "error: test qemu command line is not configured" > /dev/stderr return 1 From 91f1d5989b741eea0ec58525e2d784430282ab7a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 1 Apr 2021 16:53:35 +0800 Subject: [PATCH 368/806] Update eppic to latest upstream snapshot Also fixes a package build failure: ar ccurl libeppic.a eppic_util.o eppic_node.o eppic_var.o eppic_func.o eppic_str.o eppic_op.o eppic_num.o eppic_stat.o eppic_builtin.o eppic_type.o eppic_case.o eppic_api.o eppic_member.o eppic_alloc.o eppic_define.o eppic_input.o eppic_print.o eppicpp.tab.o eppic.tab.o lex.eppic.o lex.eppicpp.o baseops.o ar: eppic_util.o: file format not recognized See eppic commit 0037321e64952b4feb3bd37761fb1067266e9e72 for more details. Signed-off-by: Kairui Song --- ...move-duplicated-variable-declaration.patch | 36 ------------------- kexec-tools.spec | 4 +-- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch diff --git a/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch b/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch deleted file mode 100644 index 8d77b9b..0000000 --- a/kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 2837fb1f5f8362976c188b30ebe50dc8b0377f64 Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Wed, 29 Jan 2020 11:33:18 +0800 -Subject: [PATCH] Remove duplicated variable declaration - -When building on Fedora 32, following error is observed: - -... -/usr/bin/ld: ../eppic/libeppic/libeppic.a(eppic_stat.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: multiple definition of `lastv'; -../eppic/libeppic/libeppic.a(eppic_func.o):/builddir/build/BUILD/kexec-tools-2.0.20/eppic/libeppic/eppic.h:474: first defined here -... - -And apparently, the variable is wrongly declared multiple times. So -remove duplicated declaration. - -Signed-off-by: Kairui Song ---- - libeppic/eppic.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libeppic/eppic.h b/libeppic/eppic.h -index 5664583..836b475 100644 ---- a/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h -+++ b/eppic-d84c3541035d95077aa8571f5d5c3e07c6ef510b/libeppic/eppic.h -@@ -471,7 +471,7 @@ type_t *eppic_addstorage(type_t *t1, type_t *t2); - type_t *eppic_getvoidstruct(int ctype); - - extern int lineno, needvar, instruct, nomacs, eppic_legacy; --node_t *lastv; -+extern node_t *lastv; - - #define NULLNODE ((node_t*)0) - --- -2.24.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 00cf64c..fa5c707 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,4 +1,4 @@ -%global eppic_ver d84c3541035d95077aa8571f5d5c3e07c6ef510b +%global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) %global mkdf_ver 1.6.8 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) @@ -101,7 +101,6 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # -Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch @@ -120,7 +119,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch601 -p1 %patch603 -p1 %patch604 -p1 %patch605 -p1 From ad655087c994fba8f0293e1db47c66e35dcecaa3 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 5 Apr 2021 02:33:03 +0800 Subject: [PATCH 369/806] Release 2.0.21-8 Signed-off-by: Kairui Song --- kexec-tools.spec | 13 ++++++++++++- sources | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index fa5c707..24c6b36 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -360,6 +360,17 @@ done %endif %changelog +* Sat Apr 03 2021 Kairui Song - 2.0.21-8 +- Update eppic to latest upstream snapshot +- mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed +- Fix incorrect permissions on kdump dmesg file +- Fix incorrect vmcore permissions when dumped through ssh +- (origin/main) Stop reloading kdump service on CPU hotplug event for FADump +- Rebuilt for updated systemd-rpm-macros +- fadump: improve fadump-howto.txt about remote dump target setup +- kdumpctl: enable secure boot on ppc64le LPARs +- add dependency on ipcalc + * Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek - 2.0.21-7 - Rebuilt for updated systemd-rpm-macros See https://pagure.io/fesco/issue/2583. diff --git a/sources b/sources index 58d314e..c0e1169 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (eppic-d84c354.tar.gz) = 455b3386c3e4cc546b858f1f8b0e6874072aaae708ebe072452fb5f0b6a81b1f3a315b40f94c3967f38525cadd276864a7bc7f0f12fa421655dcc3b15b70914d SHA512 (makedumpfile-1.6.8.tar.gz) = 15e60688b06013bf86e339ec855774ea2c904d425371ea867101704ba0611c69da891eb3cc96f67eb10197d8c42d217ea28bf11bcaa93ddc2495cbf984c0b7ec SHA512 (kexec-tools-2.0.21.tar.xz) = f487d2e243c2c4f29fbc9da7d06806f65210f717904655fc84d8d162b9c4614c3dd62e1bb47104a79f0dc2af04e462baf764fb309b5d7e6d287264cb48fd2a3e +SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 From c6021648f1db52a5e2eee31ec409efe468fe5af2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 19 Mar 2021 18:21:11 +0800 Subject: [PATCH 370/806] Don't iterate the whole /sys/devices just to find drm device On some large systems, /sys/devices is huge and it's not a wise idea to iterate it. `find` may cause tremendous contention on the kernfs_mutex when there are already stress on /sys, and it will perform very very poorly. Simply check if drm class presents should be good enough. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8316589..affd711 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -58,7 +58,7 @@ depends() { _dep="$_dep znet" fi - if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then + if [ -n "$( ls -A /sys/class/drm 2>/dev/null )" ] || [ -d /sys/module/hyperv_fb ]; then add_opt_module drm fi From 8b4b7bf808117ccf3a4be5c9dc16ad1f008659a3 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 26 Mar 2021 10:22:09 +0800 Subject: [PATCH 371/806] Don't use die in dracut-module-setup.sh die (in dracut-lib.sh) is supposed to be used in the initramfs environment. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index affd711..af8336c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -334,7 +334,10 @@ kdump_setup_znet() { kdump_get_ip_route() { local _route=$(/sbin/ip -o route get to $1 2>&1) - [ $? != 0 ] && die "Bad kdump network destination: $1" + if [[ $? != 0 ]]; then + derror "Bad kdump network destination: $1" + exit 1 + fi echo $_route } From 1ca1b71780b83aa7ede1246d435c9a4207473a3b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Apr 2021 11:44:26 +0800 Subject: [PATCH 372/806] Implement IP netmask calculation to replace "ipcalc -m" Recently, dracut-network drops depedency on dhcp-client which requires ipcalc. Thus the dependency chain "kexec-tools -> dracut-network -> dhcp-client -> ipcalc" is broken. When NIC is configured to a static IP, kexec-tools depended on "ipcalc -m" to get netmask. This commit implements the shell equivalent of "ipcalc -m". The following test code shows cal_netmask_by_prefix is consistent with "ipcalc -m", #!/bin/bash . dracut-module-setup.sh for i in {0..128}; do mask_expected=$(ipcalc -m fe::/$i| cut -d"=" -f2) mask_actual=$(cal_netmask_by_prefix $i "-6") if [[ "$mask_expected" != "$mask_actual" ]]; then echo "prefix="$i, "expected="$mask_expected, "acutal="$mask_actual exit fi done echo "IPv6 tests passed" for i in {0..32}; do mask_expected=$(ipcalc -m 8.8.8.8/$i| cut -d"=" -f2) mask_actual=$(cal_netmask_by_prefix $i "") if [[ "$mask_expected" != "$mask_actual" ]]; then echo "prefix="$i, "expected="$mask_expected, "acutal="$mask_actual exit fi done echo "IPv4 tests passed" i=-2 res=$(cal_netmask_by_prefix "$i" "") if [[ $? -ne 1 ]]; then echo "cal_netmask_by_prefix should exit when prefix<0" exit fi res=$(cal_netmask_by_prefix "$i" "") if [[ $? -ne 1 ]]; then echo "cal_netmask_by_prefix should exit when prefix<0" exit fi i=33 $(cal_netmask_by_prefix $i "") if [[ $? -ne 1 ]]; then echo "cal_netmask_by_prefix should exit when prefix>32 for IPv4" exit fi i=129 $(cal_netmask_by_prefix $i "-6") if [[ $? -ne 1 ]]; then echo "cal_netmask_by_prefix should exit when prefix>128 for IPv4" exit fi echo "Bad prefixes tests passed" echo "All tests passed" Reported-by: Jie Li Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 119 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index af8336c..066d0ce 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -121,12 +121,122 @@ kdump_setup_dns() { done < "/etc/resolv.conf" } +# $1: repeat times +# $2: string to be repeated +# $3: separator +repeatedly_join_str() { + local _count="$1" + local _str="$2" + local _separator="$3" + local i _res + + if [[ "$_count" -le 0 ]]; then + echo -n "" + return + fi + + i=0 + _res="$_str" + ((_count--)) + + while [[ "$i" -lt "$_count" ]]; do + ((i++)) + _res="${_res}${_separator}${_str}" + done + echo -n "$_res" +} + +# $1: prefix +# $2: ipv6_flag="-6" indicates it's IPv6 +# Given a prefix, calculate the netmask (equivalent of "ipcalc -m") +# by concatenating three parts, +# 1) the groups with all bits set 1 +# 2) a group with partial bits set to 0 +# 3) the groups with all bits set to 0 +cal_netmask_by_prefix() { + local _prefix="$1" + local _ipv6_flag="$2" _ipv6 + local _bits_per_octet=8 + local _count _res _octets_per_group _octets_total _seperator _total_groups + local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits + + if [[ "$_ipv6_flag" == "-6" ]]; then + _ipv6=1 + else + _ipv6=0 + fi + + if [[ "$_prefix" -lt 0 || "$_prefix" -gt 128 ]] || \ + ( ((!_ipv6)) && [[ "$_prefix" -gt 32 ]] ); then + derror "Bad prefix:$_prefix for calculating netmask" + exit 1 + fi + + if ((_ipv6)); then + _octets_per_group=2 + _octets_total=16 + _seperator=":" + else + _octets_per_group=1 + _octets_total=4 + _seperator="." + fi + + _total_groups=$((_octets_total/_octets_per_group)) + _bits_per_group=$((_octets_per_group * _bits_per_octet)) + _max_group_value=$(((1 << _bits_per_group) - 1)) + + if ((_ipv6)); then + _max_group_value_repr=$(printf "%x" $_max_group_value) + else + _max_group_value_repr="$_max_group_value" + fi + + _count=$((_prefix/_octets_per_group/_bits_per_octet)) + _first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator") + _res="$_first_part" + + _tmp=$((_octets_total*_bits_per_octet-_prefix)) + _zero_bits=$(expr $_tmp % $_bits_per_group) + if [[ "$_zero_bits" -ne 0 ]]; then + _second_part=$((_max_group_value >> _zero_bits << _zero_bits)) + if ((_ipv6)); then + _second_part=$(printf "%x" $_second_part) + fi + ((_count++)) + if [[ -z "$_first_part" ]]; then + _res="$_second_part" + else + _res="${_first_part}${_seperator}${_second_part}" + fi + fi + + _count=$((_total_groups-_count)) + if [[ "$_count" -eq 0 ]]; then + echo -n "$_res" + return + fi + + if ((_ipv6)) && [[ "$_count" -gt 1 ]] ; then + # use condensed notion for IPv6 + _third_part=":" + else + _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator") + fi + + if [[ -z "$_res" ]] && ((!_ipv6)) ; then + echo -n "${_third_part}" + else + echo -n "${_res}${_seperator}${_third_part}" + fi +} + #$1: netdev name #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { local _netdev="$1" _srcaddr="$2" _ipv6_flag - local _netmask _gateway _ipaddr _target _nexthop + local _netmask _gateway _ipaddr _target _nexthop _prefix _ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}") @@ -144,7 +254,12 @@ kdump_static_ip() { _srcaddr="[$_srcaddr]" _gateway="[$_gateway]" else - _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2) + _prefix=$(cut -d'/' -f2 <<< "$_ipaddr") + _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag") + if [[ "$?" -ne 0 ]]; then + derror "Failed to calculate netmask for $_ipaddr" + exit 1 + fi fi echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi From eca77117062d0a8029ed68bd1cad775db406548a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Apr 2021 11:44:27 +0800 Subject: [PATCH 373/806] Drop dependency on ipcalc A shell equivalent of "ipcalc -m" has been implemented. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kexec-tools.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 24c6b36..5a1fd22 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -63,7 +63,6 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Recommends: dracut-squash >= 050 Requires: ethtool -Requires: ipcalc BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext From 75bdcb7399b6fe48032a8db534e18b01206601bc Mon Sep 17 00:00:00 2001 From: Kelvin Fan Date: Fri, 16 Apr 2021 22:31:13 +0000 Subject: [PATCH 374/806] Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable The `/boot` directory on some operating systems might be read-only. If we cannot write to `$KDUMP_BOOTDIR` when generating the kdump initrd, attempt to place the generated initrd at `/var/lib/kdump` instead. Signed-off by: Kelvin Fan Acked-by: Kairui Song --- 60-kdump.install | 14 ++++++++++---- kdump-lib.sh | 24 +++++++++++++++++------- kdumpctl | 4 ++-- kexec-tools.spec | 2 ++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/60-kdump.install b/60-kdump.install index 0a3b40e..5b0e021 100755 --- a/60-kdump.install +++ b/60-kdump.install @@ -2,17 +2,23 @@ COMMAND="$1" KERNEL_VERSION="$2" -BOOT_DIR_ABS="$3" +KDUMP_INITRD_DIR_ABS="$3" KERNEL_IMAGE="$4" if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then exit 0 fi -if [[ -d "$BOOT_DIR_ABS" ]]; then +if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then KDUMP_INITRD="initrdkdump" else - BOOT_DIR_ABS="/boot" + # If `KDUMP_BOOTDIR` is not writable, then the kdump + # initrd must have been placed at `/var/lib/kdump` + if [[ ! -w "/boot" ]]; then + KDUMP_INITRD_DIR_ABS="/var/lib/kdump" + else + KDUMP_INITRD_DIR_ABS="/boot" + fi KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img" fi @@ -23,7 +29,7 @@ case "$COMMAND" in # and managed by kdump service ;; remove) - rm -f -- "$BOOT_DIR_ABS/$KDUMP_INITRD" + rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD" ret=$? ;; esac diff --git a/kdump-lib.sh b/kdump-lib.sh index 21271cf..5f53a8a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -733,20 +733,30 @@ prepare_kdump_bootinfo() boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" for initrd in $boot_initrdlist; do if [ -f "$KDUMP_BOOTDIR/$initrd" ]; then - DEFAULT_INITRD="$KDUMP_BOOTDIR/$initrd" + defaut_initrd_base="$initrd" + DEFAULT_INITRD="$KDUMP_BOOTDIR/$defaut_initrd_base" break fi done - # Get kdump initrd from default initrd filename + # Create kdump initrd basename from default initrd basename # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img # initrd => initrdkdump - if [[ -z "$DEFAULT_INITRD" ]]; then - KDUMP_INITRD=${KDUMP_BOOTDIR}/initramfs-${KDUMP_KERNELVER}kdump.img - elif [[ $(basename $DEFAULT_INITRD) == *.* ]]; then - KDUMP_INITRD=${DEFAULT_INITRD%.*}kdump.${DEFAULT_INITRD##*.} + if [[ -z "$defaut_initrd_base" ]]; then + kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img + elif [[ $defaut_initrd_base == *.* ]]; then + kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} else - KDUMP_INITRD=${DEFAULT_INITRD}kdump + kdump_initrd_base=${defaut_initrd_base}kdump + fi + + # Place kdump initrd in `/var/lib/kdump` if `KDUMP_BOOTDIR` not writable + if [[ ! -w "$KDUMP_BOOTDIR" ]];then + var_target_initrd_dir="/var/lib/kdump" + mkdir -p "$var_target_initrd_dir" + KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base" + else + KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base" fi } diff --git a/kdumpctl b/kdumpctl index c3311ad..b0846fa 100755 --- a/kdumpctl +++ b/kdumpctl @@ -151,8 +151,8 @@ rebuild_kdump_initrd() rebuild_initrd() { - if [[ ! -w "$KDUMP_BOOTDIR" ]];then - derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" + if [[ ! -w $(dirname $TARGET_INITRD) ]];then + derror "$(dirname $TARGET_INITRD) does not have write permission. Cannot rebuild $TARGET_INITRD" return 1 fi diff --git a/kexec-tools.spec b/kexec-tools.spec index 5a1fd22..cd0ed19 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -169,6 +169,7 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir} mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump +mkdir -p -m755 $RPM_BUILD_ROOT%{_sharedstatedir}/kdump install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec @@ -334,6 +335,7 @@ done %dir %{_sysconfdir}/kdump %dir %{_sysconfdir}/kdump/pre.d %dir %{_sysconfdir}/kdump/post.d +%dir %{_sharedstatedir}/kdump %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 From afda4f4961dbf09f7f64cadd936e01a4675ea31f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 25 Apr 2021 15:58:25 +0800 Subject: [PATCH 375/806] get kdump ifname once in kdump_install_net Signed-off-by: Coiby Xu Acked-by: Kairui Song > $_ip_conf fi @@ -543,8 +544,8 @@ kdump_install_net() { # gateway. if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] && [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then - echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf + echo "kdumpnic=$kdumpnic" > ${initdir}/etc/cmdline.d/60kdumpnic.conf + echo "bootdev=$kdumpnic" > ${initdir}/etc/cmdline.d/70bootdev.conf fi } From 586d767697100598e167993e7cc29b3732d5406a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 25 Apr 2021 15:58:26 +0800 Subject: [PATCH 376/806] pass kdumpnic to kdump_setup_/bond/bridge/vlan directly This avoids calling kdump_setup_ifname repeatedly. Signed-off-by: Coiby Xu Acked-by: Kairui Song > ${initdir}/etc/cmdline.d/41bridge.conf + echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf fi _brif+="$_kdumpdev," done @@ -373,12 +372,11 @@ kdump_setup_bridge() { } kdump_setup_bond() { - local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _netdev=$1 kdumpnic=$2 + local _dev _mac _slaves for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) - _kdumpdev=$(kdump_setup_ifname $_dev) - echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf + echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf @@ -391,12 +389,11 @@ kdump_setup_bond() { } kdump_setup_team() { - local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _netdev=$1 kdumpnic=$2 + local _dev _mac _slaves for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do _mac=$(kdump_get_perm_addr $_dev) - _kdumpdev=$(kdump_setup_ifname $_dev) - echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf + echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf _slaves+="$_kdumpdev," done echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf @@ -414,7 +411,7 @@ kdump_setup_team() { } kdump_setup_vlan() { - local _netdev=$1 + local _netdev=$1 kdumpnic=$2 local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" local _netmac="$(kdump_get_mac_addr $_phydev)" local _kdumpdev @@ -425,10 +422,10 @@ kdump_setup_vlan() { exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" - echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$kdumpnic:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" - echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$kdumpnic:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi } @@ -516,13 +513,13 @@ kdump_install_net() { fi if kdump_is_bridge "$_netdev"; then - kdump_setup_bridge "$_netdev" + kdump_setup_bridge "$_netdev" "$kdumpnic" elif kdump_is_bond "$_netdev"; then - kdump_setup_bond "$_netdev" + kdump_setup_bond "$_netdev" "$kdumpnic" elif kdump_is_team "$_netdev"; then - kdump_setup_team "$_netdev" + kdump_setup_team "$_netdev" "$kdumpnic" elif kdump_is_vlan "$_netdev"; then - kdump_setup_vlan "$_netdev" + kdump_setup_vlan "$_netdev" "$kdumpnic" else _ifname_opts=" ifname=$kdumpnic:$_netmac" echo "$_ifname_opts" >> $_ip_conf From 18ffd3cb174e01ea18c8c56ac7b1503168bf0ec2 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 25 Apr 2021 15:58:27 +0800 Subject: [PATCH 377/806] rd.route should use the name from kdump_setup_ifname This fix bz1854037 which happens because kexec-tools generates rd.route for eth0 instead of for kdump-eth0, 1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools 2. In the 2rd kernel, - dracut/modules.d/40network/net-lib.sh will write /tmp/net.route.eth0 based on rd.route - dracut/modules.d/45ifcfg/write-ifcfg.sh will copy /tmp/net.route.eth0 to /tmp/icfg and then copytree /tmp/ifcfg to /run/initramfs/state/etc/sysconfig/network-scripts 3. NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out ``` $ ip link show 2: kdump-eth0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff 3: eth0: mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000 ``` Reported-by: Huijing Hei Signed-off-by: Coiby Xu Acked-by: Kairui Song > ${initdir}/etc/cmdline.d/45route-static.conf - kdump_handle_mulitpath_route $_netdev $_srcaddr + kdump_handle_mulitpath_route $_netdev $_srcaddr $kdumpnic } kdump_handle_mulitpath_route() { - local _netdev="$1" _srcaddr="$2" _ipv6_flag + local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag local _target _nexthop _route _weight _max_weight _rule if is_ipv6_address $_srcaddr; then @@ -299,9 +299,9 @@ kdump_handle_mulitpath_route() { _nexthop=`echo "$_route" | cut -d ' ' -f3` _max_weight=$_weight if [ "x" != "x"$_ipv6_flag ]; then - _rule="rd.route=[$_target]:[$_nexthop]:$_netdev" + _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" else - _rule="rd.route=$_target:$_nexthop:$_netdev" + _rule="rd.route=$_target:$_nexthop:$kdumpnic" fi fi else @@ -491,7 +491,7 @@ kdump_install_net() { kdump_setup_znet $_netdev fi - _static=$(kdump_static_ip $_netdev $_srcaddr) + _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) if [ -n "$_static" ]; then _proto=none elif is_ipv6_address $_srcaddr; then From 4753ab2c70100c570f32f65245b3173588374a76 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Apr 2021 15:00:21 +0800 Subject: [PATCH 378/806] Revert "rd.route should use the name from kdump_setup_ifname" This reverts commit 18ffd3cb174e01ea18c8c56ac7b1503168bf0ec2. --- dracut-module-setup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 80df59c..d1c2c8d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -235,7 +235,7 @@ cal_netmask_by_prefix() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag + local _netdev="$1" _srcaddr="$2" _ipv6_flag local _netmask _gateway _ipaddr _target _nexthop _prefix _ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}") @@ -273,14 +273,14 @@ kdump_static_ip() { _target="[$_target]" _nexthop="[$_nexthop]" fi - echo "rd.route=$_target:$_nexthop:$kdumpnic" + echo "rd.route=$_target:$_nexthop:$_netdev" done >> ${initdir}/etc/cmdline.d/45route-static.conf - kdump_handle_mulitpath_route $_netdev $_srcaddr $kdumpnic + kdump_handle_mulitpath_route $_netdev $_srcaddr } kdump_handle_mulitpath_route() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag + local _netdev="$1" _srcaddr="$2" _ipv6_flag local _target _nexthop _route _weight _max_weight _rule if is_ipv6_address $_srcaddr; then @@ -299,9 +299,9 @@ kdump_handle_mulitpath_route() { _nexthop=`echo "$_route" | cut -d ' ' -f3` _max_weight=$_weight if [ "x" != "x"$_ipv6_flag ]; then - _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" + _rule="rd.route=[$_target]:[$_nexthop]:$_netdev" else - _rule="rd.route=$_target:$_nexthop:$kdumpnic" + _rule="rd.route=$_target:$_nexthop:$_netdev" fi fi else @@ -491,7 +491,7 @@ kdump_install_net() { kdump_setup_znet $_netdev fi - _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) + _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none elif is_ipv6_address $_srcaddr; then From b0156e9b64778e318039cb12933562d79406d46f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Apr 2021 15:00:15 +0800 Subject: [PATCH 379/806] Revert "pass kdumpnic to kdump_setup_/bond/bridge/vlan directly" This reverts commit 586d767697100598e167993e7cc29b3732d5406a. --- dracut-module-setup.sh | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d1c2c8d..c6c1a9b 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -352,8 +352,8 @@ kdump_setup_ifname() { } kdump_setup_bridge() { - local _netdev=$1 kdumpnic=$2 - local _brif _dev _mac + local _netdev=$1 + local _brif _dev _mac _kdumpdev for _dev in `ls /sys/class/net/$_netdev/brif/`; do _kdumpdev=$_dev if kdump_is_bond "$_dev"; then @@ -364,7 +364,8 @@ kdump_setup_bridge() { kdump_setup_vlan "$_dev" else _mac=$(kdump_get_mac_addr $_dev) - echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf + _kdumpdev=$(kdump_setup_ifname $_dev) + echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf fi _brif+="$_kdumpdev," done @@ -372,11 +373,12 @@ kdump_setup_bridge() { } kdump_setup_bond() { - local _netdev=$1 kdumpnic=$2 - local _dev _mac _slaves + local _netdev=$1 + local _dev _mac _slaves _kdumpdev for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) - echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf + _kdumpdev=$(kdump_setup_ifname $_dev) + echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf @@ -389,11 +391,12 @@ kdump_setup_bond() { } kdump_setup_team() { - local _netdev=$1 kdumpnic=$2 - local _dev _mac _slaves + local _netdev=$1 + local _dev _mac _slaves _kdumpdev for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do _mac=$(kdump_get_perm_addr $_dev) - echo -n " ifname=$kdumpnic:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf + _kdumpdev=$(kdump_setup_ifname $_dev) + echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf _slaves+="$_kdumpdev," done echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf @@ -411,7 +414,7 @@ kdump_setup_team() { } kdump_setup_vlan() { - local _netdev=$1 kdumpnic=$2 + local _netdev=$1 local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" local _netmac="$(kdump_get_mac_addr $_phydev)" local _kdumpdev @@ -422,10 +425,10 @@ kdump_setup_vlan() { exit 1 elif kdump_is_bond "$_phydev"; then kdump_setup_bond "$_phydev" - echo " vlan=$kdumpnic:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" - echo " vlan=$kdumpnic:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi } @@ -513,13 +516,13 @@ kdump_install_net() { fi if kdump_is_bridge "$_netdev"; then - kdump_setup_bridge "$_netdev" "$kdumpnic" + kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - kdump_setup_bond "$_netdev" "$kdumpnic" + kdump_setup_bond "$_netdev" elif kdump_is_team "$_netdev"; then - kdump_setup_team "$_netdev" "$kdumpnic" + kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then - kdump_setup_vlan "$_netdev" "$kdumpnic" + kdump_setup_vlan "$_netdev" else _ifname_opts=" ifname=$kdumpnic:$_netmac" echo "$_ifname_opts" >> $_ip_conf From 8d0ef743e0df7a77b4c67f6a98363c1a92de4038 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Apr 2021 15:00:12 +0800 Subject: [PATCH 380/806] Revert "get kdump ifname once in kdump_install_net" This reverts commit afda4f4961dbf09f7f64cadd936e01a4675ea31f. --- dracut-module-setup.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c6c1a9b..066d0ce 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -480,7 +480,7 @@ kdump_get_remote_ip() # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _srcaddr _route _netdev kdumpnic + local _destaddr _srcaddr _route _netdev local _static _proto _ip_conf _ip_opts _ifname_opts _destaddr=$(kdump_get_remote_ip $1) @@ -488,7 +488,6 @@ kdump_install_net() { _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _netmac=$(kdump_get_mac_addr $_netdev) - kdumpnic=$(kdump_setup_ifname $_netdev) if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev @@ -504,7 +503,7 @@ kdump_install_net() { fi _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" - _ip_opts=" ip=${_static}$kdumpnic:${_proto}" + _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}" # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates @@ -524,7 +523,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" else - _ifname_opts=" ifname=$kdumpnic:$_netmac" + _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$_netmac" echo "$_ifname_opts" >> $_ip_conf fi @@ -544,8 +543,8 @@ kdump_install_net() { # gateway. if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] && [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then - echo "kdumpnic=$kdumpnic" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=$kdumpnic" > ${initdir}/etc/cmdline.d/70bootdev.conf + echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf + echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf fi } From d0e9c51e0de57273a99af8484515f213b8414e65 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 22 Apr 2021 18:21:59 +0530 Subject: [PATCH 381/806] fadump: fix dump capture failure to root disk If the dump target is the root disk, kdump scripts add an entry in /etc/fstab for root disk with /sysroot as the mount point. The root disk, passed through root=<> kernel commandline parameter, is mounted at /sysroot in read-only mode before switching from initial ramdisk. So, in fadump mode, a remount of /sysroot to read-write mode is needed to capture dump successfully, because /sysroot is already mounted as read-only based on root=<> boot parameter. Commit e8ef4db8ff91 ("Fix dump_fs mount point detection and fallback mount") removed initialization of $_op variable, the variable holding the options the dump target was mounted with, leading to the below error as remount was skipped: kdump[586]: saving to /sysroot/var/crash/127.0.0.1-2021-04-22-07:22:08/ kdump.sh[587]: mkdir: cannot create directory '/sysroot/var/crash/127.0.0.1-2021-04-22-07:22:08/': Read-only file system kdump[589]: saving vmcore failed Restore $_op variable initialization in dump_fs() function to fix this. Fixes: e8ef4db8ff91 ("Fix dump_fs mount point detection and fallback mount") Signed-off-by: Hari Bathini Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 5cb0223..15bbd85 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -119,7 +119,8 @@ dump_fs() { local _exitcode local _mp=$1 - ddebug "dump_fs _mp=$_mp" + local _op=$(get_mount_info OPTIONS target $_mp -f) + ddebug "dump_fs _mp=$_mp _opts=$_op" if ! is_mounted "$_mp"; then dinfo "dump path \"$_mp\" is not mounted, trying to mount..." @@ -139,8 +140,8 @@ dump_fs() # Only remount to read-write mode if the dump target is mounted read-only. if [[ "$_op" = "ro"* ]]; then - dinfo "Mounting Dump target $_dev in rw mode." - mount -o remount,rw $_dev $_mp || return 1 + dinfo "Remounting the dump target in rw mode." + mount -o remount,rw $_mp || return 1 fi mkdir -p $_dump_path || return 1 From e1ab0275c0106bccca7131627c40523ce8b6333b Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 19 Apr 2021 22:13:36 +0800 Subject: [PATCH 382/806] Add --dry-run option to prevent writing the dumpfile Backport from upstream. commit 3422e1d6bc3511c5af9cb05ba74ad97dd93ffd7f Author: Julien Thierry Date: Tue Nov 24 10:45:24 2020 +0000 [PATCH 1/2] Add --dry-run option to prevent writing the dumpfile Add a --dry-run option to run all operations without writing the dump to the output file. Signed-off-by: Julien Thierry Signed-off-by: Kazuhito Hagio Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...0.21-makedumpfile-Add-dry-run-option.patch | 177 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 179 insertions(+) create mode 100644 kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch diff --git a/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch b/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch new file mode 100644 index 0000000..ffe8a39 --- /dev/null +++ b/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch @@ -0,0 +1,177 @@ +From 3422e1d6bc3511c5af9cb05ba74ad97dd93ffd7f Mon Sep 17 00:00:00 2001 +From: Julien Thierry +Date: Tue, 24 Nov 2020 10:45:24 +0000 +Subject: [PATCH 02/12] [PATCH 1/2] Add --dry-run option to prevent writing the + dumpfile + +Add a --dry-run option to run all operations without writing the +dump to the output file. + +Signed-off-by: Julien Thierry +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.8 | 6 ++++++ + makedumpfile.c | 37 ++++++++++++++++++++++++++++++------- + makedumpfile.h | 2 ++ + print_info.c | 3 +++ + 4 files changed, 41 insertions(+), 7 deletions(-) + +diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 +index b68a7e3..5e902cd 100644 +--- a/makedumpfile-1.6.8/makedumpfile.8 ++++ b/makedumpfile-1.6.8/makedumpfile.8 +@@ -637,6 +637,12 @@ Show the version of makedumpfile. + Only check whether the command-line parameters are valid or not, and exit. + Preferable to be given as the first parameter. + ++.TP ++\fB\-\-dry-run\fR ++Do not write the output dump file while still performing operations specified ++by other options. ++This option cannot be used with the --dump-dmesg, --reassemble and -g options. ++ + .SH ENVIRONMENT VARIABLES + + .TP 8 +diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c +index ecd63fa..8c80c49 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -1372,6 +1372,8 @@ open_dump_file(void) + if (info->flag_flatten) { + fd = STDOUT_FILENO; + info->name_dumpfile = filename_stdout; ++ } else if (info->flag_dry_run) { ++ fd = -1; + } else if ((fd = open(info->name_dumpfile, open_flags, + S_IRUSR|S_IWUSR)) < 0) { + ERRMSG("Can't open the dump file(%s). %s\n", +@@ -4711,6 +4713,9 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) + { + int status, written_size = 0; + ++ if (info->flag_dry_run) ++ return TRUE; ++ + while (written_size < buf_size) { + status = write(fd, buf + written_size, + buf_size - written_size); +@@ -4748,13 +4753,12 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) + } + if (!write_and_check_space(fd, &fdh, sizeof(fdh), file_name)) + return FALSE; +- } else { +- if (lseek(fd, offset, SEEK_SET) == failed) { +- ERRMSG("Can't seek the dump file(%s). %s\n", +- file_name, strerror(errno)); +- return FALSE; +- } ++ } else if (!info->flag_dry_run && ++ lseek(fd, offset, SEEK_SET) == failed) { ++ ERRMSG("Can't seek the dump file(%s). %s\n", file_name, strerror(errno)); ++ return FALSE; + } ++ + if (!write_and_check_space(fd, buf, buf_size, file_name)) + return FALSE; + +@@ -9112,7 +9116,7 @@ close_dump_memory(void) + void + close_dump_file(void) + { +- if (info->flag_flatten) ++ if (info->flag_flatten || info->flag_dry_run) + return; + + if (close(info->fd_dumpfile) < 0) +@@ -10985,6 +10989,11 @@ check_param_for_generating_vmcoreinfo(int argc, char *argv[]) + + return FALSE; + ++ if (info->flag_dry_run) { ++ MSG("--dry-run cannot be used with -g.\n"); ++ return FALSE; ++ } ++ + return TRUE; + } + +@@ -11029,6 +11038,11 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[]) + || info->flag_exclude_xen_dom || info->flag_split) + return FALSE; + ++ if (info->flag_dry_run) { ++ MSG("--dry-run cannot be used with --reassemble.\n"); ++ return FALSE; ++ } ++ + if ((info->splitting_info + = malloc(sizeof(struct splitting_info) * info->num_dumpfile)) + == NULL) { +@@ -11057,6 +11071,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + || (info->flag_read_vmcoreinfo && info->name_xen_syms)) + return FALSE; + ++ if (info->flag_dry_run && info->flag_dmesg) { ++ MSG("--dry-run cannot be used with --dump-dmesg.\n"); ++ return FALSE; ++ } ++ + if (info->flag_flatten && info->flag_split) + return FALSE; + +@@ -11520,6 +11539,7 @@ static struct option longopts[] = { + {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, + {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, + {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, ++ {"dry-run", no_argument, NULL, OPT_DRY_RUN}, + {0, 0, 0, 0} + }; + +@@ -11686,6 +11706,9 @@ main(int argc, char *argv[]) + info->flag_check_params = TRUE; + message_level = DEFAULT_MSG_LEVEL; + break; ++ case OPT_DRY_RUN: ++ info->flag_dry_run = TRUE; ++ break; + case '?': + MSG("Commandline parameter is invalid.\n"); + MSG("Try `makedumpfile --help' for more information.\n"); +diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h +index 5f50080..4c4222c 100644 +--- a/makedumpfile-1.6.8/makedumpfile.h ++++ b/makedumpfile-1.6.8/makedumpfile.h +@@ -1322,6 +1322,7 @@ struct DumpInfo { + int flag_vmemmap; /* kernel supports vmemmap address space */ + int flag_excludevm; /* -e - excluding unused vmemmap pages */ + int flag_use_count; /* _refcount is named _count in struct page */ ++ int flag_dry_run; /* do not create a vmcore file */ + unsigned long vaddr_for_vtop; /* virtual address for debugging */ + long page_size; /* size of page */ + long page_shift; +@@ -2425,6 +2426,7 @@ struct elf_prstatus { + #define OPT_NUM_THREADS OPT_START+16 + #define OPT_PARTIAL_DMESG OPT_START+17 + #define OPT_CHECK_PARAMS OPT_START+18 ++#define OPT_DRY_RUN OPT_START+19 + + /* + * Function Prototype. +diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c +index e0c38b4..d2b0cb7 100644 +--- a/makedumpfile-1.6.8/print_info.c ++++ b/makedumpfile-1.6.8/print_info.c +@@ -308,6 +308,9 @@ print_usage(void) + MSG(" the crashkernel range, then calculates the page number of different kind per\n"); + MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); + MSG("\n"); ++ MSG(" [--dry-run]:\n"); ++ MSG(" This option runs makedumpfile without writting output dump file.\n"); ++ MSG("\n"); + MSG(" [-D]:\n"); + MSG(" Print debugging message.\n"); + MSG("\n"); +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index cd0ed19..0b16728 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -103,6 +103,7 @@ Requires: systemd-udev%{?_isa} Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch +Patch606: ./kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -121,6 +122,7 @@ tar -z -x -v -f %{SOURCE19} %patch603 -p1 %patch604 -p1 %patch605 -p1 +%patch606 -p1 %ifarch ppc %define archdef ARCH=ppc From 8973bd7ed0a870ccc3c5b9c77f80d704ca2b59c8 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 19 Apr 2021 22:13:37 +0800 Subject: [PATCH 383/806] Add shorthand --show-stats option to show report stats Backport from upstream: commit 6f3e75a558ed50d6ff0b42e3f61c099b2005b7bb Author: Julien Thierry Date: Tue Nov 24 10:45:25 2020 +0000 [PATCH 2/2] Add shorthand --show-stats option to show report stats Provide shorthand --show-stats option to enable report messages without needing to set a particular value for message-level. Signed-off-by: Julien Thierry Signed-off-by: Kazuhito Hagio Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...file-Add-shorthand-show-stats-option.patch | 107 ++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 109 insertions(+) create mode 100644 kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch diff --git a/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch b/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch new file mode 100644 index 0000000..4f259ab --- /dev/null +++ b/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch @@ -0,0 +1,107 @@ +From 6f3e75a558ed50d6ff0b42e3f61c099b2005b7bb Mon Sep 17 00:00:00 2001 +From: Julien Thierry +Date: Tue, 24 Nov 2020 10:45:25 +0000 +Subject: [PATCH 03/12] [PATCH 2/2] Add shorthand --show-stats option to show + report stats + +Provide shorthand --show-stats option to enable report messages +without needing to set a particular value for message-level. + +Signed-off-by: Julien Thierry +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.8 | 5 +++++ + makedumpfile.c | 9 ++++++++- + makedumpfile.h | 1 + + print_info.c | 7 ++++++- + 4 files changed, 20 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 +index 5e902cd..dcca2dd 100644 +--- a/makedumpfile-1.6.8/makedumpfile.8 ++++ b/makedumpfile-1.6.8/makedumpfile.8 +@@ -643,6 +643,11 @@ Do not write the output dump file while still performing operations specified + by other options. + This option cannot be used with the --dump-dmesg, --reassemble and -g options. + ++.TP ++\fB\-\-show-stats\fR ++Display report messages. This is an alternative to enabling bit 4 in the level ++provided to --message-level. ++ + .SH ENVIRONMENT VARIABLES + + .TP 8 +diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c +index 8c80c49..ba0003a 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -11540,13 +11540,14 @@ static struct option longopts[] = { + {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, + {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {"dry-run", no_argument, NULL, OPT_DRY_RUN}, ++ {"show-stats", no_argument, NULL, OPT_SHOW_STATS}, + {0, 0, 0, 0} + }; + + int + main(int argc, char *argv[]) + { +- int i, opt, flag_debug = FALSE; ++ int i, opt, flag_debug = FALSE, flag_show_stats = FALSE; + + if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) { + ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n", +@@ -11709,6 +11710,9 @@ main(int argc, char *argv[]) + case OPT_DRY_RUN: + info->flag_dry_run = TRUE; + break; ++ case OPT_SHOW_STATS: ++ flag_show_stats = TRUE; ++ break; + case '?': + MSG("Commandline parameter is invalid.\n"); + MSG("Try `makedumpfile --help' for more information.\n"); +@@ -11718,6 +11722,9 @@ main(int argc, char *argv[]) + if (flag_debug) + message_level |= ML_PRINT_DEBUG_MSG; + ++ if (flag_show_stats) ++ message_level |= ML_PRINT_REPORT_MSG; ++ + if (info->flag_check_params) + /* suppress debugging messages */ + message_level = DEFAULT_MSG_LEVEL; +diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h +index 4c4222c..2fcb62e 100644 +--- a/makedumpfile-1.6.8/makedumpfile.h ++++ b/makedumpfile-1.6.8/makedumpfile.h +@@ -2427,6 +2427,7 @@ struct elf_prstatus { + #define OPT_PARTIAL_DMESG OPT_START+17 + #define OPT_CHECK_PARAMS OPT_START+18 + #define OPT_DRY_RUN OPT_START+19 ++#define OPT_SHOW_STATS OPT_START+20 + + /* + * Function Prototype. +diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c +index d2b0cb7..ad4184e 100644 +--- a/makedumpfile-1.6.8/print_info.c ++++ b/makedumpfile-1.6.8/print_info.c +@@ -309,7 +309,12 @@ print_usage(void) + MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); + MSG("\n"); + MSG(" [--dry-run]:\n"); +- MSG(" This option runs makedumpfile without writting output dump file.\n"); ++ MSG(" Do not write the output dump file while still performing operations specified\n"); ++ MSG(" by other options. This option cannot be used with --dump-dmesg, --reassemble\n"); ++ MSG(" and -g options.\n"); ++ MSG("\n"); ++ MSG(" [--show-stats]:\n"); ++ MSG(" Set message-level to print report messages\n"); + MSG("\n"); + MSG(" [-D]:\n"); + MSG(" Print debugging message.\n"); +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 0b16728..ba3c247 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -104,6 +104,7 @@ Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ring Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch Patch606: ./kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch +Patch607: ./kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -123,6 +124,7 @@ tar -z -x -v -f %{SOURCE19} %patch604 -p1 %patch605 -p1 %patch606 -p1 +%patch607 -p1 %ifarch ppc %define archdef ARCH=ppc From 0db060c4e26dc13e0f98553480b0e8af4a186874 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 19 Apr 2021 22:13:38 +0800 Subject: [PATCH 384/806] Show write byte size in report messages Backport from upstream: commit 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Author: Kazuhito Hagio Date: Thu Feb 4 16:29:06 2021 +0900 [PATCH] Show write byte size in report messages Show write byte size in report messages. This value can be different from the size of the actual file because of some holes on dumpfile data structure. $ makedumpfile --show-stats -l -d 1 vmcore dump.ld1 ... Total pages : 0x0000000000080000 Write bytes : 377686445 ... # ls -l dump.ld1 -rw------- 1 root root 377691573 Feb 4 16:28 dump.ld1 Note that this value should not be used with /proc/kcore to determine how much disk space is needed for crash dump, because the real memory usage when a crash occurs can vary widely. Signed-off-by: Kazuhito Hagio Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...w-write-byte-size-in-report-messages.patch | 59 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 61 insertions(+) create mode 100644 kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch diff --git a/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch b/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch new file mode 100644 index 0000000..be89b54 --- /dev/null +++ b/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch @@ -0,0 +1,59 @@ +From 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Thu, 4 Feb 2021 16:29:06 +0900 +Subject: [PATCH 09/12] [PATCH] Show write byte size in report messages + +Show write byte size in report messages. This value can be different +from the size of the actual file because of some holes on dumpfile +data structure. + + $ makedumpfile --show-stats -l -d 1 vmcore dump.ld1 + ... + Total pages : 0x0000000000080000 + Write bytes : 377686445 + ... + # ls -l dump.ld1 + -rw------- 1 root root 377691573 Feb 4 16:28 dump.ld1 + +Note that this value should not be used with /proc/kcore to determine +how much disk space is needed for crash dump, because the real memory +usage when a crash occurs can vary widely. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c +index fcd766b..894c88e 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -48,6 +48,8 @@ char filename_stdout[] = FILENAME_STDOUT; + static unsigned long long cache_hit; + static unsigned long long cache_miss; + ++static unsigned long long write_bytes; ++ + static void first_cycle(mdf_pfn_t start, mdf_pfn_t max, struct cycle *cycle) + { + cycle->start_pfn = round(start, info->pfn_cyclic); +@@ -4715,6 +4717,8 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) + { + int status, written_size = 0; + ++ write_bytes += buf_size; ++ + if (info->flag_dry_run) + return TRUE; + +@@ -10002,6 +10006,7 @@ print_report(void) + REPORT_MSG("Memory Hole : 0x%016llx\n", pfn_memhole); + REPORT_MSG("--------------------------------------------------\n"); + REPORT_MSG("Total pages : 0x%016llx\n", info->max_mapnr); ++ REPORT_MSG("Write bytes : %llu\n", write_bytes); + REPORT_MSG("\n"); + REPORT_MSG("Cache hit: %lld, miss: %lld", cache_hit, cache_miss); + if (cache_hit + cache_miss) +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index ba3c247..1e6c99e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -105,6 +105,7 @@ Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch Patch606: ./kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch Patch607: ./kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch +Patch608: ./kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -125,6 +126,7 @@ tar -z -x -v -f %{SOURCE19} %patch605 -p1 %patch606 -p1 %patch607 -p1 +%patch608 -p1 %ifarch ppc %define archdef ARCH=ppc From 475e33030b680143972d8de3273e648cae8372d8 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sun, 25 Apr 2021 17:05:42 +0800 Subject: [PATCH 385/806] Make dracut-squash required for kexec-tools This patch reverts commit "Make dracut-squash a weak dep". Although kexec-tools can work without dracut-squash, it is essential for kdump to run properly in cases [1][2] where minimal amount of memory consumption is expected. Thus dracut-squash is needed for it. [1] https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org/message/SJX7CW3WLOYSFI2YJKGTUGDBWSCMZXVZ/ [2] https://www.spinics.net/lists/systemd-devel/msg05864.html Signed-off-by: Tao Liu Acked-by: Kairui Song --- dracut-module-setup.sh | 3 --- kexec-tools.spec | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 066d0ce..5b810a0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -35,9 +35,6 @@ depends() { modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 fi done - - # check that the dracut squash module is available - [ -d "$(dracut_module_path squash)" ] || return 1 } if is_squash_available && ! is_fadump_capable; then diff --git a/kexec-tools.spec b/kexec-tools.spec index 1e6c99e..49cffce 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -61,7 +61,7 @@ Requires(postun): systemd-units Requires(pre): coreutils sed zlib Requires: dracut >= 050 Requires: dracut-network >= 050 -Recommends: dracut-squash >= 050 +Requires: dracut-squash >= 050 Requires: ethtool BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel From d0a301aa3a76e8006dfbfafb5b1e2f6437bd80af Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 28 Apr 2021 16:51:35 +0800 Subject: [PATCH 386/806] Release 2.0.21-9 Signed-off-by: Kairui Song --- kexec-tools.spec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 49cffce..69a89d5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.21 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -367,6 +367,18 @@ done %endif %changelog +* Wed Apr 28 2021 Kairui Song - 2.0.21-9 +- Make dracut-squash required for kexec-tools +- Show write byte size in report messages +- Add shorthand --show-stats option to show report stats +- Add --dry-run option to prevent writing the dumpfile +- fadump: fix dump capture failure to root disk +- Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable +- Drop dependency on ipcalc +- Implement IP netmask calculation to replace "ipcalc -m" +- Don't use die in dracut-module-setup.sh +- Don't iterate the whole /sys/devices just to find drm device + * Sat Apr 03 2021 Kairui Song - 2.0.21-8 - Update eppic to latest upstream snapshot - mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed From 6137956f79e8dc79bc1048efbe9bccbd66ac61e9 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 14 Apr 2021 13:41:19 +0800 Subject: [PATCH 387/806] kdumpctl: fix check_config error when kdump.conf is empty Kdump scirpt already have default values for core_collector, path in many other place. Empty kdump.conf still works. Fix this corner case and fix the error message. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdumpctl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kdumpctl b/kdumpctl index b0846fa..009d259 100755 --- a/kdumpctl +++ b/kdumpctl @@ -237,12 +237,7 @@ restore_default_initrd() check_config() { local -A _opt_rec - while read config_opt config_val; do - if [ -z "$config_val" ]; then - derror "Invalid kdump config value for option $config_opt" - return 1 - fi - + while read -r config_opt config_val; do case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then @@ -268,12 +263,20 @@ check_config() derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." return 1 ;; + '') + continue + ;; *) derror "Invalid kdump config option $config_opt" return 1 ;; esac + if [[ -z "$config_val" ]]; then + derror "Invalid kdump config value for option '$config_opt'" + return 1 + fi + if [ -n "${_opt_rec[$config_opt]}" ]; then if [ $config_opt == _target ]; then derror "More than one dump targets specified" From ee160bf04dfbe207fdec57adf05a98bf9ad8a83a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 19 Apr 2021 23:00:10 +0800 Subject: [PATCH 388/806] Revert "Always set vm.zone_reclaim_mode = 3 in kdump kernel" This reverts commit 5633e8331866098c97e72e99f233a254fa479a4d. vm.zone_reclaim_mode may cause trashing on some machines. And after second thought, vm.zone_reclaim_mode is barely helpful for machines with high mem stress, so just revert it. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- dracut-module-setup.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 5b810a0..eb8adfd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -642,18 +642,16 @@ kdump_install_conf() { rm -f ${initdir}/tmp/$$-kdump.conf } -# Remove user custom configurations sysctl.conf & sysctl.d/* -# and apply some optimization for kdump -overwrite_sysctl_conf() { +# Default sysctl parameters should suffice for kdump kernel. +# Remove custom configurations sysctl.conf & sysctl.d/* +remove_sysctl_conf() { + # As custom configurations like vm.min_free_kbytes can lead # to OOM issues in kdump kernel, avoid them rm -f "${initdir}/etc/sysctl.conf" rm -rf "${initdir}/etc/sysctl.d" rm -rf "${initdir}/run/sysctl.d" rm -rf "${initdir}/usr/lib/sysctl.d" - - mkdir -p "${initdir}/etc/sysctl.d" - echo "vm.zone_reclaim_mode = 3" > "${initdir}/etc/sysctl.d/99-zone-reclaim.conf" } kdump_iscsi_get_rec_val() { @@ -944,7 +942,7 @@ kdump_install_systemd_conf() { install() { kdump_module_init kdump_install_conf - overwrite_sysctl_conf + remove_sysctl_conf if is_ssh_dump_target; then kdump_install_random_seed From ca05b754af74ab81525ff372f589ccfbc3ac81d9 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 10 May 2021 22:10:26 +0800 Subject: [PATCH 389/806] Fix incorrect file permissions of vmcore-dmesg-incomplete.txt vmcore-dmesg-incomplete.txt is generated by shell redirection, which taking the default umask value. When dmesg collector exits with non-zero, the file will exist and anyone can have access to it. This patch fixed the issue by chmod the file, making it accessible only to its owner. Signed-off-by: Tao Liu Acked-by: Kairui Song --- kdump-lib-initramfs.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 15bbd85..d0d124f 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -188,6 +188,9 @@ save_vmcore_dmesg_fs() { sync dinfo "saving vmcore-dmesg.txt complete" else + if [ -f ${_path}/vmcore-dmesg-incomplete.txt ]; then + chmod 600 ${_path}/vmcore-dmesg-incomplete.txt + fi derror "saving vmcore-dmesg.txt failed" fi } From 97ee5dc64c362cd9eef841378e3d95608f73c72d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 6 May 2021 09:20:26 +0800 Subject: [PATCH 390/806] get kdump ifname once in kdump_install_net Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index eb8adfd..3657b35 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -477,7 +477,7 @@ kdump_get_remote_ip() # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _srcaddr _route _netdev + local _destaddr _srcaddr _route _netdev kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts _destaddr=$(kdump_get_remote_ip $1) @@ -485,6 +485,7 @@ kdump_install_net() { _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _netmac=$(kdump_get_mac_addr $_netdev) + kdumpnic=$(kdump_setup_ifname $_netdev) if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev @@ -500,7 +501,7 @@ kdump_install_net() { fi _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" - _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}" + _ip_opts=" ip=${_static}$kdumpnic:${_proto}" # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates @@ -520,7 +521,7 @@ kdump_install_net() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" else - _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$_netmac" + _ifname_opts=" ifname=$kdumpnic:$_netmac" echo "$_ifname_opts" >> $_ip_conf fi @@ -540,8 +541,8 @@ kdump_install_net() { # gateway. if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] && [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then - echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf + echo "kdumpnic=$kdumpnic" > ${initdir}/etc/cmdline.d/60kdumpnic.conf + echo "bootdev=$kdumpnic" > ${initdir}/etc/cmdline.d/70bootdev.conf fi } From 8a33ffffbcaab4d1baabed889c2a063649dcbab8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 6 May 2021 09:20:27 +0800 Subject: [PATCH 391/806] rd.route should use the name from kdump_setup_ifname This fixes bz1854037 which happens because kexec-tools generates rd.route for eth0 instead of for kdump-eth0, 1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools 2. In the 2rd kernel, dracut/modules.d/35network-manager/nm-config.sh calls /usr/libexec/nm-initrd-generator to generate two .nmconnection files based on the dracut cmdline, i.e. kdump-eth0.nmconnection and eth0.nmconnection, - /run/NetworkManager/system-connections/kdump-eth0.nmconnection [connection] id=kdump-eth0 uuid=3ef53b1b-3908-437e-a15f-cf1f3ea2678b type=ethernet autoconnect-retries=1 interface-name=kdump-eth0 multi-connect=1 permissions= wait-device-timeout=60000 [ethernet] mac-address-blacklist= [ipv4] address1=10.0.0.4/24,10.0.0.1 dhcp-timeout=90 dns=168.63.129.16; dns-search= may-fail=false method=manual [ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=disabled [proxy] - /run/NetworkManager/system-connections/eth0.nmconnection [connection] id=eth0 uuid=f224dc22-2891-4d7b-8f66-745029df4b53 type=ethernet autoconnect-retries=1 interface-name=eth0 multi-connect=1 permissions= [ethernet] mac-address-blacklist= [ipv4] dhcp-timeout=90 dns=168.63.129.16; dns-search= method=auto route1=168.63.129.16/32,10.0.0.1 route2=169.254.169.254/32,10.0.0.1 [ipv6] addr-gen-mode=eui64 dhcp-timeout=90 dns-search= method=auto [proxy] 3. Since there's eth0.nmconnection, NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out ``` $ ip link show 2: kdump-eth0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff 3: eth0: mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000 ``` Reported-by: Huijing Hei Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3657b35..a8bfe53 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -232,7 +232,7 @@ cal_netmask_by_prefix() { #$2: srcaddr #if it use static ip echo it, or echo null kdump_static_ip() { - local _netdev="$1" _srcaddr="$2" _ipv6_flag + local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag local _netmask _gateway _ipaddr _target _nexthop _prefix _ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}") @@ -270,14 +270,14 @@ kdump_static_ip() { _target="[$_target]" _nexthop="[$_nexthop]" fi - echo "rd.route=$_target:$_nexthop:$_netdev" + echo "rd.route=$_target:$_nexthop:$kdumpnic" done >> ${initdir}/etc/cmdline.d/45route-static.conf - kdump_handle_mulitpath_route $_netdev $_srcaddr + kdump_handle_mulitpath_route $_netdev $_srcaddr $kdumpnic } kdump_handle_mulitpath_route() { - local _netdev="$1" _srcaddr="$2" _ipv6_flag + local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag local _target _nexthop _route _weight _max_weight _rule if is_ipv6_address $_srcaddr; then @@ -296,9 +296,9 @@ kdump_handle_mulitpath_route() { _nexthop=`echo "$_route" | cut -d ' ' -f3` _max_weight=$_weight if [ "x" != "x"$_ipv6_flag ]; then - _rule="rd.route=[$_target]:[$_nexthop]:$_netdev" + _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" else - _rule="rd.route=$_target:$_nexthop:$_netdev" + _rule="rd.route=$_target:$_nexthop:$kdumpnic" fi fi else @@ -491,7 +491,7 @@ kdump_install_net() { kdump_setup_znet $_netdev fi - _static=$(kdump_static_ip $_netdev $_srcaddr) + _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) if [ -n "$_static" ]; then _proto=none elif is_ipv6_address $_srcaddr; then From dece041609e9139d0a227ca70f8f329feacce92f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 11 May 2021 01:35:11 +0800 Subject: [PATCH 392/806] Release 2.0.22-1 Update kexec-tools to 2.0.22 Signed-off-by: Kairui Song --- kexec-tools.spec | 12 ++++++++++-- sources | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 69a89d5..264dd40 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.21 -Release: 9%{?dist} +Version: 2.0.22 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -367,6 +367,14 @@ done %endif %changelog +* Tue May 11 2021 Kairui Song - 2.0.22-1 +- Update kexec-tools to 2.0.22 +- rd.route should use the name from kdump_setup_ifname +- get kdump ifname once in kdump_install_net +- Fix incorrect file permissions of vmcore-dmesg-incomplete.txt +- Revert "Always set vm.zone_reclaim_mode = 3 in kdump kernel" +- kdumpctl: fix check_config error when kdump.conf is empty + * Wed Apr 28 2021 Kairui Song - 2.0.21-9 - Make dracut-squash required for kexec-tools - Show write byte size in report messages diff --git a/sources b/sources index c0e1169..c3da2cf 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (makedumpfile-1.6.8.tar.gz) = 15e60688b06013bf86e339ec855774ea2c904d425371ea867101704ba0611c69da891eb3cc96f67eb10197d8c42d217ea28bf11bcaa93ddc2495cbf984c0b7ec -SHA512 (kexec-tools-2.0.21.tar.xz) = f487d2e243c2c4f29fbc9da7d06806f65210f717904655fc84d8d162b9c4614c3dd62e1bb47104a79f0dc2af04e462baf764fb309b5d7e6d287264cb48fd2a3e SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 +SHA512 (kexec-tools-2.0.22.tar.xz) = 7580860f272eee5af52139809f12961e5a5d3a65f4e191183ca9c845410425d25818945ac14ed04a60e6ce474dc2656fc6a14041177b0bf703f450820c7d6aba From c05d8a16a071303920ec840a6207f4db7fc26db4 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 13 May 2021 16:45:13 +0800 Subject: [PATCH 393/806] Update makedumpfile to 1.6.9 Signed-off-by: Kairui Song --- ...ove-duplicated-variable-declarations.patch | 98 --- ...-add-support-for-lockless-ringbuffer.patch | 587 ------------------ ...-use-committed-finalized-state-value.patch | 99 --- ...0.21-makedumpfile-Add-dry-run-option.patch | 177 ------ ...file-Add-shorthand-show-stats-option.patch | 107 ---- ...w-write-byte-size-in-report-messages.patch | 59 -- ...f-uts_namespace.name-offset-in-VMCOR.patch | 101 --- kexec-tools.spec | 16 +- sources | 2 +- 9 files changed, 3 insertions(+), 1243 deletions(-) delete mode 100644 kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch delete mode 100644 kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch delete mode 100644 kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch delete mode 100644 kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch delete mode 100644 kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch delete mode 100644 kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch diff --git a/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch b/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch deleted file mode 100644 index 966f007..0000000 --- a/kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 23daba8bb97ff4291447e54859ed759cfe07975e Mon Sep 17 00:00:00 2001 -From: Kairui Song -Date: Wed, 29 Jan 2020 10:48:27 +0800 -Subject: [PATCH] kexec-tools: Remove duplicated variable declarations - -When building kexec-tools for Fedora 32, following error is observed: - -/usr/bin/ld: kexec/arch/x86_64/kexec-bzImage64.o:(.bss+0x0): multiple definition of `bzImage_support_efi_boot'; -kexec/arch/i386/kexec-bzImage.o:(.bss+0x0): first defined here - -/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm/../../fs2dt.h:33: multiple definition of `my_debug'; -kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/kexec/fs2dt.h:33: first defined here - -/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:68: multiple definition of `arm64_mem'; -kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:68: first defined here - -/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:54: multiple definition of `initrd_size'; -kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:54: first defined here - -/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:53: multiple definition of `initrd_base'; -kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:53: first defined here - -And apparently, these variables are wrongly declared multiple times. So -remove duplicated declaration. - -Signed-off-by: Kairui Song ---- - kexec/arch/arm64/kexec-arm64.h | 6 +++--- - kexec/arch/ppc64/kexec-elf-ppc64.c | 2 -- - kexec/arch/x86_64/kexec-bzImage64.c | 1 - - kexec/fs2dt.h | 2 +- - 4 files changed, 4 insertions(+), 7 deletions(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index 628de79..ed447ac 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -50,8 +50,8 @@ int zImage_arm64_load(int argc, char **argv, const char *kernel_buf, - void zImage_arm64_usage(void); - - --off_t initrd_base; --off_t initrd_size; -+extern off_t initrd_base; -+extern off_t initrd_size; - - /** - * struct arm64_mem - Memory layout info. -@@ -65,7 +65,7 @@ struct arm64_mem { - }; - - #define arm64_mem_ngv UINT64_MAX --struct arm64_mem arm64_mem; -+extern struct arm64_mem arm64_mem; - - uint64_t get_phys_offset(void); - uint64_t get_vp_offset(void); -diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c -index 3510b70..695b8b0 100644 ---- a/kexec/arch/ppc64/kexec-elf-ppc64.c -+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c -@@ -44,8 +44,6 @@ - uint64_t initrd_base, initrd_size; - unsigned char reuse_initrd = 0; - const char *ramdisk; --/* Used for enabling printing message from purgatory code */ --int my_debug = 0; - - int elf_ppc64_probe(const char *buf, off_t len) - { -diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c -index 8edb3e4..ba8dc48 100644 ---- a/kexec/arch/x86_64/kexec-bzImage64.c -+++ b/kexec/arch/x86_64/kexec-bzImage64.c -@@ -42,7 +42,6 @@ - #include - - static const int probe_debug = 0; --int bzImage_support_efi_boot; - - int bzImage64_probe(const char *buf, off_t len) - { -diff --git a/kexec/fs2dt.h b/kexec/fs2dt.h -index 7633273..fe24931 100644 ---- a/kexec/fs2dt.h -+++ b/kexec/fs2dt.h -@@ -30,7 +30,7 @@ extern struct bootblock bb[1]; - - /* Used for enabling printing message from purgatory code - * Only has implemented for PPC64 */ --int my_debug; -+extern int my_debug; - extern int dt_no_old_root; - - void reserve(unsigned long long where, unsigned long long length); --- -2.24.1 - diff --git a/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch b/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch deleted file mode 100644 index c445e76..0000000 --- a/kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch +++ /dev/null @@ -1,587 +0,0 @@ -From c617ec63339222f3a44d73e36677a9acc8954ccd Mon Sep 17 00:00:00 2001 -From: John Ogness -Date: Thu, 19 Nov 2020 02:41:21 +0000 -Subject: [PATCH 1/2] [PATCH 1/2] printk: add support for lockless ringbuffer - -* Required for kernel 5.10 - -Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer -is structured completely different to the previous iterations. -Add support for retrieving the ringbuffer from debug information -and/or using vmcoreinfo. The new ringbuffer is detected based on -the availability of the "prb" symbol. - -Signed-off-by: John Ogness -Signed-off-by: Kazuhito Hagio ---- - Makefile | 2 +- - dwarf_info.c | 36 ++++++++- - makedumpfile.c | 103 +++++++++++++++++++++++- - makedumpfile.h | 58 ++++++++++++++ - printk.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 399 insertions(+), 7 deletions(-) - create mode 100644 printk.c - -diff --git a/makedumpfile-1.6.8/Makefile b/makedumpfile-1.6.8/Makefile -index e5ac71a..cb6bd42 100644 ---- a/makedumpfile-1.6.8/Makefile -+++ b/makedumpfile-1.6.8/Makefile -@@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32 - endif - - SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h --SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c -+SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c - OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) - SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c - OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) -diff --git a/makedumpfile-1.6.8/dwarf_info.c b/makedumpfile-1.6.8/dwarf_info.c -index e42a9f5..543588b 100644 ---- a/makedumpfile-1.6.8/dwarf_info.c -+++ b/makedumpfile-1.6.8/dwarf_info.c -@@ -614,6 +614,7 @@ search_structure(Dwarf_Die *die, int *found) - { - int tag; - const char *name; -+ Dwarf_Die die_type; - - /* - * If we get to here then we don't have any more -@@ -622,9 +623,31 @@ search_structure(Dwarf_Die *die, int *found) - do { - tag = dwarf_tag(die); - name = dwarf_diename(die); -- if ((tag != DW_TAG_structure_type) || (!name) -- || strcmp(name, dwarf_info.struct_name)) -+ if ((!name) || strcmp(name, dwarf_info.struct_name)) -+ continue; -+ -+ if (tag == DW_TAG_typedef) { -+ if (!get_die_type(die, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ break; -+ } -+ -+ /* Resolve typedefs of typedefs. */ -+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { -+ if (!get_die_type(&die_type, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ return; -+ } -+ } -+ -+ if (tag != DW_TAG_structure_type) -+ continue; -+ die = &die_type; -+ -+ } else if (tag != DW_TAG_structure_type) { - continue; -+ } -+ - /* - * Skip if DW_AT_byte_size is not included. - */ -@@ -740,6 +763,15 @@ search_typedef(Dwarf_Die *die, int *found) - ERRMSG("Can't get CU die of DW_AT_type.\n"); - break; - } -+ -+ /* Resolve typedefs of typedefs. */ -+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { -+ if (!get_die_type(&die_type, &die_type)) { -+ ERRMSG("Can't get CU die of DW_AT_type.\n"); -+ return; -+ } -+ } -+ - dwarf_info.struct_size = dwarf_bytesize(&die_type); - if (dwarf_info.struct_size <= 0) - continue; -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index cdde040..061741f 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -1555,6 +1555,7 @@ get_symbol_info(void) - SYMBOL_INIT(node_data, "node_data"); - SYMBOL_INIT(pgdat_list, "pgdat_list"); - SYMBOL_INIT(contig_page_data, "contig_page_data"); -+ SYMBOL_INIT(prb, "prb"); - SYMBOL_INIT(log_buf, "log_buf"); - SYMBOL_INIT(log_buf_len, "log_buf_len"); - SYMBOL_INIT(log_end, "log_end"); -@@ -1971,16 +1972,47 @@ get_structure_info(void) - OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz"); - - SIZE_INIT(printk_log, "printk_log"); -- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ SIZE_INIT(printk_ringbuffer, "printk_ringbuffer"); -+ if ((SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE)) { -+ info->flag_use_printk_ringbuffer = TRUE; -+ info->flag_use_printk_log = FALSE; -+ -+ OFFSET_INIT(printk_ringbuffer.desc_ring, "printk_ringbuffer", "desc_ring"); -+ OFFSET_INIT(printk_ringbuffer.text_data_ring, "printk_ringbuffer", "text_data_ring"); -+ -+ OFFSET_INIT(prb_desc_ring.count_bits, "prb_desc_ring", "count_bits"); -+ OFFSET_INIT(prb_desc_ring.descs, "prb_desc_ring", "descs"); -+ OFFSET_INIT(prb_desc_ring.infos, "prb_desc_ring", "infos"); -+ OFFSET_INIT(prb_desc_ring.head_id, "prb_desc_ring", "head_id"); -+ OFFSET_INIT(prb_desc_ring.tail_id, "prb_desc_ring", "tail_id"); -+ -+ SIZE_INIT(prb_desc, "prb_desc"); -+ OFFSET_INIT(prb_desc.state_var, "prb_desc", "state_var"); -+ OFFSET_INIT(prb_desc.text_blk_lpos, "prb_desc", "text_blk_lpos"); -+ -+ OFFSET_INIT(prb_data_blk_lpos.begin, "prb_data_blk_lpos", "begin"); -+ OFFSET_INIT(prb_data_blk_lpos.next, "prb_data_blk_lpos", "next"); -+ -+ OFFSET_INIT(prb_data_ring.size_bits, "prb_data_ring", "size_bits"); -+ OFFSET_INIT(prb_data_ring.data, "prb_data_ring", "data"); -+ -+ SIZE_INIT(printk_info, "printk_info"); -+ OFFSET_INIT(printk_info.ts_nsec, "printk_info", "ts_nsec"); -+ OFFSET_INIT(printk_info.text_len, "printk_info", "text_len"); -+ -+ OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter"); -+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { - /* - * In kernel 3.11-rc4 the log structure name was renamed - * to "printk_log". - */ -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = TRUE; - OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec"); - OFFSET_INIT(printk_log.len, "printk_log", "len"); - OFFSET_INIT(printk_log.text_len, "printk_log", "text_len"); - } else { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = FALSE; - SIZE_INIT(printk_log, "log"); - OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec"); -@@ -2191,6 +2223,7 @@ write_vmcoreinfo_data(void) - WRITE_SYMBOL("node_data", node_data); - WRITE_SYMBOL("pgdat_list", pgdat_list); - WRITE_SYMBOL("contig_page_data", contig_page_data); -+ WRITE_SYMBOL("prb", prb); - WRITE_SYMBOL("log_buf", log_buf); - WRITE_SYMBOL("log_buf_len", log_buf_len); - WRITE_SYMBOL("log_end", log_end); -@@ -2222,7 +2255,11 @@ write_vmcoreinfo_data(void) - WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s); - WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t); - WRITE_STRUCTURE_SIZE("pageflags", pageflags); -- if (info->flag_use_printk_log) -+ if (info->flag_use_printk_ringbuffer) { -+ WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); -+ WRITE_STRUCTURE_SIZE("prb_desc", prb_desc); -+ WRITE_STRUCTURE_SIZE("printk_info", printk_info); -+ } else if (info->flag_use_printk_log) - WRITE_STRUCTURE_SIZE("printk_log", printk_log); - else - WRITE_STRUCTURE_SIZE("log", printk_log); -@@ -2268,7 +2305,30 @@ write_vmcoreinfo_data(void) - WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr); - WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start); - WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list); -- if (info->flag_use_printk_log) { -+ if (info->flag_use_printk_ringbuffer) { -+ WRITE_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); -+ WRITE_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); -+ -+ WRITE_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); -+ WRITE_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); -+ -+ WRITE_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); -+ WRITE_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); -+ -+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); -+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); -+ -+ WRITE_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); -+ WRITE_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); -+ -+ WRITE_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); -+ WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); -+ -+ WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); -+ } else if (info->flag_use_printk_log) { - WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); - WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len); - WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); -@@ -2606,6 +2666,7 @@ read_vmcoreinfo(void) - READ_SYMBOL("node_data", node_data); - READ_SYMBOL("pgdat_list", pgdat_list); - READ_SYMBOL("contig_page_data", contig_page_data); -+ READ_SYMBOL("prb", prb); - READ_SYMBOL("log_buf", log_buf); - READ_SYMBOL("log_buf_len", log_buf_len); - READ_SYMBOL("log_end", log_end); -@@ -2684,12 +2745,43 @@ read_vmcoreinfo(void) - READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); - - READ_STRUCTURE_SIZE("printk_log", printk_log); -- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); -+ if (SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE) { -+ info->flag_use_printk_ringbuffer = TRUE; -+ info->flag_use_printk_log = FALSE; -+ -+ READ_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring); -+ READ_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring); -+ -+ READ_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits); -+ READ_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs); -+ READ_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos); -+ READ_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id); -+ READ_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id); -+ -+ READ_STRUCTURE_SIZE("prb_desc", prb_desc); -+ READ_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var); -+ READ_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos); -+ -+ READ_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin); -+ READ_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next); -+ -+ READ_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits); -+ READ_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data); -+ -+ READ_STRUCTURE_SIZE("printk_info", printk_info); -+ READ_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec); -+ READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len); -+ -+ READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter); -+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = TRUE; - READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec); - READ_MEMBER_OFFSET("printk_log.len", printk_log.len); - READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len); - } else { -+ info->flag_use_printk_ringbuffer = FALSE; - info->flag_use_printk_log = FALSE; - READ_STRUCTURE_SIZE("log", printk_log); - READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec); -@@ -5286,6 +5378,9 @@ dump_dmesg() - if (!initial()) - return FALSE; - -+ if ((SYMBOL(prb) != NOT_FOUND_SYMBOL)) -+ return dump_lockless_dmesg(); -+ - if ((SYMBOL(log_buf) == NOT_FOUND_SYMBOL) - || (SYMBOL(log_buf_len) == NOT_FOUND_SYMBOL)) { - ERRMSG("Can't find some symbols for log_buf.\n"); -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 698c054..47f7e79 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1317,6 +1317,7 @@ struct DumpInfo { - int flag_partial_dmesg; /* dmesg dump only from the last cleared index*/ - int flag_mem_usage; /*show the page number of memory in different use*/ - int flag_use_printk_log; /* did we read printk_log symbol name? */ -+ int flag_use_printk_ringbuffer; /* using lockless printk ringbuffer? */ - int flag_nospace; /* the flag of "No space on device" error */ - int flag_vmemmap; /* kernel supports vmemmap address space */ - int flag_excludevm; /* -e - excluding unused vmemmap pages */ -@@ -1602,6 +1603,7 @@ struct symbol_table { - unsigned long long node_data; - unsigned long long pgdat_list; - unsigned long long contig_page_data; -+ unsigned long long prb; - unsigned long long log_buf; - unsigned long long log_buf_len; - unsigned long long log_end; -@@ -1689,6 +1691,13 @@ struct size_table { - long nodemask_t; - long printk_log; - -+ /* -+ * for lockless printk ringbuffer -+ */ -+ long printk_ringbuffer; -+ long prb_desc; -+ long printk_info; -+ - /* - * for Xen extraction - */ -@@ -1864,6 +1873,52 @@ struct offset_table { - long text_len; - } printk_log; - -+ /* -+ * for lockless printk ringbuffer -+ */ -+ struct printk_ringbuffer_s { -+ long desc_ring; -+ long text_data_ring; -+ long fail; -+ } printk_ringbuffer; -+ -+ struct prb_desc_ring_s { -+ long count_bits; -+ long descs; -+ long infos; -+ long head_id; -+ long tail_id; -+ } prb_desc_ring; -+ -+ struct prb_desc_s { -+ long state_var; -+ long text_blk_lpos; -+ } prb_desc; -+ -+ struct prb_data_blk_lpos_s { -+ long begin; -+ long next; -+ } prb_data_blk_lpos; -+ -+ struct printk_info_s { -+ long seq; -+ long ts_nsec; -+ long text_len; -+ long caller_id; -+ long dev_info; -+ } printk_info; -+ -+ struct prb_data_ring_s { -+ long size_bits; -+ long data; -+ long head_lpos; -+ long tail_lpos; -+ } prb_data_ring; -+ -+ struct atomic_long_t_s { -+ long counter; -+ } atomic_long_t; -+ - /* - * symbols on ppc64 arch - */ -@@ -2390,4 +2445,7 @@ int hexadecimal(char *s, int count); - int decimal(char *s, int count); - int file_exists(char *file); - -+int open_dump_file(void); -+int dump_lockless_dmesg(void); -+ - #endif /* MAKEDUMPFILE_H */ -diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c -new file mode 100644 -index 0000000..acffb6c ---- /dev/null -+++ b/makedumpfile-1.6.8/printk.c -@@ -0,0 +1,207 @@ -+#include "makedumpfile.h" -+#include -+ -+#define DESC_SV_BITS (sizeof(unsigned long) * 8) -+#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) -+#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) -+#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) -+#define DESC_ID_MASK (~DESC_FLAGS_MASK) -+ -+/* convenience struct for passing many values to helper functions */ -+struct prb_map { -+ char *prb; -+ -+ char *desc_ring; -+ unsigned long desc_ring_count; -+ char *descs; -+ char *infos; -+ -+ char *text_data_ring; -+ unsigned long text_data_ring_size; -+ char *text_data; -+}; -+ -+static void -+dump_record(struct prb_map *m, unsigned long id) -+{ -+ unsigned long long ts_nsec; -+ unsigned long state_var; -+ unsigned short text_len; -+ unsigned long begin; -+ unsigned long next; -+ char buf[BUFSIZE]; -+ ulonglong nanos; -+ int indent_len; -+ int buf_need; -+ char *bufp; -+ char *text; -+ char *desc; -+ char *inf; -+ ulong rem; -+ char *p; -+ int i; -+ -+ desc = m->descs + ((id % m->desc_ring_count) * SIZE(prb_desc)); -+ -+ /* skip non-committed record */ -+ state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); -+ if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) -+ return; -+ -+ begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % -+ m->text_data_ring_size; -+ next = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.next)) % -+ m->text_data_ring_size; -+ -+ /* skip data-less text blocks */ -+ if (begin == next) -+ return; -+ -+ inf = m->infos + ((id % m->desc_ring_count) * SIZE(printk_info)); -+ -+ text_len = USHORT(inf + OFFSET(printk_info.text_len)); -+ -+ /* handle wrapping data block */ -+ if (begin > next) -+ begin = 0; -+ -+ /* skip over descriptor ID */ -+ begin += sizeof(unsigned long); -+ -+ /* handle truncated messages */ -+ if (next - begin < text_len) -+ text_len = next - begin; -+ -+ text = m->text_data + begin; -+ -+ ts_nsec = ULONGLONG(inf + OFFSET(printk_info.ts_nsec)); -+ nanos = (ulonglong)ts_nsec / (ulonglong)1000000000; -+ rem = (ulonglong)ts_nsec % (ulonglong)1000000000; -+ -+ bufp = buf; -+ bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000); -+ indent_len = strlen(buf); -+ -+ /* How much buffer space is needed in the worst case */ -+ buf_need = MAX(sizeof("\\xXX\n"), sizeof("\n") + indent_len); -+ -+ for (i = 0, p = text; i < text_len; i++, p++) { -+ if (bufp - buf >= sizeof(buf) - buf_need) { -+ if (write(info->fd_dumpfile, buf, bufp - buf) < 0) -+ return; -+ bufp = buf; -+ } -+ -+ if (*p == '\n') -+ bufp += sprintf(bufp, "\n%-*s", indent_len, ""); -+ else if (isprint(*p) || isspace(*p)) -+ *bufp++ = *p; -+ else -+ bufp += sprintf(bufp, "\\x%02x", *p); -+ } -+ -+ *bufp++ = '\n'; -+ -+ write(info->fd_dumpfile, buf, bufp - buf); -+} -+ -+int -+dump_lockless_dmesg(void) -+{ -+ unsigned long head_id; -+ unsigned long tail_id; -+ unsigned long kaddr; -+ unsigned long id; -+ struct prb_map m; -+ int ret = FALSE; -+ -+ /* setup printk_ringbuffer */ -+ if (!readmem(VADDR, SYMBOL(prb), &kaddr, sizeof(kaddr))) { -+ ERRMSG("Can't get the prb address.\n"); -+ return ret; -+ } -+ -+ m.prb = malloc(SIZE(printk_ringbuffer)); -+ if (!m.prb) { -+ ERRMSG("Can't allocate memory for prb.\n"); -+ return ret; -+ } -+ if (!readmem(VADDR, kaddr, m.prb, SIZE(printk_ringbuffer))) { -+ ERRMSG("Can't get prb.\n"); -+ goto out_prb; -+ } -+ -+ /* setup descriptor ring */ -+ m.desc_ring = m.prb + OFFSET(printk_ringbuffer.desc_ring); -+ m.desc_ring_count = 1 << UINT(m.desc_ring + OFFSET(prb_desc_ring.count_bits)); -+ -+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.descs)); -+ m.descs = malloc(SIZE(prb_desc) * m.desc_ring_count); -+ if (!m.descs) { -+ ERRMSG("Can't allocate memory for prb.desc_ring.descs.\n"); -+ goto out_prb; -+ } -+ if (!readmem(VADDR, kaddr, m.descs, -+ SIZE(prb_desc) * m.desc_ring_count)) { -+ ERRMSG("Can't get prb.desc_ring.descs.\n"); -+ goto out_descs; -+ } -+ -+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.infos)); -+ m.infos = malloc(SIZE(printk_info) * m.desc_ring_count); -+ if (!m.infos) { -+ ERRMSG("Can't allocate memory for prb.desc_ring.infos.\n"); -+ goto out_descs; -+ } -+ if (!readmem(VADDR, kaddr, m.infos, SIZE(printk_info) * m.desc_ring_count)) { -+ ERRMSG("Can't get prb.desc_ring.infos.\n"); -+ goto out_infos; -+ } -+ -+ /* setup text data ring */ -+ m.text_data_ring = m.prb + OFFSET(printk_ringbuffer.text_data_ring); -+ m.text_data_ring_size = 1 << UINT(m.text_data_ring + OFFSET(prb_data_ring.size_bits)); -+ -+ kaddr = ULONG(m.text_data_ring + OFFSET(prb_data_ring.data)); -+ m.text_data = malloc(m.text_data_ring_size); -+ if (!m.text_data) { -+ ERRMSG("Can't allocate memory for prb.text_data_ring.data.\n"); -+ goto out_infos; -+ } -+ if (!readmem(VADDR, kaddr, m.text_data, m.text_data_ring_size)) { -+ ERRMSG("Can't get prb.text_data_ring.\n"); -+ goto out_text_data; -+ } -+ -+ /* ready to go */ -+ -+ tail_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.tail_id) + -+ OFFSET(atomic_long_t.counter)); -+ head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) + -+ OFFSET(atomic_long_t.counter)); -+ -+ if (!open_dump_file()) { -+ ERRMSG("Can't open output file.\n"); -+ goto out_text_data; -+ } -+ -+ for (id = tail_id; id != head_id; id = (id + 1) & DESC_ID_MASK) -+ dump_record(&m, id); -+ -+ /* dump head record */ -+ dump_record(&m, id); -+ -+ if (!close_files_for_creating_dumpfile()) -+ goto out_text_data; -+ -+ ret = TRUE; -+out_text_data: -+ free(m.text_data); -+out_infos: -+ free(m.infos); -+out_descs: -+ free(m.descs); -+out_prb: -+ free(m.prb); -+ return ret; -+} --- -2.29.2 - diff --git a/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch b/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch deleted file mode 100644 index 8ec27bf..0000000 --- a/kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 44b073b7ec467aee0d7de381d455b8ace1199184 Mon Sep 17 00:00:00 2001 -From: John Ogness -Date: Wed, 25 Nov 2020 10:10:31 +0106 -Subject: [PATCH 2/2] [PATCH 2/2] printk: use committed/finalized state values - -* Required for kernel 5.10 - -The ringbuffer entries use 2 state values (committed and finalized) -rather than a single flag to represent being available for reading. -Copy the definitions and state lookup function directly from the -kernel source and use the new states. - -Signed-off-by: John Ogness ---- - printk.c | 48 +++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 41 insertions(+), 7 deletions(-) - -diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c -index acffb6c..2af8562 100644 ---- a/makedumpfile-1.6.8/printk.c -+++ b/makedumpfile-1.6.8/printk.c -@@ -1,12 +1,6 @@ - #include "makedumpfile.h" - #include - --#define DESC_SV_BITS (sizeof(unsigned long) * 8) --#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1)) --#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2)) --#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK) --#define DESC_ID_MASK (~DESC_FLAGS_MASK) -- - /* convenience struct for passing many values to helper functions */ - struct prb_map { - char *prb; -@@ -21,12 +15,51 @@ struct prb_map { - char *text_data; - }; - -+/* -+ * desc_state and DESC_* definitions taken from kernel source: -+ * -+ * kernel/printk/printk_ringbuffer.h -+ */ -+ -+/* The possible responses of a descriptor state-query. */ -+enum desc_state { -+ desc_miss = -1, /* ID mismatch (pseudo state) */ -+ desc_reserved = 0x0, /* reserved, in use by writer */ -+ desc_committed = 0x1, /* committed by writer, could get reopened */ -+ desc_finalized = 0x2, /* committed, no further modification allowed */ -+ desc_reusable = 0x3, /* free, not yet used by any writer */ -+}; -+ -+#define DESC_SV_BITS (sizeof(unsigned long) * 8) -+#define DESC_FLAGS_SHIFT (DESC_SV_BITS - 2) -+#define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) -+#define DESC_STATE(sv) (3UL & (sv >> DESC_FLAGS_SHIFT)) -+#define DESC_ID_MASK (~DESC_FLAGS_MASK) -+#define DESC_ID(sv) ((sv) & DESC_ID_MASK) -+ -+/* -+ * get_desc_state() taken from kernel source: -+ * -+ * kernel/printk/printk_ringbuffer.c -+ */ -+ -+/* Query the state of a descriptor. */ -+static enum desc_state get_desc_state(unsigned long id, -+ unsigned long state_val) -+{ -+ if (id != DESC_ID(state_val)) -+ return desc_miss; -+ -+ return DESC_STATE(state_val); -+} -+ - static void - dump_record(struct prb_map *m, unsigned long id) - { - unsigned long long ts_nsec; - unsigned long state_var; - unsigned short text_len; -+ enum desc_state state; - unsigned long begin; - unsigned long next; - char buf[BUFSIZE]; -@@ -45,7 +78,8 @@ dump_record(struct prb_map *m, unsigned long id) - - /* skip non-committed record */ - state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter)); -- if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK) -+ state = get_desc_state(id, state_var); -+ if (state != desc_committed && state != desc_finalized) - return; - - begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) % --- -2.29.2 - diff --git a/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch b/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch deleted file mode 100644 index ffe8a39..0000000 --- a/kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 3422e1d6bc3511c5af9cb05ba74ad97dd93ffd7f Mon Sep 17 00:00:00 2001 -From: Julien Thierry -Date: Tue, 24 Nov 2020 10:45:24 +0000 -Subject: [PATCH 02/12] [PATCH 1/2] Add --dry-run option to prevent writing the - dumpfile - -Add a --dry-run option to run all operations without writing the -dump to the output file. - -Signed-off-by: Julien Thierry -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.8 | 6 ++++++ - makedumpfile.c | 37 ++++++++++++++++++++++++++++++------- - makedumpfile.h | 2 ++ - print_info.c | 3 +++ - 4 files changed, 41 insertions(+), 7 deletions(-) - -diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 -index b68a7e3..5e902cd 100644 ---- a/makedumpfile-1.6.8/makedumpfile.8 -+++ b/makedumpfile-1.6.8/makedumpfile.8 -@@ -637,6 +637,12 @@ Show the version of makedumpfile. - Only check whether the command-line parameters are valid or not, and exit. - Preferable to be given as the first parameter. - -+.TP -+\fB\-\-dry-run\fR -+Do not write the output dump file while still performing operations specified -+by other options. -+This option cannot be used with the --dump-dmesg, --reassemble and -g options. -+ - .SH ENVIRONMENT VARIABLES - - .TP 8 -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index ecd63fa..8c80c49 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -1372,6 +1372,8 @@ open_dump_file(void) - if (info->flag_flatten) { - fd = STDOUT_FILENO; - info->name_dumpfile = filename_stdout; -+ } else if (info->flag_dry_run) { -+ fd = -1; - } else if ((fd = open(info->name_dumpfile, open_flags, - S_IRUSR|S_IWUSR)) < 0) { - ERRMSG("Can't open the dump file(%s). %s\n", -@@ -4711,6 +4713,9 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) - { - int status, written_size = 0; - -+ if (info->flag_dry_run) -+ return TRUE; -+ - while (written_size < buf_size) { - status = write(fd, buf + written_size, - buf_size - written_size); -@@ -4748,13 +4753,12 @@ write_buffer(int fd, off_t offset, void *buf, size_t buf_size, char *file_name) - } - if (!write_and_check_space(fd, &fdh, sizeof(fdh), file_name)) - return FALSE; -- } else { -- if (lseek(fd, offset, SEEK_SET) == failed) { -- ERRMSG("Can't seek the dump file(%s). %s\n", -- file_name, strerror(errno)); -- return FALSE; -- } -+ } else if (!info->flag_dry_run && -+ lseek(fd, offset, SEEK_SET) == failed) { -+ ERRMSG("Can't seek the dump file(%s). %s\n", file_name, strerror(errno)); -+ return FALSE; - } -+ - if (!write_and_check_space(fd, buf, buf_size, file_name)) - return FALSE; - -@@ -9112,7 +9116,7 @@ close_dump_memory(void) - void - close_dump_file(void) - { -- if (info->flag_flatten) -+ if (info->flag_flatten || info->flag_dry_run) - return; - - if (close(info->fd_dumpfile) < 0) -@@ -10985,6 +10989,11 @@ check_param_for_generating_vmcoreinfo(int argc, char *argv[]) - - return FALSE; - -+ if (info->flag_dry_run) { -+ MSG("--dry-run cannot be used with -g.\n"); -+ return FALSE; -+ } -+ - return TRUE; - } - -@@ -11029,6 +11038,11 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[]) - || info->flag_exclude_xen_dom || info->flag_split) - return FALSE; - -+ if (info->flag_dry_run) { -+ MSG("--dry-run cannot be used with --reassemble.\n"); -+ return FALSE; -+ } -+ - if ((info->splitting_info - = malloc(sizeof(struct splitting_info) * info->num_dumpfile)) - == NULL) { -@@ -11057,6 +11071,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) - || (info->flag_read_vmcoreinfo && info->name_xen_syms)) - return FALSE; - -+ if (info->flag_dry_run && info->flag_dmesg) { -+ MSG("--dry-run cannot be used with --dump-dmesg.\n"); -+ return FALSE; -+ } -+ - if (info->flag_flatten && info->flag_split) - return FALSE; - -@@ -11520,6 +11539,7 @@ static struct option longopts[] = { - {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, - {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, - {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, -+ {"dry-run", no_argument, NULL, OPT_DRY_RUN}, - {0, 0, 0, 0} - }; - -@@ -11686,6 +11706,9 @@ main(int argc, char *argv[]) - info->flag_check_params = TRUE; - message_level = DEFAULT_MSG_LEVEL; - break; -+ case OPT_DRY_RUN: -+ info->flag_dry_run = TRUE; -+ break; - case '?': - MSG("Commandline parameter is invalid.\n"); - MSG("Try `makedumpfile --help' for more information.\n"); -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 5f50080..4c4222c 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1322,6 +1322,7 @@ struct DumpInfo { - int flag_vmemmap; /* kernel supports vmemmap address space */ - int flag_excludevm; /* -e - excluding unused vmemmap pages */ - int flag_use_count; /* _refcount is named _count in struct page */ -+ int flag_dry_run; /* do not create a vmcore file */ - unsigned long vaddr_for_vtop; /* virtual address for debugging */ - long page_size; /* size of page */ - long page_shift; -@@ -2425,6 +2426,7 @@ struct elf_prstatus { - #define OPT_NUM_THREADS OPT_START+16 - #define OPT_PARTIAL_DMESG OPT_START+17 - #define OPT_CHECK_PARAMS OPT_START+18 -+#define OPT_DRY_RUN OPT_START+19 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c -index e0c38b4..d2b0cb7 100644 ---- a/makedumpfile-1.6.8/print_info.c -+++ b/makedumpfile-1.6.8/print_info.c -@@ -308,6 +308,9 @@ print_usage(void) - MSG(" the crashkernel range, then calculates the page number of different kind per\n"); - MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); - MSG("\n"); -+ MSG(" [--dry-run]:\n"); -+ MSG(" This option runs makedumpfile without writting output dump file.\n"); -+ MSG("\n"); - MSG(" [-D]:\n"); - MSG(" Print debugging message.\n"); - MSG("\n"); --- -2.29.2 - diff --git a/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch b/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch deleted file mode 100644 index 4f259ab..0000000 --- a/kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 6f3e75a558ed50d6ff0b42e3f61c099b2005b7bb Mon Sep 17 00:00:00 2001 -From: Julien Thierry -Date: Tue, 24 Nov 2020 10:45:25 +0000 -Subject: [PATCH 03/12] [PATCH 2/2] Add shorthand --show-stats option to show - report stats - -Provide shorthand --show-stats option to enable report messages -without needing to set a particular value for message-level. - -Signed-off-by: Julien Thierry -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.8 | 5 +++++ - makedumpfile.c | 9 ++++++++- - makedumpfile.h | 1 + - print_info.c | 7 ++++++- - 4 files changed, 20 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile-1.6.8/makedumpfile.8 b/makedumpfile-1.6.8/makedumpfile.8 -index 5e902cd..dcca2dd 100644 ---- a/makedumpfile-1.6.8/makedumpfile.8 -+++ b/makedumpfile-1.6.8/makedumpfile.8 -@@ -643,6 +643,11 @@ Do not write the output dump file while still performing operations specified - by other options. - This option cannot be used with the --dump-dmesg, --reassemble and -g options. - -+.TP -+\fB\-\-show-stats\fR -+Display report messages. This is an alternative to enabling bit 4 in the level -+provided to --message-level. -+ - .SH ENVIRONMENT VARIABLES - - .TP 8 -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index 8c80c49..ba0003a 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -11540,13 +11540,14 @@ static struct option longopts[] = { - {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, - {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, - {"dry-run", no_argument, NULL, OPT_DRY_RUN}, -+ {"show-stats", no_argument, NULL, OPT_SHOW_STATS}, - {0, 0, 0, 0} - }; - - int - main(int argc, char *argv[]) - { -- int i, opt, flag_debug = FALSE; -+ int i, opt, flag_debug = FALSE, flag_show_stats = FALSE; - - if ((info = calloc(1, sizeof(struct DumpInfo))) == NULL) { - ERRMSG("Can't allocate memory for the pagedesc cache. %s.\n", -@@ -11709,6 +11710,9 @@ main(int argc, char *argv[]) - case OPT_DRY_RUN: - info->flag_dry_run = TRUE; - break; -+ case OPT_SHOW_STATS: -+ flag_show_stats = TRUE; -+ break; - case '?': - MSG("Commandline parameter is invalid.\n"); - MSG("Try `makedumpfile --help' for more information.\n"); -@@ -11718,6 +11722,9 @@ main(int argc, char *argv[]) - if (flag_debug) - message_level |= ML_PRINT_DEBUG_MSG; - -+ if (flag_show_stats) -+ message_level |= ML_PRINT_REPORT_MSG; -+ - if (info->flag_check_params) - /* suppress debugging messages */ - message_level = DEFAULT_MSG_LEVEL; -diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h -index 4c4222c..2fcb62e 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -2427,6 +2427,7 @@ struct elf_prstatus { - #define OPT_PARTIAL_DMESG OPT_START+17 - #define OPT_CHECK_PARAMS OPT_START+18 - #define OPT_DRY_RUN OPT_START+19 -+#define OPT_SHOW_STATS OPT_START+20 - - /* - * Function Prototype. -diff --git a/makedumpfile-1.6.8/print_info.c b/makedumpfile-1.6.8/print_info.c -index d2b0cb7..ad4184e 100644 ---- a/makedumpfile-1.6.8/print_info.c -+++ b/makedumpfile-1.6.8/print_info.c -@@ -309,7 +309,12 @@ print_usage(void) - MSG(" vmcoreinfo. So currently /proc/kcore need be specified explicitly.\n"); - MSG("\n"); - MSG(" [--dry-run]:\n"); -- MSG(" This option runs makedumpfile without writting output dump file.\n"); -+ MSG(" Do not write the output dump file while still performing operations specified\n"); -+ MSG(" by other options. This option cannot be used with --dump-dmesg, --reassemble\n"); -+ MSG(" and -g options.\n"); -+ MSG("\n"); -+ MSG(" [--show-stats]:\n"); -+ MSG(" Set message-level to print report messages\n"); - MSG("\n"); - MSG(" [-D]:\n"); - MSG(" Print debugging message.\n"); --- -2.29.2 - diff --git a/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch b/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch deleted file mode 100644 index be89b54..0000000 --- a/kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0ef2ca6c9fa2f61f217a4bf5d7fd70f24e12b2eb Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Thu, 4 Feb 2021 16:29:06 +0900 -Subject: [PATCH 09/12] [PATCH] Show write byte size in report messages - -Show write byte size in report messages. This value can be different -from the size of the actual file because of some holes on dumpfile -data structure. - - $ makedumpfile --show-stats -l -d 1 vmcore dump.ld1 - ... - Total pages : 0x0000000000080000 - Write bytes : 377686445 - ... - # ls -l dump.ld1 - -rw------- 1 root root 377691573 Feb 4 16:28 dump.ld1 - -Note that this value should not be used with /proc/kcore to determine -how much disk space is needed for crash dump, because the real memory -usage when a crash occurs can vary widely. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c -index fcd766b..894c88e 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -48,6 +48,8 @@ char filename_stdout[] = FILENAME_STDOUT; - static unsigned long long cache_hit; - static unsigned long long cache_miss; - -+static unsigned long long write_bytes; -+ - static void first_cycle(mdf_pfn_t start, mdf_pfn_t max, struct cycle *cycle) - { - cycle->start_pfn = round(start, info->pfn_cyclic); -@@ -4715,6 +4717,8 @@ write_and_check_space(int fd, void *buf, size_t buf_size, char *file_name) - { - int status, written_size = 0; - -+ write_bytes += buf_size; -+ - if (info->flag_dry_run) - return TRUE; - -@@ -10002,6 +10006,7 @@ print_report(void) - REPORT_MSG("Memory Hole : 0x%016llx\n", pfn_memhole); - REPORT_MSG("--------------------------------------------------\n"); - REPORT_MSG("Total pages : 0x%016llx\n", info->max_mapnr); -+ REPORT_MSG("Write bytes : %llu\n", write_bytes); - REPORT_MSG("\n"); - REPORT_MSG("Cache hit: %lld, miss: %lld", cache_hit, cache_miss); - if (cache_hit + cache_miss) --- -2.29.2 - diff --git a/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch b/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch deleted file mode 100644 index 0c29723..0000000 --- a/kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 54aec3878b3f91341e6bc735eda158cca5c54ec9 Mon Sep 17 00:00:00 2001 -From: Alexander Egorenkov -Date: Fri, 18 Sep 2020 13:55:56 +0200 -Subject: [PATCH] [PATCH] make use of 'uts_namespace.name' offset in VMCOREINFO - -* Required for kernel 5.11 - -The offset of the field 'init_uts_ns.name' has changed since -kernel commit 9a56493f6942 ("uts: Use generic ns_common::count"). -Make use of the offset 'uts_namespace.name' if available in -VMCOREINFO. - -Signed-off-by: Alexander Egorenkov ---- - makedumpfile.c | 17 +++++++++++++++-- - makedumpfile.h | 6 ++++++ - 2 files changed, 21 insertions(+), 2 deletions(-) - -diff --git a/makedumpfile.c b/makedumpfile.c -index 061741f..ecd63fa 100644 ---- a/makedumpfile-1.6.8/makedumpfile.c -+++ b/makedumpfile-1.6.8/makedumpfile.c -@@ -1159,7 +1159,10 @@ check_release(void) - if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) { - utsname = SYMBOL(system_utsname); - } else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) { -- utsname = SYMBOL(init_uts_ns) + sizeof(int); -+ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE) -+ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name); -+ else -+ utsname = SYMBOL(init_uts_ns) + sizeof(int); - } else { - ERRMSG("Can't get the symbol of system_utsname.\n"); - return FALSE; -@@ -2040,6 +2043,11 @@ get_structure_info(void) - SIZE_INIT(cpu_spec, "cpu_spec"); - OFFSET_INIT(cpu_spec.mmu_features, "cpu_spec", "mmu_features"); - -+ /* -+ * Get offsets of the uts_namespace's members. -+ */ -+ OFFSET_INIT(uts_namespace.name, "uts_namespace", "name"); -+ - return TRUE; - } - -@@ -2109,7 +2117,10 @@ get_str_osrelease_from_vmlinux(void) - if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) { - utsname = SYMBOL(system_utsname); - } else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) { -- utsname = SYMBOL(init_uts_ns) + sizeof(int); -+ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE) -+ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name); -+ else -+ utsname = SYMBOL(init_uts_ns) + sizeof(int); - } else { - ERRMSG("Can't get the symbol of system_utsname.\n"); - return FALSE; -@@ -2344,6 +2355,7 @@ write_vmcoreinfo_data(void) - WRITE_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); - WRITE_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); - WRITE_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); -+ WRITE_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name); - - if (SYMBOL(node_data) != NOT_FOUND_SYMBOL) - WRITE_ARRAY_LENGTH("node_data", node_data); -@@ -2743,6 +2755,7 @@ read_vmcoreinfo(void) - READ_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list); - READ_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift); - READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features); -+ READ_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name); - - READ_STRUCTURE_SIZE("printk_log", printk_log); - READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer); -diff --git a/makedumpfile.h b/makedumpfile.h -index 47f7e79..5f50080 100644 ---- a/makedumpfile-1.6.8/makedumpfile.h -+++ b/makedumpfile-1.6.8/makedumpfile.h -@@ -1728,6 +1728,8 @@ struct size_table { - long cpu_spec; - - long pageflags; -+ -+ long uts_namespace; - }; - - struct offset_table { -@@ -1935,6 +1937,10 @@ struct offset_table { - struct cpu_spec_s { - long mmu_features; - } cpu_spec; -+ -+ struct uts_namespace_s { -+ long name; -+ } uts_namespace; - }; - - /* --- -2.29.2 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 264dd40..d498e0a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.6.8 +%global mkdf_ver 1.6.9 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools @@ -93,6 +93,7 @@ Requires: systemd-udev%{?_isa} # # Patches 401 through 500 are meant for s390 kexec-tools enablement # + # # Patches 501 through 600 are meant for ARM kexec-tools enablement # @@ -100,12 +101,6 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # -Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch -Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch -Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch -Patch606: ./kexec-tools-2.0.21-makedumpfile-Add-dry-run-option.patch -Patch607: ./kexec-tools-2.0.21-makedumpfile-Add-shorthand-show-stats-option.patch -Patch608: ./kexec-tools-2.0.21-makedumpfile-Show-write-byte-size-in-report-messages.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -121,13 +116,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch603 -p1 -%patch604 -p1 -%patch605 -p1 -%patch606 -p1 -%patch607 -p1 -%patch608 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif diff --git a/sources b/sources index c3da2cf..80b4d4e 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (makedumpfile-1.6.8.tar.gz) = 15e60688b06013bf86e339ec855774ea2c904d425371ea867101704ba0611c69da891eb3cc96f67eb10197d8c42d217ea28bf11bcaa93ddc2495cbf984c0b7ec SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 SHA512 (kexec-tools-2.0.22.tar.xz) = 7580860f272eee5af52139809f12961e5a5d3a65f4e191183ca9c845410425d25818945ac14ed04a60e6ce474dc2656fc6a14041177b0bf703f450820c7d6aba +SHA512 (makedumpfile-1.6.9.tar.gz) = 9982985498ae641d390c3b87d92aecd263a502f1a4a9e96e145d86d8778b9e778e4ee98034ef4dbe12ed5586c57278917ea5f3c9ae2989ad1ac051215e03b3d9 From 10c309b5f715496d70959a06f7c236cab31fb5a9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:08 +0800 Subject: [PATCH 394/806] Add helper to get value by field using "nmcli --get-values" nmcli --get-values connection show /org/freedesktop/NetworkManager/ActiveConnection/1 returns the following value for the corresponding field respectively, Field Value IP4.DNS "10.19.42.41 | 10.11.5.19 | 10.5.30.160" 802-3-ethernet.s390-subchannels "" bond.options "mode=balance-rr" Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kdump-lib.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 5f53a8a..17414a9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -372,6 +372,26 @@ get_hwaddr() fi } + +# Get value by a field using "nmcli -g" +# +# "nmcli --get-values" allows us to retrive value(s) by field, for example, +# nmcli --get-values connection show /org/freedesktop/NetworkManager/ActiveConnection/1 +# returns the following value for the corresponding field respectively, +# Field Value +# IP4.DNS "10.19.42.41 | 10.11.5.19 | 10.5.30.160" +# 802-3-ethernet.s390-subchannels "" +# bond.options "mode=balance-rr" +get_nmcli_value_by_field() +{ + local _nm_show_cmd=$1 + local _field=$2 + + local val=$(LANG=C nmcli --get-values $_field $_nm_show_cmd) + + echo -n "$val" +} + get_ifcfg_by_device() { grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ From c69578ca431998d7460d40e58769a05b58bab0e8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:09 +0800 Subject: [PATCH 395/806] Add helper to get nmcli connection apath by ifname apath (a D-Bus active connection path) is used for nmcli connection operations, e.g. $ nmcli connection show $apath Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kdump-lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 17414a9..d74ca7d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -392,6 +392,20 @@ get_nmcli_value_by_field() echo -n "$val" } +# Get nmcli connection apath (a D-Bus active connection path ) by ifname +# +# apath is used for nmcli connection operations, e.g. +# $ nmcli connection show $apath +get_nmcli_connection_apath_by_ifname() +{ + local _ifname=$1 + local _nm_show_cmd="device show $_ifname" + + local _apath=$(get_nmcli_value_by_field "$_nm_show_cmd" "GENERAL.CON-PATH") + + echo -n "$_apath" +} + get_ifcfg_by_device() { grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ From 0c292f49c7a148c2ba21c9992371456b1030b54c Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:10 +0800 Subject: [PATCH 396/806] Add helper to get nmcli connection show cmd by ifname Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kdump-lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index d74ca7d..4dcd134 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -406,6 +406,20 @@ get_nmcli_connection_apath_by_ifname() echo -n "$_apath" } +# Get nmcli connection show cmd by ifname +# +# "$_apath" is supposed to not contain any chracter that +# need to be escapded, e.g. space. Otherwise get_nmcli_value_by_field +# would fail. +get_nmcli_connection_show_cmd_by_ifname() +{ + local _ifname="$1" + local _apath=$(get_nmcli_connection_apath_by_ifname "$_ifname") + local _nm_show_cmd="connection show $_apath" + + echo -n "$_nm_show_cmd" +} + get_ifcfg_by_device() { grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ From 8b08b4f17ba0141eb9c78cb4d626adbdaee433f5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:11 +0800 Subject: [PATCH 397/806] Set up s390 znet cmdline by "nmcli --get-values" Now kdumpctl will abort when failing to set up znet. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a8bfe53..8a53ac6 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -430,17 +430,33 @@ kdump_setup_vlan() { } # setup s390 znet cmdline -# $1: netdev name +# $1: netdev (ifname) +# $2: nmcli connection show output kdump_setup_znet() { + local _netdev="$1" + local _nmcli_cmd="$2" + local s390_prefix="802-3-ethernet.s390-" local _options="" - local _netdev=$1 + local NETTYPE + local SUBCHANNELS - source_ifcfg_file $_netdev + NETTYPE=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}nettype") + SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels") + _options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options") - for i in $OPTIONS; do - _options=${_options},$i - done - echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf + if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then + dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." + source_ifcfg_file $_netdev + for i in $OPTIONS; do + _options=${_options},$i + done + fi + + if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then + exit 1 + fi + + echo rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf } kdump_get_ip_route() @@ -477,18 +493,23 @@ kdump_get_remote_ip() # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _srcaddr _route _netdev kdumpnic + local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts _destaddr=$(kdump_get_remote_ip $1) _route=$(kdump_get_ip_route $_destaddr) _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") + _nm_show_cmd=$(get_nmcli_connection_show_cmd_by_ifname "$_netdev") _netmac=$(kdump_get_mac_addr $_netdev) kdumpnic=$(kdump_setup_ifname $_netdev) if [ "$(uname -m)" = "s390x" ]; then - kdump_setup_znet $_netdev + $(kdump_setup_znet "$_netdev" "$_nm_show_cmd") + if [[ $? != 0 ]]; then + derror "Failed to set up znet" + exit 1 + fi fi _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) From 6f1badec789c86761f5777af80ba229ec13fc793 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:12 +0800 Subject: [PATCH 398/806] Set up dns cmdline by parsing "nmcli --get-values" Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8a53ac6..b186d71 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -94,15 +94,26 @@ source_ifcfg_file() { fi } -# $1: netdev name +# $1: nmcli connection show output kdump_setup_dns() { - local _nameserver _dns + local _netdev="$1" + local _nm_show_cmd="$2" + local _nameserver _dns _tmp array local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - source_ifcfg_file $1 - - [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" + _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") + array=(${_tmp//|/ }) + if [[ ${array[@]} ]]; then + for _dns in "${array[@]}" + do + echo "nameserver=$_dns" >> "$_dnsfile" + done + else + dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" + source_ifcfg_file "$_netdev" + [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" + [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" + fi while read content; do @@ -546,7 +557,7 @@ kdump_install_net() { echo "$_ifname_opts" >> $_ip_conf fi - kdump_setup_dns "$_netdev" + kdump_setup_dns "$_netdev" "$_nm_show_cmd" if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then # network-manager module needs this parameter From d5f6d38173f66c0b45e82cb52a66ba0140b7dd22 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:13 +0800 Subject: [PATCH 399/806] Set up bond cmdline by "nmcli --get-values" Now kdumpctl will exit if failing to set up bond cmdline. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index b186d71..67bcaf0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -365,7 +365,10 @@ kdump_setup_bridge() { for _dev in `ls /sys/class/net/$_netdev/brif/`; do _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - kdump_setup_bond "$_dev" + $(kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") + if [[ $? != 0 ]]; then + exit 1 + fi elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then @@ -380,9 +383,13 @@ kdump_setup_bridge() { echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf } +# drauct takes bond=[::[:]] syntax to parse +# bond. For example: +# bond=bond0:eth0,eth1:mode=balance-rr kdump_setup_bond() { - local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _netdev="$1" + local _nm_show_cmd="$2" + local _dev _mac _slaves _kdumpdev _bondoptions for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) @@ -390,12 +397,21 @@ kdump_setup_bond() { _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf - # Get bond options specified in ifcfg - source_ifcfg_file $_netdev + _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") - bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")" - echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf + if [[ -z "_bondoptions" ]]; then + dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." + source_ifcfg_file $_netdev + _bondoptions="$(echo $BONDING_OPTS | xargs echo | tr " " ",")" + fi + + if [[ -z "_bondoptions" ]]; then + derror "Get empty bond options" + exit 1 + fi + + echo ":$_bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } kdump_setup_team() { @@ -432,7 +448,10 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - kdump_setup_bond "$_phydev" + $(kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") + if [[ $? != 0 ]]; then + exit 1 + fi echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" @@ -547,7 +566,10 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - kdump_setup_bond "$_netdev" + $(kdump_setup_bond "$_netdev" "$_nm_show_cmd") + if [[ $? != 0 ]]; then + exit 1 + fi elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then From 8178d7a5a1b164aecea73d9cf3e32ac57a9f33e8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:14 +0800 Subject: [PATCH 400/806] Warn the user if network scripts are used Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 67bcaf0..a99a0ea 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -86,6 +86,7 @@ kdump_is_vlan() { source_ifcfg_file() { local ifcfg_file + dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." ifcfg_file=$(get_ifcfg_filename $1) if [ -f "${ifcfg_file}" ]; then . ${ifcfg_file} From d5fe96cd7a779984bf2ba4c8dc51cd10c7e37efd Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 27 Apr 2021 17:58:40 +0800 Subject: [PATCH 401/806] Disable CMA in kdump 2nd kernel kexec-tools needs to disable CMA for kdump kernel cmdline, otherwise kdump kernel may run out of memory. This patch strips the inherited cma=, hugetlb_cma= cmd line from 1st kernel, and sets to be 0 for 2nd kernel. Signed-off-by: Tao Liu Acked-by: Kairui Song --- kdump.sysconfig | 4 ++-- kdump.sysconfig.aarch64 | 4 ++-- kdump.sysconfig.i386 | 4 ++-- kdump.sysconfig.ppc64 | 4 ++-- kdump.sysconfig.ppc64le | 4 ++-- kdump.sysconfig.s390x | 4 ++-- kdump.sysconfig.x86_64 | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index 30f0c63..70ebf04 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd cma=0 hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 6f7830a..fedd3bc 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index d2de7d6..7e18c1c 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index 39b69bb..ebb22f6 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 39b69bb..ebb22f6 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index f9218e5..439e462 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd" +KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0" # Any additional /sbin/mkdumprd arguments required. MKDUMPRD_ARGS="" diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 0521893..1285506 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -17,11 +17,11 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0" # Any additional kexec arguments required. In most situations, this should # be left empty From 13796ca93a80e95dd53419e40c8ace2bf4dde386 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 13 May 2021 16:46:28 +0800 Subject: [PATCH 402/806] Release 2.0.22-2 Signed-off-by: Kairui Song --- kexec-tools.spec | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d498e0a..11c64cb 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -355,6 +355,17 @@ done %endif %changelog +* Thu May 13 2021 Kairui Song - 2.0.22-2 +- Disable CMA in kdump 2nd kernel +- Warn the user if network scripts are used +- Set up bond cmdline by "nmcli --get-values" +- Set up dns cmdline by parsing "nmcli --get-values" +- Set up s390 znet cmdline by "nmcli --get-values" +- Add helper to get nmcli connection show cmd by ifname +- Add helper to get nmcli connection apath by ifname +- Add helper to get value by field using "nmcli --get-values" +- Update makedumpfile to 1.6.9 + * Tue May 11 2021 Kairui Song - 2.0.22-1 - Update kexec-tools to 2.0.22 - rd.route should use the name from kdump_setup_ifname From 3423bbc17f5521de8ff80e76d91ce13657b1cea2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 8 Apr 2021 01:36:49 +0800 Subject: [PATCH 403/806] kdump-lib.sh: introduce a helper to get underlying crypt device Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 4dcd134..ecb2721 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -958,3 +958,20 @@ kdump_get_arch_recommend_size() echo $result return 0 } + +# Print all underlying crypt devices of a block device +# print nothing if device is not on top of a crypt device +# $1: the block device to be checked in maj:min format +get_luks_crypt_dev() +{ + [[ -b /dev/block/$1 ]] || return 1 + + local _type=$(eval "$(blkid -u filesystem,crypto -o export -- /dev/block/$1); echo \$TYPE") + [[ $_type == "crypto_LUKS" ]] && echo $1 + + for _x in /sys/dev/block/$1/slaves/*; do + [[ -f $_x/dev ]] || continue + [[ $_x/subsystem -ef /sys/class/block ]] || continue + get_luks_crypt_dev "$(< "$_x/dev")" + done +} From 1c70cf51c7678499e2d48eec10ad24b839fe9f64 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 18 May 2021 16:13:16 +0800 Subject: [PATCH 404/806] kdump-lib.sh: introduce a helper to get all crypt dev used by kdump Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index ecb2721..e00ea43 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -975,3 +975,24 @@ get_luks_crypt_dev() get_luks_crypt_dev "$(< "$_x/dev")" done } + +# kdump_get_maj_min +# Prints the major and minor of a device node. +# Example: +# $ get_maj_min /dev/sda2 +# 8:2 +kdump_get_maj_min() { + local _majmin + _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" + printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" +} + +get_all_kdump_crypt_dev() +{ + local _dev _crypt + + for _dev in $(get_block_dump_target); do + _crypt=$(get_luks_crypt_dev $(kdump_get_maj_min "$_dev")) + [[ -n "$_crypt" ]] && echo $_crypt + done +} From 85c725813b49ae9495841b4b55736a26079dc75d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 8 Apr 2021 01:41:21 +0800 Subject: [PATCH 405/806] mkdumprd: make use of the new get_luks_crypt_dev helper Simplfy the code and also improve the performance. udevadm call is heavy. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- mkdumprd | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/mkdumprd b/mkdumprd index 50ebdc8..b518078 100644 --- a/mkdumprd +++ b/mkdumprd @@ -325,7 +325,6 @@ get_override_resettable() fi } - # $1: function name for_each_block_target() { @@ -340,8 +339,6 @@ for_each_block_target() return 0 } - - #judge if a specific device with $1 is unresettable #return false if unresettable. is_unresettable() @@ -378,32 +375,15 @@ check_resettable() return 1 } -# $1: maj:min -is_crypt() -{ - local majmin=$1 dev line ID_FS_TYPE="" - - line=$(udevadm info --query=property --path=/sys/dev/block/$majmin \ - | grep "^ID_FS_TYPE") - eval "$line" - [[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && { - dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}') - derror "Device $dev is encrypted." - return 0 - } - return 1 -} - check_crypt() { - local _ret _target + local _dev - for_each_block_target is_crypt - _ret=$? - - [ $_ret -eq 0 ] && return - - return 1 + for _dev in $(get_kdump_targets); do + if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then + derror "Device $_dev is encrypted." && return 1 + fi + done } if ! check_resettable; then From e9e6a2c745d41f5447c0062525c0e4f3f489b903 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 22 Apr 2021 03:27:10 +0800 Subject: [PATCH 406/806] kdumpctl: Add kdumpctl estimate Add a rough esitimation support, currently, following memory usage are checked by this sub command: - System RAM - Kdump Initramfs size - Kdump Kernel image size - Kdump Kernel module size - Kdump userspace user and other runtime allocated memory (currently simply using a fixed value: 64M) - LUKS encryption memory usage The output of kdumpctl estimate looks like this: # kdumpctl estimate Reserved crashkernel: 256M Recommanded crashkernel: 160M Kernel image size: 47M Kernel modules size: 12M Initramfs size: 19M Runtime reservation: 64M Large modules: xfs: 1892352 nouveau: 2318336 And if the kdump target is encrypted: # kdumpctl estimate Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement Reserved crashkernel: 256M Recommanded crashkernel: 655M Kernel image size: 47M Kernel modules size: 12M Initramfs size: 19M Runtime reservation: 64M LUKS required size: 512M Large modules: xfs: 1892352 nouveau: 2318336 WARNING: Current crashkernel size is lower than recommanded size 655M. The "Recommanded" value is calculated based on memory usages mentioned above, and will be adjusted accodingly to be no less than the value provided by kdump_get_arch_recommend_size. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 71 ++++++++++++++++++++++++++++++++++++++ kdumpctl | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++- kdumpctl.8 | 5 +++ 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index e00ea43..74072c5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -996,3 +996,74 @@ get_all_kdump_crypt_dev() [[ -n "$_crypt" ]] && echo $_crypt done } + +check_vmlinux() +{ + # Use readelf to check if it's a valid ELF + readelf -h $1 &>/dev/null || return 1 +} + +get_vmlinux_size() +{ + local size=0 + + while read _type _offset _virtaddr _physaddr _fsize _msize _flg _aln; do + size=$(( $size + $_msize )) + done <<< $(readelf -l -W $1 | grep "^ LOAD" 2>/dev/stderr) + + echo $size +} + +try_decompress() +{ + # The obscure use of the "tr" filter is to work around older versions of + # "grep" that report the byte offset of the line instead of the pattern. + + # Try to find the header ($1) and decompress from here + for pos in `tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"` + do + if ! type -P $3 > /dev/null; then + ddebug "Signiature detected but '$3' is missing, skip this decompressor" + break + fi + + pos=${pos%%:*} + tail -c+$pos "$img" | $3 > $5 2> /dev/null + if check_vmlinux $5; then + ddebug "Kernel is extracted with '$3'" + return 0 + fi + done + + return 1 +} + +# Borrowed from linux/scripts/extract-vmlinux +get_kernel_size() +{ + # Prepare temp files: + local img=$1 tmp=$(mktemp /tmp/vmlinux-XXX) + trap "rm -f $tmp" 0 + + # Try to check if it's a vmlinux already + check_vmlinux $img && get_vmlinux_size $img && return 0 + + # That didn't work, so retry after decompression. + try_decompress '\037\213\010' xy gunzip $img $tmp || \ + try_decompress '\3757zXZ\000' abcde unxz $img $tmp || \ + try_decompress 'BZh' xy bunzip2 $img $tmp || \ + try_decompress '\135\0\0\0' xxx unlzma $img $tmp || \ + try_decompress '\211\114\132' xy 'lzop -d' $img $tmp || \ + try_decompress '\002!L\030' xxx 'lz4 -d' $img $tmp || \ + try_decompress '(\265/\375' xxx unzstd $img $tmp + + # Finally check for uncompressed images or objects: + [[ $? -eq 0 ]] && get_vmlinux_size $tmp && return 0 + + # Fallback to use iomem + local _size=0 + for _seg in $(cat /proc/iomem | grep -E "Kernel (code|rodata|data|bss)" | cut -d ":" -f 1); do + _size=$(( $_size + 0x${_seg#*-} - 0x${_seg%-*} )) + done + echo $_size +} diff --git a/kdumpctl b/kdumpctl index 009d259..978dae5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1249,6 +1249,97 @@ rebuild() { return $? } +do_estimate() { + local kdump_mods + local -A large_mods + local baseline + local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommanded_size + local size_mb=$(( 1024 * 1024 )) + + setup_initrd + if [ ! -f "$TARGET_INITRD" ]; then + derror "kdumpctl estimate: kdump initramfs is not built yet." + exit 1 + fi + + kdump_mods="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" + baseline=$(kdump_get_arch_recommend_size) + if [[ "${baseline: -1}" == "M" ]]; then + baseline=${baseline%M} + elif [[ "${baseline: -1}" == "G" ]]; then + baseline=$(( ${baseline%G} * 1024 )) + elif [[ "${baseline: -1}" == "T" ]]; then + baseline=$(( ${baseline%Y} * 1048576 )) + fi + + # The default value when using crashkernel=auto + baseline_size=$((baseline * size_mb)) + # Current reserved crashkernel size + reserved_size=$(cat /sys/kernel/kexec_crash_size) + # A pre-estimated value for userspace usage and kernel + # runtime allocation, 64M should good for most cases + runtime_size=$((64 * size_mb)) + # Kernel image size + kernel_size=$(get_kernel_size "$KDUMP_KERNEL") + # Kdump initramfs size + initrd_size=$(du -b "$TARGET_INITRD" | awk '{print $1}') + # Kernel modules static size after loaded + mod_size=0 + while read -r _name _size _; do + if [[ ! " $kdump_mods " == *" $_name "* ]]; then + continue + fi + mod_size=$((mod_size + _size)) + + # Mark module with static size larger than 2M as large module + if [[ $((_size / size_mb)) -ge 1 ]]; then + large_mods[$_name]=$_size + fi + done <<< "$(< /proc/modules)" + + # Extra memory usage required for LUKS2 decryption + crypt_size=0 + for _dev in $(get_all_kdump_crypt_dev); do + _crypt_info=$(cryptsetup luksDump "/dev/block/$_dev") + [[ $(echo "$_crypt_info" | sed -n "s/^Version:\s*\(.*\)/\1/p" ) == "2" ]] || continue + for _mem in $(echo "$_crypt_info" | sed -n "s/\sMemory:\s*\(.*\)/\1/p" | sort -n ); do + crypt_size=$((crypt_size + _mem * 1024)) + break + done + done + [[ $crypt_size -ne 0 ]] && echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement\n" + + estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size + crypt_size)) + if [[ $baseline_size -gt $estimated_size ]]; then + recommanded_size=$baseline_size + else + recommanded_size=$estimated_size + fi + + echo "Reserved crashkernel: $((reserved_size / size_mb))M" + echo "Recommanded crashkernel: $((recommanded_size / size_mb))M" + echo + echo "Kernel image size: $((kernel_size / size_mb))M" + echo "Kernel modules size: $((mod_size / size_mb))M" + echo "Initramfs size: $((initrd_size / size_mb))M" + echo "Runtime reservation: $((runtime_size / size_mb))M" + [[ $crypt_size -ne 0 ]] && \ + echo "LUKS required size: $((crypt_size / size_mb))M" + echo -n "Large modules:" + if [[ "${#large_mods[@]}" -eq 0 ]]; then + echo " " + else + echo "" + for _mod in "${!large_mods[@]}"; do + echo " $_mod: ${large_mods[$_mod]}" + done + fi + + if [[ $reserved_size -le $recommanded_size ]]; then + echo "WARNING: Current crashkernel size is lower than recommanded size $((recommanded_size / size_mb))M." + fi +} + if [ ! -f "$KDUMP_CONFIG_FILE" ]; then derror "Error: No kdump config file found!" exit 1 @@ -1304,8 +1395,11 @@ main () showmem) show_reserved_mem ;; + estimate) + do_estimate + ;; *) - dinfo $"Usage: $0 {start|stop|status|restart|reload|rebuild|propagate|showmem}" + dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|propagate|showmem}" exit 1 esac } diff --git a/kdumpctl.8 b/kdumpctl.8 index ae97af7..a32a972 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -44,6 +44,11 @@ impossible to use password authentication during kdump. .TP .I showmem Prints the size of reserved memory for crash kernel in megabytes. +.TP +.I estimate +Estimate a suitable crashkernel value for current machine. This is a +best-effort estimate. It will print a recommanded crashkernel value +based on current kdump setup, and list some details of memory usage. .SH "SEE ALSO" .BR kdump.conf (5), From 45377836b014e22c27e5a210e679501f97ba4525 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 25 May 2021 09:26:09 +0800 Subject: [PATCH 407/806] kdump-lib.sh: fix the case if no enough total RAM for kdump in get_recommend_size() For crashkernel=auto policy, if total RAM size is under a throttle, there is no memory reserved for kdump. Also correct a trivial bug by correcting the arch name. Signed-off-by: Pingfan Liu Acked-by: Kairui Song --- kdump-lib.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 74072c5..ecf909e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -913,6 +913,11 @@ get_recommend_size() last_sz="" last_unit="" + start=${_ck_cmdline: :1} + if [ $mem_size -lt $start ]; then + echo "0M" + return + fi IFS=',' for i in $_ck_cmdline; do end=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $1 }') @@ -940,9 +945,9 @@ kdump_get_arch_recommend_size() fi arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:]) - if [ $arch == "X86_64" ] || [ $arch == "S390" ]; then + if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" - elif [ $arch == "ARM64" ]; then + elif [ $arch == "AARCH64" ]; then ck_cmdline="2G-:448M" elif [ $arch == "PPC64LE" ]; then if is_fadump_capable; then From 39a642b66b2b4341a1345b63c5731e4ab90ad1b5 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Tue, 1 Jun 2021 16:46:58 +0530 Subject: [PATCH 408/806] kdump-lib.sh: fix a warning in prepare_kdump_bootinfo() Fix the warning observed when KDUMP_KERNELVER is specified: kdumpctl[10926]: /lib/kdump/kdump-lib.sh: line 697: [: missing `]' Signed-off-by: Hari Bathini Acked-by: Kairui Song --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index ecf909e..27741fb 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -746,7 +746,7 @@ prepare_kdump_bootinfo() local boot_imglist boot_dirlist boot_initrdlist curr_kver="$(uname -r)" local machine_id - if [ -z "$KDUMP_KERNELVER"]; then + if [ -z "$KDUMP_KERNELVER" ]; then KDUMP_KERNELVER="$(uname -r)" fi From 108258139a24b596be454c9aaa07b6ebf96e49a1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 26 Apr 2021 17:09:55 +0800 Subject: [PATCH 409/806] Don's try to restart dracut-initqueue if it's already there kdump's dump_to_rootfs will try to start initqueue unconditionally. dump_to_rootfs will run after systemd isolate to emergency target, so this is currently accetable. But there is a problem when initqueue starts the emergency action because of initqueue timeout. dump_to_rootfs will start initqueue and lead to timeout again. So following patch will remove the previous isolation wrapper, and detect the service status here. Previous isolation makes the detection impossible. Now this detection will be valid and helpful to prevent double timeout or hang. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdump-lib-initramfs.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index d0d124f..e359a15 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -222,8 +222,11 @@ save_opalcore_fs() { dump_to_rootfs() { - dinfo "Trying to bring up rootfs device" - systemctl start dracut-initqueue + if [[ $(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p") == "inactive" ]]; then + dinfo "Trying to bring up initqueue for rootfs mount" + systemctl start dracut-initqueue + fi + dinfo "Waiting for rootfs mount, will timeout after 90 seconds" systemctl start sysroot.mount From a2306346bc6671e99f8af137785a442ec0020d57 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 26 Apr 2021 17:09:56 +0800 Subject: [PATCH 410/806] Remove the kdump error handler isolation wrapper The wrapper is introduced in commit 002337c, according to the commit message, the only usage of the wrapper is when dracut-initqueue calls "systemctl start emergency" directly. In that case, emergency is started, but not in a isolation mode, which means dracut-initqueue is still running. On the other hand, emergency will call "systemctl start dracut-initqueue" again when default action is dump_to_rootfs. systemd would block on the last dracut-initqueue, waiting for the first instance to exit, which leaves us hang. In previous commit we added initqueue status detect in dump_to_rootfs, so now even without the wrapper, it will not hang. And actually, previously, with the wrapper, emergency might still hang for like 30s. When dracut called emergency service because initqueue timed out, dump_to_rootfs will try start initqueue again and timeout again. Now with the wrapper removed, we can avoid these two kinds of hangs, bacause without the isolation we can detect initqueue service status correctly in such case. Also remove the invalid header comments in service file, the service is not part of systemd code. And sync the service spec with dracut. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- dracut-kdump-emergency.service | 25 +++++++++++----------- dracut-kdump-error-handler.service | 33 ------------------------------ dracut-module-setup.sh | 1 - kexec-tools.spec | 2 -- 4 files changed, 12 insertions(+), 49 deletions(-) delete mode 100644 dracut-kdump-error-handler.service diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service index e023284..f2f6fad 100644 --- a/dracut-kdump-emergency.service +++ b/dracut-kdump-emergency.service @@ -1,27 +1,26 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -# This service will be placed in kdump initramfs and replace both the systemd -# emergency service and dracut emergency shell. IOW, any emergency will be -# kick this service and in turn isolating to kdump error handler. +# This service will run the real kdump error handler code. Executing the +# failure action configured in kdump.conf [Unit] -Description=Kdump Emergency +Description=Kdump Error Handler DefaultDependencies=no -IgnoreOnIsolate=yes +After=systemd-vconsole-setup.service +Wants=systemd-vconsole-setup.service [Service] -ExecStart=/usr/bin/systemctl --no-block isolate kdump-error-handler.service +Environment=HOME=/ +Environment=DRACUT_SYSTEMD=1 +Environment=NEWROOT=/sysroot +WorkingDirectory=/ +ExecStart=/bin/kdump-error-handler.sh +ExecStopPost=-/bin/rm -f -- /.console_lock Type=oneshot StandardInput=tty-force StandardOutput=inherit StandardError=inherit KillMode=process IgnoreSIGPIPE=no +TasksMax=infinity # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # terminates cleanly. diff --git a/dracut-kdump-error-handler.service b/dracut-kdump-error-handler.service deleted file mode 100644 index a23b75e..0000000 --- a/dracut-kdump-error-handler.service +++ /dev/null @@ -1,33 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -# This service will run the real kdump error handler code. Executing the -# failure action configured in kdump.conf - -[Unit] -Description=Kdump Error Handler -DefaultDependencies=no -After=systemd-vconsole-setup.service -Wants=systemd-vconsole-setup.service -AllowIsolate=yes - -[Service] -Environment=HOME=/ -Environment=DRACUT_SYSTEMD=1 -Environment=NEWROOT=/sysroot -WorkingDirectory=/ -ExecStart=/bin/kdump-error-handler.sh -Type=oneshot -StandardInput=tty-force -StandardOutput=inherit -StandardError=inherit -KillMode=process -IgnoreSIGPIPE=no - -# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash -# terminates cleanly. -KillSignal=SIGHUP diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a99a0ea..68ee28e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1026,7 +1026,6 @@ install() { inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" - inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service" # Replace existing emergency service and emergency target cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" diff --git a/kexec-tools.spec b/kexec-tools.spec index 11c64cb..e94ed02 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -49,7 +49,6 @@ Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress Source103: dracut-kdump-error-handler.sh Source104: dracut-kdump-emergency.service -Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target Source108: dracut-early-kdump.sh @@ -220,7 +219,6 @@ cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} -cp %{SOURCE105} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE105}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} From 41980f30d9f5806a2e34e30fe279167c12d0ae75 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 26 Apr 2021 17:09:57 +0800 Subject: [PATCH 411/806] Use a customized emergency shell Use a modified and minimized version of emergency shell. The differences of this kdump shell and dracut emergency shell are: - Kdump shell won't generate a rdsosreport automatically - Customized prompts - Never ask root password - Won't tangle with dracut's emergency_action. If emergency_action is set, dracut emergency shell will perform dracut's emergency_action instead of kdump final_action on exit. - If rd.shell=no is set, kdump shell will still work, dracut emergency shell won't, even if kdump failure_action is set to shell. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdump-lib-initramfs.sh | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e359a15..ca6a825 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -237,10 +237,35 @@ dump_to_rootfs() kdump_emergency_shell() { - echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile - ddebug "Switching to dracut emergency..." - /bin/dracut-emergency - rm -f /etc/profile + ddebug "Switching to kdump emergency shell..." + + [ -f /etc/profile ] && . /etc/profile + export PS1='kdump:${PWD}# ' + + . /lib/dracut-lib.sh + if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2>/dev/null + fi + + source_conf /etc/conf.d + + type plymouth >/dev/null 2>&1 && plymouth quit + + source_hook "emergency" + while read _tty rest; do + ( + echo + echo + echo 'Entering kdump emergency mode.' + echo 'Type "journalctl" to view system logs.' + echo 'Type "rdsosreport" to generate a sosreport, you can then' + echo 'save it elsewhere and attach it to a bug report.' + echo + echo + ) > /dev/$_tty + done < /proc/consoles + sh -i -l + /bin/rm -f -- /.console_lock } do_failure_action() From 7d472515688fb330eee76dac1c39ae628398f757 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 7 Jun 2021 07:26:03 +0800 Subject: [PATCH 412/806] Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet This patch fixes bz1941106 and bz1941905 which passed empty rd.znet to the kernel command line in the following cases, - The IBM (Z15) KVM guest uses virtio for all devices including network device, so there is no znet device for IBM KVM guest. So we can't assume a s390x machine always has a znet device. - When a bridged network is used, kexec-tools tries to obtain the znet configuration from the ifcfg script of the bridged network rather than from the ifcfg script of znet device. We can iterate /sys/bus/ccwgroup/devices to tell if there if there is a znet network device. By getting an ifname from znet, we can also avoid mistaking the slave netdev as a znet network device in a bridged network or bonded network. Note: This patch also assumes there is only one znet device as commit 7148c0a30dfc48221eadf255e8a89619f98a8752 ("add s390x netdev setup") which greatly simplifies the code. According to IBM [1], there could be more than znet devices for a z/VM system and a z/VM system may have a non-znet network device like ConnectX. Since kdump_setup_znet was introduced in 2012 and so far there is no known customer complaint that invalidates this assumption I think it's safe to assume an IBM z/VM system only has one znet device. Besides, there is no z/VM system found on beaker to test the alternative scenarios. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1941905#c13 Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 68ee28e..35a961a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -460,6 +460,34 @@ kdump_setup_vlan() { fi } +# find online znet device +# return ifname (_netdev) +# code reaped from the list_configured function of +# https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf +find_online_znet_device() { + local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" + local NETWORK_DEVICES d ifname ONLINE + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR -type l) + for d in $NETWORK_DEVICES + do + read ONLINE < $d/online + if [ $ONLINE -ne 1 ]; then + continue + fi + # determine interface name, if there (only for qeth and if + # device is online) + if [ -f $d/if_name ] + then + read ifname < $d/if_name + elif [ -d $d/net ] + then + ifname=$(ls $d/net/) + fi + [ -n "$ifname" ] && break + done + echo -n "$ifname" +} + # setup s390 znet cmdline # $1: netdev (ifname) # $2: nmcli connection show output @@ -526,6 +554,7 @@ kdump_get_remote_ip() kdump_install_net() { local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts + local _znet_netdev _nm_show_cmd_znet _destaddr=$(kdump_get_remote_ip $1) _route=$(kdump_get_ip_route $_destaddr) @@ -535,8 +564,10 @@ kdump_install_net() { _netmac=$(kdump_get_mac_addr $_netdev) kdumpnic=$(kdump_setup_ifname $_netdev) - if [ "$(uname -m)" = "s390x" ]; then - $(kdump_setup_znet "$_netdev" "$_nm_show_cmd") + _znet_netdev=$(find_online_znet_device) + if [[ -n "$_znet_netdev" ]]; then + _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") + $(kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet") if [[ $? != 0 ]]; then derror "Failed to set up znet" exit 1 From 2d9504c4a4dc5e2c659fbd8810b1fed681e5b4ba Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Tue, 1 Jun 2021 18:33:44 +0800 Subject: [PATCH 413/806] mkdumprd: display the absolute path of dump location in the check_user_configured_target() When kdump service fails, the current errors do not display the absolute path of dump location(marked it as "^"), for example: kdump: kexec: unloaded kdump kernel kdump: Stopping kdump: [OK] kdump: Detected change(s) in the following file(s): /etc/kdump.conf kdump: Rebuilding /boot/initramfs-4.18.0-304.el8.x86_64kdump.img kdump: Dump path "/var1/crash" does not exist in dump target "UUID=c202ef45-3ac3-4adb-85e7-307a916757f0" ^^^^^^^^^^^ kdump: mkdumprd: failed to make kdump initrd kdump: Starting kdump: [FAILED] Here, it should output the absolute path of dump location with this format: "/". To fix it, let's extend the relative pathname to the absolute pathname in check_user_configured_target(). Signed-off-by: Lianbo Jiang Acked-by: Kairui Song --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index b518078..6d699c3 100644 --- a/mkdumprd +++ b/mkdumprd @@ -246,7 +246,7 @@ check_user_configured_target() # For user configured target, use $SAVE_PATH as the dump path within the target if [ ! -d "$_mnt/$SAVE_PATH" ]; then - perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\"" + perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\"" fi check_size fs "$_target" From 0a15d859bbcec7415f12a1123d00e223b9f864be Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 7 Jun 2021 14:40:50 +0800 Subject: [PATCH 414/806] selftest: fix the error of misplacing double quotes Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/scripts/testcases/nfs-kdump/0-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/testcases/nfs-kdump/0-server.sh b/tests/scripts/testcases/nfs-kdump/0-server.sh index 41a0212..cf54e70 100755 --- a/tests/scripts/testcases/nfs-kdump/0-server.sh +++ b/tests/scripts/testcases/nfs-kdump/0-server.sh @@ -17,7 +17,7 @@ on_build() { img_run_cmd "systemctl enable dnsmasq" img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo BOOTPROTO="none >> /etc/sysconfig/network-scripts/ifcfg-eth0"' + img_run_cmd 'echo BOOTPROTO="none" >> /etc/sysconfig/network-scripts/ifcfg-eth0' img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' From 560c0e8a7b1ca03ae881b80419b05d129c8a035d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 7 Jun 2021 14:40:52 +0800 Subject: [PATCH 415/806] selftest: Make test_base_image depends on EXTRA_RPMS test_base_image should depend on EXTRA_RPMS so it gets rebuild when EXTRA_RPMS changes. Fixes: commit bbc064f9582080124a4acc41f7e33e21c4f18a4f ("selftest: add EXTRA_RPMs so dracut RPMs can be installed onto the image to run the tests") Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 4e9c55f..8fb38c7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -67,7 +67,7 @@ $(BUILD_ROOT)/inst-base-image: $(BUILD_ROOT)/base-image $(BUILD_ROOT)/inst-base-image \ $(TEST_ROOT)/scripts/build-scripts/base-image.sh -$(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS_RPM) $(KEXEC_TOOLS_TEST_SRC) +$(TEST_ROOT)/output/test-base-image: $(BUILD_ROOT)/inst-base-image $(KEXEC_TOOLS_RPM) $(KEXEC_TOOLS_TEST_SRC) $(EXTRA_RPMS) @echo "Building test base image" mkdir -p $(TEST_ROOT)/output $(TEST_ROOT)/scripts/build-image.sh \ From 62578ace21227f1b584cf652b60775ab6035b803 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 7 Jun 2021 14:40:53 +0800 Subject: [PATCH 416/806] selftest: ignore all spaces when compare the dmesg files For the log entry that has multiple lines, "makedumpfile --dump-dmesg" would indent the remaining lines while vmcore-dmesg doesn't. For example, vmcore-dmesg.txt and vmcore-dmesg.txt.2 are the outputs of vmcore-dmesg and "makedumpfile --dump-dmesg" respectively, ``` diff -u vmcore-dmesg.txt vmcore-dmesg.txt.2 --- vmcore-dmesg.txt 2021-03-28 22:13:09.986000000 -0400 +++ vmcore-dmesg.txt.2 2021-03-28 22:13:39.920106131 -0400 @@ -397,9 +397,9 @@ [ 1.710742] vc vcsa: hash matches [ 1.711938] RAS: Correctable Errors collector initialized. [ 1.713736] Unstable clock detected, switching default tracing clock to "global" -If you want to keep using the local clock, then add: - "trace_clock=local" -on the kernel command line + If you want to keep using the local clock, then add: + "trace_clock=local" + on the kernel command line [ 1.750539] ata1.01: NODEV after polling detection [ 1.750973] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100 [ 1.752885] ata1.00: 8388608 sectors, multi 16: LBA48 ``` Quite often, all three tests could fail because of the above difference. So let's ignore all the spaces. This patch could fix bz1952299 [1]. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1952299 Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/scripts/kexec-kdump-test/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh index f427905..deacb51 100755 --- a/tests/scripts/kexec-kdump-test/init.sh +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -95,7 +95,7 @@ has_valid_vmcore_dir() { return 1 fi - if ! diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then + if ! diff -w $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then test_output "Dmesg retrived from vmcore is different from dump version!" return 1 fi From 302be5c34b400b6dcb948f18fd1ee6d254a3d8bd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 20 Jun 2021 02:37:47 +0800 Subject: [PATCH 417/806] Release 2.0.22-3 Signed-off-by: Kairui Song --- kexec-tools.spec | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index e94ed02..7b29b0e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -353,6 +353,21 @@ done %endif %changelog +* Sun Jun 20 2021 Kairui Song - 2.0.22-3 +- selftest: Make test_base_image depends on EXTRA_RPMS +- selftest: fix the error of misplacing double quotes +- mkdumprd: display the absolute path of dump location in the check_user_configured_target() +- Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet +- Use a customized emergency shell +- Remove the kdump error handler isolation wrapper +- Don's try to restart dracut-initqueue if it's already there +- kdump-lib.sh: fix a warning in prepare_kdump_bootinfo() +- kdump-lib.sh: fix the case if no enough total RAM for kdump in get_recommend_size() +- kdumpctl: Add kdumpctl estimate +- mkdumprd: make use of the new get_luks_crypt_dev helper +- kdump-lib.sh: introduce a helper to get all crypt dev used by kdump +- kdump-lib.sh: introduce a helper to get underlying crypt device + * Thu May 13 2021 Kairui Song - 2.0.22-2 - Disable CMA in kdump 2nd kernel - Warn the user if network scripts are used From 18b9b763de77e151ea013e9d033a7242b3d86235 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 22 Jun 2021 21:30:25 +0800 Subject: [PATCH 418/806] Increase SECTION_MAP_LAST_BIT to 5 Backport from upstream. commit 646456862df8926ba10dd7330abf3bf0f887e1b6 Author: Kazuhito Hagio Date: Wed May 26 14:31:26 2021 +0900 [PATCH] Increase SECTION_MAP_LAST_BIT to 5 * Required for kernel 5.12 Kernel commit 1f90a3477df3 ("mm: teach pfn_to_online_page() about ZONE_DEVICE section collisions") added a section flag (SECTION_TAINT_ZONE_DEVICE) and causes makedumpfile an error on some machines like this: __vtop4_x86_64: Can't get a valid pmd_pte. readmem: Can't convert a virtual address(ffffe2bdc2000000) to physical address. readmem: type_addr: 0, addr:ffffe2bdc2000000, size:32768 __exclude_unnecessary_pages: Can't read the buffer of struct page. create_2nd_bitmap: Can't exclude unnecessary pages. Increase SECTION_MAP_LAST_BIT to 5 to fix this. The bit had not been used until the change, so we can just increase the value. Signed-off-by: Kazuhito Hagio Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...e-Increase-SECTION_MAP_LAST_BIT-to-5.patch | 42 +++++++++++++++++++ kexec-tools.spec | 3 ++ 2 files changed, 45 insertions(+) create mode 100644 kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch diff --git a/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch b/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch new file mode 100644 index 0000000..a59bef1 --- /dev/null +++ b/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch @@ -0,0 +1,42 @@ +From 646456862df8926ba10dd7330abf3bf0f887e1b6 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 26 May 2021 14:31:26 +0900 +Subject: [PATCH] Increase SECTION_MAP_LAST_BIT to 5 + +* Required for kernel 5.12 + +Kernel commit 1f90a3477df3 ("mm: teach pfn_to_online_page() about +ZONE_DEVICE section collisions") added a section flag +(SECTION_TAINT_ZONE_DEVICE) and causes makedumpfile an error on +some machines like this: + + __vtop4_x86_64: Can't get a valid pmd_pte. + readmem: Can't convert a virtual address(ffffe2bdc2000000) to physical address. + readmem: type_addr: 0, addr:ffffe2bdc2000000, size:32768 + __exclude_unnecessary_pages: Can't read the buffer of struct page. + create_2nd_bitmap: Can't exclude unnecessary pages. + +Increase SECTION_MAP_LAST_BIT to 5 to fix this. The bit had not +been used until the change, so we can just increase the value. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.9/makedumpfile.h b/makedumpfile-1.6.9/makedumpfile.h +index 93aa774..79046f2 100644 +--- a/makedumpfile-1.6.9/makedumpfile.h ++++ b/makedumpfile-1.6.9/makedumpfile.h +@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) + * 2. it has been verified that (1UL<<2) was never set, so it is + * safe to mask that bit off even in old kernels. + */ +-#define SECTION_MAP_LAST_BIT (1UL<<4) ++#define SECTION_MAP_LAST_BIT (1UL<<5) + #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) + #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) + #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 7b29b0e..ca2e30c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -100,6 +100,7 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # +Patch601: ./kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -115,6 +116,8 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch601 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 0feb109818c53bf1f7e6acd55ca02a119855b77b Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 22 Jun 2021 21:30:26 +0800 Subject: [PATCH 419/806] check for invalid physical address of /proc/kcore when finding max_paddr Backport from upstream. commit 38d921a2ef50ebd36258097553626443ffe27496 Author: Coiby Xu Date: Tue Jun 15 18:26:31 2021 +0800 [PATCH] check for invalid physical address of /proc/kcore when finding max_paddr Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore: update physical address for kcore ram and text") sets an invalid paddr (0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped regions: $ readelf -l /proc/kcore ... Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align NOTE 0x0000000000000120 0x0000000000000000 0x0000000000000000 0x0000000000002320 0x0000000000000000 0x0 LOAD 0x1000000000010000 0xd000000000000000 0xffffffffffffffff ^^^^^^^^^^^^^^^^^^ 0x0001f80000000000 0x0001f80000000000 RWE 0x10000 makedumpfile uses max_paddr to calculate the number of sections for sparse memory model thus wrong number is obtained based on max_paddr (-1). This error could lead to the failure of copying /proc/kcore for RHEL-8.5 on ppc64le machine [1]: $ makedumpfile /proc/kcore vmcore1 get_mem_section: Could not validate mem_section. get_mm_sparsemem: Can't get the address of mem_section. makedumpfile Failed. Let's check if the phys_start of the segment is a valid physical address to fix this problem. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267 Reported-by: Xiaoying Yan Signed-off-by: Coiby Xu Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...ss-proc-kcore-when-finding-max_paddr.patch | 60 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 62 insertions(+) create mode 100644 kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch diff --git a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch new file mode 100644 index 0000000..f79ea55 --- /dev/null +++ b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch @@ -0,0 +1,60 @@ +From 38d921a2ef50ebd36258097553626443ffe27496 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Tue, 15 Jun 2021 18:26:31 +0800 +Subject: [PATCH] check for invalid physical address of /proc/kcore + when finding max_paddr + +Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore: +update physical address for kcore ram and text") sets an invalid paddr +(0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped +regions: + + $ readelf -l /proc/kcore + ... + Program Headers: + Type Offset VirtAddr PhysAddr + FileSiz MemSiz Flags Align + NOTE 0x0000000000000120 0x0000000000000000 0x0000000000000000 + 0x0000000000002320 0x0000000000000000 0x0 + LOAD 0x1000000000010000 0xd000000000000000 0xffffffffffffffff + ^^^^^^^^^^^^^^^^^^ + 0x0001f80000000000 0x0001f80000000000 RWE 0x10000 + +makedumpfile uses max_paddr to calculate the number of sections for +sparse memory model thus wrong number is obtained based on max_paddr +(-1). This error could lead to the failure of copying /proc/kcore +for RHEL-8.5 on ppc64le machine [1]: + + $ makedumpfile /proc/kcore vmcore1 + get_mem_section: Could not validate mem_section. + get_mm_sparsemem: Can't get the address of mem_section. + + makedumpfile Failed. + +Let's check if the phys_start of the segment is a valid physical +address to fix this problem. + +[1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267 + +Reported-by: Xiaoying Yan +Signed-off-by: Coiby Xu +--- + elf_info.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.9/elf_info.c b/makedumpfile-1.6.9/elf_info.c +index e8affb7..bc24083 100644 +--- a/makedumpfile-1.6.9/elf_info.c ++++ b/makedumpfile-1.6.9/elf_info.c +@@ -628,7 +628,7 @@ get_max_paddr(void) + + for (i = 0; i < num_pt_loads; i++) { + pls = &pt_loads[i]; +- if (max_paddr < pls->phys_end) ++ if (pls->phys_start != NOT_PADDR && max_paddr < pls->phys_end) + max_paddr = pls->phys_end; + } + return max_paddr; +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index ca2e30c..5aeda5a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -101,6 +101,7 @@ Requires: systemd-udev%{?_isa} # Patches 601 onward are generic patches # Patch601: ./kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch +Patch602: ./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -117,6 +118,7 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch601 -p1 +%patch602 -p1 %ifarch ppc %define archdef ARCH=ppc From 50bb8b701f90a614849788bd01e9b005d159541e Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 22 Jun 2021 21:30:27 +0800 Subject: [PATCH 420/806] check for invalid physical address of /proc/kcore when making ELF dumpfile Backport from upstream. commit 9a6f589d99dcef114c89fde992157f5467028c8f Author: Tao Liu Date: Fri Jun 18 18:28:04 2021 +0800 [PATCH] check for invalid physical address of /proc/kcore when making ELF dumpfile Previously when executing makedumpfile with -E option against /proc/kcore, makedumpfile will fail: # makedumpfile -E -d 31 /proc/kcore kcore.dump ... write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset. makedumpfile Failed. It's because /proc/kcore contains PT_LOAD program headers which have physaddr (0xffffffffffffffff). With -E option, makedumpfile will try to convert the physaddr to an offset and fails. Skip the PT_LOAD program headers which have such physaddr. Signed-off-by: Tao Liu Signed-off-by: Kazuhito Hagio Signed-off-by: Tao Liu Acked-by: Kairui Song --- ...-proc-kcore-when-making-ELF-dumpfile.patch | 43 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 45 insertions(+) create mode 100644 kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch diff --git a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch new file mode 100644 index 0000000..8cf780c --- /dev/null +++ b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch @@ -0,0 +1,43 @@ +From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Fri, 18 Jun 2021 18:28:04 +0800 +Subject: [PATCH] check for invalid physical address of /proc/kcore + when making ELF dumpfile + +Previously when executing makedumpfile with -E option against +/proc/kcore, makedumpfile will fail: + + # makedumpfile -E -d 31 /proc/kcore kcore.dump + ... + write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset. + + makedumpfile Failed. + +It's because /proc/kcore contains PT_LOAD program headers which have +physaddr (0xffffffffffffffff). With -E option, makedumpfile will +try to convert the physaddr to an offset and fails. + +Skip the PT_LOAD program headers which have such physaddr. + +Signed-off-by: Tao Liu +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.9/makedumpfile.c b/makedumpfile-1.6.9/makedumpfile.c +index 894c88e..fcb571f 100644 +--- a/makedumpfile-1.6.9/makedumpfile.c ++++ b/makedumpfile-1.6.9/makedumpfile.c +@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) + if (!get_phdr_memory(i, &load)) + return FALSE; + +- if (load.p_type != PT_LOAD) ++ if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR) + continue; + + off_memory= load.p_offset; +-- +2.29.2 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 5aeda5a..f14b02f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -102,6 +102,7 @@ Requires: systemd-udev%{?_isa} # Patch601: ./kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch Patch602: ./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch +Patch603: ./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -119,6 +120,7 @@ tar -z -x -v -f %{SOURCE19} %patch601 -p1 %patch602 -p1 +%patch603 -p1 %ifarch ppc %define archdef ARCH=ppc From 03f9b91351fcd245e8d9327c38de296f818ad115 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 28 Jun 2021 18:37:10 +0800 Subject: [PATCH 421/806] check the existence of /sys/bus/ccwgroup/devices before trying to find online network device /sys/bus/ccwgroup/devices doesn't exist for non-s390x machines which leads to the warning "find: '/sys/bus/ccwgroup/devices': No such file or directory". This warning can be eliminated by checking the existence of "/sys/bus/ccwgroup/devices" beforehand. Fixes: commit 7d472515688fb330eee76dac1c39ae628398f757 ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet") Reported-by: Ruowen Qin BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1974618 Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 35a961a..d9607d7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -467,7 +467,9 @@ kdump_setup_vlan() { find_online_znet_device() { local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" local NETWORK_DEVICES d ifname ONLINE - NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR -type l) + + [ ! -d "$CCWGROUPBUS_DEVICEDIR" ] && return + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) for d in $NETWORK_DEVICES do read ONLINE < $d/online From ad6f60d70df5306380c83fd1ebbd0a637ef993f1 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 28 Jun 2021 18:37:11 +0800 Subject: [PATCH 422/806] fix format issue in find_online_znet_device Change spaces to tab to fix alignment issue. Fixes: commit 7d472515688fb330eee76dac1c39ae628398f757 ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet") Signed-off-by: Coiby Xu Acked-by: Kairui Song --- dracut-module-setup.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d9607d7..9b0f432 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -465,29 +465,29 @@ kdump_setup_vlan() { # code reaped from the list_configured function of # https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf find_online_znet_device() { - local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" - local NETWORK_DEVICES d ifname ONLINE + local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" + local NETWORK_DEVICES d ifname ONLINE [ ! -d "$CCWGROUPBUS_DEVICEDIR" ] && return - NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) for d in $NETWORK_DEVICES do - read ONLINE < $d/online - if [ $ONLINE -ne 1 ]; then - continue - fi - # determine interface name, if there (only for qeth and if - # device is online) - if [ -f $d/if_name ] - then - read ifname < $d/if_name - elif [ -d $d/net ] - then - ifname=$(ls $d/net/) - fi - [ -n "$ifname" ] && break - done - echo -n "$ifname" + read ONLINE < $d/online + if [ $ONLINE -ne 1 ]; then + continue + fi + # determine interface name, if there (only for qeth and if + # device is online) + if [ -f $d/if_name ] + then + read ifname < $d/if_name + elif [ -d $d/net ] + then + ifname=$(ls $d/net/) + fi + [ -n "$ifname" ] && break + done + echo -n "$ifname" } # setup s390 znet cmdline From c4749f9c57ea8b2d3eb5208cf1e8fd6df604b9f8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 29 Jun 2021 21:23:56 +0800 Subject: [PATCH 423/806] Release 2.0.22-4 Signed-off-by: Kairui Song --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f14b02f..e4f0b02 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -360,6 +360,13 @@ done %endif %changelog +* Tue Jun 29 2021 Kairui Song - 2.0.22-4 +* fix format issue in find_online_znet_device +* check the existence of /sys/bus/ccwgroup/devices before trying to find online network device +* check for invalid physical address of /proc/kcore when making ELF dumpfile +* check for invalid physical address of /proc/kcore when finding max_paddr +* Increase SECTION_MAP_LAST_BIT to 5 + * Sun Jun 20 2021 Kairui Song - 2.0.22-3 - selftest: Make test_base_image depends on EXTRA_RPMS - selftest: fix the error of misplacing double quotes From fa9201b2400565aca8165b9cd0a5151f1f94c7be Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Wed, 23 Jun 2021 20:06:48 +0530 Subject: [PATCH 424/806] fadump: isolate fadump initramfs image within the default one In case of fadump, the initramfs image has to be built to boot into the production environment as well as to offload the active crash dump to the specified dump target (for boot after crash). As the same image would be used for both boot scenarios, it could not be built optimally while accommodating both cases. Use --include to include the initramfs image built for offloading active crash dump to the specified dump target. Also, introduce a new out-of-tree dracut module (99zz-fadumpinit) that installs a customized init program while moving the default /init to /init.dracut. This customized init program is leveraged to isolate fadump image within the default initramfs image by kicking off default boot process (exec /init.dracut) for regular boot scenario and activating fadump initramfs image, if the system is booting after a crash. If squash is available, ensure default initramfs image is also built with squash module to reduce memory consumption in capture kernel. Signed-off-by: Hari Bathini Signed-off-by: Kairui Song Acked-by: Kairui Song --- dracut-fadump-init-fadump.sh | 44 +++++++++++++++++++++++++ dracut-fadump-module-setup.sh | 23 ++++++++++++++ dracut-module-setup.sh | 16 ++-------- kdump-lib.sh | 10 ++++++ kdumpctl | 22 +++---------- kexec-tools.spec | 14 ++++++++ mkdumprd | 5 +++ mkfadumprd | 60 +++++++++++++++++++++++++++++++++++ 8 files changed, 162 insertions(+), 32 deletions(-) create mode 100755 dracut-fadump-init-fadump.sh create mode 100644 dracut-fadump-module-setup.sh create mode 100644 mkfadumprd diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh new file mode 100755 index 0000000..5468d99 --- /dev/null +++ b/dracut-fadump-init-fadump.sh @@ -0,0 +1,44 @@ +#!/bin/sh +export PATH=/usr/bin:/usr/sbin +export SYSTEMD_IN_INITRD=lenient + +[ -e /proc/mounts ] || + (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc) + +grep -q '^sysfs /sys sysfs' /proc/mounts || + (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys) + +grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1 + +if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then + mkdir /newroot + mount -t ramfs ramfs /newroot + + if [ $ROOTFS_IS_RAMFS ]; then + for FILE in $(ls -A /fadumproot/); do + mv /fadumproot/$FILE /newroot/ + done + exec switch_root /newroot /init + else + mkdir /newroot/sys /newroot/proc /newroot/oldroot + mount --move /proc /newroot/proc + mount --move /sys /newroot/sys + cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/ + cd /newroot && pivot_root . oldroot + + loop=1 + while [ $loop ]; do + unset loop + while read -r _ mp _; do + case $mp in + /oldroot/*) umount "$mp" && loop=1 ;; + esac + done /dev/null || return 1 - else - modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 - fi - done - } - - if is_squash_available && ! is_fadump_capable; then + if is_squash_available; then add_opt_module squash else dwarning "Required modules to build a squashed kdump image is missing!" @@ -1087,7 +1077,5 @@ install() { ${initdir}/etc/lvm/lvm.conf &>/dev/null # Save more memory by dropping switch root capability - if ! is_fadump_capable; then - dracut_no_switch_root - fi + dracut_no_switch_root } diff --git a/kdump-lib.sh b/kdump-lib.sh index 27741fb..8e618f8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -19,6 +19,16 @@ is_fadump_capable() return 1 } +is_squash_available() { + for kmodule in squashfs overlay loop; do + if [ -z "$KDUMP_KERNELVER" ]; then + modprobe --dry-run $kmodule &>/dev/null || return 1 + else + modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 + fi + done +} + perror_exit() { derror "$@" exit 1 diff --git a/kdumpctl b/kdumpctl index 978dae5..26247d1 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,6 +8,7 @@ KEXEC_ARGS="" KDUMP_CONFIG_FILE="/etc/kdump.conf" KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" +MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" @@ -104,25 +105,10 @@ save_core() rebuild_fadump_initrd() { - local target_initrd_tmp - - # this file tells the initrd is fadump enabled - touch /tmp/fadump.initramfs - target_initrd_tmp="$TARGET_INITRD.tmp" - ddebug "rebuild fadump initrd: $target_initrd_tmp $DEFAULT_INITRD_BAK $KDUMP_KERNELVER" - $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \ - -i /tmp/fadump.initramfs /etc/fadump.initramfs - if [ $? != 0 ]; then - derror "mkdumprd: failed to rebuild initrd with fadump support" - rm -f /tmp/fadump.initramfs + if ! $MKFADUMPRD "$DEFAULT_INITRD_BAK" "$TARGET_INITRD" --kver "$KDUMP_KERNELVER"; then + derror "mkfadumprd: failed to make fadump initrd" return 1 fi - rm -f /tmp/fadump.initramfs - - # updating fadump initrd - ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD" - mv $target_initrd_tmp $TARGET_INITRD - sync return 0 } @@ -612,7 +598,7 @@ check_rebuild() #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then - capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l) + capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l) fi fi diff --git a/kexec-tools.spec b/kexec-tools.spec index e4f0b02..8fed959 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -39,6 +39,7 @@ Source28: kdump-udev-throttler Source29: kdump.sysconfig.aarch64 Source30: 60-kdump.install Source31: kdump-logger.sh +Source32: mkfadumprd ####################################### # These are sources for mkdumpramfs @@ -54,6 +55,9 @@ Source107: dracut-kdump-emergency.target Source108: dracut-early-kdump.sh Source109: dracut-early-kdump-module-setup.sh +Source200: dracut-fadump-init-fadump.sh +Source201: dracut-fadump-module-setup.sh + Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units @@ -183,6 +187,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd +install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 @@ -218,6 +223,7 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') %define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g') +%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g') # deal with dracut modules mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -235,6 +241,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} +%ifarch ppc64 ppc64le +mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit +cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}} +cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}} +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}} +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}} +%endif %define dracutlibdir %{_prefix}/lib/dracut @@ -316,6 +329,7 @@ done /usr/sbin/makedumpfile %endif /usr/sbin/mkdumprd +/usr/sbin/mkfadumprd /usr/sbin/vmcore-dmesg %{_bindir}/* %{_datadir}/kdump diff --git a/mkdumprd b/mkdumprd index 6d699c3..89a160d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -452,6 +452,11 @@ then add_dracut_arg "--add-drivers" \"$extra_modules\" fi +# TODO: The below check is not needed anymore with the introduction of +# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd, +# but still sysroot.mount unit gets generated based on 'root=' kernel +# parameter available in fadump case. So, find a way to fix that first +# before removing this check. if ! is_fadump_capable; then # The 2nd rootfs mount stays behind the normal dump target mount, # so it doesn't affect the logic of check_dump_fs_modified(). diff --git a/mkfadumprd b/mkfadumprd new file mode 100644 index 0000000..4af4ae6 --- /dev/null +++ b/mkfadumprd @@ -0,0 +1,60 @@ +#!/bin/bash --norc +# Generate an initramfs image that isolates dump capture capability within +# the default initramfs using zz-fadumpinit dracut module. + +if [ -f /etc/sysconfig/kdump ]; then + . /etc/sysconfig/kdump +fi + +[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut +. $dracutbasedir/dracut-functions.sh +. /lib/kdump/kdump-lib.sh +. /lib/kdump/kdump-logger.sh + +#initiate the kdump logger +if ! dlog_init; then + echo "mkfadumprd: failed to initiate the kdump logger." + exit 1 +fi + +readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)" +[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed." +trap ' + ret=$?; + [[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR"; + exit $ret; + ' EXIT + +# clean up after ourselves no matter how we die. +trap 'exit 1;' SIGINT + +MKDUMPRD="/sbin/mkdumprd -f" +# Default boot initramfs to be rebuilt +REBUILD_INITRD="$1" && shift +TARGET_INITRD="$1" && shift +FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img" + +### First build an initramfs with dump capture capability +# this file tells the initrd is fadump enabled +touch "$MKFADUMPRD_TMPDIR/fadump.initramfs" +ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER" +if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then + perror_exit "mkfadumprd: failed to build image with dump capture support" +fi + +### Unpack the initramfs having dump capture capability +mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" +if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$MKFADUMPRD_TMPDIR/fadump.img" && \ + popd > /dev/null); then + derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" + exit 1 +fi + +### Pack it into the normal boot initramfs with zz-fadumpinit module +_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot" +if is_squash_available; then + _dracut_isolate_args="$_dracut_isolate_args --add squash" +fi +if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then + perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability" +fi From bf6671b60de3e1a33cda0a814b1729090f12f349 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 25 Jun 2021 14:44:45 +0800 Subject: [PATCH 425/806] fadump: kdumpctl should check the modules used by the fadump initramfs After fadump embedded the fadump initramfs in the normal initramfs, kdumpctl will mistakenly rebuild the initramfs everytime. kdumpctl checks the hostonly-kernel-modules.txt file in initramfs to check if required drivers are included, but the normal initramfs is built in non-hostonly mode, so it doesn't have a hostonly-kernel-modules.txt file. The check will always fail. So let mkfadumprd make a copy of the hostonly-kernel-modules.txt in the fadump initramfs and let kdumpctl check that file instead. Signed-off-by: Kairui Song Acked-by: Hari Bathini --- kdumpctl | 8 ++++++-- mkfadumprd | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kdumpctl b/kdumpctl index 26247d1..e4334c5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -443,9 +443,13 @@ check_drivers_modified() # Include watchdog drivers if watchdog module is not omitted is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)" - [ -z "$_new_drivers" ] && return 0 - _old_drivers="$(lsinitrd $TARGET_INITRD -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" + + if is_fadump_capable; then + _old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/fadump-kernel-modules.txt | tr '\n' ' ')" + else + _old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" + fi ddebug "Modules required for kdump: '$_new_drivers'" ddebug "Modules included in old initramfs: '$_old_drivers'" diff --git a/mkfadumprd b/mkfadumprd index 4af4ae6..aecf2a8 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -44,14 +44,18 @@ fi ### Unpack the initramfs having dump capture capability mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" -if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$MKFADUMPRD_TMPDIR/fadump.img" && \ +if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && \ popd > /dev/null); then derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" exit 1 fi ### Pack it into the normal boot initramfs with zz-fadumpinit module -_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot" +_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit \ + -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot \ + -i $MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt + /usr/lib/dracut/fadump-kernel-modules.txt" + if is_squash_available; then _dracut_isolate_args="$_dracut_isolate_args --add squash" fi From 97930d3ccad5ce090d3160a5781549b081467655 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 28 Jun 2021 13:57:27 +0800 Subject: [PATCH 426/806] fadump-init: clean up mount points properly When running with squash module enabled for both initramfs, /dev and /run are also mounted by squash-init, so move them to newroot as well, else they might leak. Also pass `-d` to umount so loop devices (if used) will be force freed. Signed-off-by: Kairui Song Acked-by: Hari Bathini --- dracut-fadump-init-fadump.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh index 5468d99..94a3751 100755 --- a/dracut-fadump-init-fadump.sh +++ b/dracut-fadump-init-fadump.sh @@ -20,9 +20,13 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o done exec switch_root /newroot /init else - mkdir /newroot/sys /newroot/proc /newroot/oldroot - mount --move /proc /newroot/proc + mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot + + grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev + grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run mount --move /sys /newroot/sys + mount --move /proc /newroot/proc + cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/ cd /newroot && pivot_root . oldroot @@ -31,11 +35,11 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o unset loop while read -r _ mp _; do case $mp in - /oldroot/*) umount "$mp" && loop=1 ;; + /oldroot/*) umount -d "$mp" && loop=1 ;; esac done Date: Fri, 25 Jun 2021 03:42:19 +0800 Subject: [PATCH 427/806] Revert "kdump-lib.sh: Remove is_atomic" Now we need this helper again, for `reset-crashkernel` This reverts commit ff46cfb19e9bf944a114164e33203b1a532d35f6. Signed-off-by: Kairui Song Acked-by: Baoquan He --- kdump-lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 8e618f8..df0aa02 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -341,6 +341,11 @@ kdump_get_persistent_dev() { echo $(get_persistent_dev "$dev") } +is_atomic() +{ + grep -q "ostree" /proc/cmdline +} + is_ipv6_address() { echo $1 | grep -q ":" From 86130ec10fda37cc283f717eaacb56a4cbf76418 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 10 Jun 2021 13:06:22 +0800 Subject: [PATCH 428/806] kdumpctl: Add kdumpctl reset-crashkernel In newer kernel, crashkernel.default will contain the default crashkernel value of a kernel build. So introduce a new sub command to help user reset kernel crashkernel size to the default value. Signed-off-by: Kairui Song Acked-by: Baoquan He --- kdumpctl | 41 +++++++++++++++++++++++++++++++++++++++-- kdumpctl.8 | 9 +++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index e4334c5..c5b210c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1330,6 +1330,40 @@ do_estimate() { fi } +reset_crashkernel() { + local kernel=$1 entry crashkernel_default + local grub_etc_default="/etc/default/grub" + + [[ -z "$kernel" ]] && kernel=$(uname -r) + crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null) + + if [[ -z "$crashkernel_default" ]]; then + derror "$kernel doesn't have a crashkernel.default" + exit 1 + fi + + if is_atomic; then + if rpm-ostree kargs | grep -q "crashkernel="; then + rpm-ostree --replace="crashkernel=$crashkernel_default" + else + rpm-ostree --append="crashkernel=$crashkernel_default" + fi + else + entry=$(grubby --info ALL | grep "^kernel=.*$kernel") + entry=${entry#kernel=} + entry=${entry#\"} + entry=${entry%\"} + + if [[ -f "$grub_etc_default" ]]; then + sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default" + fi + + [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" + grubby --args "$crashkernel_default" --update-kernel "$entry" $zipl_arg + [[ $zipl_arg ]] && zipl > /dev/null + fi + } + if [ ! -f "$KDUMP_CONFIG_FILE" ]; then derror "Error: No kdump config file found!" exit 1 @@ -1388,8 +1422,11 @@ main () estimate) do_estimate ;; + reset-crashkernel) + reset_crashkernel "$2" + ;; *) - dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|propagate|showmem}" + dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" exit 1 esac } @@ -1399,6 +1436,6 @@ single_instance_lock # To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main. # So that fd isn't leaking when main is invoking a subshell. -(exec 9<&-; main $1) +(exec 9<&-; main "$@") exit $? diff --git a/kdumpctl.8 b/kdumpctl.8 index a32a972..74be062 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -49,6 +49,15 @@ Prints the size of reserved memory for crash kernel in megabytes. Estimate a suitable crashkernel value for current machine. This is a best-effort estimate. It will print a recommanded crashkernel value based on current kdump setup, and list some details of memory usage. +.TP +.I reset-crashkernel [KERNEL] +Reset crashkernel value to default value. kdumpctl will try to read +from /usr/lib/modules//crashkernel.default and reset specified +kernel's crashkernel cmdline value. If no kernel is +specified, will reset current running kernel's crashkernel value. +If /usr/lib/modules//crashkernel.default doesn't exist, will +simply exit return 1. + .SH "SEE ALSO" .BR kdump.conf (5), From 646364193597401a55eb2485ef7840bb5eef7d88 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 10 Jun 2021 13:06:23 +0800 Subject: [PATCH 429/806] Add a new hook: 92-crashkernel.install To track and manage kernel's crashkernel usage by kernel version, each kernel package will include a crashkernel.default containing the default `crashkernel=` value of that kernel. So we can use a hook to update the kernel cmdline of new installed kernel accordingly. Put it after all other grub boot loader setup hooks, so it can simply call grubby to modify the kernel cmdline. Signed-off-by: Kairui Song Acked-by: Baoquan He --- 92-crashkernel.install | 143 +++++++++++++++++++++++++++++++++++++++++ kexec-tools.spec | 4 ++ 2 files changed, 147 insertions(+) create mode 100755 92-crashkernel.install diff --git a/92-crashkernel.install b/92-crashkernel.install new file mode 100755 index 0000000..7613bc6 --- /dev/null +++ b/92-crashkernel.install @@ -0,0 +1,143 @@ +#!/usr/bin/bash + +COMMAND="$1" +KERNEL_VERSION="$2" +KDUMP_INITRD_DIR_ABS="$3" +KERNEL_IMAGE="$4" + +grub_etc_default="/etc/default/grub" + +ver_lt() { + [[ "$(echo -e "$1\n$2" | sort -V)" == $1$'\n'* ]] && [[ $1 != "$2" ]] +} + +# Read crashkernel= value in /etc/default/grub +get_grub_etc_ck() { + [[ -e $grub_etc_default ]] && \ + sed -n -e "s/^GRUB_CMDLINE_LINUX=.*\(crashkernel=[^\ \"]*\)[\ \"].*$/\1/p" $grub_etc_default +} + +# Read crashkernel.default value of specified kernel +get_ck_default() { + ck_file="/usr/lib/modules/$1/crashkernel.default" + [[ -f "$ck_file" ]] && cat "$ck_file" +} + +# Iterate installed kernels, find the kernel with the highest version that has a +# valid crashkernel.default file, exclude current installing/removing kernel +# +# $1: a string representing a crashkernel= cmdline. If given, will also check the +# content of crashkernel.default, only crashkernel.default with the same value will match +get_highest_ck_default_kver() { + for kernel in $(find /usr/lib/modules -maxdepth 1 -mindepth 1 -printf "%f\n" | sort --version-sort -r); do + [[ $kernel == "$KERNEL_VERSION" ]] && continue + [[ -s "/usr/lib/modules/$kernel/crashkernel.default" ]] || continue + + echo "$kernel" + return 0 + done + + return 1 +} + +set_grub_ck() { + sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$1\2/" "$grub_etc_default" +} + +# Set specified kernel's crashkernel cmdline value +set_kernel_ck() { + kernel=$1 + ck_cmdline=$2 + + entry=$(grubby --info ALL | grep "^kernel=.*$kernel") + entry=${entry#kernel=} + entry=${entry#\"} + entry=${entry%\"} + + if [[ -z "$entry" ]]; then + echo "$0: failed to find boot entry for kernel $kernel" + return 1 + fi + + [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" + grubby --args "$ck_cmdline" --update-kernel "$entry" $zipl_arg + [[ $zipl_arg ]] && zipl > /dev/null +} + +case "$COMMAND" in +add) + # - If current boot kernel is using default crashkernel value, update + # installing kernel's crashkernel value to its default value, + # - If intalling a higher version kernel, and /etc/default/grub's + # crashkernel value is using default value, update it to installing + # kernel's default value. + inst_ck_default=$(get_ck_default "$KERNEL_VERSION") + # If installing kernel doesn't have crashkernel.default, just exit. + [[ -z "$inst_ck_default" ]] && exit 0 + + boot_kernel=$(uname -r) + boot_ck_cmdline=$(sed -n -e "s/^.*\(crashkernel=\S*\).*$/\1/p" /proc/cmdline) + highest_ck_default_kver=$(get_highest_ck_default_kver) + highest_ck_default=$(get_ck_default "$highest_ck_default_kver") + + # Try update /etc/default/grub if present, else grub2-mkconfig could + # override crashkernel value. + grub_etc_ck=$(get_grub_etc_ck) + if [[ -n "$grub_etc_ck" ]]; then + if [[ -z "$highest_ck_default_kver" ]]; then + # None of installed kernel have a crashkernel.default, + # check for 'crashkernel=auto' in case of legacy kernel + [[ "$grub_etc_ck" == "crashkernel=auto" ]] && \ + set_grub_ck "$inst_ck_default" + else + # There is a valid crashkernel.default, check if installing kernel + # have a higher version and grub config is using default value + ver_lt "$highest_ck_default_kver" "$KERNEL_VERSION" && \ + [[ "$grub_etc_ck" == "$highest_ck_default" ]] && \ + [[ "$grub_etc_ck" != "$inst_ck_default" ]] && \ + set_grub_ck "$inst_ck_default" + fi + fi + + # Exit if crashkernel is not used in current cmdline + [[ -z $boot_ck_cmdline ]] && exit 0 + + # Get current boot kernel's default value + boot_ck_default=$(get_ck_default "$boot_kernel") + if [[ $boot_ck_cmdline == "crashkernel=auto" ]]; then + # Legacy RHEL kernel defaults to "auto" + boot_ck_default="$boot_ck_cmdline" + fi + + # If boot kernel doesn't have a crashkernel.default, check + # if it's using any installed kernel's crashkernel.default + if [[ -z $boot_ck_default ]]; then + [[ $(get_highest_ck_default_kver "$boot_ck_cmdline") ]] && boot_ck_default="$boot_ck_cmdline" + fi + + # If boot kernel is using a default crashkernel, update + # installing kernel's crashkernel to new default value + if [[ "$boot_ck_cmdline" != "$inst_ck_default" ]] && [[ "$boot_ck_cmdline" == "$boot_ck_default" ]]; then + set_kernel_ck "$KERNEL_VERSION" "$inst_ck_default" + fi + ;; + +remove) + # If grub default value is upgraded when this kernel was installed, try downgrade it + grub_etc_ck=$(get_grub_etc_ck) + [[ $grub_etc_ck ]] || exit 0 + + removing_ck_conf=$(get_ck_default "$KERNEL_VERSION") + [[ $removing_ck_conf ]] || exit 0 + + highest_ck_default_kver=$(get_highest_ck_default_kver) || exit 0 + highest_ck_default=$(get_ck_default "$highest_ck_default_kver") + [[ $highest_ck_default ]] || exit 0 + + if ver_lt "$highest_ck_default_kver" "$KERNEL_VERSION"; then + if [[ $grub_etc_ck == "$removing_ck_conf" ]] && [[ $grub_etc_ck != "$highest_ck_default" ]]; then + set_grub_ck "$highest_ck_default" + fi + fi + ;; +esac diff --git a/kexec-tools.spec b/kexec-tools.spec index 8fed959..9848c2d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -40,6 +40,7 @@ Source29: kdump.sysconfig.aarch64 Source30: 60-kdump.install Source31: kdump-logger.sh Source32: mkfadumprd +Source33: 92-crashkernel.install ####################################### # These are sources for mkdumpramfs @@ -66,6 +67,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool +Requires: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext @@ -210,6 +212,7 @@ install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install +install -m 755 -D %{SOURCE33} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/92-crashkernel.install %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile @@ -360,6 +363,7 @@ done %{_unitdir}/kdump.service %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %{_prefix}/lib/kernel/install.d/60-kdump.install +%{_prefix}/lib/kernel/install.d/92-crashkernel.install %doc News %license COPYING %doc TODO From 7dbbb4bb31b6311e1283d0f801a26e7b6409248e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 25 Jun 2021 04:01:45 +0800 Subject: [PATCH 430/806] Add a crashkernel-howto.txt doc Signed-off-by: Kairui Song Acked-by: Baoquan He --- crashkernel-howto.txt | 204 ++++++++++++++++++++++++++++++++++++++++++ kexec-tools.spec | 3 + 2 files changed, 207 insertions(+) create mode 100644 crashkernel-howto.txt diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt new file mode 100644 index 0000000..4abd090 --- /dev/null +++ b/crashkernel-howto.txt @@ -0,0 +1,204 @@ +Introduction +============ + +This document describes features the kexec-tools package provides for setting +and estimating the crashkernel value. + +Kdump lives in a pre-reserved chunk of memory, and the size of the reserved +memory is specified by the `crashkernel=` kernel parameter. It's hard to +estimate an accurate `crashkernel=` value, so it's always recommended to test +kdump after you updated the `crashkernel=` value or changed the dump target. + + +Default crashkernel value +========================= + +Latest kernel packages includes a `crashkernel.default` file installed in kernel +modules folder, available as: + + /usr/lib/modules//crashkernel.default + +The content of the file will be taken as the default value of 'crashkernel=', or +take this file as a reference for setting crashkernel value manually. + + +New installed system +==================== + +Anaconda is the OS installer which sets all the kernel boot cmdline on a new +installed system. If kdump is set enabled during Anaconda installation, Anaconda +will use the `crashkernel.default` file as the default `crashkernel=` value on +the new installed system. + +Users can also override the value during Anaconda installation manually. + + +Auto update of crashkernel boot parameter +========================================= + +Following context in this section assumes all kernel packages have a +`crashkernel.default` file bundled, which is true for the latest official kernel +packages. For kexec-tools behavior with a kernel that doesn't have a +`crashkernel.default` file, please refer to the “Custom Kernel” section of this +doc. + +When `crashkernel=` is using the default value, kexec-tools will need to update +the `crashkernel=` value of new installed kernels, since the default value may +change in new kernel packages. + +kexec-tools does so by adding a kernel installation hook, which gets triggered +every time a new kernel is installed, so kexec-tools can do necessary checks and +updates. + + +Supported Bootloaders +--------------------- + +This auto update only works with GRUB2 and ZIPL, as kexec-tools heavily depends +on `grubby`. If other boot loaders are used, the user will have to update the +`crashkernel=` value manually. + + +Updating kernel package +----------------------- + +When a new version of package kernel is released in the official repository, the +package will always come with a `crashkernel.default` file bundled. Kexec-tools +will act with following rules: + +If current boot kernel is using the default `crashkernel=` boot param value from +its `crashkernel.default` file, then kexec-tools will update new installed +kernel’s `crashkernel=` boot param using the value from the new installed +kernel’s `crashkernel.default` file. This ensures `crashkernel=` is always using +the latest default value. + +If current boot kernel's `crashkernel=` value is set to a non-default value, the +new installed kernel simply inherits this value. + +On systems using GRUB2 as the bootloader, each kernel has its own boot entry, +making it possible to set different `crashkernel=` boot param values for +different kernels. So kexec-tools won’t touch any already installed kernel's +boot param, only new installed kernel's `crashkernel=` boot param value will be +updated. + +But some utilities like `grub2-mkconfig` and `grubby` can override all boot +entry's boot params with the boot params value from the GRUB config file +`/etc/defaults/grub`, so kexec-tools will also update the GRUB config file in +case old `crashkernel=` value overrides new installed kernel’s boot param. + + +Downgrading kernel package +-------------------------- + +When upgrading a kernel package, kexec-tools may update the `crashkernel=` value +in GRUB2 config file to the new value. So when downgrading the kernel package, +kexec-tools will also try to revert that update by setting GRUB2 config file’s +`crashkernel=` value back to the default value in the older kernel package. This +will only occur when the GRUB2 config file is using the default `crashkernel=` +value. + + +Custom kernel +============= + +To make auto crashkernel update more robust, kexec-tools will try to keep +tracking the default 'crashkernel=` value with kernels that don’t have a +`crashkernel.default` file, such kernels are referred to as “custom kernel” in +this doc. This is only a best-effort support to make it easier debugging and +testing the system. + +When installing a custom kernel that doesn’t have a `crashkernel.default` file, +the `crashkernel=` value will be simply inherited from the current boot kernel. + +When installing a new official kernel package and current boot kernel is a +custom kernel, since the boot kernel doesn’t have a `crashkernel.default` file, +kexec-tools will iterate installed kernels and check if the boot kernel +inherited the default value from any other existing kernels’ +`crashkernel.default` file. If a matching `crashkernel.default` file is found, +kexec-tools will update the new installed kernel `crashkernel=` boot param using +the value from the new installed kernel’s `crashkernel.default` file, ensures +the auto crashkernel value update won’t break over one or two custom kernel +installations. + +It is possible that the auto crashkernel value update will fail when custom +kernels are used. One example is a custom kernel inheriting the default +`crashkernel=` value from an older official kernel package, but later that +kernel package is uninstalled. So when booted with the custom kernel, +kexec-tools can't determine if the boot kernel is inheriting a default +`crashkernel=` value from any official build. In such a case, please refer to +the "Reset crashkernel to default value" section of this doc. + + +Reset crashkernel to default value +================================== + +kexec-tools only perform the auto update of crashkernel value when it can +confirm the boot kernel's crashkernel value is using its corresponding default +value or inherited from any installed kernel. + +kexec-tools may fail to determine if the boot kernel is using default +crashkernel value in some use cases: +- kexec-tools package is absent during a kernel package upgrade, and the new + kernel package’s `crashkernel.default` value has changed. +- Custom kernel is used and the kernel it inherits `crashkernel=` value from is + uninstalled. + +So it's recommended to reset the crashkernel value if users have uninstalled +kexec-tools or using a custom kernel. + +Reset using kdumpctl +-------------------- + +To make it easier to reset the `crashkernel=` kernel cmdline to this default +value properly, `kdumpctl` also provides a sub-command: + + `kdumpctl reset-crashkernel []` + +This command will read from the `crashkernel.default` file and reset +bootloader's kernel cmdline to the default value. It will also update bootloader +config if the bootloader has a standalone config file. User will have to reboot +the machine after this command to make it take effect. + +Reset manually +-------------- + +To reset the crashkernel value manually, it's recommended to use utils like +`grubby`. A one liner script for resetting `crashkernel=` value of all installed +kernels to current boot kernel's crashkernel.default` is: + + grubby --update-kernel ALL --args "$(cat /usr/lib/modules/$(uname -r)/crashkernel.default)" + +Estimate crashkernel +==================== + +The best way to estimate a usable crashkernel value is by testing kdump +manually. And you can set crashkernel to a large value, then adjust the +crashkernel value to an acceptable value gradually. + +`kdumpctl` also provides a sub-command for doing rough estimating without +triggering kdump: + + `kdumpctl estimate` + +The output will be like this: + +``` + Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement + + Reserved crashkernel: 256M + Recommended crashkernel: 655M + + Kernel image size: 47M + Kernel modules size: 12M + Initramfs size: 19M + Runtime reservation: 64M + LUKS required size: 512M + Large modules: + xfs: 1892352 + nouveau: 2318336 + WARNING: Current crashkernel size is lower than recommended size 655M. +``` + +It will generate a summary report about the estimated memory consumption +of each component of kdump. The value may not be accurate enough, but +would be a good start for finding a suitable crashkernel value. diff --git a/kexec-tools.spec b/kexec-tools.spec index 9848c2d..98d39fe 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -41,6 +41,7 @@ Source30: 60-kdump.install Source31: kdump-logger.sh Source32: mkfadumprd Source33: 92-crashkernel.install +Source34: crashkernel-howto.txt ####################################### # These are sources for mkdumpramfs @@ -151,6 +152,7 @@ cp %{SOURCE11} . cp %{SOURCE21} . cp %{SOURCE26} . cp %{SOURCE27} . +cp %{SOURCE34} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -372,6 +374,7 @@ done %doc fadump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt +%doc crashkernel-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_libdir}/eppic_makedumpfile.so /usr/share/makedumpfile/ From 2603ba71878f73ffa0608cb9c855da398c4132c1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 2 Jul 2021 03:27:05 +0800 Subject: [PATCH 431/806] Cleanup dead systemd services before start sysroot.mount When kdump failed due to initqueue timeout, the sysroot.mount and other serivces could be stuck in `start` but `dead` status: Example output of systemctl: dev-disk-by\x2duuid-530830d1\x2df2c7\x2d4c9a\x2d9a82\x2d148609097521.device loaded inactive dead start <... snip ...> squash-root.mount loaded active mounted /squash/root squash.mount loaded active mounted /squash sysroot.mount loaded inactive dead start /sysroot <... snip ...> dracut-cmdline.service loaded active exited dracut cmdline hook dracut-initqueue.service loaded activating start start dracut initqueue hook dracut-mount.service loaded inactive dead start dracut mount hook At this point calling `systemctl start sysroot.mount` will just hang as systemd will just wait for the services that are stuck in `start` status. So call `systemctl cancel` here to cancel all pending jobs and have a clean start for mounting sysroot. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdump-lib-initramfs.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index ca6a825..4cd18e4 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -227,6 +227,8 @@ dump_to_rootfs() systemctl start dracut-initqueue fi + dinfo "Clean up dead systemd services" + systemctl cancel dinfo "Waiting for rootfs mount, will timeout after 90 seconds" systemctl start sysroot.mount From 231a75ac1b7a1126678499b7413c15ff756636bb Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 6 Jul 2021 10:35:39 +0800 Subject: [PATCH 432/806] Revert "Revert "x86_64: enable the kexec file load by default"" This reverts commit 073c30973cf45ce0cea7bfd2bb30c5449a041a54, i.e. re-enable the kexec file load by default since this dual signature issue no longer bothers Fedora 34. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kdump.sysconfig.x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 1285506..188ba3c 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="-s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 7b7ddaba88af9bcbbcc3d219e1c7f00b3a61152d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 2 Jul 2021 01:31:26 +0800 Subject: [PATCH 433/806] kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default The new `crashkernel.default` file in kernel package can be used as the ck_cmdline source. Also keep the legacy code so old kernel packages will still work. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib.sh | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index df0aa02..4bd9751 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -952,31 +952,40 @@ get_recommend_size() } # return recommended size based on current system RAM size +# $1: kernel version, if not set, will defaults to `uname -r` kdump_get_arch_recommend_size() { - if ! [[ -r "/proc/iomem" ]] ; then + local kernel=$1 arch + + if ! [ -r "/proc/iomem" ] ; then echo "Error, can not access /proc/iomem." return 1 fi - arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr [:lower:] [:upper:]) - if [ $arch == "X86_64" ] || [ $arch == "S390X" ]; then - ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" - elif [ $arch == "AARCH64" ]; then - ck_cmdline="2G-:448M" - elif [ $arch == "PPC64LE" ]; then - if is_fadump_capable; then - ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" - else - ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + [ -z "$kernel" ] && kernel=$(uname -r) + ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null) + + if [ -n "$ck_cmdline" ]; then + ck_cmdline=${ck_cmdline#crashkernel=} + else + arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') + if [ "$arch" = "X86_64" ] || [ "$arch" = "S390X" ]; then + ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" + elif [ "$arch" = "AARCH64" ]; then + ck_cmdline="2G-:448M" + elif [ "$arch" = "PPC64LE" ]; then + if is_fadump_capable; then + ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" + else + ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + fi fi fi ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g') sys_mem=$(get_system_size) - result=$(get_recommend_size $sys_mem "$ck_cmdline") - echo $result - return 0 + + get_recommend_size "$sys_mem" "$ck_cmdline" } # Print all underlying crypt devices of a block device From c894022e9b95390c700bfaf59b5a29311c69b896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 1 Jun 2021 10:15:11 +0200 Subject: [PATCH 434/806] Remove references to systemd-sysv-convert Packaging guidelines have been amended to not require systemd for scriptlets, see https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_scriptlets. The comment duplicates what the macro contains. systemd-sysv-convert binary was removed in 2013, trying to call it is unlikely to succeed. chkconfig binary is provided by the chkconfig package, which is not in Requires. (And makes little sense to call nowadays anyway.) --- kexec-tools.spec | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 98d39fe..ad29bf9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -60,9 +60,6 @@ Source109: dracut-early-kdump-module-setup.sh Source200: dracut-fadump-init-fadump.sh Source201: dracut-fadump-module-setup.sh -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units Requires(pre): coreutils sed zlib Requires: dracut >= 050 Requires: dracut-network >= 050 @@ -72,7 +69,7 @@ Requires: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext -BuildRequires: systemd-units +BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool %ifarch %{ix86} x86_64 ppc64 ppc s390x ppc64le Obsoletes: diskdumputils netdump kexec-tools-eppic @@ -292,20 +289,8 @@ fi %systemd_postun_with_restart kdump.service %preun -# Package removal, not upgrade %systemd_preun kdump.service -%triggerun -- kexec-tools < 2.0.2-3 -# Save the current service runlevel info -# User must manually run systemd-sysv-convert --apply kdump -# to migrate them to systemd targets -/usr/bin/systemd-sysv-convert --save kdump >/dev/null 2>&1 ||: - -# Run these because the SysV package being removed won't do them -/sbin/chkconfig --del kdump >/dev/null 2>&1 || : -/bin/systemctl try-restart kdump.service >/dev/null 2>&1 || : - - %triggerin -- kernel-kdump touch %{_sysconfdir}/kdump.conf From bcd8d6a47b3a1daa7ffb62561b7288dbadab3e61 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 15 Jul 2021 03:08:28 +0800 Subject: [PATCH 435/806] kdumpctl: fix a typo Recommanded -> Recommended Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdumpctl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kdumpctl b/kdumpctl index c5b210c..9e4005f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1243,7 +1243,7 @@ do_estimate() { local kdump_mods local -A large_mods local baseline - local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommanded_size + local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommended_size local size_mb=$(( 1024 * 1024 )) setup_initrd @@ -1301,13 +1301,13 @@ do_estimate() { estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size + crypt_size)) if [[ $baseline_size -gt $estimated_size ]]; then - recommanded_size=$baseline_size + recommended_size=$baseline_size else - recommanded_size=$estimated_size + recommended_size=$estimated_size fi echo "Reserved crashkernel: $((reserved_size / size_mb))M" - echo "Recommanded crashkernel: $((recommanded_size / size_mb))M" + echo "Recommended crashkernel: $((recommended_size / size_mb))M" echo echo "Kernel image size: $((kernel_size / size_mb))M" echo "Kernel modules size: $((mod_size / size_mb))M" @@ -1325,8 +1325,8 @@ do_estimate() { done fi - if [[ $reserved_size -le $recommanded_size ]]; then - echo "WARNING: Current crashkernel size is lower than recommanded size $((recommanded_size / size_mb))M." + if [[ $reserved_size -le $recommended_size ]]; then + echo "WARNING: Current crashkernel size is lower than recommended size $((recommended_size / size_mb))M." fi } From 914a856c66410099d0e8747e900d097624a3eb60 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 16 Jul 2021 10:34:35 +0200 Subject: [PATCH 436/806] kdump.sysconfig.s390: Remove "prot_virt" from kdump kernel cmdline "prot_virt" enables the kernel to run Secure Execution virtual machines on s390. These virtual machines are isolated from the hypervisor and thus protected against tampering by a malicious host. Enabling "prot_virt" requires a minimum of ~2.5GB memory which exceeds what is typically reserved for the crashkernel. Thus remove "prot_virt" from the command line for the 2nd kernel to prevent it to run out-of-memory. For more discussions about this, see: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org/thread/QSRRNV4ALKXUJC2VM3US4Z2NSQRHVMXB/ Signed-off-by: Philipp Rudo Acked-by: Baoquan He --- kdump.sysconfig.s390x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 439e462..234cfe9 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE From 71b7a2f47c783b33965e8fc469dc44bda08cf458 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 12 Jul 2021 15:33:03 +0530 Subject: [PATCH 437/806] kdump/ppc64: rebuild initramfs image after migration Dump capture initramfs needs rebuild after partition migration (LPM). Use servicelog notification mechanism to invoke kdump rebuild after migration. Signed-off-by: Hari Bathini Reviewed-by: Pingfan Liu Acked-by: Kairui Song --- kdump-migrate-action.sh | 8 ++++++++ kdump-restart.sh | 8 ++++++++ kexec-tools.spec | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100755 kdump-migrate-action.sh create mode 100644 kdump-restart.sh diff --git a/kdump-migrate-action.sh b/kdump-migrate-action.sh new file mode 100755 index 0000000..c516639 --- /dev/null +++ b/kdump-migrate-action.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +systemctl is-active kdump +if [ $? -ne 0 ]; then + exit 0 +fi + +/usr/lib/kdump/kdump-restart.sh diff --git a/kdump-restart.sh b/kdump-restart.sh new file mode 100644 index 0000000..a9ecfc1 --- /dev/null +++ b/kdump-restart.sh @@ -0,0 +1,8 @@ +#!/bin/bash +export PATH="$PATH:/usr/bin:/usr/sbin" + +exec >>/var/log/kdump-migration.log 2>&1 + +echo "kdump: Partition Migration detected. Rebuilding initramfs image to reload." +/usr/bin/kdumpctl rebuild +/usr/bin/kdumpctl reload diff --git a/kexec-tools.spec b/kexec-tools.spec index ad29bf9..7f88863 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -42,6 +42,8 @@ Source31: kdump-logger.sh Source32: mkfadumprd Source33: 92-crashkernel.install Source34: crashkernel-howto.txt +Source35: kdump-migrate-action.sh +Source36: kdump-restart.sh ####################################### # These are sources for mkdumpramfs @@ -60,6 +62,9 @@ Source109: dracut-early-kdump-module-setup.sh Source200: dracut-fadump-init-fadump.sh Source201: dracut-fadump-module-setup.sh +%ifarch ppc64 ppc64le +Requires(post): servicelog +%endif Requires(pre): coreutils sed zlib Requires: dracut >= 050 Requires: dracut-network >= 050 @@ -196,6 +201,10 @@ install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh +%ifarch ppc64 ppc64le +install -m 755 %{SOURCE35} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-migrate-action.sh +install -m 755 %{SOURCE36} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-restart.sh +%endif %ifnarch s390x install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler %endif @@ -262,6 +271,13 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d %systemd_post kdump.service touch /etc/kdump.conf + +ARCH=`uname -m` +if [ "$ARCH" == "ppc64" ] || [ "$ARCH" == "ppc64le" ] +then + servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin +fi + # This portion of the script is temporary. Its only here # to fix up broken boxes that require special settings # in /etc/sysconfig/kdump. It will be removed when From 7435ecf3c43c0d15dc103c964043facce4b21a37 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 21 Jul 2021 14:05:25 +0800 Subject: [PATCH 438/806] Update crashkernel-howto.txt Fix some grammar issues. Signed-off-by: Kairui Song --- crashkernel-howto.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt index 4abd090..20f50e0 100644 --- a/crashkernel-howto.txt +++ b/crashkernel-howto.txt @@ -13,7 +13,7 @@ kdump after you updated the `crashkernel=` value or changed the dump target. Default crashkernel value ========================= -Latest kernel packages includes a `crashkernel.default` file installed in kernel +Latest kernel packages include a `crashkernel.default` file installed in kernel modules folder, available as: /usr/lib/modules//crashkernel.default @@ -25,12 +25,12 @@ take this file as a reference for setting crashkernel value manually. New installed system ==================== -Anaconda is the OS installer which sets all the kernel boot cmdline on a new -installed system. If kdump is set enabled during Anaconda installation, Anaconda +Anaconda is the OS installer which sets all the kernel boot cmdline on a newly +installed system. If kdump is enabled during Anaconda installation, Anaconda will use the `crashkernel.default` file as the default `crashkernel=` value on -the new installed system. +the newly installed system. -Users can also override the value during Anaconda installation manually. +Users can override the value during Anaconda installation manually. Auto update of crashkernel boot parameter From 660cf4ac03f29c42801725908cac156151159d2b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 20 Jul 2021 13:41:08 +0800 Subject: [PATCH 439/806] Make `dump_to_rootfs` wait for 90s for real When `failure_action` is set to `dump_to_rootfs`, the message: "Waiting for rootfs mount, will timeout after 90 seconds" is actually wrong. Kdump will simply call `systemctl start sysroot.mount`, but the timeout value of sysroot.mount depends on the unit service and dracut parameters. And by default, dracut will set JobRunningTimeoutSec=0 and JobTimeoutSec=0 for the device units, which means it will wait forever. (see wait_for_dev function in dracut) For some devices, this can be fixed by setting rd.timeout=90. But when initqueue is set enabled during initramfs build, dracut will force set timeout for host devices to `0`. (see 99base/module-setup.sh). Depending on dracut / systemd can make things unpredictable and break as parameters or code change. To make things easy to understand and maintain, just call `systemctl` with `--no-block` params, and implement a standalone wait loop. Now `dump_to_rootfs` will actually wait for 90s then timeout. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdump-lib-initramfs.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 4cd18e4..319f9a0 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -230,10 +230,20 @@ dump_to_rootfs() dinfo "Clean up dead systemd services" systemctl cancel dinfo "Waiting for rootfs mount, will timeout after 90 seconds" - systemctl start sysroot.mount + systemctl start --no-block sysroot.mount + + _loop=0 + while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do + sleep 1 + _loop=$((_loop + 1)) + done + + if ! is_mounted /sysroot; then + derror "Failed to mount rootfs" + return + fi ddebug "NEWROOT=$NEWROOT" - dump_fs $NEWROOT } From b2bbb54d897959b1a6de6841ff397d6ec9565a12 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 15 Jul 2021 09:18:33 +0800 Subject: [PATCH 440/806] Check the existence of /sys/bus/ccwgroup/devices/*/online beforehand On s390x KVM machines, the following errors would show when building kdump initramfs that dumps vmcore to a remote target, $ kdumpctl rebuild /usr/lib/dracut/modules.d/99kdumpbase/module-setup.sh: line 475: /sys/bus/ccwgroup/devices/online: No such file or directory /usr/lib/dracut/modules.d/99kdumpbase/module-setup.sh: line 476: [: -ne: unary operator expected This happens because s390x KVM machines use virtual network and /sys/bus/ccwgroup/devices/ exists but is empty. Fix it by check the existence of file "/sys/bus/ccwgroup/devices/*/online". Fixes: commit 7d472515688fb330eee76dac1c39ae628398f757 ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet") BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1982474 Reported-by: Jie Li Signed-off-by: Coiby Xu t Acked-by: Kairui Song --- dracut-module-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8211d14..a1f33e8 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -462,6 +462,7 @@ find_online_znet_device() { NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) for d in $NETWORK_DEVICES do + [ ! -f "$d/online" ] && continue read ONLINE < $d/online if [ $ONLINE -ne 1 ]; then continue From 152cf5e46cddc49b716fb3fd5bf85dbf12a020cb Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 22 Jul 2021 09:42:58 +0000 Subject: [PATCH 441/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 7f88863..6f421fa 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -382,6 +382,9 @@ done %endif %changelog +* Thu Jul 22 2021 Fedora Release Engineering - 2.0.22-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Tue Jun 29 2021 Kairui Song - 2.0.22-4 * fix format issue in find_online_znet_device * check the existence of /sys/bus/ccwgroup/devices before trying to find online network device From 146f66262222e96bca47b691ed243fa5097aa55c Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Tue, 27 Jul 2021 23:59:48 +0530 Subject: [PATCH 442/806] kdump/ppc64: migration action registration clean up While kdump migration action is registered for LPM event, ensure it is cleared as appropriate to avoid duplicate/stale notification entries. Signed-off-by: Hari Bathini Acked-by: Kairui Song --- kexec-tools.spec | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6f421fa..c042590 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -272,11 +272,10 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d touch /etc/kdump.conf -ARCH=`uname -m` -if [ "$ARCH" == "ppc64" ] || [ "$ARCH" == "ppc64le" ] -then - servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin -fi +%ifarch ppc64 ppc64le +servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh +servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin +%endif # This portion of the script is temporary. Its only here # to fix up broken boxes that require special settings @@ -305,6 +304,9 @@ fi %systemd_postun_with_restart kdump.service %preun +%ifarch ppc64 ppc64le +servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh +%endif %systemd_preun kdump.service %triggerin -- kernel-kdump From 097059dedc987548742437bca6fd90793cf74c18 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 30 Jul 2021 14:40:45 +0800 Subject: [PATCH 443/806] Clear old crashkernl=auto in comment and doc Acked-by: Pingfan Liu Signed-off-by: Kairui Song --- fadump-howto.txt | 9 ++++++--- kdumpctl | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index 433e9a6..bc87644 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -344,9 +344,12 @@ or OR # grubby --update-kernel=/boot/vmlinuz-`uname -r` --args="fadump=off" -If KDump is to be used as the dump capturing mechanism, update the crashkernel -parameter (Else, remove "crashkernel=" parameter too, using grubby): +Remove "crashkernel=" from kernel cmdline parameters: - # grubby --update-kernel=/boot/vmlinuz-$kver --args="crashkernl=auto" + # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="crashkernel" + +If KDump is to be used as the dump capturing mechanism, reset the crashkernel parameter: + + # kdumpctl reset-crashkernel `uname -r` Reboot the system for the settings to take effect. diff --git a/kdumpctl b/kdumpctl index 9e4005f..c2f0b3f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1262,7 +1262,7 @@ do_estimate() { baseline=$(( ${baseline%Y} * 1048576 )) fi - # The default value when using crashkernel=auto + # The default pre-reserved crashkernel value baseline_size=$((baseline * size_mb)) # Current reserved crashkernel size reserved_size=$(cat /sys/kernel/kexec_crash_size) From 7ddda7e6d0d5051321639c922c9aa117c869dcb5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Aug 2021 22:25:22 +0800 Subject: [PATCH 444/806] Remove hard requirement on grubby Downgrade to "Recommends:" as suggested by CoreOS team. Signed-off-by: Kairui Song Acked-by: Tao Liu --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c042590..951c9d6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -70,7 +70,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool -Requires: grubby +Recommends: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext From 6c390b70e847588271b7fc5e57091a36a7207f9e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 20 Aug 2021 20:09:33 +0800 Subject: [PATCH 445/806] Release 2.0.22-6 Also fix a format error in changelog. Signed-off-by: Kairui Song --- kexec-tools.spec | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 951c9d6..58be768 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -384,15 +384,37 @@ done %endif %changelog +* Fri Aug 20 2021 Kairui Song - 2.0.22-6 +- Remove hard requirement on grubby +- Clear old crashkernl=auto in comment and doc +- kdump/ppc64: migration action registration clean up +- Check the existence of /sys/bus/ccwgroup/devices/*/online beforehand +- Make `dump_to_rootfs` wait for 90s for real +- Update crashkernel-howto.txt +- kdump/ppc64: rebuild initramfs image after migration +- kdump.sysconfig.s390: Remove "prot_virt" from kdump kernel cmdline +- kdumpctl: fix a typo +- Remove references to systemd-sysv-convert +- kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default +- Revert "Revert "x86_64: enable the kexec file load by default"" +- Cleanup dead systemd services before start sysroot.mount +- Add a crashkernel-howto.txt doc +- Add a new hook: 92-crashkernel.install +- kdumpctl: Add kdumpctl reset-crashkernel +- Revert "kdump-lib.sh: Remove is_atomic" +- fadump-init: clean up mount points properly +- fadump: kdumpctl should check the modules used by the fadump initramfs +- fadump: isolate fadump initramfs image within the default one + * Thu Jul 22 2021 Fedora Release Engineering - 2.0.22-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild * Tue Jun 29 2021 Kairui Song - 2.0.22-4 -* fix format issue in find_online_znet_device -* check the existence of /sys/bus/ccwgroup/devices before trying to find online network device -* check for invalid physical address of /proc/kcore when making ELF dumpfile -* check for invalid physical address of /proc/kcore when finding max_paddr -* Increase SECTION_MAP_LAST_BIT to 5 +- fix format issue in find_online_znet_device +- check the existence of /sys/bus/ccwgroup/devices before trying to find online network device +- check for invalid physical address of /proc/kcore when making ELF dumpfile +- check for invalid physical address of /proc/kcore when finding max_paddr +- Increase SECTION_MAP_LAST_BIT to 5 * Sun Jun 20 2021 Kairui Song - 2.0.22-3 - selftest: Make test_base_image depends on EXTRA_RPMS From 5270d40dd0b690d4be628f937e508cdc80dab1d9 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 31 Aug 2021 16:07:51 -0700 Subject: [PATCH 446/806] Don't exit 1 from 92-crashkernel.install if zipl is absent (#1993505) At least, this is a plausible suspect for #1993505 - thanks to @kevin for identifying it - and fixing it should be safe and correct, so we may as well do it and see if it helps. --- 92-crashkernel.install | 2 +- kexec-tools.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/92-crashkernel.install b/92-crashkernel.install index 7613bc6..de5b2fb 100755 --- a/92-crashkernel.install +++ b/92-crashkernel.install @@ -61,7 +61,7 @@ set_kernel_ck() { [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" grubby --args "$ck_cmdline" --update-kernel "$entry" $zipl_arg - [[ $zipl_arg ]] && zipl > /dev/null + [[ $zipl_arg ]] && zipl > /dev/null ||: } case "$COMMAND" in diff --git a/kexec-tools.spec b/kexec-tools.spec index 58be768..7db9f9c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -384,6 +384,9 @@ done %endif %changelog +* Tue Aug 31 2021 Adam Williamson - 2.0.22-7 +- Don't exit 1 from 92-crashkernel.install if zipl is absent (#1993505) + * Fri Aug 20 2021 Kairui Song - 2.0.22-6 - Remove hard requirement on grubby - Clear old crashkernl=auto in comment and doc From bcb1176ec6f17538ffff94d2fbd21579938c3c05 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 30 Jul 2021 01:08:30 +0800 Subject: [PATCH 447/806] Add a .editorconfig file EditorConfig file is helpful for tools like `shfmt`, also could be a hint for code styling. The code style spec used in this new added .editorconfig file is generated based on existing code style. Following commits will make mkfadumprd, mkdumprd, kdumpctl, kdump-lib.sh, and *-module-setup.sh only be used in first kernel, so use bash syntax for these scripts. Other scripts will use sh syntax for better POSIX compatibility. Signed-off-by: Kairui Song Acked-by: Pingfan Liu Acked-by: Philipp Rudo Signed-off-by: Kairui Song --- .editorconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bd8fc8c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +# EditorConfig configuration for kexec-tools +# http://EditorConfig.org + +# Top-most EditorConfig file +root = true + +# Default code style for kexec-tools scripts +[*] +end_of_line = lf +shell_variant = posix +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 1 +switch_case_indent = false +function_next_line = true +binary_next_line = false +space_redirects = true + +# Some scripts will only run with bash +[{mkfadumprd,mkdumprd,kdumpctl}] +shell_variant = bash + +# Use dracut code style for *-module-setup.sh +[*-module-setup.sh] +shell_variant = bash +indent_style = space +indent_size = 4 +switch_case_indent = true +function_next_line = false +binary_next_line = true +space_redirects = true From a0282ab22c4e61294346c8ab9c42ab87b8bdfbb0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Aug 2021 19:49:51 +0800 Subject: [PATCH 448/806] kdump-lib.sh: add a config format and read helper Add a helper `kdump_read_conf` to replace read_strip_comments. `kdump_read_conf` does a few more things: - remove trailing spaces. - format the content, remove duplicated spaces between name and value. - read from KDUMP_CONFIG_FILE (/etc/kdump.conf) directly, avoid pasting "/etc/kdump.conf" path everywhere in the code. - check if config file exists, just in case. Also unify the environmental variable, now KDUMP_CONFIG_FILE stands for the default config location. This helps avoid some shell pitfalls about spaces when reading config. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 10 +++++----- dracut-module-setup.sh | 5 +++-- kdump-lib-initramfs.sh | 3 +-- kdump-lib.sh | 11 ++++++----- kdumpctl | 7 +++---- mkdumprd | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 3e65c44..3c165b3 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -246,10 +246,10 @@ get_host_ip() return 0 } -read_kdump_conf() +read_kdump_confs() { - if [ ! -f "$KDUMP_CONF" ]; then - derror "$KDUMP_CONF not found" + if [ ! -f "$KDUMP_CONFIG_FILE" ]; then + derror "$KDUMP_CONFIG_FILE not found" return fi @@ -278,7 +278,7 @@ read_kdump_conf() add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac - done <<< "$(read_strip_comments $KDUMP_CONF)" + done <<< "$(kdump_read_conf)" } fence_kdump_notify() @@ -288,7 +288,7 @@ fence_kdump_notify() fi } -read_kdump_conf +read_kdump_confs fence_kdump_notify get_host_ip diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a1f33e8..ff9f7fe 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -682,7 +682,8 @@ default_dump_target_install_conf() #install kdump.conf and what user specifies in kdump.conf kdump_install_conf() { local _opt _val _pdev - (read_strip_comments /etc/kdump.conf) > ${initdir}/tmp/$$-kdump.conf + + kdump_read_conf > "${initdir}/tmp/$$-kdump.conf" while read _opt _val; do @@ -711,7 +712,7 @@ kdump_install_conf() { dracut_install "${_val%%[[:blank:]]*}" ;; esac - done <<< "$(read_strip_comments /etc/kdump.conf)" + done <<< "$(kdump_read_conf)" kdump_install_pre_post_conf diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 319f9a0..50443e5 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -16,7 +16,6 @@ SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" KDUMP_SCRIPT_DIR="/kdumpscripts" DD_BLKSIZE=512 FINAL_ACTION="systemctl reboot -f" -KDUMP_CONF="/etc/kdump.conf" KDUMP_PRE="" KDUMP_POST="" NEWROOT="/sysroot" @@ -93,7 +92,7 @@ get_kdump_confs() esac ;; esac - done <<< "$(read_strip_comments $KDUMP_CONF)" + done <<< "$(kdump_read_conf)" if [ -z "$CORE_COLLECTOR" ]; then CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" diff --git a/kdump-lib.sh b/kdump-lib.sh index 4bd9751..841740b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -7,6 +7,7 @@ DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" +KDUMP_CONFIG_FILE="/etc/kdump.conf" is_fadump_capable() { @@ -80,12 +81,12 @@ strip_comments() echo $@ | sed -e 's/\(.*\)#.*/\1/' } -# Read from kdump config file stripping all comments -read_strip_comments() +# Read kdump config in well formatted style +kdump_read_conf() { - # strip heading spaces, and print any content starting with - # neither space or #, and strip everything after # - sed -n -e "s/^\s*\([^# \t][^#]\+\).*/\1/gp" $1 + # Following steps are applied in order: strip trailing comment, strip trailing space, + # strip heading space, match non-empty line, remove duplicated spaces between conf name and value + [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE } # Check if fence kdump is configured in Pacemaker cluster diff --git a/kdumpctl b/kdumpctl index c2f0b3f..5d9420d 100755 --- a/kdumpctl +++ b/kdumpctl @@ -5,7 +5,6 @@ KDUMP_KERNELVER="" KDUMP_KERNEL="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" -KDUMP_CONFIG_FILE="/etc/kdump.conf" KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" @@ -272,7 +271,7 @@ check_config() return 1 fi _opt_rec[$config_opt]="$config_val" - done <<< "$(read_strip_comments $KDUMP_CONFIG_FILE)" + done <<< "$(kdump_read_conf)" check_failure_action_config || return 1 check_final_action_config || return 1 @@ -731,7 +730,7 @@ check_ssh_config() *) ;; esac - done <<< "$(read_strip_comments $KDUMP_CONFIG_FILE)" + done <<< "$(kdump_read_conf)" #make sure they've configured kdump.conf for ssh dumps local SSH_TARGET=`echo -n $DUMP_TARGET | sed -n '/.*@/p'` @@ -1362,7 +1361,7 @@ reset_crashkernel() { grubby --args "$crashkernel_default" --update-kernel "$entry" $zipl_arg [[ $zipl_arg ]] && zipl > /dev/null fi - } +} if [ ! -f "$KDUMP_CONFIG_FILE" ]; then derror "Error: No kdump config file found!" diff --git a/mkdumprd b/mkdumprd index 89a160d..d554511 100644 --- a/mkdumprd +++ b/mkdumprd @@ -443,7 +443,7 @@ do *) ;; esac -done <<< "$(read_strip_comments $conf_file)" +done <<< "$(kdump_read_conf)" handle_default_dump_target From 09ccf88405793220af640c5317cbadb71cf03d36 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 16 Aug 2021 23:25:14 +0800 Subject: [PATCH 449/806] kdump-lib.sh: add a config value retrive helper Add a helper kdump_get_conf_val to replace get_option_value. It can help cover more corner cases in the code, like when there are multiple spaces in config file, config value separated by a tab, heading spaces, or trailing comments. And this uses "sed group command" and "sed hold buffer", make it much faster than previous `grep | tail -1`. This helper is supposed to provide a universal way for kexec-tools scripts to read in config value. Currently, different scripts are reading the config in many different fragile ways. For example, following codes are found in kexec-tools script code base: 1. grep ^force_rebuild $KDUMP_CONFIG_FILE echo $_force_rebuild | cut -d' ' -f2 2. grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2 3. awk '/^sshkey/ {print $2}' $conf_file 4. grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2- 1, 2, and 4 will fail if the space is replaced by, e.g. a tab 1 and 2 might fail if there are multiple spaces between config name and config value: "kdump_post /var/crash/scripts/kdump-post.sh" A space will be read instead of config value. 1, 2, 3 will fail if there are space in file path, like: "kdump_post /var/crash/scripts dir/kdump-post.sh" 4 will fail if there are trailing comments: "path /var/crash # some comment here" And all will fail if there are heading space, " path /var/crash" And all will most likely cause problems if the config file contains the same option more than once. And all of them are slower than the new sed call. Old get_option_value is also very slow and doesn't handle heading space. Although we never claim to support heading space or tailing comments before, it's harmless to be more robust on config reading, and many conf files in /etc support heading spaces. And have a faster and safer config reading helper makes it easier to clean up the code. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 4 ++-- kdump-lib.sh | 20 +++++++++----------- kdumpctl | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff9f7fe..53abdc7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -938,7 +938,7 @@ get_generic_fence_kdump_nodes() { local filtered local nodes - nodes=$(get_option_value "fence_kdump_nodes") + nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in ${nodes}; do # Skip its own node name if is_localhost $node; then @@ -999,7 +999,7 @@ kdump_install_random_seed() { } kdump_install_systemd_conf() { - local failure_action=$(get_option_value "failure_action") + local failure_action=$(kdump_get_conf_val "failure_action") # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. diff --git a/kdump-lib.sh b/kdump-lib.sh index 841740b..b57457c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -76,11 +76,6 @@ is_fs_dump_target() egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf } -strip_comments() -{ - echo $@ | sed -e 's/\(.*\)#.*/\1/' -} - # Read kdump config in well formatted style kdump_read_conf() { @@ -89,6 +84,15 @@ kdump_read_conf() [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE } +# Retrieves config value defined in kdump.conf +# $1: config name, sed regexp compatible +kdump_get_conf_val() { + # For lines matching "^\s*$1\s+", remove matched part (config name including space), + # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. + [ -f "$KDUMP_CONFIG_FILE" ] && \ + sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE +} + # Check if fence kdump is configured in Pacemaker cluster is_pcs_fence_kdump() { @@ -322,12 +326,6 @@ get_kdump_mntpoint_from_target() echo $_mntpoint | tr -s "/" } -# get_option_value -# retrieves value of option defined in kdump.conf -get_option_value() { - strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` -} - kdump_get_persistent_dev() { local dev="${1//\"/}" diff --git a/kdumpctl b/kdumpctl index 5d9420d..db3a301 100755 --- a/kdumpctl +++ b/kdumpctl @@ -961,7 +961,7 @@ check_fence_kdump_config() { local hostname=`hostname` local ipaddrs=`hostname -I` - local nodes=$(get_option_value "fence_kdump_nodes") + local nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in $nodes; do if [ "$node" = "$hostname" ]; then From ab1ef78aa25b7ae2e34e16a74712079653981e6b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 01:18:48 +0800 Subject: [PATCH 450/806] kdump-lib.sh: use kdump_get_conf_val to read config values Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index b57457c..7e620c7 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -42,16 +42,16 @@ is_fs_type_nfs() is_ssh_dump_target() { - grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf + [[ $(kdump_get_conf_val ssh) == *@* ]] } is_nfs_dump_target() { - if grep -q "^nfs" /etc/kdump.conf; then + if [[ $(kdump_get_conf_val nfs) ]]; then return 0; fi - if is_fs_type_nfs $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)"); then + if is_fs_type_nfs $(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)"); then return 0 fi @@ -68,12 +68,12 @@ is_nfs_dump_target() is_raw_dump_target() { - grep -q "^raw" /etc/kdump.conf + [[ $(kdump_get_conf_val raw) ]] } is_fs_dump_target() { - egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf + [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix") ]] } # Read kdump config in well formatted style @@ -109,7 +109,7 @@ is_generic_fence_kdump() { [ -x $FENCE_KDUMP_SEND ] || return 1 - grep -q "^fence_kdump_nodes" /etc/kdump.conf + [[ $(kdump_get_conf_val fence_kdump_nodes) ]] } to_dev_name() { @@ -128,17 +128,17 @@ to_dev_name() { is_user_configured_dump_target() { - grep -E -q "^ext[234]|^xfs|^btrfs|^minix|^raw|^nfs|^ssh" /etc/kdump.conf || is_mount_in_dracut_args; + [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh") ]] || is_mount_in_dracut_args } get_user_configured_dump_disk() { local _target - _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}') + _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") [ -n "$_target" ] && echo $_target && return - _target=$(get_dracut_args_target "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)") + _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") [ -b "$_target" ] && echo $_target } @@ -149,7 +149,7 @@ get_root_fs_device() get_save_path() { - local _save_path=$(awk '$1 == "path" {print $2}' /etc/kdump.conf) + local _save_path=$(kdump_get_conf_val path) [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH # strip the duplicated "/" @@ -175,7 +175,7 @@ get_block_dump_target() is_dump_to_rootfs() { - grep -E "^(failure_action|default)[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null + [[ $(kdump_get_conf_val "failure_action|default") == dump_to_rootfs ]] } get_failure_action_target() @@ -530,7 +530,7 @@ get_ifcfg_filename() { is_dracut_mod_omitted() { local dracut_args dracut_mod=$1 - set -- $(grep "^dracut_args" /etc/kdump.conf) + set -- $(kdump_get_conf_val dracut_args) while [ $# -gt 0 ]; do case $1 in -o|--omit) @@ -559,7 +559,7 @@ is_wdt_active() { # its correctness). is_mount_in_dracut_args() { - grep -q "^dracut_args .*\-\-mount" /etc/kdump.conf + [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] } # If $1 contains dracut_args "--mount", return From 01613b7211a3de096a889000817ebb9da513f4af Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Aug 2021 22:50:02 +0800 Subject: [PATCH 451/806] kdumpctl: use kdump_get_conf_val to read config values Also fixed kdumpctl, use `awk` instead of `cut` to read core_collector's executable name correctly when its arguments are not seperated by space. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdumpctl | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/kdumpctl b/kdumpctl index db3a301..3f92dac 100755 --- a/kdumpctl +++ b/kdumpctl @@ -339,8 +339,8 @@ check_files_modified() #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. modified_files=$(get_pcs_cluster_modified_files) - EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` - CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` + EXTRA_BINS=$(kdump_get_conf_val kdump_post) + CHECK_FILES=$(kdump_get_conf_val kdump_pre) HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" if [ -d /etc/kdump/post.d ]; then for file in /etc/kdump/post.d/*; do @@ -357,17 +357,17 @@ check_files_modified() done fi HOOKS="$HOOKS $POST_FILES $PRE_FILES" - CORE_COLLECTOR=`grep ^core_collector $KDUMP_CONFIG_FILE | cut -d\ -f2` + CORE_COLLECTOR=$(kdump_get_conf_val core_collector | awk '{print $1}') CORE_COLLECTOR=`type -P $CORE_COLLECTOR` # POST_FILES and PRE_FILES are already checked against executable, need not to check again. EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` + CHECK_FILES=$(kdump_get_conf_val extra_bins) EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $KDUMP_KERNEL $EXTRA_BINS $CORE_COLLECTOR" [[ -e /etc/fstab ]] && files="$files /etc/fstab" # Check for any updated extra module - EXTRA_MODULES="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed 's/^extra_modules\s*//')" + EXTRA_MODULES="$(kdump_get_conf_val extra_modules)" if [ -n "$EXTRA_MODULES" ]; then if [ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]; then files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" @@ -555,8 +555,7 @@ check_system_modified() check_rebuild() { local capture_capable_initrd="1" - local _force_rebuild force_rebuild="0" - local _force_no_rebuild force_no_rebuild="0" + local force_rebuild force_no_rebuild local ret system_modified="0" setup_initrd @@ -565,22 +564,18 @@ check_rebuild() return 1 fi - _force_no_rebuild=`grep ^force_no_rebuild $KDUMP_CONFIG_FILE 2>/dev/null` - if [ $? -eq 0 ]; then - force_no_rebuild=`echo $_force_no_rebuild | cut -d' ' -f2` - if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then - derror "Error: force_no_rebuild value is invalid" - return 1 - fi + force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) + force_no_rebuild=${force_no_rebuild:-0} + if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then + derror "Error: force_no_rebuild value is invalid" + return 1 fi - _force_rebuild=`grep ^force_rebuild $KDUMP_CONFIG_FILE 2>/dev/null` - if [ $? -eq 0 ]; then - force_rebuild=`echo $_force_rebuild | cut -d' ' -f2` - if [ "$force_rebuild" != "0" ] && [ "$force_rebuild" != "1" ];then - derror "Error: force_rebuild value is invalid" - return 1 - fi + force_rebuild=$(kdump_get_conf_val force_rebuild) + force_rebuild=${force_rebuild:-0} + if [ "$force_rebuild" != "0" ] && [ "$force_rebuild" != "1" ];then + derror "Error: force_rebuild value is invalid" + return 1 fi if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then @@ -867,7 +862,7 @@ save_raw() local kdump_dir local raw_target - raw_target=$(awk '$1 ~ /^raw$/ { print $2; }' $KDUMP_CONFIG_FILE) + raw_target=$(kdump_get_conf_val raw) [ -z "$raw_target" ] && return 0 [ -b "$raw_target" ] || { derror "raw partition $raw_target not found" @@ -878,7 +873,7 @@ save_raw() dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." return 0 fi - kdump_dir=`grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2-` + kdump_dir=$(kdump_get_conf_val path) if [ -z "${kdump_dir}" ]; then coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" else @@ -1018,8 +1013,8 @@ check_failure_action_config() local failure_action local option="failure_action" - default_option=$(awk '$1 ~ /^default$/ {print $2;}' $KDUMP_CONFIG_FILE) - failure_action=$(awk '$1 ~ /^failure_action$/ {print $2;}' $KDUMP_CONFIG_FILE) + default_option=$(kdump_get_conf_val default) + failure_action=$(kdump_get_conf_val failure_action) if [ -z "$failure_action" -a -z "$default_option" ]; then return 0 @@ -1047,7 +1042,7 @@ check_final_action_config() { local final_action - final_action=$(awk '$1 ~ /^final_action$/ {print $2;}' $KDUMP_CONFIG_FILE) + final_action=$(kdump_get_conf_val final_action) if [ -z "$final_action" ]; then return 0 else From dfb76467c9d9462e91e4dd8838f461fb7ab2538f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 16:22:17 +0800 Subject: [PATCH 452/806] kdumpctl: fix fragile loops over find output For loops over find output are fragile, use a while read loop: https://github.com/koalaman/shellcheck/wiki/SC2044 Signed-off-by: Kairui Song Acked-by: Philipp Rudo /dev/null) + while IFS= read -r -d '' _i; do + _attr=$(getfattr -m "security.selinux" "$_i" 2>/dev/null) if [ -z "$_attr" ]; then - restorecon $_i; + restorecon "$_i"; fi - done + done < <(find "$_path" -print0) } check_fence_kdump_config() From 80525afaceac3fa6bdf6e57686f66ab497d2f153 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:44:02 +0800 Subject: [PATCH 453/806] kdumpctl: refine grep usage Use `grep -q` instead of redirect to /dev/null. Use `grep -c` instead, as suggested in: https://github.com/koalaman/shellcheck/wiki/SC2126 Use `grep -E` instead of `egrep`. https://github.com/koalaman/shellcheck/wiki/SC2196 Signed-off-by: Kairui Song --- kdumpctl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index 01858a3..bb3d42a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -506,7 +506,7 @@ check_fs_modified() # if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - echo $_dracut_args | grep "\-\-mount" &> /dev/null + echo $_dracut_args | grep -q "\-\-mount" if [[ $? -eq 0 ]];then set -- $(echo $_dracut_args | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1 @@ -596,7 +596,7 @@ check_rebuild() #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then - capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l) + capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$) fi fi @@ -761,7 +761,7 @@ check_and_wait_network_ready() # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" - echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" &> /dev/null + echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" if [ $? -eq 0 ]; then derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" return 1 @@ -901,7 +901,7 @@ local_fs_dump_target() { local _target - _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf) + _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf) if [ $? -eq 0 ]; then echo $_target|awk '{print $2}' fi @@ -964,7 +964,7 @@ check_fence_kdump_config() return 1 fi # node can be ipaddr - echo "$ipaddrs " | grep "$node " > /dev/null + echo "$ipaddrs " | grep -q "$node " if [ $? -eq 0 ]; then derror "Option fence_kdump_nodes cannot contain $node" return 1 From 075e62252ec13e582e8aaa43a0fefee1ad5d8a58 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 01:58:04 +0800 Subject: [PATCH 454/806] mkdumprd: use kdump_get_conf_val to read config values Simplify the code and cover more corner cases. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/mkdumprd b/mkdumprd index d554511..8687b30 100644 --- a/mkdumprd +++ b/mkdumprd @@ -23,7 +23,6 @@ if [ $? -ne 0 ]; then exit 1 fi -conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 @@ -312,19 +311,6 @@ handle_default_dump_target() check_size fs $_target } -get_override_resettable() -{ - local override_resettable - - override_resettable=$(grep "^override_resettable" $conf_file) - if [ -n "$override_resettable" ]; then - OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' ' -f2) - if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then - perror_exit "override_resettable value $OVERRIDE_RESETTABLE is invalid" - fi - fi -} - # $1: function name for_each_block_target() { @@ -363,9 +349,13 @@ is_unresettable() #return true if resettable check_resettable() { - local _ret _target + local _ret _target _override_resettable - get_override_resettable + _override_resettable=$(kdump_get_conf_val override_resettable) + OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE} + if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then + perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid" + fi for_each_block_target is_unresettable _ret=$? @@ -395,7 +385,7 @@ if ! check_crypt; then fi # firstly get right SSH_KEY_LOCATION -keyfile=$(awk '/^sshkey/ {print $2}' $conf_file) +keyfile=$(kdump_get_conf_val sshkey) if [ -f "$keyfile" ]; then # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) From 227fc2bc7dcd9ebc328634dc421373624ba22cc2 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 03:50:04 +0800 Subject: [PATCH 455/806] mkdumprd: make dracut_args an array again To make arguments list work as expected, array is preferred. Use xargs only to parse the "dracut_args" config value, and pass the array directly to dracut. Check following link for details: https://github.com/koalaman/shellcheck/wiki/SC2089 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mkdumprd b/mkdumprd index 8687b30..c7538a9 100644 --- a/mkdumprd +++ b/mkdumprd @@ -28,7 +28,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args="--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o \"plymouth dash resume ifcfg earlykdump\"" +dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" ) readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." @@ -45,15 +45,15 @@ trap ' trap 'exit 1;' SIGINT add_dracut_arg() { - dracut_args="$dracut_args $@" + dracut_args+=( "$@" ) } add_dracut_mount() { - add_dracut_arg "--mount" "\"$1\"" + add_dracut_arg "--mount" "$1" } add_dracut_sshkey() { - add_dracut_arg "--sshkey" "\"$1\"" + add_dracut_arg "--sshkey" "$1" } # caller should ensure $1 is valid and mounted in 1st kernel @@ -428,7 +428,9 @@ do verify_core_collector "$config_val" ;; dracut_args) - add_dracut_arg $config_val + while read -r dracut_arg; do + add_dracut_arg "$dracut_arg" + done <<< "$(echo "$config_val" | xargs -n 1 echo)" ;; *) ;; @@ -439,7 +441,7 @@ handle_default_dump_target if [ -n "$extra_modules" ] then - add_dracut_arg "--add-drivers" \"$extra_modules\" + add_dracut_arg "--add-drivers" "$extra_modules" fi # TODO: The below check is not needed anymore with the introduction of @@ -455,7 +457,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" fi -echo "$dracut_args $@" | xargs dracut +dracut "${dracut_args[@]}" "$@" _rc=$? sync From e4c7b5bbf598be896ae6aeb7b842a15b4be63d38 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 03:53:35 +0800 Subject: [PATCH 456/806] mkdumprd: remove some redundant echo Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mkdumprd b/mkdumprd index c7538a9..de0e22d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -94,7 +94,7 @@ to_mount() { #$1=dump target #called from while loop and shouldn't read from stdin, so we're using "ssh -n" get_ssh_size() { - local _opt _out _size + local _opt _out _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes" _out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH") [ $? -ne 0 ] && { @@ -102,8 +102,7 @@ get_ssh_size() { } #ssh output removed the line break, so print field NF-2 - _size=$(echo -n $_out| awk '{avail=NF-2; print $avail}') - echo -n $_size + echo -n "$_out" | awk '{avail=NF-2; print $avail}' } #mkdir if save path does not exist on ssh dump target @@ -134,14 +133,13 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - local _mnt=$(get_mntpoint_from_target $1) - echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}') + df -P "$(get_mntpoint_from_target "$1")/$SAVE_PATH"|tail -1|awk '{print $4}' } #Function: get_raw_size #$1=dump target get_raw_size() { - echo -n $(fdisk -s "$1") + fdisk -s "$1" } #Function: check_size From d6449e7293fb426ebb9f0bffee57d675573a64d6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 17:15:42 +0800 Subject: [PATCH 457/806] mkdumprd: fix multiple issues with get_ssh_size Currently get_ssh_size is not working as expected, it should return the target's available space, but it will include df's header row string as the result. Fix this issue by only use the last output line. And the _opt variable will be used as args so it should be an array. Also remove the awk call, just use `df --output=avail` instead. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mkdumprd b/mkdumprd index de0e22d..bc50208 100644 --- a/mkdumprd +++ b/mkdumprd @@ -94,15 +94,14 @@ to_mount() { #$1=dump target #called from while loop and shouldn't read from stdin, so we're using "ssh -n" get_ssh_size() { - local _opt _out - _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes" - _out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH") - [ $? -ne 0 ] && { - perror_exit "checking remote ssh server available size failed." - } + local _out + local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes") - #ssh output removed the line break, so print field NF-2 - echo -n "$_out" | awk '{avail=NF-2; print $avail}' + if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then + perror_exit "checking remote ssh server available size failed." + fi + + echo -n "$_out" | tail -1 } #mkdir if save path does not exist on ssh dump target From c486b1fa3010c4c5f190ece9a2ed0a1430dfe7b5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 7 Sep 2021 14:42:30 +0800 Subject: [PATCH 458/806] mkdumprd: remove an awk call in get_fs_size By using `df --output=avail`, the awk call can be dropped. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index bc50208..79cc6b5 100644 --- a/mkdumprd +++ b/mkdumprd @@ -132,7 +132,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - df -P "$(get_mntpoint_from_target "$1")/$SAVE_PATH"|tail -1|awk '{print $4}' + df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1 } #Function: get_raw_size From 3a4b0351d0f31de739a2aae794e0e2af7fcc4942 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Aug 2021 15:45:20 +0800 Subject: [PATCH 459/806] mkdumprd: use array to store ssh arguments in mkdir_save_path_ssh For storing arguments, plain string is not a good choice. Array is preferred: See: https://github.com/koalaman/shellcheck/wiki/SC2089 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkdumprd b/mkdumprd index 79cc6b5..aa0f785 100644 --- a/mkdumprd +++ b/mkdumprd @@ -111,20 +111,20 @@ get_ssh_size() { mkdir_save_path_ssh() { local _opt _dir - _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes" - ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null + _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) + ssh -qn "${_opt[@]}" $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null _ret=$? if [ $_ret -ne 0 ]; then perror_exit "mkdir failed on $1:$SAVE_PATH" fi #check whether user has write permission on $1:$SAVE_PATH - _dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null) + _dir=$(ssh -qn "${_opt[@]}" $1 mktemp -dqp $SAVE_PATH 2>/dev/null) _ret=$? if [ $_ret -ne 0 ]; then perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" fi - ssh -qn $_opt $1 rmdir $_dir + ssh -qn "${_opt[@]}" $1 rmdir $_dir return 0 } From 982205d6072b1c10b2f0eff44c3ccbfa92dd3198 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 03:06:57 +0800 Subject: [PATCH 460/806] mkfadumprd: make _dracut_isolate_args an array To make arguments list work as expected, array is preferred. Check following link for details: https://github.com/koalaman/shellcheck/wiki/SC2089 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkfadumprd | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mkfadumprd b/mkfadumprd index aecf2a8..5c87933 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -51,14 +51,17 @@ if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$F fi ### Pack it into the normal boot initramfs with zz-fadumpinit module -_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit \ - -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot \ - -i $MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt - /usr/lib/dracut/fadump-kernel-modules.txt" +_dracut_isolate_args=(\ + --rebuild "$REBUILD_INITRD" --add zz-fadumpinit \ + -i "$MKFADUMPRD_TMPDIR/fadumproot" /fadumproot + -i "$MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt" + /usr/lib/dracut/fadump-kernel-modules.txt +) if is_squash_available; then - _dracut_isolate_args="$_dracut_isolate_args --add squash" + _dracut_isolate_args+=( --add squash ) fi -if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then + +if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability" fi From 46542ccda5df42a8b07e1d7fee629374e51e732a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 02:59:43 +0800 Subject: [PATCH 461/806] dracut-module-setup.sh: rework kdump_get_ip_route_field Avoid duplicated echo / cut / grep call, just use sed. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 53abdc7..d7f8cb5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -523,9 +523,7 @@ kdump_get_ip_route() kdump_get_ip_route_field() { - if `echo $1 | grep -q $2`; then - echo ${1##*$2} | cut -d ' ' -f1 - fi + echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" } kdump_get_remote_ip() From ba7aa447b25f2c66f48ff7ca4a139eb39e4f2340 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 14:29:10 +0800 Subject: [PATCH 462/806] dracut-module-setup.sh: remove an unused variable Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d7f8cb5..7396403 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -997,8 +997,6 @@ kdump_install_random_seed() { } kdump_install_systemd_conf() { - local failure_action=$(kdump_get_conf_val "failure_action") - # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null From 49dd4fcdbb9a21e938829e014d2db7ec3e5d2fea Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:41:10 +0800 Subject: [PATCH 463/806] dracut-module-setup.sh: fix _bondoptions wrong references Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7396403..815abeb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -391,13 +391,13 @@ kdump_setup_bond() { _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") - if [[ -z "_bondoptions" ]]; then + if [[ -z "$_bondoptions" ]]; then dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." source_ifcfg_file $_netdev _bondoptions="$(echo $BONDING_OPTS | xargs echo | tr " " ",")" fi - if [[ -z "_bondoptions" ]]; then + if [[ -z "$_bondoptions" ]]; then derror "Get empty bond options" exit 1 fi From da3ad9cbdaa332ed9384799e4b3198b9e55c5cd3 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:47:43 +0800 Subject: [PATCH 464/806] dracut-module-setup.sh: use "*" to expend array as string As suggested by: https://github.com/koalaman/shellcheck/wiki/SC2199 The array is not quoted here but implicitly concatenate still happens, could be harmless but shellcheck complains about it so fix it. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 815abeb..3d465c4 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -94,7 +94,7 @@ kdump_setup_dns() { _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") array=(${_tmp//|/ }) - if [[ ${array[@]} ]]; then + if [[ ${array[*]} ]]; then for _dns in "${array[@]}" do echo "nameserver=$_dns" >> "$_dnsfile" From dfe7555323e22d3f23621fcdae11b2c467754175 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:51:34 +0800 Subject: [PATCH 465/806] dracut-module-setup.sh: fix a ambiguous variable reference Wrap the variable with {...}, else it may get interpreted as array due to the '[' char next to it. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3d465c4..8b0398a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,11 +689,11 @@ kdump_install_conf() { case "$_opt" in raw) _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val) - sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ext[234]|xfs|btrfs|minix) _pdev=$(kdump_get_persistent_dev $_val) - sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$_val" From 3b2fa982bbe413e61ac53fa114782e1f08f8a939 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 16:16:44 +0800 Subject: [PATCH 466/806] dracut-module-setup.sh: fix a loop over ls issue Iterating over ls output is fragile: https://github.com/koalaman/shellcheck/wiki/SC2045 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8b0398a..f13b1a7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -353,7 +353,9 @@ kdump_setup_ifname() { kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev - for _dev in `ls /sys/class/net/$_netdev/brif/`; do + for _dev in "/sys/class/net/$_netdev/brif/"*; do + [[ -e $_dev ]] || continue + _dev=${_dev##*/} _kdumpdev=$_dev if kdump_is_bond "$_dev"; then $(kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") From 67e559a6b905b8f06a0929b7d7c86130fbe30638 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 16:29:55 +0800 Subject: [PATCH 467/806] dracut-module-setup.sh: make iscsi check fail early if cd failed As suggested by: https://github.com/koalaman/shellcheck/wiki/SC2164 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f13b1a7..267c98e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -855,7 +855,7 @@ kdump_check_iscsi_targets () { _dev=$1 [[ -L /sys/dev/block/$_dev ]] || return - cd "$(readlink -f /sys/dev/block/$_dev)" + cd "$(readlink -f "/sys/dev/block/$_dev")" || return 1 until [[ -d sys || -d iscsi_session ]]; do cd .. done From 3b0157197b4dcc7c06487d5f44395317c5f4670f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 15:15:44 +0800 Subject: [PATCH 468/806] dracut-module-setup.sh: remove surrounding $() for subshell Some functions are executed in subshell to avoid variable environment pollution. But the surrounding $() is not needed, and it may lead to executing output which is unexpected here. See: https://github.com/koalaman/shellcheck/wiki/SC2091 Signed-off-by: Kairui Song Suggested-by: Coiby Xu --- dracut-module-setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 267c98e..af17736 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -358,7 +358,7 @@ kdump_setup_bridge() { _dev=${_dev##*/} _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - $(kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") + (kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") if [[ $? != 0 ]]; then exit 1 fi @@ -441,7 +441,7 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - $(kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") + (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") if [[ $? != 0 ]]; then exit 1 fi @@ -560,7 +560,7 @@ kdump_install_net() { _znet_netdev=$(find_online_znet_device) if [[ -n "$_znet_netdev" ]]; then _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") - $(kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet") + (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet") if [[ $? != 0 ]]; then derror "Failed to set up znet" exit 1 @@ -591,7 +591,7 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - $(kdump_setup_bond "$_netdev" "$_nm_show_cmd") + (kdump_setup_bond "$_netdev" "$_nm_show_cmd") if [[ $? != 0 ]]; then exit 1 fi From 6d45257cc15b3a5b28ed3bfdacb06af065aaecb7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:14:00 +0800 Subject: [PATCH 469/806] bash scripts: remove useless cat Some `cat` calls are useless, remove them to make it cleaner. See: https://github.com/koalaman/shellcheck/wiki/SC2002 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 6 ++++-- kdumpctl | 20 +++++++++++--------- mkdumprd | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index af17736..ef731fc 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -114,7 +114,7 @@ kdump_setup_dns() { _dns=$(echo $_nameserver | cut -d' ' -f2) [ -z "$_dns" ] && continue - if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then + if [ ! -f $_dnsfile ] || ! grep -q "$_dns" "$_dnsfile" ; then echo "nameserver=$_dns" >> "$_dnsfile" fi done < "/etc/resolv.conf" @@ -988,7 +988,9 @@ kdump_configure_fence_kdump () { # Install a random seed used to feed /dev/urandom # By the time kdump service starts, /dev/uramdom is already fed by systemd kdump_install_random_seed() { - local poolsize=`cat /proc/sys/kernel/random/poolsize` + local poolsize + + poolsize=$( Date: Wed, 4 Aug 2021 15:18:59 +0800 Subject: [PATCH 470/806] bash scripts: get rid of expr and let As suggested by: https://github.com/koalaman/shellcheck/wiki/SC2219 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 2 +- kdumpctl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ef731fc..fc90912 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -196,7 +196,7 @@ cal_netmask_by_prefix() { _res="$_first_part" _tmp=$((_octets_total*_bits_per_octet-_prefix)) - _zero_bits=$(expr $_tmp % $_bits_per_group) + _zero_bits=$((_tmp % _bits_per_group)) if [[ "$_zero_bits" -ne 0 ]]; then _second_part=$((_max_group_value >> _zero_bits << _zero_bits)) if ((_ipv6)); then diff --git a/kdumpctl b/kdumpctl index 2226417..3e92804 100755 --- a/kdumpctl +++ b/kdumpctl @@ -772,7 +772,7 @@ check_and_wait_network_ready() fi cur=$(date +%s) - let "diff = $cur - $start_time" + diff=$((cur - start_time)) # 60s time out if [ $diff -gt 180 ]; then break; @@ -835,7 +835,7 @@ show_reserved_mem() local mem_mb mem=$( Date: Wed, 4 Aug 2021 15:46:27 +0800 Subject: [PATCH 471/806] bash scripts: get rid of unnecessary sed calls Use bash builtin string substitution instead, as suggested by: https://github.com/koalaman/shellcheck/wiki/SC2001 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 8 ++++---- mkdumprd | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index fc90912..f37d2d2 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -288,7 +288,7 @@ kdump_handle_mulitpath_route() { while IFS="" read _route; do if [[ "$_route" =~ [[:space:]]+nexthop ]]; then - _route=$(echo "$_route" | sed -e 's/^[[:space:]]*//') + _route=${_route##[[:space:]]} # Parse multipath route, using previous _target [[ "$_target" == 'default' ]] && continue [[ "$_route" =~ .*via.*\ $_netdev ]] || continue @@ -373,7 +373,7 @@ kdump_setup_bridge() { fi _brif+="$_kdumpdev," done - echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf + echo " bridge=$_netdev:${_brif%,}" >> "${initdir}/etc/cmdline.d/41bridge.conf" } # drauct takes bond=[::[:]] syntax to parse @@ -389,7 +389,7 @@ kdump_setup_bond() { echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf _slaves+="$_kdumpdev," done - echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf + echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf" _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") @@ -416,7 +416,7 @@ kdump_setup_team() { echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf _slaves+="$_kdumpdev," done - echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf + echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf" #Buggy version teamdctl outputs to stderr! #Try to use the latest version of teamd. teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf diff --git a/mkdumprd b/mkdumprd index 36e2b90..5341245 100644 --- a/mkdumprd +++ b/mkdumprd @@ -58,7 +58,7 @@ add_dracut_sshkey() { # caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev + local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" @@ -67,9 +67,9 @@ to_mount() { if [[ "$_fstype" == "nfs"* ]]; then _pdev=$_target - _options=$(echo $_options | sed 's/,addr=[^,]*//') - _options=$(echo $_options | sed 's/,proto=[^,]*//') - _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') + _sed_cmd+='s/,addr=[^,]*//;' + _sed_cmd+='s/,proto=[^,]*//;' + _sed_cmd+='s/,clientaddr=[^,]*//;' else # for non-nfs _target converting to use udev persistent name _pdev="$(kdump_get_persistent_dev $_target)" @@ -79,13 +79,15 @@ to_mount() { fi # mount fs target as rw in 2nd kernel - _options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g') + _sed_cmd+='s/\(^\|,\)ro\($\|,\)/\1rw\2/g;' # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd # kernel, filter it out here. - _options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g') + _sed_cmd+='s/\(^\|,\)noauto\($\|,\)/\1/g;' # drop nofail or nobootwait - _options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g') - _options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g') + _sed_cmd+='s/\(^\|,\)nofail\($\|,\)/\1/g;' + _sed_cmd+='s/\(^\|,\)nobootwait\($\|,\)/\1/g;' + + _options=$(echo "$_options" | sed "$_sed_cmd") echo "$_pdev $_new_mntpoint $_fstype $_options" } From a416930706944828ae9bd8daf49be8ca998d3fcc Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 4 Aug 2021 15:50:30 +0800 Subject: [PATCH 472/806] bash scripts: always use "read -r" This helps to strip spaces and avoid mangling backslashes: https://github.com/koalaman/shellcheck/wiki/SC2162 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 14 +++++++------- kdumpctl | 2 +- mkdumprd | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f37d2d2..202fce5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -106,7 +106,7 @@ kdump_setup_dns() { [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" fi - while read content; + while read -r content; do _nameserver=$(echo $content | grep ^nameserver) [ -z "$_nameserver" ] && continue @@ -265,7 +265,7 @@ kdump_static_ip() { /sbin/ip $_ipv6_flag route show | grep -v default |\ grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ - while read _route; do + while read -r _route; do _target=`echo $_route | cut -d ' ' -f1` _nexthop=`echo $_route | cut -d ' ' -f3` if [ "x" != "x"$_ipv6_flag ]; then @@ -286,7 +286,7 @@ kdump_handle_mulitpath_route() { _ipv6_flag="-6" fi - while IFS="" read _route; do + while IFS="" read -r _route; do if [[ "$_route" =~ [[:space:]]+nexthop ]]; then _route=${_route##[[:space:]]} # Parse multipath route, using previous _target @@ -465,7 +465,7 @@ find_online_znet_device() { for d in $NETWORK_DEVICES do [ ! -f "$d/online" ] && continue - read ONLINE < $d/online + read -r ONLINE < $d/online if [ $ONLINE -ne 1 ]; then continue fi @@ -473,7 +473,7 @@ find_online_znet_device() { # device is online) if [ -f $d/if_name ] then - read ifname < $d/if_name + read -r ifname < $d/if_name elif [ -d $d/net ] then ifname=$(ls $d/net/) @@ -685,7 +685,7 @@ kdump_install_conf() { kdump_read_conf > "${initdir}/tmp/$$-kdump.conf" - while read _opt _val; + while read -r _opt _val; do # remove inline comments after the end of a directive. case "$_opt" in @@ -753,7 +753,7 @@ kdump_get_iscsi_initiator() { [ -f "$initiator_conf" ] || return 1 - while read _initiator; do + while read -r _initiator; do [ -z "${_initiator%%#*}" ] && continue # Skip comment lines case $_initiator in diff --git a/kdumpctl b/kdumpctl index 3e92804..72c4966 100755 --- a/kdumpctl +++ b/kdumpctl @@ -704,7 +704,7 @@ load_kdump() check_ssh_config() { - while read config_opt config_val; do + while read -r config_opt config_val; do case "$config_opt" in sshkey) # remove inline comments after the end of a directive. diff --git a/mkdumprd b/mkdumprd index 5341245..6621e30 100644 --- a/mkdumprd +++ b/mkdumprd @@ -390,7 +390,7 @@ if [ -f "$keyfile" ]; then SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi -while read config_opt config_val; +while read -r config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in From 54cc5c44befa308e122d93221c65486164ffb3e5 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 01:48:52 +0800 Subject: [PATCH 473/806] bash scripts: use $(...) notation instead of legacy `...` This is a batch update done with following command: `sed -i -e 's/`\([^`]*\)`/\$(\1)/g' mkfadumprd mkdumprd \ kdumpctl dracut-module-setup.sh dracut-fadump-module-setup.sh \ dracut-early-kdump-module-setup.sh` And manually converted some corner cases. This fixes all related issues detected by shellcheck. Make it easier to do clean up in later commits. Check following link for reasons to switch to the new syntax: https://github.com/koalaman/shellcheck/wiki/SC2006 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 22 +++++++++++----------- kdumpctl | 31 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 202fce5..29a2f27 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -266,8 +266,8 @@ kdump_static_ip() { /sbin/ip $_ipv6_flag route show | grep -v default |\ grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ while read -r _route; do - _target=`echo $_route | cut -d ' ' -f1` - _nexthop=`echo $_route | cut -d ' ' -f3` + _target=$(echo $_route | cut -d ' ' -f1) + _nexthop=$(echo $_route | cut -d ' ' -f3) if [ "x" != "x"$_ipv6_flag ]; then _target="[$_target]" _nexthop="[$_nexthop]" @@ -293,9 +293,9 @@ kdump_handle_mulitpath_route() { [[ "$_target" == 'default' ]] && continue [[ "$_route" =~ .*via.*\ $_netdev ]] || continue - _weight=`echo "$_route" | cut -d ' ' -f7` + _weight=$(echo "$_route" | cut -d ' ' -f7) if [[ "$_weight" -gt "$_max_weight" ]]; then - _nexthop=`echo "$_route" | cut -d ' ' -f3` + _nexthop=$(echo "$_route" | cut -d ' ' -f3) _max_weight=$_weight if [ "x" != "x"$_ipv6_flag ]; then _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" @@ -305,7 +305,7 @@ kdump_handle_mulitpath_route() { fi else [[ -n "$_rule" ]] && echo "$_rule" - _target=`echo "$_route" | cut -d ' ' -f1` + _target=$(echo "$_route" | cut -d ' ' -f1) _rule="" _max_weight=0 _weight=0 fi done >> ${initdir}/etc/cmdline.d/45route-static.conf\ @@ -383,7 +383,7 @@ kdump_setup_bond() { local _netdev="$1" local _nm_show_cmd="$2" local _dev _mac _slaves _kdumpdev _bondoptions - for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do + for _dev in $(cat /sys/class/net/$_netdev/bonding/slaves); do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf @@ -410,7 +410,7 @@ kdump_setup_bond() { kdump_setup_team() { local _netdev=$1 local _dev _mac _slaves _kdumpdev - for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do + for _dev in $(teamnl $_netdev ports | awk -F':' '{print $2}'); do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf @@ -532,11 +532,11 @@ kdump_get_remote_ip() { local _remote=$(get_remote_host $1) _remote_temp if is_hostname $_remote; then - _remote_temp=`getent ahosts $_remote | grep -v : | head -n 1` + _remote_temp=$(getent ahosts $_remote | grep -v : | head -n 1) if [ -z "$_remote_temp" ]; then - _remote_temp=`getent ahosts $_remote | head -n 1` + _remote_temp=$(getent ahosts $_remote | head -n 1) fi - _remote=`echo $_remote_temp | cut -d' ' -f1` + _remote=$(echo $_remote_temp | cut -d' ' -f1) fi echo $_remote } @@ -908,7 +908,7 @@ get_pcs_fence_kdump_nodes() { pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1 # get cluster nodes from cluster cib, get interface and ip address - nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -` + nodelist=$(pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -) # nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"' # we need to convert each to node1, node2 ... nodeX in each iteration diff --git a/kdumpctl b/kdumpctl index 72c4966..1f76bf2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -76,7 +76,7 @@ determine_dump_mode() save_core() { - coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" + coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" mkdir -p $coredir ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" @@ -290,15 +290,14 @@ get_pcs_cluster_modified_files() is_generic_fence_kdump && return 1 is_pcs_fence_kdump || return 1 - time_stamp=`pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | \ - xargs -0 date +%s --date` + time_stamp=$(pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | xargs -0 date +%s --date) if [ -n $time_stamp -a $time_stamp -gt $image_time ]; then modified_files="cluster-cib" fi if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then - time_stamp=`stat -c "%Y" $FENCE_KDUMP_CONFIG_FILE` + time_stamp=$(stat -c "%Y" $FENCE_KDUMP_CONFIG_FILE) if [ "$time_stamp" -gt "$image_time" ]; then modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" fi @@ -358,7 +357,7 @@ check_files_modified() fi HOOKS="$HOOKS $POST_FILES $PRE_FILES" CORE_COLLECTOR=$(kdump_get_conf_val core_collector | awk '{print $1}') - CORE_COLLECTOR=`type -P $CORE_COLLECTOR` + CORE_COLLECTOR=$(type -P $CORE_COLLECTOR) # POST_FILES and PRE_FILES are already checked against executable, need not to check again. EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=$(kdump_get_conf_val extra_bins) @@ -395,13 +394,13 @@ check_files_modified() for file in $files; do if [ -e "$file" ]; then - time_stamp=`stat -c "%Y" $file` + time_stamp=$(stat -c "%Y" $file) if [ "$time_stamp" -gt "$image_time" ]; then modified_files="$modified_files $file" fi if [ -L "$file" ]; then file=$(readlink -m $file) - time_stamp=`stat -c "%Y" $file` + time_stamp=$(stat -c "%Y" $file) if [ "$time_stamp" -gt "$image_time" ]; then modified_files="$modified_files $file" fi @@ -591,7 +590,7 @@ check_rebuild() #check to see if dependent files has been modified #since last build of the image file if [ -f $TARGET_INITRD ]; then - image_time=`stat -c "%Y" $TARGET_INITRD 2>/dev/null` + image_time=$(stat -c "%Y" $TARGET_INITRD 2>/dev/null) #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability @@ -727,7 +726,7 @@ check_ssh_config() done <<< "$(kdump_read_conf)" #make sure they've configured kdump.conf for ssh dumps - local SSH_TARGET=`echo -n $DUMP_TARGET | sed -n '/.*@/p'` + local SSH_TARGET=$(echo -n $DUMP_TARGET | sed -n '/.*@/p') if [ -z "$SSH_TARGET" ]; then return 1 fi @@ -814,8 +813,8 @@ propagate_ssh_key() fi #now find the target ssh user and server to contact. - SSH_USER=`echo $DUMP_TARGET | cut -d\ -f2 | cut -d@ -f1` - SSH_SERVER=`echo $DUMP_TARGET | sed -e's/\(.*@\)\(.*$\)/\2/'` + SSH_USER=$(echo $DUMP_TARGET | cut -d\ -f2 | cut -d@ -f1) + SSH_SERVER=$(echo $DUMP_TARGET | sed -e's/\(.*@\)\(.*$\)/\2/') #now send the found key to the found server ssh-copy-id -i $KEYFILE $SSH_USER@$SSH_SERVER @@ -844,7 +843,7 @@ check_current_fadump_status() { # Check if firmware-assisted dump has been registered. rc=$(<$FADUMP_REGISTER_SYS_NODE) - [[ $rc -eq 1 ]] && return 0 + [ $rc -eq 1 ] && return 0 return 1 } @@ -877,9 +876,9 @@ save_raw() fi kdump_dir=$(kdump_get_conf_val path) if [ -z "${kdump_dir}" ]; then - coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" + coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" else - coredir="${kdump_dir}/`date +"%Y-%m-%d-%H:%M"`" + coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")" fi mkdir -p "$coredir" @@ -956,8 +955,8 @@ selinux_relabel() check_fence_kdump_config() { - local hostname=`hostname` - local ipaddrs=`hostname -I` + local hostname=$(hostname) + local ipaddrs=$(hostname -I) local nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in $nodes; do From 70978c00e5a573f0901ac404067eaea2c6536370 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 17:20:51 +0800 Subject: [PATCH 474/806] bash scripts: replace '[ ]' with '[[ ]]' for bash scripts kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they only run in first kernel and depend on dracut, and dracut depends on bash. So use '[[ ]]' to replace '[ ]'. This is a batch update done with following command: `sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh` and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually. See https://tldp.org/LDP/abs/html/testconstructs.html for more details on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'. This will also help shfmt to clean up the code in later commits. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-early-kdump-module-setup.sh | 10 +- dracut-module-setup.sh | 108 +++++++------- kdumpctl | 218 ++++++++++++++--------------- mkdumprd | 50 +++---- mkfadumprd | 2 +- 5 files changed, 194 insertions(+), 194 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index b25d6b5..00546e0 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -6,8 +6,8 @@ KDUMP_KERNEL="" KDUMP_INITRD="" check() { - if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\ - || [ -n "${IN_KDUMP}" ] + if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]]\ + || [[ -n "${IN_KDUMP}" ]] then return 1 fi @@ -25,7 +25,7 @@ prepare_kernel_initrd() { prepare_kdump_bootinfo # $kernel is a variable from dracut - if [ "$KDUMP_KERNELVER" != $kernel ]; then + if [[ "$KDUMP_KERNELVER" != $kernel ]]; then dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ "but the initramfs is generated for kernel version '$kernel'" fi @@ -33,12 +33,12 @@ prepare_kernel_initrd() { install() { prepare_kernel_initrd - if [ ! -f "$KDUMP_KERNEL" ]; then + if [[ ! -f "$KDUMP_KERNEL" ]]; then derror "Could not find required kernel for earlykdump," \ "earlykdump will not work!" return 1 fi - if [ ! -f "$KDUMP_INITRD" ]; then + if [[ ! -f "$KDUMP_INITRD" ]]; then derror "Could not find required kdump initramfs for earlykdump," \ "please ensure kdump initramfs is generated first," \ "earlykdump will not work!" diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 29a2f27..515cff0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -11,7 +11,7 @@ kdump_module_init() { check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly - if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ] + if [[ -z "$IN_KDUMP" ]] || [[ ! -f /etc/kdump.conf ]] then return 1 fi @@ -41,11 +41,11 @@ depends() { _dep="$_dep ssh-client" fi - if [ "$(uname -m)" = "s390x" ]; then + if [[ "$(uname -m)" = "s390x" ]]; then _dep="$_dep znet" fi - if [ -n "$( ls -A /sys/class/drm 2>/dev/null )" ] || [ -d /sys/module/hyperv_fb ]; then + if [[ -n "$( ls -A /sys/class/drm 2>/dev/null )" ]] || [[ -d /sys/module/hyperv_fb ]]; then add_opt_module drm fi @@ -57,19 +57,19 @@ depends() { } kdump_is_bridge() { - [ -d /sys/class/net/"$1"/bridge ] + [[ -d /sys/class/net/"$1"/bridge ]] } kdump_is_bond() { - [ -d /sys/class/net/"$1"/bonding ] + [[ -d /sys/class/net/"$1"/bonding ]] } kdump_is_team() { - [ -f /usr/bin/teamnl ] && teamnl $1 ports &> /dev/null + [[ -f /usr/bin/teamnl ]] && teamnl $1 ports &> /dev/null } kdump_is_vlan() { - [ -f /proc/net/vlan/"$1" ] + [[ -f /proc/net/vlan/"$1" ]] } # $1: netdev name @@ -78,7 +78,7 @@ source_ifcfg_file() { dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." ifcfg_file=$(get_ifcfg_filename $1) - if [ -f "${ifcfg_file}" ]; then + if [[ -f "${ifcfg_file}" ]]; then . ${ifcfg_file} else dwarning "The ifcfg file of $1 is not found!" @@ -102,19 +102,19 @@ kdump_setup_dns() { else dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" source_ifcfg_file "$_netdev" - [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" + [[ -n "$DNS1" ]] && echo "nameserver=$DNS1" > "$_dnsfile" + [[ -n "$DNS2" ]] && echo "nameserver=$DNS2" >> "$_dnsfile" fi while read -r content; do _nameserver=$(echo $content | grep ^nameserver) - [ -z "$_nameserver" ] && continue + [[ -z "$_nameserver" ]] && continue _dns=$(echo $_nameserver | cut -d' ' -f2) - [ -z "$_dns" ] && continue + [[ -z "$_dns" ]] && continue - if [ ! -f $_dnsfile ] || ! grep -q "$_dns" "$_dnsfile" ; then + if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile" ; then echo "nameserver=$_dns" >> "$_dnsfile" fi done < "/etc/resolv.conf" @@ -243,11 +243,11 @@ kdump_static_ip() { _ipv6_flag="-6" fi - if [ -n "$_ipaddr" ]; then + if [[ -n "$_ipaddr" ]]; then _gateway=$(ip $_ipv6_flag route list dev $_netdev | \ awk '/^default /{print $3}' | head -n 1) - if [ "x" != "x"$_ipv6_flag ]; then + if [[ "x" != "x"$_ipv6_flag ]]; then # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" _netmask=${_ipaddr#*\/} _srcaddr="[$_srcaddr]" @@ -268,7 +268,7 @@ kdump_static_ip() { while read -r _route; do _target=$(echo $_route | cut -d ' ' -f1) _nexthop=$(echo $_route | cut -d ' ' -f3) - if [ "x" != "x"$_ipv6_flag ]; then + if [[ "x" != "x"$_ipv6_flag ]]; then _target="[$_target]" _nexthop="[$_nexthop]" fi @@ -297,7 +297,7 @@ kdump_handle_mulitpath_route() { if [[ "$_weight" -gt "$_max_weight" ]]; then _nexthop=$(echo "$_route" | cut -d ' ' -f3) _max_weight=$_weight - if [ "x" != "x"$_ipv6_flag ]; then + if [[ "x" != "x"$_ipv6_flag ]]; then _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" else _rule="rd.route=$_target:$_nexthop:$kdumpnic" @@ -322,7 +322,7 @@ kdump_get_mac_addr() { #of its slaves, we should use perm address kdump_get_perm_addr() { local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //') - if [ -z "$addr" ] || [ "$addr" = "00:00:00:00:00:00" ] + if [[ -z "$addr" ]] || [[ "$addr" = "00:00:00:00:00:00" ]] then derror "Can't get the permanent address of $1" else @@ -420,7 +420,7 @@ kdump_setup_team() { #Buggy version teamdctl outputs to stderr! #Try to use the latest version of teamd. teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf - if [ $? -ne 0 ] + if [[ $? -ne 0 ]] then derror "teamdctl failed." exit 1 @@ -460,25 +460,25 @@ find_online_znet_device() { local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" local NETWORK_DEVICES d ifname ONLINE - [ ! -d "$CCWGROUPBUS_DEVICEDIR" ] && return + [[ ! -d "$CCWGROUPBUS_DEVICEDIR" ]] && return NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) for d in $NETWORK_DEVICES do - [ ! -f "$d/online" ] && continue + [[ ! -f "$d/online" ]] && continue read -r ONLINE < $d/online - if [ $ONLINE -ne 1 ]; then + if [[ $ONLINE -ne 1 ]]; then continue fi # determine interface name, if there (only for qeth and if # device is online) - if [ -f $d/if_name ] + if [[ -f $d/if_name ]] then read -r ifname < $d/if_name - elif [ -d $d/net ] + elif [[ -d $d/net ]] then ifname=$(ls $d/net/) fi - [ -n "$ifname" ] && break + [[ -n "$ifname" ]] && break done echo -n "$ifname" } @@ -533,7 +533,7 @@ kdump_get_remote_ip() local _remote=$(get_remote_host $1) _remote_temp if is_hostname $_remote; then _remote_temp=$(getent ahosts $_remote | grep -v : | head -n 1) - if [ -z "$_remote_temp" ]; then + if [[ -z "$_remote_temp" ]]; then _remote_temp=$(getent ahosts $_remote | head -n 1) fi _remote=$(echo $_remote_temp | cut -d' ' -f1) @@ -568,7 +568,7 @@ kdump_install_net() { fi _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) - if [ -n "$_static" ]; then + if [[ -n "$_static" ]]; then _proto=none elif is_ipv6_address $_srcaddr; then _proto=auto6 @@ -583,7 +583,7 @@ kdump_install_net() { # so we have to avoid adding duplicates # We should also check /proc/cmdline for existing ip=xx arg. # For example, iscsi boot will specify ip=xxx arg in cmdline. - if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ + if [[ ! -f $_ip_conf ]] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf fi @@ -606,7 +606,7 @@ kdump_install_net() { kdump_setup_dns "$_netdev" "$_nm_show_cmd" - if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then + if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then # network-manager module needs this parameter echo "rd.neednet" >> ${initdir}/etc/cmdline.d/50neednet.conf fi @@ -618,8 +618,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway. - if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] && - [ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] && + [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then echo "kdumpnic=$kdumpnic" > ${initdir}/etc/cmdline.d/60kdumpnic.conf echo "bootdev=$kdumpnic" > ${initdir}/etc/cmdline.d/70bootdev.conf fi @@ -627,21 +627,21 @@ kdump_install_net() { # install etc/kdump/pre.d and /etc/kdump/post.d kdump_install_pre_post_conf() { - if [ -d /etc/kdump/pre.d ]; then + if [[ -d /etc/kdump/pre.d ]]; then for file in /etc/kdump/pre.d/*; do - if [ -x "$file" ]; then + if [[ -x "$file" ]]; then dracut_install $file - elif [ $file != "/etc/kdump/pre.d/*" ]; then + elif [[ $file != "/etc/kdump/pre.d/*" ]]; then echo "$file is not executable" fi done fi - if [ -d /etc/kdump/post.d ]; then + if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do - if [ -x "$file" ]; then + if [[ -x "$file" ]]; then dracut_install $file - elif [ $file != "/etc/kdump/post.d/*" ]; then + elif [[ $file != "/etc/kdump/post.d/*" ]]; then echo "$file is not executable" fi done @@ -670,7 +670,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf # don't touch the path under root mount - if [ "$_mntpoint" != "/" ]; then + if [[ "$_mntpoint" != "/" ]]; then _save_path=${_save_path##"$_mntpoint"} fi @@ -751,10 +751,10 @@ kdump_get_iscsi_initiator() { local _initiator local initiator_conf="/etc/iscsi/initiatorname.iscsi" - [ -f "$initiator_conf" ] || return 1 + [[ -f "$initiator_conf" ]] || return 1 while read -r _initiator; do - [ -z "${_initiator%%#*}" ] && continue # Skip comment lines + [[ -z "${_initiator%%#*}" ]] && continue # Skip comment lines case $_initiator in InitiatorName=*) @@ -770,7 +770,7 @@ kdump_get_iscsi_initiator() { # Figure out iBFT session according to session type is_ibft() { - [ "$(kdump_iscsi_get_rec_val $1 "node.discovery_type")" = fw ] + [[ "$(kdump_iscsi_get_rec_val $1 "node.discovery_type")" = fw ]] } kdump_setup_iscsi_device() { @@ -803,18 +803,18 @@ kdump_setup_iscsi_device() { # get and set username and password details username=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username") - [ "$username" == "" ] && username="" + [[ "$username" == "" ]] && username="" password=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password") - [ "$password" == "" ] && password="" + [[ "$password" == "" ]] && password="" username_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username_in") - [ -n "$username" ] && userpwd_str="$username:$password" + [[ -n "$username" ]] && userpwd_str="$username:$password" # get and set incoming username and password details - [ "$username_in" == "" ] && username_in="" + [[ "$username_in" == "" ]] && username_in="" password_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password_in") - [ "$password_in" == "" ] && password_in="" + [[ "$password_in" == "" ]] && password_in="" - [ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in" + [[ -n "$username_in" ]] && userpwd_in_str=":$username_in:$password_in" kdump_install_net "$tgt_ipaddr" @@ -837,7 +837,7 @@ kdump_setup_iscsi_device() { # Setup initator initiator_str=$(kdump_get_iscsi_initiator) - [ $? -ne "0" ] && derror "Failed to get initiator name" && return 1 + [[ $? -ne "0" ]] && derror "Failed to get initiator name" && return 1 # If initiator details do not exist already, append. if ! grep -q "$initiator_str" $netroot_conf; then @@ -878,7 +878,7 @@ get_alias() { do # in /etc/hosts, alias can come at the 2nd column entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }') - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then alias_set="$alias_set $entries" fi done @@ -895,7 +895,7 @@ is_localhost() { hostnames="$hostnames $shortnames $aliasname" for name in ${hostnames}; do - if [ "$name" == "$nodename" ]; then + if [[ "$name" == "$nodename" ]]; then return 0 fi done @@ -928,7 +928,7 @@ get_pcs_fence_kdump_nodes() { # retrieves fence_kdump args from config file get_pcs_fence_kdump_args() { - if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then + if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then . $FENCE_KDUMP_CONFIG_FILE echo $FENCE_KDUMP_OPTS fi @@ -966,7 +966,7 @@ kdump_configure_fence_kdump () { echo "fence_kdump_nodes $nodes" >> ${kdump_cfg_file} args=$(get_pcs_fence_kdump_args) - if [ -n "$args" ]; then + if [[ -n "$args" ]]; then echo "fence_kdump_args $args" >> ${kdump_cfg_file} fi @@ -992,7 +992,7 @@ kdump_install_random_seed() { poolsize=$( ${initdir}/etc/systemd/system.conf.d/kdump.conf echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf diff --git a/kdumpctl b/kdumpctl index 1f76bf2..11782df 100755 --- a/kdumpctl +++ b/kdumpctl @@ -27,7 +27,7 @@ standard_kexec_args="-d -p" # Some default values in case /etc/sysconfig/kdump doesn't include KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug" -if [ -f /etc/sysconfig/kdump ]; then +if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -38,7 +38,7 @@ fi #initiate the kdump logger dlog_init -if [ $? -ne 0 ]; then +if [[ $? -ne 0 ]]; then echo "failed to initiate the kdump logger." exit 1 fi @@ -48,7 +48,7 @@ single_instance_lock() local rc timeout=5 exec 9>/var/lock/kdump - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Create file lock failed" exit 1 fi @@ -56,7 +56,7 @@ single_instance_lock() flock -n 9 rc=$? - while [ $rc -ne 0 ]; do + while [[ $rc -ne 0 ]]; do dinfo "Another app is currently holding the kdump lock; waiting for it to exit..." flock -w $timeout 9 rc=$? @@ -81,7 +81,7 @@ save_core() mkdir -p $coredir ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete - if [ $? == 0 ]; then + if [[ $? == 0 ]]; then mv $coredir/vmcore-incomplete $coredir/vmcore dinfo "saved a vmcore to $coredir" else @@ -91,12 +91,12 @@ save_core() # pass the dmesg to Abrt tool if exists, in order # to collect the kernel oops message. # https://fedorahosted.org/abrt/ - if [ -x /usr/bin/dumpoops ]; then + if [[ -x /usr/bin/dumpoops ]]; then ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg >/dev/null 2>&1 ddebug "dumpoops -d $coredir/dmesg" dumpoops -d $coredir/dmesg >/dev/null 2>&1 - if [ $? == 0 ]; then + if [[ $? == 0 ]]; then dinfo "kernel oops has been collected by abrt tool" fi fi @@ -122,7 +122,7 @@ rebuild_kdump_initrd() { ddebug "rebuild kdump initrd: $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER" $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER - if [ $? != 0 ]; then + if [[ $? != 0 ]]; then derror "mkdumprd: failed to make kdump initrd" return 1 fi @@ -141,7 +141,7 @@ rebuild_initrd() return 1 fi - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then rebuild_fadump_initrd else rebuild_kdump_initrd @@ -154,7 +154,7 @@ rebuild_initrd() check_exist() { for file in $1; do - if [ ! -e "$file" ]; then + if [[ ! -e "$file" ]]; then derror "Error: $file not found." return 1 fi @@ -165,7 +165,7 @@ check_exist() check_executable() { for file in $1; do - if [ ! -x "$file" ]; then + if [[ ! -x "$file" ]]; then derror "Error: $file is not executable." return 1 fi @@ -176,16 +176,16 @@ backup_default_initrd() { ddebug "backup default initrd: $DEFAULT_INITRD" - if [ ! -f "$DEFAULT_INITRD" ]; then + if [[ ! -f "$DEFAULT_INITRD" ]]; then return fi - if [ ! -e $DEFAULT_INITRD_BAK ]; then + if [[ ! -e $DEFAULT_INITRD_BAK ]]; then dinfo "Backing up $DEFAULT_INITRD before rebuild." # save checksum to verify before restoring sha1sum $DEFAULT_INITRD > $INITRD_CHECKSUM_LOCATION cp $DEFAULT_INITRD $DEFAULT_INITRD_BAK - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." rm -f $DEFAULT_INITRD_BAK fi @@ -196,17 +196,17 @@ restore_default_initrd() { ddebug "restore default initrd: $DEFAULT_INITRD" - if [ ! -f "$DEFAULT_INITRD" ]; then + if [[ ! -f "$DEFAULT_INITRD" ]]; then return fi # If a backup initrd exists, we must be switching back from # fadump to kdump. Restore the original default initrd. - if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then + if [[ -f $DEFAULT_INITRD_BAK ]] && [[ -f $INITRD_CHECKSUM_LOCATION ]]; then # verify checksum before restoring backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }') default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION") - if [ "$default_checksum" != "$backup_checksum" ]; then + if [[ "$default_checksum" != "$backup_checksum" ]]; then dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else rm -f $INITRD_CHECKSUM_LOCATION @@ -226,7 +226,7 @@ check_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then - if [ $(echo $config_val | grep -o "\-\-mount" | wc -l) -ne 1 ]; then + if [[ $(echo $config_val | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then derror "Multiple mount targets specified in one \"dracut_args\"." return 1 fi @@ -234,7 +234,7 @@ check_config() fi ;; raw) - if [ -d "/proc/device-tree/ibm,opal/dump" ]; then + if [[ -d "/proc/device-tree/ibm,opal/dump" ]]; then dwarn "WARNING: Won't capture opalcore when 'raw' dump target is used." fi config_opt=_target @@ -262,8 +262,8 @@ check_config() return 1 fi - if [ -n "${_opt_rec[$config_opt]}" ]; then - if [ $config_opt == _target ]; then + if [[ -n "${_opt_rec[$config_opt]}" ]]; then + if [[ $config_opt == _target ]]; then derror "More than one dump targets specified" else derror "Duplicated kdump config value of option $config_opt" @@ -292,13 +292,13 @@ get_pcs_cluster_modified_files() time_stamp=$(pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | xargs -0 date +%s --date) - if [ -n $time_stamp -a $time_stamp -gt $image_time ]; then + if [[ -n $time_stamp ]] && [[ $time_stamp -gt $image_time ]]; then modified_files="cluster-cib" fi - if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then + if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then time_stamp=$(stat -c "%Y" $FENCE_KDUMP_CONFIG_FILE) - if [ "$time_stamp" -gt "$image_time" ]; then + if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" fi fi @@ -309,13 +309,13 @@ get_pcs_cluster_modified_files() setup_initrd() { prepare_kdump_bootinfo - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "failed to prepare for kdump bootinfo." return 1 fi DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename $DEFAULT_INITRD).default" - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then TARGET_INITRD="$DEFAULT_INITRD" # backup initrd for reference before replacing it @@ -341,16 +341,16 @@ check_files_modified() EXTRA_BINS=$(kdump_get_conf_val kdump_post) CHECK_FILES=$(kdump_get_conf_val kdump_pre) HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" - if [ -d /etc/kdump/post.d ]; then + if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do - if [ -x "$file" ]; then + if [[ -x "$file" ]]; then POST_FILES="$POST_FILES $file" fi done fi - if [ -d /etc/kdump/pre.d ]; then + if [[ -d /etc/kdump/pre.d ]]; then for file in /etc/kdump/pre.d/*; do - if [ -x "$file" ]; then + if [[ -x "$file" ]]; then PRE_FILES="$PRE_FILES $file" fi done @@ -367,8 +367,8 @@ check_files_modified() # Check for any updated extra module EXTRA_MODULES="$(kdump_get_conf_val extra_modules)" - if [ -n "$EXTRA_MODULES" ]; then - if [ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]; then + if [[ -n "$EXTRA_MODULES" ]]; then + if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" fi for _module in $EXTRA_MODULES; do @@ -390,18 +390,18 @@ check_files_modified() # HOOKS is mandatory and need to check the modification time files="$files $HOOKS" check_exist "$files" && check_executable "$EXTRA_BINS" - [ $? -ne 0 ] && return 2 + [[ $? -ne 0 ]] && return 2 for file in $files; do - if [ -e "$file" ]; then + if [[ -e "$file" ]]; then time_stamp=$(stat -c "%Y" $file) - if [ "$time_stamp" -gt "$image_time" ]; then + if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $file" fi - if [ -L "$file" ]; then + if [[ -L "$file" ]]; then file=$(readlink -m $file) time_stamp=$(stat -c "%Y" $file) - if [ "$time_stamp" -gt "$image_time" ]; then + if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $file" fi fi @@ -410,7 +410,7 @@ check_files_modified() fi done - if [ -n "$modified_files" ]; then + if [[ -n "$modified_files" ]]; then dinfo "Detected change(s) in the following file(s): $modified_files" return 1 fi @@ -441,7 +441,7 @@ check_drivers_modified() # Include watchdog drivers if watchdog module is not omitted is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)" - [ -z "$_new_drivers" ] && return 0 + [[ -z "$_new_drivers" ]] && return 0 if is_fadump_capable; then _old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/fadump-kernel-modules.txt | tr '\n' ' ')" @@ -455,7 +455,7 @@ check_drivers_modified() # Skip deprecated/invalid driver name or built-in module _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name $_driver 2>/dev/null) _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n $_driver 2>/dev/null) - if [ $? -ne 0 ] || [ -z "$_module_name" ] || [[ "$_module_filename" = *"(builtin)"* ]]; then + if [[ $? -ne 0 ]] || [[ -z "$_module_name" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then continue fi if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then @@ -491,7 +491,7 @@ check_fs_modified() ddebug "_target=$_target _new_fstype=$_new_fstype" _new_dev=$(kdump_get_persistent_dev $_target) - if [ -z "$_new_dev" ]; then + if [[ -z "$_new_dev" ]]; then perror "Get persistent device name failed" return 2 fi @@ -532,19 +532,19 @@ check_system_modified() check_files_modified ret=$? - if [ $ret -ne 0 ]; then + if [[ $ret -ne 0 ]]; then return $ret fi check_fs_modified ret=$? - if [ $ret -ne 0 ]; then + if [[ $ret -ne 0 ]]; then return $ret fi check_drivers_modified ret=$? - if [ $ret -ne 0 ]; then + if [[ $ret -ne 0 ]]; then return $ret fi @@ -559,20 +559,20 @@ check_rebuild() setup_initrd - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then return 1 fi force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) force_no_rebuild=${force_no_rebuild:-0} - if [ "$force_no_rebuild" != "0" ] && [ "$force_no_rebuild" != "1" ];then + if [[ "$force_no_rebuild" != "0" ]] && [[ "$force_no_rebuild" != "1" ]];then derror "Error: force_no_rebuild value is invalid" return 1 fi force_rebuild=$(kdump_get_conf_val force_rebuild) force_rebuild=${force_rebuild:-0} - if [ "$force_rebuild" != "0" ] && [ "$force_rebuild" != "1" ];then + if [[ "$force_rebuild" != "0" ]] && [[ "$force_rebuild" != "1" ]];then derror "Error: force_rebuild value is invalid" return 1 fi @@ -583,37 +583,37 @@ check_rebuild() fi # Will not rebuild kdump initrd - if [ "$force_no_rebuild" == "1" ]; then + if [[ "$force_no_rebuild" == "1" ]]; then return 0 fi #check to see if dependent files has been modified #since last build of the image file - if [ -f $TARGET_INITRD ]; then + if [[ -f $TARGET_INITRD ]]; then image_time=$(stat -c "%Y" $TARGET_INITRD 2>/dev/null) #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability - if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then + if [[ "$DEFAULT_DUMP_MODE" == "fadump" ]]; then capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$) fi fi check_system_modified ret=$? - if [ $ret -eq 2 ]; then + if [[ $ret -eq 2 ]]; then return 1 - elif [ $ret -eq 1 ];then + elif [[ $ret -eq 1 ]];then system_modified="1" fi - if [ $image_time -eq 0 ]; then + if [[ $image_time -eq 0 ]]; then dinfo "No kdump initial ramdisk found." - elif [ "$capture_capable_initrd" == "0" ]; then + elif [[ "$capture_capable_initrd" == "0" ]]; then dinfo "Rebuild $TARGET_INITRD with dump capture support" - elif [ "$force_rebuild" != "0" ]; then + elif [[ "$force_rebuild" != "0" ]]; then dinfo "Force rebuild $TARGET_INITRD" - elif [ "$system_modified" != "0" ]; then + elif [[ "$system_modified" != "0" ]]; then : else return 0 @@ -633,7 +633,7 @@ function load_kdump_kernel_key() # this is only required if DT /ibm,secure-boot is a file. # if it is a dir, we are on OpenPower and don't need this. - if ! [ -f /proc/device-tree/ibm,secure-boot ]; then + if ! [[ -f /proc/device-tree/ibm,secure-boot ]]; then return fi @@ -645,7 +645,7 @@ function load_kdump_kernel_key() # to be idempotent and so as to reduce the potential for confusion. function remove_kdump_kernel_key() { - if [ -z "$KDUMP_KEY_ID" ]; then + if [[ -z "$KDUMP_KEY_ID" ]]; then return fi @@ -692,7 +692,7 @@ load_kdump() remove_kdump_kernel_key - if [ $ret == 0 ]; then + if [[ $ret == 0 ]]; then dinfo "kexec: loaded kdump kernel" return 0 else @@ -707,7 +707,7 @@ check_ssh_config() case "$config_opt" in sshkey) # remove inline comments after the end of a directive. - if [ -f "$config_val" ]; then + if [[ -f "$config_val" ]]; then # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m $config_val) else @@ -727,7 +727,7 @@ check_ssh_config() #make sure they've configured kdump.conf for ssh dumps local SSH_TARGET=$(echo -n $DUMP_TARGET | sed -n '/.*@/p') - if [ -z "$SSH_TARGET" ]; then + if [[ -z "$SSH_TARGET" ]]; then return 1 fi return 0 @@ -750,9 +750,9 @@ check_and_wait_network_ready() retval=$? # ssh exits with the exit status of the remote command or with 255 if an error occurred - if [ $retval -eq 0 ]; then + if [[ $retval -eq 0 ]]; then return 0 - elif [ $retval -ne 255 ]; then + elif [[ $retval -ne 255 ]]; then derror "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" return 1 fi @@ -760,12 +760,12 @@ check_and_wait_network_ready() # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" return 1 fi - if [ $warn_once -eq 1 ]; then + if [[ $warn_once -eq 1 ]]; then dwarn "Network dump target is not usable, waiting for it to be ready..." warn_once=0 fi @@ -773,7 +773,7 @@ check_and_wait_network_ready() cur=$(date +%s) diff=$((cur - start_time)) # 60s time out - if [ $diff -gt 180 ]; then + if [[ $diff -gt 180 ]]; then break; fi sleep 1 @@ -786,7 +786,7 @@ check_and_wait_network_ready() check_ssh_target() { check_and_wait_network_ready - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then return 1 fi return 0 @@ -795,7 +795,7 @@ check_ssh_target() propagate_ssh_key() { check_ssh_config - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate" exit 1 fi @@ -804,7 +804,7 @@ propagate_ssh_key() local errmsg="Failed to propagate ssh key" #Check to see if we already created key, if not, create it. - if [ -f $KEYFILE ]; then + if [[ -f $KEYFILE ]]; then dinfo "Using existing keys..." else dinfo "Generating new ssh keys... " @@ -819,7 +819,7 @@ propagate_ssh_key() #now send the found key to the found server ssh-copy-id -i $KEYFILE $SSH_USER@$SSH_SERVER RET=$? - if [ $RET == 0 ]; then + if [[ $RET == 0 ]]; then dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER" return 0 else @@ -843,13 +843,13 @@ check_current_fadump_status() { # Check if firmware-assisted dump has been registered. rc=$(<$FADUMP_REGISTER_SYS_NODE) - [ $rc -eq 1 ] && return 0 + [[ $rc -eq 1 ]] && return 0 return 1 } check_current_status() { - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then check_current_fadump_status else check_current_kdump_status @@ -864,8 +864,8 @@ save_raw() local raw_target raw_target=$(kdump_get_conf_val raw) - [ -z "$raw_target" ] && return 0 - [ -b "$raw_target" ] || { + [[ -z "$raw_target" ]] && return 0 + [[ -b "$raw_target" ]] || { derror "raw partition $raw_target not found" return 1 } @@ -875,14 +875,14 @@ save_raw() return 0 fi kdump_dir=$(kdump_get_conf_val path) - if [ -z "${kdump_dir}" ]; then + if [[ -z "${kdump_dir}" ]]; then coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" else coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")" fi mkdir -p "$coredir" - [ -d "$coredir" ] || { + [[ -d "$coredir" ]] || { derror "failed to create $coredir" return 1 } @@ -903,7 +903,7 @@ local_fs_dump_target() local _target _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf) - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then echo $_target|awk '{print $2}' fi } @@ -931,7 +931,7 @@ path_to_be_relabeled() _path=$(get_save_path) # if $_path is masked by other mount, we will not relabel it. _rmnt=$(df $_mnt/$_path 2>/dev/null | tail -1 | awk '{ print $NF }') - if [ "$_rmnt" == "$_mnt" ]; then + if [[ "$_rmnt" == "$_mnt" ]]; then echo $_mnt/$_path fi } @@ -941,13 +941,13 @@ selinux_relabel() local _path _i _attr _path=$(path_to_be_relabeled) - if [ -z "$_path" ] || ! [ -d "$_path" ] ; then + if [[ -z "$_path" ]] || ! [[ -d "$_path" ]] ; then return fi while IFS= read -r -d '' _i; do _attr=$(getfattr -m "security.selinux" "$_i" 2>/dev/null) - if [ -z "$_attr" ]; then + if [[ -z "$_attr" ]]; then restorecon "$_i"; fi done < <(find "$_path" -print0) @@ -960,13 +960,13 @@ check_fence_kdump_config() local nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in $nodes; do - if [ "$node" = "$hostname" ]; then + if [[ "$node" = "$hostname" ]]; then derror "Option fence_kdump_nodes cannot contain $hostname" return 1 fi # node can be ipaddr echo "$ipaddrs " | grep -q "$node " - if [ $? -eq 0 ]; then + if [[ $? -eq 0 ]]; then derror "Option fence_kdump_nodes cannot contain $node" return 1 fi @@ -977,7 +977,7 @@ check_fence_kdump_config() check_dump_feasibility() { - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then return 0 fi @@ -999,7 +999,7 @@ start_fadump() start_dump() { - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then start_fadump else load_kdump @@ -1017,14 +1017,14 @@ check_failure_action_config() default_option=$(kdump_get_conf_val default) failure_action=$(kdump_get_conf_val failure_action) - if [ -z "$failure_action" -a -z "$default_option" ]; then + if [[ -z "$failure_action" ]] && [[ -z "$default_option" ]]; then return 0 - elif [ -n "$failure_action" -a -n "$default_option" ]; then + elif [[ -n "$failure_action" ]] && [[ -n "$default_option" ]]; then derror "Cannot specify 'failure_action' and 'default' option together" return 1 fi - if [ -n "$default_option" ]; then + if [[ -n "$default_option" ]]; then option="default" failure_action="$default_option" fi @@ -1044,7 +1044,7 @@ check_final_action_config() local final_action final_action=$(kdump_get_conf_val final_action) - if [ -z "$final_action" ]; then + if [[ -z "$final_action" ]]; then return 0 else case "$final_action" in @@ -1061,13 +1061,13 @@ check_final_action_config() start() { check_dump_feasibility - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi check_config - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1077,13 +1077,13 @@ start() fi save_raw - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi check_current_status - if [ $? == 0 ]; then + if [[ $? == 0 ]]; then dwarn "Kdump already running: [WARNING]" return 0 fi @@ -1096,13 +1096,13 @@ start() fi check_rebuild - if [ $? != 0 ]; then + if [[ $? != 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi start_dump - if [ $? != 0 ]; then + if [[ $? != 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1113,18 +1113,18 @@ start() reload() { check_current_status - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then dwarn "Kdump was not running: [WARNING]" fi - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then reload_fadump return $? else stop_kdump fi - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Stopping kdump: [FAILED]" return 1 fi @@ -1132,13 +1132,13 @@ reload() dinfo "Stopping kdump: [OK]" setup_initrd - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi start_dump - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1166,7 +1166,7 @@ stop_kdump() $KEXEC -p -u fi - if [ $? != 0 ]; then + if [[ $? != 0 ]]; then derror "kexec: failed to unload kdump kernel" return 1 fi @@ -1178,7 +1178,7 @@ stop_kdump() reload_fadump() { echo 1 > $FADUMP_REGISTER_SYS_NODE - if [ $? == 0 ]; then + if [[ $? == 0 ]]; then dinfo "fadump: re-registered successfully" return 0 else @@ -1186,7 +1186,7 @@ reload_fadump() # support is not enabled. Try stop/start from userspace # to handle such scenario. stop_fadump - if [ $? == 0 ]; then + if [[ $? == 0 ]]; then start_fadump return $? fi @@ -1197,13 +1197,13 @@ reload_fadump() stop() { - if [ $DEFAULT_DUMP_MODE == "fadump" ]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then stop_fadump else stop_kdump fi - if [ $? != 0 ]; then + if [[ $? != 0 ]]; then derror "Stopping kdump: [FAILED]" return 1 fi @@ -1214,7 +1214,7 @@ stop() rebuild() { check_config - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then return 1 fi @@ -1225,7 +1225,7 @@ rebuild() { fi setup_initrd - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then return 1 fi @@ -1242,7 +1242,7 @@ do_estimate() { local size_mb=$(( 1024 * 1024 )) setup_initrd - if [ ! -f "$TARGET_INITRD" ]; then + if [[ ! -f "$TARGET_INITRD" ]]; then derror "kdumpctl estimate: kdump initramfs is not built yet." exit 1 fi @@ -1359,7 +1359,7 @@ reset_crashkernel() { fi } -if [ ! -f "$KDUMP_CONFIG_FILE" ]; then +if [[ ! -f "$KDUMP_CONFIG_FILE" ]]; then derror "Error: No kdump config file found!" exit 1 fi @@ -1371,7 +1371,7 @@ main () case "$1" in start) - if [ -s /proc/vmcore ]; then + if [[ -s /proc/vmcore ]]; then save_core reboot else diff --git a/mkdumprd b/mkdumprd index 6621e30..3101d3f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -6,7 +6,7 @@ # Written by Cong Wang # -if [ -f /etc/sysconfig/kdump ]; then +if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -18,7 +18,7 @@ export IN_KDUMP=1 #initiate the kdump logger dlog_init -if [ $? -ne 0 ]; then +if [[ $? -ne 0 ]]; then echo "failed to initiate the kdump logger." exit 1 fi @@ -73,7 +73,7 @@ to_mount() { else # for non-nfs _target converting to use udev persistent name _pdev="$(kdump_get_persistent_dev $_target)" - if [ -z "$_pdev" ]; then + if [[ -z "$_pdev" ]]; then return 1 fi fi @@ -116,14 +116,14 @@ mkdir_save_path_ssh() _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) ssh -qn "${_opt[@]}" $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null _ret=$? - if [ $_ret -ne 0 ]; then + if [[ $_ret -ne 0 ]]; then perror_exit "mkdir failed on $1:$SAVE_PATH" fi #check whether user has write permission on $1:$SAVE_PATH _dir=$(ssh -qn "${_opt[@]}" $1 mktemp -dqp $SAVE_PATH 2>/dev/null) _ret=$? - if [ $_ret -ne 0 ]; then + if [[ $_ret -ne 0 ]]; then perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" fi ssh -qn "${_opt[@]}" $1 rmdir $_dir @@ -164,11 +164,11 @@ check_size() { return esac - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then perror_exit "Check dump target size failed" fi - if [ $avail -lt $memtotal ]; then + if [[ $avail -lt $memtotal ]]; then dwarn "Warning: There might not be enough space to save a vmcore." dwarn " The size of $2 should be greater than $memtotal kilo bytes." fi @@ -178,7 +178,7 @@ check_save_path_fs() { local _path=$1 - if [ ! -d $_path ]; then + if [[ ! -d $_path ]]; then perror_exit "Dump path $_path does not exist." fi } @@ -190,7 +190,7 @@ mount_failure() local _fstype=$3 local msg="Failed to mount $_target" - if [ -n "$_mnt" ]; then + if [[ -n "$_mnt" ]]; then msg="$msg on $_mnt" fi @@ -210,11 +210,11 @@ check_user_configured_target() local _opt=$(get_mntopt_from_target $_target) local _fstype=$(get_fs_type_from_target $_target) - if [ -n "$_fstype" ]; then + if [[ -n "$_fstype" ]]; then # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf [[ $_fstype = "nfs"* ]] && _fstype=nfs - if [ -n "$_cfg_fs_type" ] && [ "$_fstype" != "$_cfg_fs_type" ]; then + if [[ -n "$_cfg_fs_type" ]] && [[ "$_fstype" != "$_cfg_fs_type" ]]; then perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\"" fi else @@ -224,11 +224,11 @@ check_user_configured_target() # For noauto mount, mount it inplace with default value. # Else use the temporary target directory - if [ -n "$_mnt" ]; then + if [[ -n "$_mnt" ]]; then if ! is_mounted "$_mnt"; then if [[ $_opt = *",noauto"* ]]; then mount $_mnt - [ $? -ne 0 ] && mount_failure "$_target" "$_mnt" "$_fstype" + [[ $? -ne 0 ]] && mount_failure "$_target" "$_mnt" "$_fstype" _mounted=$_mnt else perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" @@ -238,19 +238,19 @@ check_user_configured_target() _mnt=$MKDUMPRD_TMPMNT mkdir -p $_mnt mount $_target $_mnt -t $_fstype -o defaults - [ $? -ne 0 ] && mount_failure "$_target" "" "$_fstype" + [[ $? -ne 0 ]] && mount_failure "$_target" "" "$_fstype" _mounted=$_mnt fi # For user configured target, use $SAVE_PATH as the dump path within the target - if [ ! -d "$_mnt/$SAVE_PATH" ]; then + if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\"" fi check_size fs "$_target" # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway - if [ -n "$_mounted" ]; then + if [[ -n "$_mounted" ]]; then umount -f -- $_mounted fi } @@ -260,7 +260,7 @@ verify_core_collector() { local _cmd="${1%% *}" local _params="${1#* }" - if [ "$_cmd" != "makedumpfile" ]; then + if [[ "$_cmd" != "makedumpfile" ]]; then if is_raw_dump_target; then dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." fi @@ -284,7 +284,7 @@ verify_core_collector() { add_mount() { local _mnt=$(to_mount $@) - if [ $? -ne 0 ]; then + if [[ $? -ne 0 ]]; then exit 1 fi @@ -316,7 +316,7 @@ for_each_block_target() local dev majmin for dev in $(get_kdump_targets); do - [ -b "$dev" ] || continue + [[ -b "$dev" ]] || continue majmin=$(get_maj_min $dev) check_block_and_slaves $1 $majmin && return 1 done @@ -331,10 +331,10 @@ is_unresettable() local path="/sys/$(udevadm info --query=all --path=/sys/dev/block/$1 | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" local resettable=1 - if [ -f "$path" ] + if [[ -f "$path" ]] then resettable="$(<"$path")" - [ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && { + [[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && { local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}') derror "Error: Can not save vmcore because device $device is unresettable" return 0 @@ -359,7 +359,7 @@ check_resettable() for_each_block_target is_unresettable _ret=$? - [ $_ret -eq 0 ] && return + [[ $_ret -eq 0 ]] && return return 1 } @@ -385,7 +385,7 @@ fi # firstly get right SSH_KEY_LOCATION keyfile=$(kdump_get_conf_val sshkey) -if [ -f "$keyfile" ]; then +if [[ -f "$keyfile" ]]; then # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) fi @@ -407,7 +407,7 @@ do perror_exit "Bad raw disk $config_val" } _praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val) - if [ -z "$_praw" ]; then + if [[ -z "$_praw" ]]; then exit 1 fi add_dracut_arg "--device" "$_praw" @@ -438,7 +438,7 @@ done <<< "$(kdump_read_conf)" handle_default_dump_target -if [ -n "$extra_modules" ] +if [[ -n "$extra_modules" ]] then add_dracut_arg "--add-drivers" "$extra_modules" fi diff --git a/mkfadumprd b/mkfadumprd index 5c87933..ca9f362 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -2,7 +2,7 @@ # Generate an initramfs image that isolates dump capture capability within # the default initramfs using zz-fadumpinit dracut module. -if [ -f /etc/sysconfig/kdump ]; then +if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi From 86538ca6e2e555caa8cdd2bcfcc3c5e94ac6bf58 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 17:21:41 +0800 Subject: [PATCH 475/806] bash scripts: fix variable quoting issue Fixed quoting issues found by shellcheck, no feature change. This should fix many errors when there is space in any shell variables, eg. dump target's name/path/id. False positives are marked with "# shellcheck disable=SCXXXX", for example, args are expected to split so it should not be quoted. And replaced some `cut -d ' ' -fX` with `awk '{print $X}'` since cut is fragile, and doesn't work well with any quoted strings that have redundant space. Following quoting related issues are fixed (check the link for example code and what could go wrong): https://github.com/koalaman/shellcheck/wiki/SC2046 https://github.com/koalaman/shellcheck/wiki/SC2053 https://github.com/koalaman/shellcheck/wiki/SC2068 https://github.com/koalaman/shellcheck/wiki/SC2086 https://github.com/koalaman/shellcheck/wiki/SC2206 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-early-kdump-module-setup.sh | 2 +- dracut-module-setup.sh | 261 +++++++++++++++-------------- kdumpctl | 104 ++++++------ mkdumprd | 69 ++++---- 4 files changed, 220 insertions(+), 216 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 00546e0..83e067c 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -25,7 +25,7 @@ prepare_kernel_initrd() { prepare_kdump_bootinfo # $kernel is a variable from dracut - if [[ "$KDUMP_KERNELVER" != $kernel ]]; then + if [[ "$KDUMP_KERNELVER" != "$kernel" ]]; then dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ "but the initramfs is generated for kernel version '$kernel'" fi diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 515cff0..07a96e5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -53,7 +53,7 @@ depends() { _dep="$_dep network" fi - echo $_dep + echo "$_dep" } kdump_is_bridge() { @@ -65,7 +65,7 @@ kdump_is_bond() { } kdump_is_team() { - [[ -f /usr/bin/teamnl ]] && teamnl $1 ports &> /dev/null + [[ -f /usr/bin/teamnl ]] && teamnl "$1" ports &> /dev/null } kdump_is_vlan() { @@ -77,9 +77,9 @@ source_ifcfg_file() { local ifcfg_file dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." - ifcfg_file=$(get_ifcfg_filename $1) + ifcfg_file=$(get_ifcfg_filename "$1") if [[ -f "${ifcfg_file}" ]]; then - . ${ifcfg_file} + . "${ifcfg_file}" else dwarning "The ifcfg file of $1 is not found!" fi @@ -93,7 +93,8 @@ kdump_setup_dns() { local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") - array=(${_tmp//|/ }) + # shellcheck disable=SC2206 + array=( ${_tmp//|/ } ) if [[ ${array[*]} ]]; then for _dns in "${array[@]}" do @@ -108,10 +109,10 @@ kdump_setup_dns() { while read -r content; do - _nameserver=$(echo $content | grep ^nameserver) + _nameserver=$(echo "$content" | grep ^nameserver) [[ -z "$_nameserver" ]] && continue - _dns=$(echo $_nameserver | cut -d' ' -f2) + _dns=$(echo "$_nameserver" | awk '{print $2}') [[ -z "$_dns" ]] && continue if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile" ; then @@ -237,14 +238,14 @@ kdump_static_ip() { local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag local _netmask _gateway _ipaddr _target _nexthop _prefix - _ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}") + _ipaddr=$(ip addr show dev "$_netdev" permanent | awk "/ $_srcaddr\/.* /{print \$2}") - if is_ipv6_address $_srcaddr; then + if is_ipv6_address "$_srcaddr"; then _ipv6_flag="-6" fi if [[ -n "$_ipaddr" ]]; then - _gateway=$(ip $_ipv6_flag route list dev $_netdev | \ + _gateway=$(ip $_ipv6_flag route list dev "$_netdev" | \ awk '/^default /{print $3}' | head -n 1) if [[ "x" != "x"$_ipv6_flag ]]; then @@ -266,23 +267,23 @@ kdump_static_ip() { /sbin/ip $_ipv6_flag route show | grep -v default |\ grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ while read -r _route; do - _target=$(echo $_route | cut -d ' ' -f1) - _nexthop=$(echo $_route | cut -d ' ' -f3) + _target=$(echo "$_route" | awk '{print $1}') + _nexthop=$(echo "$_route" | awk '{print $3}') if [[ "x" != "x"$_ipv6_flag ]]; then _target="[$_target]" _nexthop="[$_nexthop]" fi echo "rd.route=$_target:$_nexthop:$kdumpnic" - done >> ${initdir}/etc/cmdline.d/45route-static.conf + done >> "${initdir}/etc/cmdline.d/45route-static.conf" - kdump_handle_mulitpath_route $_netdev $_srcaddr $kdumpnic + kdump_handle_mulitpath_route "$_netdev" "$_srcaddr" "$kdumpnic" } kdump_handle_mulitpath_route() { local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag local _target _nexthop _route _weight _max_weight _rule - if is_ipv6_address $_srcaddr; then + if is_ipv6_address "$_srcaddr"; then _ipv6_flag="-6" fi @@ -308,20 +309,20 @@ kdump_handle_mulitpath_route() { _target=$(echo "$_route" | cut -d ' ' -f1) _rule="" _max_weight=0 _weight=0 fi - done >> ${initdir}/etc/cmdline.d/45route-static.conf\ + done >> "${initdir}/etc/cmdline.d/45route-static.conf"\ <<< "$(/sbin/ip $_ipv6_flag route show)" - [[ -n $_rule ]] && echo $_rule >> ${initdir}/etc/cmdline.d/45route-static.conf + [[ -n $_rule ]] && echo "$_rule" >> "${initdir}/etc/cmdline.d/45route-static.conf" } kdump_get_mac_addr() { - cat /sys/class/net/$1/address + cat "/sys/class/net/$1/address" } #Bonding or team master modifies the mac address #of its slaves, we should use perm address kdump_get_perm_addr() { - local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //') + local addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') if [[ -z "$addr" ]] || [[ "$addr" = "00:00:00:00:00:00" ]] then derror "Can't get the permanent address of $1" @@ -367,9 +368,9 @@ kdump_setup_bridge() { elif kdump_is_vlan "$_dev"; then kdump_setup_vlan "$_dev" else - _mac=$(kdump_get_mac_addr $_dev) - _kdumpdev=$(kdump_setup_ifname $_dev) - echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf + _mac=$(kdump_get_mac_addr "$_dev") + _kdumpdev=$(kdump_setup_ifname "$_dev") + echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/41bridge.conf" fi _brif+="$_kdumpdev," done @@ -383,10 +384,10 @@ kdump_setup_bond() { local _netdev="$1" local _nm_show_cmd="$2" local _dev _mac _slaves _kdumpdev _bondoptions - for _dev in $(cat /sys/class/net/$_netdev/bonding/slaves); do - _mac=$(kdump_get_perm_addr $_dev) - _kdumpdev=$(kdump_setup_ifname $_dev) - echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf + for _dev in $(cat "/sys/class/net/$_netdev/bonding/slaves"); do + _mac=$(kdump_get_perm_addr "$_dev") + _kdumpdev=$(kdump_setup_ifname "$_dev") + echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/42bond.conf" _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf" @@ -395,8 +396,8 @@ kdump_setup_bond() { if [[ -z "$_bondoptions" ]]; then dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file $_netdev - _bondoptions="$(echo $BONDING_OPTS | xargs echo | tr " " ",")" + source_ifcfg_file "$_netdev" + _bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")" fi if [[ -z "$_bondoptions" ]]; then @@ -404,36 +405,36 @@ kdump_setup_bond() { exit 1 fi - echo ":$_bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf + echo ":$_bondoptions" >> "${initdir}/etc/cmdline.d/42bond.conf" } kdump_setup_team() { local _netdev=$1 local _dev _mac _slaves _kdumpdev - for _dev in $(teamnl $_netdev ports | awk -F':' '{print $2}'); do - _mac=$(kdump_get_perm_addr $_dev) - _kdumpdev=$(kdump_setup_ifname $_dev) - echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf + for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do + _mac=$(kdump_get_perm_addr "$_dev") + _kdumpdev=$(kdump_setup_ifname "$_dev") + echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf" _slaves+="$_kdumpdev," done echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf" #Buggy version teamdctl outputs to stderr! #Try to use the latest version of teamd. - teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf + teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf" if [[ $? -ne 0 ]] then derror "teamdctl failed." exit 1 fi inst_dir /etc/teamd - inst_simple ${initdir}/tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf" - rm -f ${initdir}/tmp/$$-$_netdev.conf + inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf" + rm -f "${initdir}/tmp/$$-$_netdev.conf" } kdump_setup_vlan() { local _netdev=$1 local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" - local _netmac="$(kdump_get_mac_addr $_phydev)" + local _netmac="$(kdump_get_mac_addr "$_phydev")" local _kdumpdev #Just support vlan over bond and team @@ -445,10 +446,10 @@ kdump_setup_vlan() { if [[ $? != 0 ]]; then exit 1 fi - echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf + echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else - _kdumpdev="$(kdump_setup_ifname $_phydev)" - echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf + _kdumpdev="$(kdump_setup_ifname "$_phydev")" + echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf" fi } @@ -465,7 +466,7 @@ find_online_znet_device() { for d in $NETWORK_DEVICES do [[ ! -f "$d/online" ]] && continue - read -r ONLINE < $d/online + read -r ONLINE < "$d/online" if [[ $ONLINE -ne 1 ]]; then continue fi @@ -473,10 +474,10 @@ find_online_znet_device() { # device is online) if [[ -f $d/if_name ]] then - read -r ifname < $d/if_name + read -r ifname < "$d/if_name" elif [[ -d $d/net ]] then - ifname=$(ls $d/net/) + ifname=$(ls "$d/net/") fi [[ -n "$ifname" ]] && break done @@ -500,7 +501,7 @@ kdump_setup_znet() { if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file $_netdev + source_ifcfg_file "$_netdev" for i in $OPTIONS; do _options=${_options},$i done @@ -510,17 +511,17 @@ kdump_setup_znet() { exit 1 fi - echo rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf + echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" } kdump_get_ip_route() { - local _route=$(/sbin/ip -o route get to $1 2>&1) + local _route=$(/sbin/ip -o route get to "$1" 2>&1) if [[ $? != 0 ]]; then derror "Bad kdump network destination: $1" exit 1 fi - echo $_route + echo "$_route" } kdump_get_ip_route_field() @@ -530,15 +531,15 @@ kdump_get_ip_route_field() kdump_get_remote_ip() { - local _remote=$(get_remote_host $1) _remote_temp - if is_hostname $_remote; then - _remote_temp=$(getent ahosts $_remote | grep -v : | head -n 1) + local _remote=$(get_remote_host "$1") _remote_temp + if is_hostname "$_remote"; then + _remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1) if [[ -z "$_remote_temp" ]]; then - _remote_temp=$(getent ahosts $_remote | head -n 1) + _remote_temp=$(getent ahosts "$_remote" | head -n 1) fi - _remote=$(echo $_remote_temp | cut -d' ' -f1) + _remote=$(echo "$_remote_temp" | awk '{print $1}') fi - echo $_remote + echo "$_remote" } # Setup dracut to bring up network interface that enable @@ -549,13 +550,13 @@ kdump_install_net() { local _static _proto _ip_conf _ip_opts _ifname_opts local _znet_netdev _nm_show_cmd_znet - _destaddr=$(kdump_get_remote_ip $1) - _route=$(kdump_get_ip_route $_destaddr) + _destaddr=$(kdump_get_remote_ip "$1") + _route=$(kdump_get_ip_route "$_destaddr") _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") _nm_show_cmd=$(get_nmcli_connection_show_cmd_by_ifname "$_netdev") - _netmac=$(kdump_get_mac_addr $_netdev) - kdumpnic=$(kdump_setup_ifname $_netdev) + _netmac=$(kdump_get_mac_addr "$_netdev") + kdumpnic=$(kdump_setup_ifname "$_netdev") _znet_netdev=$(find_online_znet_device) if [[ -n "$_znet_netdev" ]]; then @@ -567,10 +568,10 @@ kdump_install_net() { fi fi - _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) + _static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic") if [[ -n "$_static" ]]; then _proto=none - elif is_ipv6_address $_srcaddr; then + elif is_ipv6_address "$_srcaddr"; then _proto=auto6 else _proto=dhcp @@ -583,9 +584,9 @@ kdump_install_net() { # so we have to avoid adding duplicates # We should also check /proc/cmdline for existing ip=xx arg. # For example, iscsi boot will specify ip=xxx arg in cmdline. - if [[ ! -f $_ip_conf ]] || ! grep -q $_ip_opts $_ip_conf &&\ + if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then - echo "$_ip_opts" >> $_ip_conf + echo "$_ip_opts" >> "$_ip_conf" fi if kdump_is_bridge "$_netdev"; then @@ -601,14 +602,14 @@ kdump_install_net() { kdump_setup_vlan "$_netdev" else _ifname_opts=" ifname=$kdumpnic:$_netmac" - echo "$_ifname_opts" >> $_ip_conf + echo "$_ifname_opts" >> "$_ip_conf" fi kdump_setup_dns "$_netdev" "$_nm_show_cmd" if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then # network-manager module needs this parameter - echo "rd.neednet" >> ${initdir}/etc/cmdline.d/50neednet.conf + echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi # Save netdev used for kdump as cmdline @@ -620,8 +621,8 @@ kdump_install_net() { # gateway. if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] && [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then - echo "kdumpnic=$kdumpnic" > ${initdir}/etc/cmdline.d/60kdumpnic.conf - echo "bootdev=$kdumpnic" > ${initdir}/etc/cmdline.d/70bootdev.conf + echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" + echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf" fi } @@ -630,7 +631,7 @@ kdump_install_pre_post_conf() { if [[ -d /etc/kdump/pre.d ]]; then for file in /etc/kdump/pre.d/*; do if [[ -x "$file" ]]; then - dracut_install $file + dracut_install "$file" elif [[ $file != "/etc/kdump/pre.d/*" ]]; then echo "$file is not executable" fi @@ -640,7 +641,7 @@ kdump_install_pre_post_conf() { if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do if [[ -x "$file" ]]; then - dracut_install $file + dracut_install "$file" elif [[ $file != "/etc/kdump/post.d/*" ]]; then echo "$file is not executable" fi @@ -655,19 +656,19 @@ default_dump_target_install_conf() is_user_configured_dump_target && return - _save_path=$(get_bind_mount_source $(get_save_path)) - _target=$(get_target_from_path $_save_path) - _mntpoint=$(get_mntpoint_from_target $_target) + _save_path=$(get_bind_mount_source "$(get_save_path)") + _target=$(get_target_from_path "$_save_path") + _mntpoint=$(get_mntpoint_from_target "$_target") - _fstype=$(get_fs_type_from_target $_target) - if is_fs_type_nfs $_fstype; then + _fstype=$(get_fs_type_from_target "$_target") + if is_fs_type_nfs "$_fstype"; then kdump_install_net "$_target" _fstype="nfs" else - _target=$(kdump_get_persistent_dev $_target) + _target=$(kdump_get_persistent_dev "$_target") fi - echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf + echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf" # don't touch the path under root mount if [[ "$_mntpoint" != "/" ]]; then @@ -675,8 +676,8 @@ default_dump_target_install_conf() fi #erase the old path line, then insert the parsed path - sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf - echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf + sed -i "/^path/d" "${initdir}/tmp/$$-kdump.conf" + echo "path $_save_path" >> "${initdir}/tmp/$$-kdump.conf" } #install kdump.conf and what user specifies in kdump.conf @@ -690,12 +691,12 @@ kdump_install_conf() { # remove inline comments after the end of a directive. case "$_opt" in raw) - _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val) - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf + _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val") + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" ;; ext[234]|xfs|btrfs|minix) - _pdev=$(kdump_get_persistent_dev $_val) - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf + _pdev=$(kdump_get_persistent_dev "$_val") + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" ;; ssh|nfs) kdump_install_net "$_val" @@ -706,7 +707,7 @@ kdump_install_conf() { fi ;; kdump_pre|kdump_post|extra_bins) - dracut_install $_val + dracut_install "$_val" ;; core_collector) dracut_install "${_val%%[[:blank:]]*}" @@ -720,7 +721,7 @@ kdump_install_conf() { kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf" - rm -f ${initdir}/tmp/$$-kdump.conf + rm -f "${initdir}/tmp/$$-kdump.conf" } # Default sysctl parameters should suffice for kdump kernel. @@ -742,9 +743,9 @@ kdump_iscsi_get_rec_val() { # The open-iscsi 742 release changed to using flat files in # /var/lib/iscsi. - result=$(/sbin/iscsiadm --show -m session -r ${1} | grep "^${2} = ") + result=$(/sbin/iscsiadm --show -m session -r "$1" | grep "^${2} = ") result=${result##* = } - echo $result + echo "$result" } kdump_get_iscsi_initiator() { @@ -770,7 +771,7 @@ kdump_get_iscsi_initiator() { # Figure out iBFT session according to session type is_ibft() { - [[ "$(kdump_iscsi_get_rec_val $1 "node.discovery_type")" = fw ]] + [[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" = fw ]] } kdump_setup_iscsi_device() { @@ -786,32 +787,32 @@ kdump_setup_iscsi_device() { # Check once before getting explicit values, so we can bail out early, # e.g. in case of pure-hardware(all-offload) iscsi. - if ! /sbin/iscsiadm -m session -r ${path} &>/dev/null ; then + if ! /sbin/iscsiadm -m session -r "$path" &>/dev/null ; then return 1 fi - if is_ibft ${path}; then + if is_ibft "$path"; then return fi # Remove software iscsi cmdline generated by 95iscsi, # and let kdump regenerate here. - rm -f ${initdir}/etc/cmdline.d/95iscsi.conf + rm -f "${initdir}/etc/cmdline.d/95iscsi.conf" - tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name") - tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address") + tgt_name=$(kdump_iscsi_get_rec_val "$path" "node.name") + tgt_ipaddr=$(kdump_iscsi_get_rec_val "$path" "node.conn\[0\].address") # get and set username and password details - username=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username") + username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username") [[ "$username" == "" ]] && username="" - password=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password") + password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password") [[ "$password" == "" ]] && password="" - username_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username_in") + username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in") [[ -n "$username" ]] && userpwd_str="$username:$password" # get and set incoming username and password details [[ "$username_in" == "" ]] && username_in="" - password_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password_in") + password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in") [[ "$password_in" == "" ]] && password_in="" [[ -n "$username_in" ]] && userpwd_in_str=":$username_in:$password_in" @@ -822,16 +823,16 @@ kdump_setup_iscsi_device() { # FIXME: Do we need to parse and set other parameters like protocol, port # iscsi_iface_name, netdev_name, LUN etc. - if is_ipv6_address $tgt_ipaddr; then + if is_ipv6_address "$tgt_ipaddr"; then tgt_ipaddr="[$tgt_ipaddr]" fi netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name" - [[ -f $netroot_conf ]] || touch $netroot_conf + [[ -f $netroot_conf ]] || touch "$netroot_conf" # If netroot target does not exist already, append. - if ! grep -q $netroot_str $netroot_conf; then - echo $netroot_str >> $netroot_conf + if ! grep -q "$netroot_str" "$netroot_conf"; then + echo "$netroot_str" >> "$netroot_conf" dinfo "Appended $netroot_str to $netroot_conf" fi @@ -840,9 +841,9 @@ kdump_setup_iscsi_device() { [[ $? -ne "0" ]] && derror "Failed to get initiator name" && return 1 # If initiator details do not exist already, append. - if ! grep -q "$initiator_str" $netroot_conf; then - echo "$initiator_str" >> $netroot_conf - dinfo "Appended "$initiator_str" to $netroot_conf" + if ! grep -q "$initiator_str" "$netroot_conf"; then + echo "$initiator_str" >> "$netroot_conf" + dinfo "Appended $initiator_str to $netroot_conf" fi } @@ -877,13 +878,13 @@ get_alias() { for ip in $ips do # in /etc/hosts, alias can come at the 2nd column - entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }') + entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }') if [[ $? -eq 0 ]]; then alias_set="$alias_set $entries" fi done - echo $alias_set + echo "$alias_set" } is_localhost() { @@ -914,23 +915,23 @@ get_pcs_fence_kdump_nodes() { # we need to convert each to node1, node2 ... nodeX in each iteration for node in ${nodelist}; do # convert $node from 'uname="nodeX"' to 'nodeX' - eval $node - nodename=$uname + eval "$node" + nodename="$uname" # Skip its own node name - if is_localhost $nodename; then + if is_localhost "$nodename"; then continue fi nodes="$nodes $nodename" done - echo $nodes + echo "$nodes" } # retrieves fence_kdump args from config file get_pcs_fence_kdump_args() { if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then - . $FENCE_KDUMP_CONFIG_FILE - echo $FENCE_KDUMP_OPTS + . "$FENCE_KDUMP_CONFIG_FILE" + echo "$FENCE_KDUMP_OPTS" fi } @@ -941,12 +942,12 @@ get_generic_fence_kdump_nodes() { nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in ${nodes}; do # Skip its own node name - if is_localhost $node; then + if is_localhost "$node"; then continue fi filtered="$filtered $node" done - echo $filtered + echo "$filtered" } # setup fence_kdump in cluster @@ -963,11 +964,11 @@ kdump_configure_fence_kdump () { nodes=$(get_pcs_fence_kdump_nodes) # set appropriate options in kdump.conf - echo "fence_kdump_nodes $nodes" >> ${kdump_cfg_file} + echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}" args=$(get_pcs_fence_kdump_args) if [[ -n "$args" ]]; then - echo "fence_kdump_args $args" >> ${kdump_cfg_file} + echo "fence_kdump_args $args" >> "${kdump_cfg_file}" fi else @@ -977,12 +978,12 @@ kdump_configure_fence_kdump () { # setup network for each node for node in ${nodes}; do - kdump_install_net $node + kdump_install_net "$node" done dracut_install /etc/hosts dracut_install /etc/nsswitch.conf - dracut_install $FENCE_KDUMP_SEND + dracut_install "$FENCE_KDUMP_SEND" } # Install a random seed used to feed /dev/urandom @@ -992,32 +993,32 @@ kdump_install_random_seed() { poolsize=$( /dev/null + dd if=/dev/urandom of="${initdir}/var/lib/random-seed" \ + bs="$poolsize" count=1 2> /dev/null } kdump_install_systemd_conf() { # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. - grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null + grep -r "^[[:space:]]*DefaultTimeoutStartSec=" "${initdir}/etc/systemd/system.conf"* &>/dev/null if [[ $? -ne 0 ]]; then - mkdir -p ${initdir}/etc/systemd/system.conf.d - echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf - echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf + mkdir -p "${initdir}/etc/systemd/system.conf.d" + echo "[Manager]" > "${initdir}/etc/systemd/system.conf.d/kdump.conf" + echo "DefaultTimeoutStartSec=300s" >> "${initdir}/etc/systemd/system.conf.d/kdump.conf" fi # Forward logs to console directly, and don't read Kmsg, this avoids # unneccessary memory consumption and make console output more useful. # Only do so for non fadump image. - mkdir -p ${initdir}/etc/systemd/journald.conf.d - echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf - echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf + mkdir -p "${initdir}/etc/systemd/journald.conf.d" + echo "[Journal]" > "${initdir}/etc/systemd/journald.conf.d/kdump.conf" + echo "Storage=volatile" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" + echo "ReadKMsg=no" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" + echo "ForwardToConsole=yes" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" } install() { @@ -1030,7 +1031,7 @@ install() { fi dracut_install -o /etc/adjtime /etc/localtime inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" - chmod +x ${initdir}/kdumpscripts/monitor_dd_progress + chmod +x "${initdir}/kdumpscripts/monitor_dd_progress" inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date" @@ -1076,7 +1077,7 @@ install() { # actually does nothing. sed -i -e \ 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ - ${initdir}/etc/lvm/lvm.conf &>/dev/null + "${initdir}/etc/lvm/lvm.conf" &>/dev/null # Save more memory by dropping switch root capability dracut_no_switch_root diff --git a/kdumpctl b/kdumpctl index 11782df..ed6dc3a 100755 --- a/kdumpctl +++ b/kdumpctl @@ -78,11 +78,11 @@ save_core() { coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" - mkdir -p $coredir + mkdir -p "$coredir" ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" - cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete + cp --sparse=always /proc/vmcore "$coredir/vmcore-incomplete" if [[ $? == 0 ]]; then - mv $coredir/vmcore-incomplete $coredir/vmcore + mv "$coredir/vmcore-incomplete" "$coredir/vmcore" dinfo "saved a vmcore to $coredir" else derror "failed to save a vmcore to $coredir" @@ -93,9 +93,9 @@ save_core() # https://fedorahosted.org/abrt/ if [[ -x /usr/bin/dumpoops ]]; then ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" - makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg >/dev/null 2>&1 + makedumpfile --dump-dmesg "$coredir/vmcore" "$coredir/dmesg" >/dev/null 2>&1 ddebug "dumpoops -d $coredir/dmesg" - dumpoops -d $coredir/dmesg >/dev/null 2>&1 + dumpoops -d "$coredir/dmesg" >/dev/null 2>&1 if [[ $? == 0 ]]; then dinfo "kernel oops has been collected by abrt tool" fi @@ -121,7 +121,7 @@ check_earlykdump_is_enabled() rebuild_kdump_initrd() { ddebug "rebuild kdump initrd: $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER" - $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER + $MKDUMPRD "$TARGET_INITRD" "$KDUMP_KERNELVER" if [[ $? != 0 ]]; then derror "mkdumprd: failed to make kdump initrd" return 1 @@ -136,8 +136,8 @@ rebuild_kdump_initrd() rebuild_initrd() { - if [[ ! -w $(dirname $TARGET_INITRD) ]];then - derror "$(dirname $TARGET_INITRD) does not have write permission. Cannot rebuild $TARGET_INITRD" + if [[ ! -w $(dirname "$TARGET_INITRD") ]];then + derror "$(dirname "$TARGET_INITRD") does not have write permission. Cannot rebuild $TARGET_INITRD" return 1 fi @@ -183,11 +183,11 @@ backup_default_initrd() if [[ ! -e $DEFAULT_INITRD_BAK ]]; then dinfo "Backing up $DEFAULT_INITRD before rebuild." # save checksum to verify before restoring - sha1sum $DEFAULT_INITRD > $INITRD_CHECKSUM_LOCATION - cp $DEFAULT_INITRD $DEFAULT_INITRD_BAK + sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION" + cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK" if [[ $? -ne 0 ]]; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." - rm -f $DEFAULT_INITRD_BAK + rm -f "$DEFAULT_INITRD_BAK" fi fi } @@ -210,7 +210,7 @@ restore_default_initrd() dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else rm -f $INITRD_CHECKSUM_LOCATION - mv $DEFAULT_INITRD_BAK $DEFAULT_INITRD + mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD" if [[ $? -eq 0 ]]; then derror "Restoring original initrd as fadump mode is disabled." sync @@ -226,7 +226,7 @@ check_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then - if [[ $(echo $config_val | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then + if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then derror "Multiple mount targets specified in one \"dracut_args\"." return 1 fi @@ -297,13 +297,13 @@ get_pcs_cluster_modified_files() fi if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then - time_stamp=$(stat -c "%Y" $FENCE_KDUMP_CONFIG_FILE) + time_stamp=$(stat -c "%Y" "$FENCE_KDUMP_CONFIG_FILE") if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" fi fi - echo $modified_files + echo "$modified_files" } setup_initrd() @@ -314,7 +314,7 @@ setup_initrd() return 1 fi - DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename $DEFAULT_INITRD).default" + DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename "$DEFAULT_INITRD").default" if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then TARGET_INITRD="$DEFAULT_INITRD" @@ -357,7 +357,7 @@ check_files_modified() fi HOOKS="$HOOKS $POST_FILES $PRE_FILES" CORE_COLLECTOR=$(kdump_get_conf_val core_collector | awk '{print $1}') - CORE_COLLECTOR=$(type -P $CORE_COLLECTOR) + CORE_COLLECTOR=$(type -P "$CORE_COLLECTOR") # POST_FILES and PRE_FILES are already checked against executable, need not to check again. EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" CHECK_FILES=$(kdump_get_conf_val extra_bins) @@ -375,8 +375,8 @@ check_files_modified() _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2>/dev/null)" if [[ $? -eq 0 ]]; then files="$files $_module_file" - for _dep_modules in $(modinfo -F depends $_module | tr ',' ' '); do - files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename $_dep_modules 2>/dev/null)" + for _dep_modules in $(modinfo -F depends "$_module" | tr ',' ' '); do + files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_dep_modules" 2>/dev/null)" done else # If it's not a module nor builtin, give an error @@ -394,13 +394,13 @@ check_files_modified() for file in $files; do if [[ -e "$file" ]]; then - time_stamp=$(stat -c "%Y" $file) + time_stamp=$(stat -c "%Y" "$file") if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $file" fi if [[ -L "$file" ]]; then - file=$(readlink -m $file) - time_stamp=$(stat -c "%Y" $file) + file=$(readlink -m "$file") + time_stamp=$(stat -c "%Y" "$file") if [[ "$time_stamp" -gt "$image_time" ]]; then modified_files="$modified_files $file" fi @@ -453,8 +453,8 @@ check_drivers_modified() ddebug "Modules included in old initramfs: '$_old_drivers'" for _driver in $_new_drivers; do # Skip deprecated/invalid driver name or built-in module - _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name $_driver 2>/dev/null) - _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n $_driver 2>/dev/null) + _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2>/dev/null) + _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2>/dev/null) if [[ $? -ne 0 ]] || [[ -z "$_module_name" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then continue fi @@ -483,21 +483,21 @@ check_fs_modified() fi _target=$(get_block_dump_target) - _new_fstype=$(get_fs_type_from_target $_target) + _new_fstype=$(get_fs_type_from_target "$_target") if [[ -z "$_target" ]] || [[ -z "$_new_fstype" ]];then derror "Dump target is invalid" return 2 fi ddebug "_target=$_target _new_fstype=$_new_fstype" - _new_dev=$(kdump_get_persistent_dev $_target) + _new_dev=$(kdump_get_persistent_dev "$_target") if [[ -z "$_new_dev" ]]; then perror "Get persistent device name failed" return 2 fi - _new_mntpoint="$(get_kdump_mntpoint_from_target $_target)" - _dracut_args=$(lsinitrd $TARGET_INITRD -f usr/lib/dracut/build-parameter.txt) + _new_mntpoint="$(get_kdump_mntpoint_from_target "$_target")" + _dracut_args=$(lsinitrd "$TARGET_INITRD" -f usr/lib/dracut/build-parameter.txt) if [[ -z "$_dracut_args" ]];then dwarn "Warning: No dracut arguments found in initrd" return 0 @@ -505,13 +505,14 @@ check_fs_modified() # if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - echo $_dracut_args | grep -q "\-\-mount" + echo "$_dracut_args" | grep -q "\-\-mount" if [[ $? -eq 0 ]];then - set -- $(echo $_dracut_args | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) + # shellcheck disable=SC2046 + set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1 _old_mntpoint=$2 _old_fstype=$3 - [[ $_new_dev = $_old_dev && $_new_mntpoint = $_old_mntpoint && $_new_fstype = $_old_fstype ]] && return 0 + [[ $_new_dev = "$_old_dev" && $_new_mntpoint = "$_old_mntpoint" && $_new_fstype = "$_old_fstype" ]] && return 0 # otherwise rebuild if target device is not a root device else [[ "$_target" = "$(get_root_fs_device)" ]] && return 0 @@ -590,7 +591,7 @@ check_rebuild() #check to see if dependent files has been modified #since last build of the image file if [[ -f $TARGET_INITRD ]]; then - image_time=$(stat -c "%Y" $TARGET_INITRD 2>/dev/null) + image_time=$(stat -c "%Y" "$TARGET_INITRD" 2>/dev/null) #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability @@ -649,7 +650,7 @@ function remove_kdump_kernel_key() return fi - keyctl unlink $KDUMP_KEY_ID %:.ima + keyctl unlink "$KDUMP_KEY_ID" %:.ima } # Load the kdump kernel specified in /etc/sysconfig/kdump @@ -682,9 +683,10 @@ load_kdump() PS4='+ $(date "+%Y-%m-%d %H:%M:%S") ${BASH_SOURCE}@${LINENO}: ' set -x + # shellcheck disable=SC2086 $KEXEC $KEXEC_ARGS $standard_kexec_args \ --command-line="$KDUMP_COMMANDLINE" \ - --initrd=$TARGET_INITRD $KDUMP_KERNEL + --initrd="$TARGET_INITRD" "$KDUMP_KERNEL" ret=$? set +x @@ -709,7 +711,7 @@ check_ssh_config() # remove inline comments after the end of a directive. if [[ -f "$config_val" ]]; then # canonicalize the path - SSH_KEY_LOCATION=$(/usr/bin/readlink -m $config_val) + SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") else dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" fi @@ -726,7 +728,7 @@ check_ssh_config() done <<< "$(kdump_read_conf)" #make sure they've configured kdump.conf for ssh dumps - local SSH_TARGET=$(echo -n $DUMP_TARGET | sed -n '/.*@/p') + local SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') if [[ -z "$SSH_TARGET" ]]; then return 1 fi @@ -746,7 +748,7 @@ check_and_wait_network_ready() local errmsg while true; do - errmsg=$(ssh -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH 2>&1) + errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "$SAVE_PATH" 2>&1) retval=$? # ssh exits with the exit status of the remote command or with 255 if an error occurred @@ -759,7 +761,7 @@ check_and_wait_network_ready() # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" - echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" + echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed" if [[ $? -eq 0 ]]; then derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" return 1 @@ -808,16 +810,16 @@ propagate_ssh_key() dinfo "Using existing keys..." else dinfo "Generating new ssh keys... " - /usr/bin/ssh-keygen -t rsa -f $KEYFILE -N "" 2>&1 > /dev/null + /usr/bin/ssh-keygen -t rsa -f "$KEYFILE" -N "" 2>&1 > /dev/null dinfo "done." fi #now find the target ssh user and server to contact. - SSH_USER=$(echo $DUMP_TARGET | cut -d\ -f2 | cut -d@ -f1) - SSH_SERVER=$(echo $DUMP_TARGET | sed -e's/\(.*@\)\(.*$\)/\2/') + SSH_USER=$(echo "$DUMP_TARGET" | cut -d@ -f1) + SSH_SERVER=$(echo "$DUMP_TARGET" | sed -e's/\(.*@\)\(.*$\)/\2/') #now send the found key to the found server - ssh-copy-id -i $KEYFILE $SSH_USER@$SSH_SERVER + ssh-copy-id -i "$KEYFILE" "$SSH_USER@$SSH_SERVER" RET=$? if [[ $RET == 0 ]]; then dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER" @@ -836,7 +838,7 @@ show_reserved_mem() mem=$(/dev/null 2>&1; then + if makedumpfile -R "$coredir/vmcore" < "$raw_target" >/dev/null 2>&1; then # dump found dinfo "Dump saved to $coredir/vmcore" # wipe makedumpfile header - dd if=/dev/zero of=$raw_target bs=1b count=1 2>/dev/null + dd if=/dev/zero of="$raw_target" bs=1b count=1 2>/dev/null else rm -rf "$coredir" fi @@ -904,7 +906,7 @@ local_fs_dump_target() _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf) if [[ $? -eq 0 ]]; then - echo $_target|awk '{print $2}' + echo "$_target" | awk '{print $2}' fi } @@ -919,7 +921,7 @@ path_to_be_relabeled() _target=$(local_fs_dump_target) if [[ -n "$_target" ]]; then - _mnt=$(get_mntpoint_from_target $_target) + _mnt=$(get_mntpoint_from_target "$_target") if ! is_mounted "$_mnt"; then return fi @@ -930,9 +932,9 @@ path_to_be_relabeled() _path=$(get_save_path) # if $_path is masked by other mount, we will not relabel it. - _rmnt=$(df $_mnt/$_path 2>/dev/null | tail -1 | awk '{ print $NF }') + _rmnt=$(df "$_mnt/$_path" 2>/dev/null | tail -1 | awk '{ print $NF }') if [[ "$_rmnt" == "$_mnt" ]]; then - echo $_mnt/$_path + echo "$_mnt/$_path" fi } diff --git a/mkdumprd b/mkdumprd index 3101d3f..b5cc39e 100644 --- a/mkdumprd +++ b/mkdumprd @@ -60,9 +60,9 @@ add_dracut_sshkey() { to_mount() { local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev - _new_mntpoint=$(get_kdump_mntpoint_from_target $_target) - _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" - _options="${_options:-$(get_mntopt_from_target $_target)}" + _new_mntpoint=$(get_kdump_mntpoint_from_target "$_target") + _fstype="${_fstype:-$(get_fs_type_from_target "$_target")}" + _options="${_options:-$(get_mntopt_from_target "$_target")}" _options="${_options:-defaults}" if [[ "$_fstype" == "nfs"* ]]; then @@ -72,8 +72,8 @@ to_mount() { _sed_cmd+='s/,clientaddr=[^,]*//;' else # for non-nfs _target converting to use udev persistent name - _pdev="$(kdump_get_persistent_dev $_target)" - if [[ -z "$_pdev" ]]; then + _pdev="$(kdump_get_persistent_dev "$_target")" + if [[ -z $_pdev ]]; then return 1 fi fi @@ -114,19 +114,19 @@ mkdir_save_path_ssh() { local _opt _dir _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) - ssh -qn "${_opt[@]}" $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null + ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" 2>&1 > /dev/null _ret=$? if [[ $_ret -ne 0 ]]; then perror_exit "mkdir failed on $1:$SAVE_PATH" fi #check whether user has write permission on $1:$SAVE_PATH - _dir=$(ssh -qn "${_opt[@]}" $1 mktemp -dqp $SAVE_PATH 2>/dev/null) + _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) _ret=$? if [[ $_ret -ne 0 ]]; then perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" fi - ssh -qn "${_opt[@]}" $1 rmdir $_dir + ssh -qn "${_opt[@]}" "$1" rmdir "$_dir" return 0 } @@ -168,7 +168,7 @@ check_size() { perror_exit "Check dump target size failed" fi - if [[ $avail -lt $memtotal ]]; then + if [[ "$avail" -lt "$memtotal" ]]; then dwarn "Warning: There might not be enough space to save a vmcore." dwarn " The size of $2 should be greater than $memtotal kilo bytes." fi @@ -206,9 +206,9 @@ mount_failure() check_user_configured_target() { local _target=$1 _cfg_fs_type=$2 _mounted - local _mnt=$(get_mntpoint_from_target $_target) - local _opt=$(get_mntopt_from_target $_target) - local _fstype=$(get_fs_type_from_target $_target) + local _mnt=$(get_mntpoint_from_target "$_target") + local _opt=$(get_mntopt_from_target "$_target") + local _fstype=$(get_fs_type_from_target "$_target") if [[ -n "$_fstype" ]]; then # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf @@ -227,7 +227,7 @@ check_user_configured_target() if [[ -n "$_mnt" ]]; then if ! is_mounted "$_mnt"; then if [[ $_opt = *",noauto"* ]]; then - mount $_mnt + mount "$_mnt" [[ $? -ne 0 ]] && mount_failure "$_target" "$_mnt" "$_fstype" _mounted=$_mnt else @@ -236,8 +236,8 @@ check_user_configured_target() fi else _mnt=$MKDUMPRD_TMPMNT - mkdir -p $_mnt - mount $_target $_mnt -t $_fstype -o defaults + mkdir -p "$_mnt" + mount "$_target" "$_mnt" -t "$_fstype" -o defaults [[ $? -ne 0 ]] && mount_failure "$_target" "" "$_fstype" _mounted=$_mnt fi @@ -251,7 +251,7 @@ check_user_configured_target() # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway if [[ -n "$_mounted" ]]; then - umount -f -- $_mounted + umount -f -- "$_mounted" fi } @@ -276,13 +276,14 @@ verify_core_collector() { _params="$_params vmcore dumpfile" fi + # shellcheck disable=SC2086 if ! $_cmd --check-params $_params; then perror_exit "makedumpfile parameter check failed." fi } add_mount() { - local _mnt=$(to_mount $@) + local _mnt=$(to_mount "$@") if [[ $? -ne 0 ]]; then exit 1 @@ -299,15 +300,15 @@ handle_default_dump_target() is_user_configured_dump_target && return - check_save_path_fs $SAVE_PATH + check_save_path_fs "$SAVE_PATH" - _save_path=$(get_bind_mount_source $SAVE_PATH) - _target=$(get_target_from_path $_save_path) - _mntpoint=$(get_mntpoint_from_target $_target) + _save_path=$(get_bind_mount_source "$SAVE_PATH") + _target=$(get_target_from_path "$_save_path") + _mntpoint=$(get_mntpoint_from_target "$_target") SAVE_PATH=${_save_path##"$_mntpoint"} add_mount "$_target" - check_size fs $_target + check_size fs "$_target" } # $1: function name @@ -317,8 +318,8 @@ for_each_block_target() for dev in $(get_kdump_targets); do [[ -b "$dev" ]] || continue - majmin=$(get_maj_min $dev) - check_block_and_slaves $1 $majmin && return 1 + majmin=$(get_maj_min "$dev") + check_block_and_slaves "$1" "$majmin" && return 1 done return 0 @@ -328,14 +329,14 @@ for_each_block_target() #return false if unresettable. is_unresettable() { - local path="/sys/$(udevadm info --query=all --path=/sys/dev/block/$1 | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" + local path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" local resettable=1 if [[ -f "$path" ]] then resettable="$(<"$path")" [[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && { - local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}') + local device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') derror "Error: Can not save vmcore because device $device is unresettable" return 0 } @@ -387,7 +388,7 @@ fi keyfile=$(kdump_get_conf_val sshkey) if [[ -f "$keyfile" ]]; then # canonicalize the path - SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile) + SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile") fi while read -r config_opt config_val; @@ -403,21 +404,21 @@ do ;; raw) # checking raw disk writable - dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { + dd if="$config_val" count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } - _praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val) - if [[ -z "$_praw" ]]; then + _praw=$(persistent_policy="by-id" kdump_get_persistent_dev "$config_val") + if [[ -z $_praw ]]; then exit 1 fi add_dracut_arg "--device" "$_praw" - check_size raw $config_val + check_size raw "$config_val" ;; ssh) if strstr "$config_val" "@"; then - mkdir_save_path_ssh $config_val - check_size ssh $config_val + mkdir_save_path_ssh "$config_val" + check_size ssh "$config_val" add_dracut_sshkey "$SSH_KEY_LOCATION" else perror_exit "Bad ssh dump target $config_val" @@ -451,7 +452,7 @@ fi if ! is_fadump_capable; then # The 2nd rootfs mount stays behind the normal dump target mount, # so it doesn't affect the logic of check_dump_fs_modified(). - is_dump_to_rootfs && add_mount "$(to_dev_name $(get_root_fs_device))" + is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")" add_dracut_arg "--no-hostonly-default-device" fi From a4648fc851be56d141fd43c8ade1a61c4069f47e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 17:23:16 +0800 Subject: [PATCH 476/806] bash scripts: fix redundant exit code check As suggested by: https://github.com/koalaman/shellcheck/wiki/SC2181 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 41 ++++++--------- kdumpctl | 112 +++++++++++++---------------------------- mkdumprd | 40 ++++----------- 3 files changed, 61 insertions(+), 132 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 07a96e5..7c51e01 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -255,8 +255,7 @@ kdump_static_ip() { _gateway="[$_gateway]" else _prefix=$(cut -d'/' -f2 <<< "$_ipaddr") - _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag") - if [[ "$?" -ne 0 ]]; then + if ! _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag"); then derror "Failed to calculate netmask for $_ipaddr" exit 1 fi @@ -359,10 +358,7 @@ kdump_setup_bridge() { _dev=${_dev##*/} _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - (kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") - if [[ $? != 0 ]]; then - exit 1 - fi + (kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") || exit 1 elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then @@ -420,9 +416,7 @@ kdump_setup_team() { echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf" #Buggy version teamdctl outputs to stderr! #Try to use the latest version of teamd. - teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf" - if [[ $? -ne 0 ]] - then + if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then derror "teamdctl failed." exit 1 fi @@ -442,10 +436,7 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") - if [[ $? != 0 ]]; then - exit 1 - fi + (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") || exit 1 echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else _kdumpdev="$(kdump_setup_ifname "$_phydev")" @@ -516,8 +507,8 @@ kdump_setup_znet() { kdump_get_ip_route() { - local _route=$(/sbin/ip -o route get to "$1" 2>&1) - if [[ $? != 0 ]]; then + local _route + if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then derror "Bad kdump network destination: $1" exit 1 fi @@ -561,8 +552,7 @@ kdump_install_net() { _znet_netdev=$(find_online_znet_device) if [[ -n "$_znet_netdev" ]]; then _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") - (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet") - if [[ $? != 0 ]]; then + if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then derror "Failed to set up znet" exit 1 fi @@ -592,10 +582,7 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - (kdump_setup_bond "$_netdev" "$_nm_show_cmd") - if [[ $? != 0 ]]; then - exit 1 - fi + (kdump_setup_bond "$_netdev" "$_nm_show_cmd") || exit 1 elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then @@ -837,8 +824,10 @@ kdump_setup_iscsi_device() { fi # Setup initator - initiator_str=$(kdump_get_iscsi_initiator) - [[ $? -ne "0" ]] && derror "Failed to get initiator name" && return 1 + if ! initiator_str=$(kdump_get_iscsi_initiator); then + derror "Failed to get initiator name" + return 1 + fi # If initiator details do not exist already, append. if ! grep -q "$initiator_str" "$netroot_conf"; then @@ -878,8 +867,7 @@ get_alias() { for ip in $ips do # in /etc/hosts, alias can come at the 2nd column - entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }') - if [[ $? -eq 0 ]]; then + if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then alias_set="$alias_set $entries" fi done @@ -1004,8 +992,7 @@ kdump_install_random_seed() { kdump_install_systemd_conf() { # Kdump turns out to require longer default systemd mount timeout # than 1st kernel(90s by default), we use default 300s for kdump. - grep -r "^[[:space:]]*DefaultTimeoutStartSec=" "${initdir}/etc/systemd/system.conf"* &>/dev/null - if [[ $? -ne 0 ]]; then + if ! grep -q -r "^[[:space:]]*DefaultTimeoutStartSec=" "${initdir}/etc/systemd/system.conf"*; then mkdir -p "${initdir}/etc/systemd/system.conf.d" echo "[Manager]" > "${initdir}/etc/systemd/system.conf.d/kdump.conf" echo "DefaultTimeoutStartSec=300s" >> "${initdir}/etc/systemd/system.conf.d/kdump.conf" diff --git a/kdumpctl b/kdumpctl index ed6dc3a..208818c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -37,8 +37,7 @@ fi . /lib/kdump/kdump-logger.sh #initiate the kdump logger -dlog_init -if [[ $? -ne 0 ]]; then +if ! dlog_init; then echo "failed to initiate the kdump logger." exit 1 fi @@ -47,8 +46,7 @@ single_instance_lock() { local rc timeout=5 - exec 9>/var/lock/kdump - if [[ $? -ne 0 ]]; then + if ! exec 9>/var/lock/kdump; then derror "Create file lock failed" exit 1 fi @@ -80,8 +78,7 @@ save_core() mkdir -p "$coredir" ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" - cp --sparse=always /proc/vmcore "$coredir/vmcore-incomplete" - if [[ $? == 0 ]]; then + if cp --sparse=always /proc/vmcore "$coredir/vmcore-incomplete"; then mv "$coredir/vmcore-incomplete" "$coredir/vmcore" dinfo "saved a vmcore to $coredir" else @@ -95,8 +92,7 @@ save_core() ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" makedumpfile --dump-dmesg "$coredir/vmcore" "$coredir/dmesg" >/dev/null 2>&1 ddebug "dumpoops -d $coredir/dmesg" - dumpoops -d "$coredir/dmesg" >/dev/null 2>&1 - if [[ $? == 0 ]]; then + if dumpoops -d "$coredir/dmesg" >/dev/null 2>&1; then dinfo "kernel oops has been collected by abrt tool" fi fi @@ -121,8 +117,7 @@ check_earlykdump_is_enabled() rebuild_kdump_initrd() { ddebug "rebuild kdump initrd: $MKDUMPRD $TARGET_INITRD $KDUMP_KERNELVER" - $MKDUMPRD "$TARGET_INITRD" "$KDUMP_KERNELVER" - if [[ $? != 0 ]]; then + if ! $MKDUMPRD "$TARGET_INITRD" "$KDUMP_KERNELVER"; then derror "mkdumprd: failed to make kdump initrd" return 1 fi @@ -184,8 +179,7 @@ backup_default_initrd() dinfo "Backing up $DEFAULT_INITRD before rebuild." # save checksum to verify before restoring sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION" - cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK" - if [[ $? -ne 0 ]]; then + if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." rm -f "$DEFAULT_INITRD_BAK" fi @@ -210,8 +204,7 @@ restore_default_initrd() dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else rm -f $INITRD_CHECKSUM_LOCATION - mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD" - if [[ $? -eq 0 ]]; then + if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then derror "Restoring original initrd as fadump mode is disabled." sync fi @@ -308,8 +301,7 @@ get_pcs_cluster_modified_files() setup_initrd() { - prepare_kdump_bootinfo - if [[ $? -ne 0 ]]; then + if ! prepare_kdump_bootinfo; then derror "failed to prepare for kdump bootinfo." return 1 fi @@ -372,8 +364,7 @@ check_files_modified() files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" fi for _module in $EXTRA_MODULES; do - _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2>/dev/null)" - if [[ $? -eq 0 ]]; then + if _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2>/dev/null)"; then files="$files $_module_file" for _dep_modules in $(modinfo -F depends "$_module" | tr ',' ' '); do files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_dep_modules" 2>/dev/null)" @@ -389,8 +380,7 @@ check_files_modified() # HOOKS is mandatory and need to check the modification time files="$files $HOOKS" - check_exist "$files" && check_executable "$EXTRA_BINS" - [[ $? -ne 0 ]] && return 2 + check_exist "$files" && check_executable "$EXTRA_BINS" || return 2 for file in $files; do if [[ -e "$file" ]]; then @@ -455,7 +445,7 @@ check_drivers_modified() # Skip deprecated/invalid driver name or built-in module _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2>/dev/null) _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2>/dev/null) - if [[ $? -ne 0 ]] || [[ -z "$_module_name" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then + if [[ -z "$_module_name" ]] || [[ -z "$_module_filename" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then continue fi if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then @@ -505,8 +495,7 @@ check_fs_modified() # if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - echo "$_dracut_args" | grep -q "\-\-mount" - if [[ $? -eq 0 ]];then + if echo "$_dracut_args" | grep -q "\-\-mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1 @@ -558,11 +547,7 @@ check_rebuild() local force_rebuild force_no_rebuild local ret system_modified="0" - setup_initrd - - if [[ $? -ne 0 ]]; then - return 1 - fi + setup_initrd || return 1 force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) force_no_rebuild=${force_no_rebuild:-0} @@ -761,8 +746,7 @@ check_and_wait_network_ready() # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" - echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed" - if [[ $? -eq 0 ]]; then + if echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed"; then derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" return 1 fi @@ -788,16 +772,11 @@ check_and_wait_network_ready() check_ssh_target() { check_and_wait_network_ready - if [[ $? -ne 0 ]]; then - return 1 - fi - return 0 } propagate_ssh_key() { - check_ssh_config - if [[ $? -ne 0 ]]; then + if ! check_ssh_config; then derror "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate" exit 1 fi @@ -904,8 +883,7 @@ local_fs_dump_target() { local _target - _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf) - if [[ $? -eq 0 ]]; then + if _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf); then echo "$_target" | awk '{print $2}' fi } @@ -967,8 +945,7 @@ check_fence_kdump_config() return 1 fi # node can be ipaddr - echo "$ipaddrs " | grep -q "$node " - if [[ $? -eq 0 ]]; then + if echo "$ipaddrs " | grep -q "$node "; then derror "Option fence_kdump_nodes cannot contain $node" return 1 fi @@ -1062,14 +1039,12 @@ check_final_action_config() start() { - check_dump_feasibility - if [[ $? -ne 0 ]]; then + if ! check_dump_feasibility; then derror "Starting kdump: [FAILED]" return 1 fi - check_config - if [[ $? -ne 0 ]]; then + if ! check_config; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1078,14 +1053,12 @@ start() selinux_relabel fi - save_raw - if [[ $? -ne 0 ]]; then + if ! save_raw; then derror "Starting kdump: [FAILED]" return 1 fi - check_current_status - if [[ $? == 0 ]]; then + if check_current_status; then dwarn "Kdump already running: [WARNING]" return 0 fi @@ -1097,14 +1070,12 @@ start() fi fi - check_rebuild - if [[ $? != 0 ]]; then + if ! check_rebuild; then derror "Starting kdump: [FAILED]" return 1 fi - start_dump - if [[ $? != 0 ]]; then + if ! start_dump; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1114,8 +1085,7 @@ start() reload() { - check_current_status - if [[ $? -ne 0 ]]; then + if ! check_current_status; then dwarn "Kdump was not running: [WARNING]" fi @@ -1123,24 +1093,20 @@ reload() reload_fadump return $? else - stop_kdump - fi - - if [[ $? -ne 0 ]]; then - derror "Stopping kdump: [FAILED]" - return 1 + if ! stop_kdump; then + derror "Stopping kdump: [FAILED]" + return 1 + fi fi dinfo "Stopping kdump: [OK]" - setup_initrd - if [[ $? -ne 0 ]]; then + if ! setup_initrd; then derror "Starting kdump: [FAILED]" return 1 fi - start_dump - if [[ $? -ne 0 ]]; then + if ! start_dump; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1168,6 +1134,7 @@ stop_kdump() $KEXEC -p -u fi + # shellcheck disable=SC2181 if [[ $? != 0 ]]; then derror "kexec: failed to unload kdump kernel" return 1 @@ -1179,16 +1146,14 @@ stop_kdump() reload_fadump() { - echo 1 > $FADUMP_REGISTER_SYS_NODE - if [[ $? == 0 ]]; then + if echo 1 > $FADUMP_REGISTER_SYS_NODE; then dinfo "fadump: re-registered successfully" return 0 else # FADump could fail on older kernel where re-register # support is not enabled. Try stop/start from userspace # to handle such scenario. - stop_fadump - if [[ $? == 0 ]]; then + if stop_fadump; then start_fadump return $? fi @@ -1205,6 +1170,7 @@ stop() stop_kdump fi + # shellcheck disable=SC2181 if [[ $? != 0 ]]; then derror "Stopping kdump: [FAILED]" return 1 @@ -1215,10 +1181,7 @@ stop() } rebuild() { - check_config - if [[ $? -ne 0 ]]; then - return 1 - fi + check_config || return 1 if check_ssh_config; then if ! check_ssh_target; then @@ -1226,10 +1189,7 @@ rebuild() { fi fi - setup_initrd - if [[ $? -ne 0 ]]; then - return 1 - fi + setup_initrd || return 1 dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd diff --git a/mkdumprd b/mkdumprd index b5cc39e..b75bbdd 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,8 +17,7 @@ fi export IN_KDUMP=1 #initiate the kdump logger -dlog_init -if [[ $? -ne 0 ]]; then +if ! dlog_init; then echo "failed to initiate the kdump logger." exit 1 fi @@ -114,18 +113,12 @@ mkdir_save_path_ssh() { local _opt _dir _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) - ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" 2>&1 > /dev/null - _ret=$? - if [[ $_ret -ne 0 ]]; then + ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &>/dev/null || \ perror_exit "mkdir failed on $1:$SAVE_PATH" - fi - #check whether user has write permission on $1:$SAVE_PATH - _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) - _ret=$? - if [[ $_ret -ne 0 ]]; then + # check whether user has write permission on $1:$SAVE_PATH + _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) || \ perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" - fi ssh -qn "${_opt[@]}" "$1" rmdir "$_dir" return 0 @@ -162,11 +155,7 @@ check_size() { ;; *) return - esac - - if [[ $? -ne 0 ]]; then - perror_exit "Check dump target size failed" - fi + esac || perror_exit "Check dump target size failed" if [[ "$avail" -lt "$memtotal" ]]; then dwarn "Warning: There might not be enough space to save a vmcore." @@ -227,8 +216,7 @@ check_user_configured_target() if [[ -n "$_mnt" ]]; then if ! is_mounted "$_mnt"; then if [[ $_opt = *",noauto"* ]]; then - mount "$_mnt" - [[ $? -ne 0 ]] && mount_failure "$_target" "$_mnt" "$_fstype" + mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype" _mounted=$_mnt else perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" @@ -237,8 +225,7 @@ check_user_configured_target() else _mnt=$MKDUMPRD_TMPMNT mkdir -p "$_mnt" - mount "$_target" "$_mnt" -t "$_fstype" -o defaults - [[ $? -ne 0 ]] && mount_failure "$_target" "" "$_fstype" + mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype" _mounted=$_mnt fi @@ -283,11 +270,9 @@ verify_core_collector() { } add_mount() { - local _mnt=$(to_mount "$@") + local _mnt - if [[ $? -ne 0 ]]; then - exit 1 - fi + _mnt=$(to_mount "$@") || exit 1 add_dracut_mount "$_mnt" } @@ -349,7 +334,7 @@ is_unresettable() #return true if resettable check_resettable() { - local _ret _target _override_resettable + local _target _override_resettable _override_resettable=$(kdump_get_conf_val override_resettable) OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE} @@ -357,10 +342,7 @@ check_resettable() perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid" fi - for_each_block_target is_unresettable - _ret=$? - - [[ $_ret -eq 0 ]] && return + for_each_block_target is_unresettable && return return 1 } From 4f75e16700874b2e934fb3b9b85522cf7f36bd04 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Aug 2021 02:04:45 +0800 Subject: [PATCH 477/806] bash scripts: declare and assign separately Declare and assign separately to avoid masking return values: https://github.com/koalaman/shellcheck/wiki/SC2155 Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 22 +++++++++++++++------- kdumpctl | 17 ++++++++++++----- mkdumprd | 21 +++++++++++---------- mkfadumprd | 2 +- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 7c51e01..e9ec894 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -321,7 +321,8 @@ kdump_get_mac_addr() { #Bonding or team master modifies the mac address #of its slaves, we should use perm address kdump_get_perm_addr() { - local addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') + local addr + addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') if [[ -z "$addr" ]] || [[ "$addr" = "00:00:00:00:00:00" ]] then derror "Can't get the permanent address of $1" @@ -427,10 +428,13 @@ kdump_setup_team() { kdump_setup_vlan() { local _netdev=$1 - local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" - local _netmac="$(kdump_get_mac_addr "$_phydev")" + local _phydev + local _netmac local _kdumpdev + _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" + _netmac="$(kdump_get_mac_addr "$_phydev")" + #Just support vlan over bond and team if kdump_is_bridge "$_phydev"; then derror "Vlan over bridge is not supported!" @@ -522,7 +526,8 @@ kdump_get_ip_route_field() kdump_get_remote_ip() { - local _remote=$(get_remote_host "$1") _remote_temp + local _remote _remote_temp + _remote=$(get_remote_host "$1") if is_hostname "$_remote"; then _remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1) if [[ -z "$_remote_temp" ]]; then @@ -876,11 +881,14 @@ get_alias() { } is_localhost() { - local hostnames=$(hostname -A) - local shortnames=$(hostname -A -s) - local aliasname=$(get_alias) + local hostnames + local shortnames + local aliasname local nodename=$1 + hostnames=$(hostname -A) + shortnames=$(hostname -A -s) + aliasname=$(get_alias) hostnames="$hostnames $shortnames $aliasname" for name in ${hostnames}; do diff --git a/kdumpctl b/kdumpctl index 208818c..d11c3c1 100755 --- a/kdumpctl +++ b/kdumpctl @@ -690,6 +690,8 @@ load_kdump() check_ssh_config() { + local SSH_TARGET + while read -r config_opt config_val; do case "$config_opt" in sshkey) @@ -713,7 +715,7 @@ check_ssh_config() done <<< "$(kdump_read_conf)" #make sure they've configured kdump.conf for ssh dumps - local SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') + SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') if [[ -z "$SSH_TARGET" ]]; then return 1 fi @@ -725,13 +727,14 @@ check_ssh_config() # by the return val of 'ssh' check_and_wait_network_ready() { - local start_time=$(date +%s) + local start_time local warn_once=1 local cur local diff local retval local errmsg + start_time=$(date +%s) while true; do errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "$SAVE_PATH" 2>&1) retval=$? @@ -935,9 +938,13 @@ selinux_relabel() check_fence_kdump_config() { - local hostname=$(hostname) - local ipaddrs=$(hostname -I) - local nodes=$(kdump_get_conf_val "fence_kdump_nodes") + local hostname + local ipaddrs + local nodes + + hostname=$(hostname) + ipaddrs=$(hostname -I) + nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in $nodes; do if [[ "$node" = "$hostname" ]]; then diff --git a/mkdumprd b/mkdumprd index b75bbdd..a027e6a 100644 --- a/mkdumprd +++ b/mkdumprd @@ -29,9 +29,9 @@ OVERRIDE_RESETTABLE=0 extra_modules="" dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" ) -readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" +MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." -readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target" +MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target" trap ' ret=$?; @@ -195,9 +195,11 @@ mount_failure() check_user_configured_target() { local _target=$1 _cfg_fs_type=$2 _mounted - local _mnt=$(get_mntpoint_from_target "$_target") - local _opt=$(get_mntopt_from_target "$_target") - local _fstype=$(get_fs_type_from_target "$_target") + local _mnt _opt _fstype + + _mnt=$(get_mntpoint_from_target "$_target") + _opt=$(get_mntopt_from_target "$_target") + _fstype=$(get_fs_type_from_target "$_target") if [[ -n "$_fstype" ]]; then # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf @@ -314,14 +316,13 @@ for_each_block_target() #return false if unresettable. is_unresettable() { - local path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" - local resettable=1 + local path device resettable=1 - if [[ -f "$path" ]] - then + path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" + if [[ -f "$path" ]]; then resettable="$(<"$path")" [[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && { - local device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') + device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') derror "Error: Can not save vmcore because device $device is unresettable" return 0 } diff --git a/mkfadumprd b/mkfadumprd index ca9f362..5c96ee7 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -17,7 +17,7 @@ if ! dlog_init; then exit 1 fi -readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)" +MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)" [ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed." trap ' ret=$?; From 0e4b66b1ab4d90bea8f3021a46660f5a253eb110 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 14 Sep 2021 02:25:40 +0800 Subject: [PATCH 478/806] bash scripts: reformat with shfmt This is a batch update done with: shfmt -s -w mkfadumprd mkdumprd kdumpctl *-module-setup.sh Clean up code style and reduce code base size, no behaviour change. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-early-kdump-module-setup.sh | 11 +- dracut-module-setup.sh | 318 +++++++++--------- kdumpctl | 274 +++++++-------- mkdumprd | 518 +++++++++++++++-------------- mkfadumprd | 8 +- 5 files changed, 570 insertions(+), 559 deletions(-) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 83e067c..0e46823 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -6,9 +6,8 @@ KDUMP_KERNEL="" KDUMP_INITRD="" check() { - if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]]\ - || [[ -n "${IN_KDUMP}" ]] - then + if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]] \ + || [[ -n ${IN_KDUMP} ]]; then return 1 fi return 255 @@ -25,7 +24,7 @@ prepare_kernel_initrd() { prepare_kdump_bootinfo # $kernel is a variable from dracut - if [[ "$KDUMP_KERNELVER" != "$kernel" ]]; then + if [[ $KDUMP_KERNELVER != "$kernel" ]]; then dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ "but the initramfs is generated for kernel version '$kernel'" fi @@ -33,12 +32,12 @@ prepare_kernel_initrd() { install() { prepare_kernel_initrd - if [[ ! -f "$KDUMP_KERNEL" ]]; then + if [[ ! -f $KDUMP_KERNEL ]]; then derror "Could not find required kernel for earlykdump," \ "earlykdump will not work!" return 1 fi - if [[ ! -f "$KDUMP_INITRD" ]]; then + if [[ ! -f $KDUMP_INITRD ]]; then derror "Could not find required kdump initramfs for earlykdump," \ "please ensure kdump initramfs is generated first," \ "earlykdump will not work!" diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e9ec894..8bbf0cf 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -11,8 +11,7 @@ kdump_module_init() { check() { [[ $debug ]] && set -x #kdumpctl sets this explicitly - if [[ -z "$IN_KDUMP" ]] || [[ ! -f /etc/kdump.conf ]] - then + if [[ -z $IN_KDUMP ]] || [[ ! -f /etc/kdump.conf ]]; then return 1 fi return 0 @@ -41,11 +40,11 @@ depends() { _dep="$_dep ssh-client" fi - if [[ "$(uname -m)" = "s390x" ]]; then + if [[ "$(uname -m)" == "s390x" ]]; then _dep="$_dep znet" fi - if [[ -n "$( ls -A /sys/class/drm 2>/dev/null )" ]] || [[ -d /sys/module/hyperv_fb ]]; then + if [[ -n "$(ls -A /sys/class/drm 2> /dev/null)" ]] || [[ -d /sys/module/hyperv_fb ]]; then add_opt_module drm fi @@ -57,19 +56,19 @@ depends() { } kdump_is_bridge() { - [[ -d /sys/class/net/"$1"/bridge ]] + [[ -d /sys/class/net/"$1"/bridge ]] } kdump_is_bond() { - [[ -d /sys/class/net/"$1"/bonding ]] + [[ -d /sys/class/net/"$1"/bonding ]] } kdump_is_team() { - [[ -f /usr/bin/teamnl ]] && teamnl "$1" ports &> /dev/null + [[ -f /usr/bin/teamnl ]] && teamnl "$1" ports &> /dev/null } kdump_is_vlan() { - [[ -f /proc/net/vlan/"$1" ]] + [[ -f /proc/net/vlan/"$1" ]] } # $1: netdev name @@ -78,7 +77,7 @@ source_ifcfg_file() { dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." ifcfg_file=$(get_ifcfg_filename "$1") - if [[ -f "${ifcfg_file}" ]]; then + if [[ -f ${ifcfg_file} ]]; then . "${ifcfg_file}" else dwarning "The ifcfg file of $1 is not found!" @@ -94,28 +93,26 @@ kdump_setup_dns() { _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") # shellcheck disable=SC2206 - array=( ${_tmp//|/ } ) + array=(${_tmp//|/ }) if [[ ${array[*]} ]]; then - for _dns in "${array[@]}" - do + for _dns in "${array[@]}"; do echo "nameserver=$_dns" >> "$_dnsfile" done else dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" source_ifcfg_file "$_netdev" - [[ -n "$DNS1" ]] && echo "nameserver=$DNS1" > "$_dnsfile" - [[ -n "$DNS2" ]] && echo "nameserver=$DNS2" >> "$_dnsfile" + [[ -n $DNS1 ]] && echo "nameserver=$DNS1" > "$_dnsfile" + [[ -n $DNS2 ]] && echo "nameserver=$DNS2" >> "$_dnsfile" fi - while read -r content; - do + while read -r content; do _nameserver=$(echo "$content" | grep ^nameserver) - [[ -z "$_nameserver" ]] && continue + [[ -z $_nameserver ]] && continue _dns=$(echo "$_nameserver" | awk '{print $2}') - [[ -z "$_dns" ]] && continue + [[ -z $_dns ]] && continue - if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile" ; then + if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then echo "nameserver=$_dns" >> "$_dnsfile" fi done < "/etc/resolv.conf" @@ -130,7 +127,7 @@ repeatedly_join_str() { local _separator="$3" local i _res - if [[ "$_count" -le 0 ]]; then + if [[ $_count -le 0 ]]; then echo -n "" return fi @@ -139,7 +136,7 @@ repeatedly_join_str() { _res="$_str" ((_count--)) - while [[ "$i" -lt "$_count" ]]; do + while [[ $i -lt $_count ]]; do ((i++)) _res="${_res}${_separator}${_str}" done @@ -160,14 +157,14 @@ cal_netmask_by_prefix() { local _count _res _octets_per_group _octets_total _seperator _total_groups local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits - if [[ "$_ipv6_flag" == "-6" ]]; then + if [[ $_ipv6_flag == "-6" ]]; then _ipv6=1 else _ipv6=0 fi - if [[ "$_prefix" -lt 0 || "$_prefix" -gt 128 ]] || \ - ( ((!_ipv6)) && [[ "$_prefix" -gt 32 ]] ); then + if [[ $_prefix -lt 0 || $_prefix -gt 128 ]] \ + || ( ((!_ipv6)) && [[ $_prefix -gt 32 ]]); then derror "Bad prefix:$_prefix for calculating netmask" exit 1 fi @@ -182,7 +179,7 @@ cal_netmask_by_prefix() { _seperator="." fi - _total_groups=$((_octets_total/_octets_per_group)) + _total_groups=$((_octets_total / _octets_per_group)) _bits_per_group=$((_octets_per_group * _bits_per_octet)) _max_group_value=$(((1 << _bits_per_group) - 1)) @@ -192,39 +189,39 @@ cal_netmask_by_prefix() { _max_group_value_repr="$_max_group_value" fi - _count=$((_prefix/_octets_per_group/_bits_per_octet)) + _count=$((_prefix / _octets_per_group / _bits_per_octet)) _first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator") _res="$_first_part" - _tmp=$((_octets_total*_bits_per_octet-_prefix)) + _tmp=$((_octets_total * _bits_per_octet - _prefix)) _zero_bits=$((_tmp % _bits_per_group)) - if [[ "$_zero_bits" -ne 0 ]]; then + if [[ $_zero_bits -ne 0 ]]; then _second_part=$((_max_group_value >> _zero_bits << _zero_bits)) if ((_ipv6)); then _second_part=$(printf "%x" $_second_part) fi ((_count++)) - if [[ -z "$_first_part" ]]; then + if [[ -z $_first_part ]]; then _res="$_second_part" else _res="${_first_part}${_seperator}${_second_part}" fi fi - _count=$((_total_groups-_count)) - if [[ "$_count" -eq 0 ]]; then + _count=$((_total_groups - _count)) + if [[ $_count -eq 0 ]]; then echo -n "$_res" return fi - if ((_ipv6)) && [[ "$_count" -gt 1 ]] ; then + if ((_ipv6)) && [[ $_count -gt 1 ]]; then # use condensed notion for IPv6 _third_part=":" else _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator") fi - if [[ -z "$_res" ]] && ((!_ipv6)) ; then + if [[ -z $_res ]] && ((!_ipv6)); then echo -n "${_third_part}" else echo -n "${_res}${_seperator}${_third_part}" @@ -244,11 +241,11 @@ kdump_static_ip() { _ipv6_flag="-6" fi - if [[ -n "$_ipaddr" ]]; then - _gateway=$(ip $_ipv6_flag route list dev "$_netdev" | \ - awk '/^default /{print $3}' | head -n 1) + if [[ -n $_ipaddr ]]; then + _gateway=$(ip $_ipv6_flag route list dev "$_netdev" \ + | awk '/^default /{print $3}' | head -n 1) - if [[ "x" != "x"$_ipv6_flag ]]; then + if [[ "x" != "x"$_ipv6_flag ]]; then # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" _netmask=${_ipaddr#*\/} _srcaddr="[$_srcaddr]" @@ -263,17 +260,17 @@ kdump_static_ip() { echo -n "${_srcaddr}::${_gateway}:${_netmask}::" fi - /sbin/ip $_ipv6_flag route show | grep -v default |\ - grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ - while read -r _route; do - _target=$(echo "$_route" | awk '{print $1}') - _nexthop=$(echo "$_route" | awk '{print $3}') - if [[ "x" != "x"$_ipv6_flag ]]; then - _target="[$_target]" - _nexthop="[$_nexthop]" - fi - echo "rd.route=$_target:$_nexthop:$kdumpnic" - done >> "${initdir}/etc/cmdline.d/45route-static.conf" + /sbin/ip $_ipv6_flag route show | grep -v default \ + | grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" \ + | while read -r _route; do + _target=$(echo "$_route" | awk '{print $1}') + _nexthop=$(echo "$_route" | awk '{print $3}') + if [[ "x" != "x"$_ipv6_flag ]]; then + _target="[$_target]" + _nexthop="[$_nexthop]" + fi + echo "rd.route=$_target:$_nexthop:$kdumpnic" + done >> "${initdir}/etc/cmdline.d/45route-static.conf" kdump_handle_mulitpath_route "$_netdev" "$_srcaddr" "$kdumpnic" } @@ -287,28 +284,28 @@ kdump_handle_mulitpath_route() { fi while IFS="" read -r _route; do - if [[ "$_route" =~ [[:space:]]+nexthop ]]; then + if [[ $_route =~ [[:space:]]+nexthop ]]; then _route=${_route##[[:space:]]} # Parse multipath route, using previous _target - [[ "$_target" == 'default' ]] && continue - [[ "$_route" =~ .*via.*\ $_netdev ]] || continue + [[ $_target == 'default' ]] && continue + [[ $_route =~ .*via.*\ $_netdev ]] || continue _weight=$(echo "$_route" | cut -d ' ' -f7) - if [[ "$_weight" -gt "$_max_weight" ]]; then + if [[ $_weight -gt $_max_weight ]]; then _nexthop=$(echo "$_route" | cut -d ' ' -f3) _max_weight=$_weight - if [[ "x" != "x"$_ipv6_flag ]]; then + if [[ "x" != "x"$_ipv6_flag ]]; then _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" else _rule="rd.route=$_target:$_nexthop:$kdumpnic" fi fi else - [[ -n "$_rule" ]] && echo "$_rule" + [[ -n $_rule ]] && echo "$_rule" _target=$(echo "$_route" | cut -d ' ' -f1) _rule="" _max_weight=0 _weight=0 fi - done >> "${initdir}/etc/cmdline.d/45route-static.conf"\ + done >> "${initdir}/etc/cmdline.d/45route-static.conf" \ <<< "$(/sbin/ip $_ipv6_flag route show)" [[ -n $_rule ]] && echo "$_rule" >> "${initdir}/etc/cmdline.d/45route-static.conf" @@ -323,8 +320,7 @@ kdump_get_mac_addr() { kdump_get_perm_addr() { local addr addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') - if [[ -z "$addr" ]] || [[ "$addr" = "00:00:00:00:00:00" ]] - then + if [[ -z $addr ]] || [[ $addr == "00:00:00:00:00:00" ]]; then derror "Can't get the permanent address of $1" else echo "$addr" @@ -391,13 +387,13 @@ kdump_setup_bond() { _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") - if [[ -z "$_bondoptions" ]]; then + if [[ -z $_bondoptions ]]; then dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." source_ifcfg_file "$_netdev" _bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")" fi - if [[ -z "$_bondoptions" ]]; then + if [[ -z $_bondoptions ]]; then derror "Get empty bond options" exit 1 fi @@ -453,30 +449,27 @@ kdump_setup_vlan() { # code reaped from the list_configured function of # https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf find_online_znet_device() { - local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" - local NETWORK_DEVICES d ifname ONLINE + local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" + local NETWORK_DEVICES d ifname ONLINE - [[ ! -d "$CCWGROUPBUS_DEVICEDIR" ]] && return - NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) - for d in $NETWORK_DEVICES - do - [[ ! -f "$d/online" ]] && continue - read -r ONLINE < "$d/online" - if [[ $ONLINE -ne 1 ]]; then - continue - fi - # determine interface name, if there (only for qeth and if - # device is online) - if [[ -f $d/if_name ]] - then - read -r ifname < "$d/if_name" - elif [[ -d $d/net ]] - then - ifname=$(ls "$d/net/") - fi - [[ -n "$ifname" ]] && break - done - echo -n "$ifname" + [[ ! -d $CCWGROUPBUS_DEVICEDIR ]] && return + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) + for d in $NETWORK_DEVICES; do + [[ ! -f "$d/online" ]] && continue + read -r ONLINE < "$d/online" + if [[ $ONLINE -ne 1 ]]; then + continue + fi + # determine interface name, if there (only for qeth and if + # device is online) + if [[ -f $d/if_name ]]; then + read -r ifname < "$d/if_name" + elif [[ -d $d/net ]]; then + ifname=$(ls "$d/net/") + fi + [[ -n $ifname ]] && break + done + echo -n "$ifname" } # setup s390 znet cmdline @@ -494,7 +487,7 @@ kdump_setup_znet() { SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels") _options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options") - if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then + if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." source_ifcfg_file "$_netdev" for i in $OPTIONS; do @@ -502,15 +495,14 @@ kdump_setup_znet() { done fi - if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then + if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then exit 1 fi echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" } -kdump_get_ip_route() -{ +kdump_get_ip_route() { local _route if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then derror "Bad kdump network destination: $1" @@ -519,18 +511,16 @@ kdump_get_ip_route() echo "$_route" } -kdump_get_ip_route_field() -{ +kdump_get_ip_route_field() { echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" } -kdump_get_remote_ip() -{ +kdump_get_remote_ip() { local _remote _remote_temp _remote=$(get_remote_host "$1") if is_hostname "$_remote"; then _remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1) - if [[ -z "$_remote_temp" ]]; then + if [[ -z $_remote_temp ]]; then _remote_temp=$(getent ahosts "$_remote" | head -n 1) fi _remote=$(echo "$_remote_temp" | awk '{print $1}') @@ -555,7 +545,7 @@ kdump_install_net() { kdumpnic=$(kdump_setup_ifname "$_netdev") _znet_netdev=$(find_online_znet_device) - if [[ -n "$_znet_netdev" ]]; then + if [[ -n $_znet_netdev ]]; then _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then derror "Failed to set up znet" @@ -564,7 +554,7 @@ kdump_install_net() { fi _static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic") - if [[ -n "$_static" ]]; then + if [[ -n $_static ]]; then _proto=none elif is_ipv6_address "$_srcaddr"; then _proto=auto6 @@ -579,8 +569,8 @@ kdump_install_net() { # so we have to avoid adding duplicates # We should also check /proc/cmdline for existing ip=xx arg. # For example, iscsi boot will specify ip=xxx arg in cmdline. - if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" &&\ - ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then + if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" \ + && ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> "$_ip_conf" fi @@ -611,8 +601,8 @@ kdump_install_net() { # the default gate way for network dump, eth1 in the fence kdump path will # call kdump_install_net again and we don't want eth1 to be the default # gateway. - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] && - [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] \ + && [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf" fi @@ -622,17 +612,17 @@ kdump_install_net() { kdump_install_pre_post_conf() { if [[ -d /etc/kdump/pre.d ]]; then for file in /etc/kdump/pre.d/*; do - if [[ -x "$file" ]]; then + if [[ -x $file ]]; then dracut_install "$file" elif [[ $file != "/etc/kdump/pre.d/*" ]]; then - echo "$file is not executable" + echo "$file is not executable" fi done fi if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do - if [[ -x "$file" ]]; then + if [[ -x $file ]]; then dracut_install "$file" elif [[ $file != "/etc/kdump/post.d/*" ]]; then echo "$file is not executable" @@ -641,8 +631,7 @@ kdump_install_pre_post_conf() { fi } -default_dump_target_install_conf() -{ +default_dump_target_install_conf() { local _target _fstype local _mntpoint _save_path @@ -663,7 +652,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf" # don't touch the path under root mount - if [[ "$_mntpoint" != "/" ]]; then + if [[ $_mntpoint != "/" ]]; then _save_path=${_save_path##"$_mntpoint"} fi @@ -678,32 +667,31 @@ kdump_install_conf() { kdump_read_conf > "${initdir}/tmp/$$-kdump.conf" - while read -r _opt _val; - do + while read -r _opt _val; do # remove inline comments after the end of a directive. case "$_opt" in - raw) - _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val") - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" - ;; - ext[234]|xfs|btrfs|minix) - _pdev=$(kdump_get_persistent_dev "$_val") - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" - ;; - ssh|nfs) - kdump_install_net "$_val" - ;; - dracut_args) - if [[ $(get_dracut_args_fstype "$_val") = nfs* ]] ; then - kdump_install_net "$(get_dracut_args_target "$_val")" - fi - ;; - kdump_pre|kdump_post|extra_bins) - dracut_install "$_val" - ;; - core_collector) - dracut_install "${_val%%[[:blank:]]*}" - ;; + raw) + _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val") + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" + ;; + ext[234] | xfs | btrfs | minix) + _pdev=$(kdump_get_persistent_dev "$_val") + sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" + ;; + ssh | nfs) + kdump_install_net "$_val" + ;; + dracut_args) + if [[ $(get_dracut_args_fstype "$_val") == nfs* ]]; then + kdump_install_net "$(get_dracut_args_target "$_val")" + fi + ;; + kdump_pre | kdump_post | extra_bins) + dracut_install "$_val" + ;; + core_collector) + dracut_install "${_val%%[[:blank:]]*}" + ;; esac done <<< "$(kdump_read_conf)" @@ -711,7 +699,7 @@ kdump_install_conf() { default_dump_target_install_conf - kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" + kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf" rm -f "${initdir}/tmp/$$-kdump.conf" } @@ -744,16 +732,17 @@ kdump_get_iscsi_initiator() { local _initiator local initiator_conf="/etc/iscsi/initiatorname.iscsi" - [[ -f "$initiator_conf" ]] || return 1 + [[ -f $initiator_conf ]] || return 1 while read -r _initiator; do - [[ -z "${_initiator%%#*}" ]] && continue # Skip comment lines + [[ -z ${_initiator%%#*} ]] && continue # Skip comment lines case $_initiator in InitiatorName=*) initiator=${_initiator#InitiatorName=} echo "rd.iscsi.initiator=${initiator}" - return 0;; + return 0 + ;; *) ;; esac done < ${initiator_conf} @@ -763,15 +752,21 @@ kdump_get_iscsi_initiator() { # Figure out iBFT session according to session type is_ibft() { - [[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" = fw ]] + [[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" == fw ]] } kdump_setup_iscsi_device() { local path=$1 - local tgt_name; local tgt_ipaddr; - local username; local password; local userpwd_str; - local username_in; local password_in; local userpwd_in_str; - local netroot_str ; local initiator_str; + local tgt_name + local tgt_ipaddr + local username + local password + local userpwd_str + local username_in + local password_in + local userpwd_in_str + local netroot_str + local initiator_str local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local initiator_conf="/etc/iscsi/initiatorname.iscsi" @@ -779,7 +774,7 @@ kdump_setup_iscsi_device() { # Check once before getting explicit values, so we can bail out early, # e.g. in case of pure-hardware(all-offload) iscsi. - if ! /sbin/iscsiadm -m session -r "$path" &>/dev/null ; then + if ! /sbin/iscsiadm -m session -r "$path" &> /dev/null; then return 1 fi @@ -796,18 +791,18 @@ kdump_setup_iscsi_device() { # get and set username and password details username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username") - [[ "$username" == "" ]] && username="" + [[ $username == "" ]] && username="" password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password") - [[ "$password" == "" ]] && password="" + [[ $password == "" ]] && password="" username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in") - [[ -n "$username" ]] && userpwd_str="$username:$password" + [[ -n $username ]] && userpwd_str="$username:$password" # get and set incoming username and password details - [[ "$username_in" == "" ]] && username_in="" + [[ $username_in == "" ]] && username_in="" password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in") - [[ "$password_in" == "" ]] && password_in="" + [[ $password_in == "" ]] && password_in="" - [[ -n "$username_in" ]] && userpwd_in_str=":$username_in:$password_in" + [[ -n $username_in ]] && userpwd_in_str=":$username_in:$password_in" kdump_install_net "$tgt_ipaddr" @@ -824,8 +819,8 @@ kdump_setup_iscsi_device() { # If netroot target does not exist already, append. if ! grep -q "$netroot_str" "$netroot_conf"; then - echo "$netroot_str" >> "$netroot_conf" - dinfo "Appended $netroot_str to $netroot_conf" + echo "$netroot_str" >> "$netroot_conf" + dinfo "Appended $netroot_str to $netroot_conf" fi # Setup initator @@ -836,14 +831,14 @@ kdump_setup_iscsi_device() { # If initiator details do not exist already, append. if ! grep -q "$initiator_str" "$netroot_conf"; then - echo "$initiator_str" >> "$netroot_conf" - dinfo "Appended $initiator_str to $netroot_conf" + echo "$initiator_str" >> "$netroot_conf" + dinfo "Appended $initiator_str to $netroot_conf" fi } -kdump_check_iscsi_targets () { +kdump_check_iscsi_targets() { # If our prerequisites are not met, fail anyways. - type -P iscsistart >/dev/null || return 1 + type -P iscsistart > /dev/null || return 1 kdump_check_setup_iscsi() ( local _dev @@ -869,12 +864,11 @@ get_alias() { local alias_set ips=$(hostname -I) - for ip in $ips - do - # in /etc/hosts, alias can come at the 2nd column - if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then - alias_set="$alias_set $entries" - fi + for ip in $ips; do + # in /etc/hosts, alias can come at the 2nd column + if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then + alias_set="$alias_set $entries" + fi done echo "$alias_set" @@ -892,7 +886,7 @@ is_localhost() { hostnames="$hostnames $shortnames $aliasname" for name in ${hostnames}; do - if [[ "$name" == "$nodename" ]]; then + if [[ $name == "$nodename" ]]; then return 0 fi done @@ -948,7 +942,7 @@ get_generic_fence_kdump_nodes() { # setup fence_kdump in cluster # setup proper network and install needed files -kdump_configure_fence_kdump () { +kdump_configure_fence_kdump() { local kdump_cfg_file=$1 local nodes local args @@ -963,7 +957,7 @@ kdump_configure_fence_kdump () { echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}" args=$(get_pcs_fence_kdump_args) - if [[ -n "$args" ]]; then + if [[ -n $args ]]; then echo "fence_kdump_args $args" >> "${kdump_cfg_file}" fi @@ -987,14 +981,14 @@ kdump_configure_fence_kdump () { kdump_install_random_seed() { local poolsize - poolsize=$( /dev/null + bs="$poolsize" count=1 2> /dev/null } kdump_install_systemd_conf() { @@ -1071,8 +1065,8 @@ install() { # it unconditionally here, if "/etc/lvm/lvm.conf" doesn't exist, it # actually does nothing. sed -i -e \ - 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ - "${initdir}/etc/lvm/lvm.conf" &>/dev/null + 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ + "${initdir}/etc/lvm/lvm.conf" &> /dev/null # Save more memory by dropping switch root capability dracut_no_switch_root diff --git a/kdumpctl b/kdumpctl index d11c3c1..59ec068 100755 --- a/kdumpctl +++ b/kdumpctl @@ -46,7 +46,7 @@ single_instance_lock() { local rc timeout=5 - if ! exec 9>/var/lock/kdump; then + if ! exec 9> /var/lock/kdump; then derror "Create file lock failed" exit 1 fi @@ -90,9 +90,9 @@ save_core() # https://fedorahosted.org/abrt/ if [[ -x /usr/bin/dumpoops ]]; then ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" - makedumpfile --dump-dmesg "$coredir/vmcore" "$coredir/dmesg" >/dev/null 2>&1 + makedumpfile --dump-dmesg "$coredir/vmcore" "$coredir/dmesg" > /dev/null 2>&1 ddebug "dumpoops -d $coredir/dmesg" - if dumpoops -d "$coredir/dmesg" >/dev/null 2>&1; then + if dumpoops -d "$coredir/dmesg" > /dev/null 2>&1; then dinfo "kernel oops has been collected by abrt tool" fi fi @@ -131,7 +131,7 @@ rebuild_kdump_initrd() rebuild_initrd() { - if [[ ! -w $(dirname "$TARGET_INITRD") ]];then + if [[ ! -w $(dirname "$TARGET_INITRD") ]]; then derror "$(dirname "$TARGET_INITRD") does not have write permission. Cannot rebuild $TARGET_INITRD" return 1 fi @@ -149,7 +149,7 @@ rebuild_initrd() check_exist() { for file in $1; do - if [[ ! -e "$file" ]]; then + if [[ ! -e $file ]]; then derror "Error: $file not found." return 1 fi @@ -160,7 +160,7 @@ check_exist() check_executable() { for file in $1; do - if [[ ! -x "$file" ]]; then + if [[ ! -x $file ]]; then derror "Error: $file is not executable." return 1 fi @@ -171,7 +171,7 @@ backup_default_initrd() { ddebug "backup default initrd: $DEFAULT_INITRD" - if [[ ! -f "$DEFAULT_INITRD" ]]; then + if [[ ! -f $DEFAULT_INITRD ]]; then return fi @@ -190,7 +190,7 @@ restore_default_initrd() { ddebug "restore default initrd: $DEFAULT_INITRD" - if [[ ! -f "$DEFAULT_INITRD" ]]; then + if [[ ! -f $DEFAULT_INITRD ]]; then return fi @@ -200,7 +200,7 @@ restore_default_initrd() # verify checksum before restoring backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }') default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION") - if [[ "$default_checksum" != "$backup_checksum" ]]; then + if [[ $default_checksum != "$backup_checksum" ]]; then dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else rm -f $INITRD_CHECKSUM_LOCATION @@ -220,7 +220,7 @@ check_config() dracut_args) if [[ $config_val == *--mount* ]]; then if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then - derror "Multiple mount targets specified in one \"dracut_args\"." + derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi config_opt=_target @@ -232,12 +232,12 @@ check_config() fi config_opt=_target ;; - ext[234]|minix|btrfs|xfs|nfs|ssh) + ext[234] | minix | btrfs | xfs | nfs | ssh) config_opt=_target ;; - sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|fence_kdump_args|fence_kdump_nodes) - ;; - net|options|link_delay|disk_timeout|debug_mem_level|blacklist) + sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes) ;; + + net | options | link_delay | disk_timeout | debug_mem_level | blacklist) derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." return 1 ;; @@ -250,12 +250,12 @@ check_config() ;; esac - if [[ -z "$config_val" ]]; then + if [[ -z $config_val ]]; then derror "Invalid kdump config value for option '$config_opt'" return 1 fi - if [[ -n "${_opt_rec[$config_opt]}" ]]; then + if [[ -n ${_opt_rec[$config_opt]} ]]; then if [[ $config_opt == _target ]]; then derror "More than one dump targets specified" else @@ -291,7 +291,7 @@ get_pcs_cluster_modified_files() if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then time_stamp=$(stat -c "%Y" "$FENCE_KDUMP_CONFIG_FILE") - if [[ "$time_stamp" -gt "$image_time" ]]; then + if [[ $time_stamp -gt $image_time ]]; then modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" fi fi @@ -335,14 +335,14 @@ check_files_modified() HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do - if [[ -x "$file" ]]; then + if [[ -x $file ]]; then POST_FILES="$POST_FILES $file" fi done fi if [[ -d /etc/kdump/pre.d ]]; then for file in /etc/kdump/pre.d/*; do - if [[ -x "$file" ]]; then + if [[ -x $file ]]; then PRE_FILES="$PRE_FILES $file" fi done @@ -359,19 +359,19 @@ check_files_modified() # Check for any updated extra module EXTRA_MODULES="$(kdump_get_conf_val extra_modules)" - if [[ -n "$EXTRA_MODULES" ]]; then + if [[ -n $EXTRA_MODULES ]]; then if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" fi for _module in $EXTRA_MODULES; do - if _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2>/dev/null)"; then + if _module_file="$(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_module" 2> /dev/null)"; then files="$files $_module_file" for _dep_modules in $(modinfo -F depends "$_module" | tr ',' ' '); do - files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_dep_modules" 2>/dev/null)" + files="$files $(modinfo --set-version "$KDUMP_KERNELVER" --filename "$_dep_modules" 2> /dev/null)" done else # If it's not a module nor builtin, give an error - if ! ( modprobe --set-version "$KDUMP_KERNELVER" --dry-run "$_module" &>/dev/null ); then + if ! (modprobe --set-version "$KDUMP_KERNELVER" --dry-run "$_module" &> /dev/null); then dwarn "Module $_module not found" fi fi @@ -383,15 +383,15 @@ check_files_modified() check_exist "$files" && check_executable "$EXTRA_BINS" || return 2 for file in $files; do - if [[ -e "$file" ]]; then + if [[ -e $file ]]; then time_stamp=$(stat -c "%Y" "$file") - if [[ "$time_stamp" -gt "$image_time" ]]; then + if [[ $time_stamp -gt $image_time ]]; then modified_files="$modified_files $file" fi - if [[ -L "$file" ]]; then + if [[ -L $file ]]; then file=$(readlink -m "$file") time_stamp=$(stat -c "%Y" "$file") - if [[ "$time_stamp" -gt "$image_time" ]]; then + if [[ $time_stamp -gt $image_time ]]; then modified_files="$modified_files $file" fi fi @@ -400,7 +400,7 @@ check_files_modified() fi done - if [[ -n "$modified_files" ]]; then + if [[ -n $modified_files ]]; then dinfo "Detected change(s) in the following file(s): $modified_files" return 1 fi @@ -414,8 +414,9 @@ check_drivers_modified() # If it's dump target is on block device, detect the block driver _target=$(get_block_dump_target) - if [[ -n "$_target" ]]; then - _record_block_drivers() { + if [[ -n $_target ]]; then + _record_block_drivers() + { local _drivers _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') for _driver in $_drivers; do @@ -431,7 +432,7 @@ check_drivers_modified() # Include watchdog drivers if watchdog module is not omitted is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)" - [[ -z "$_new_drivers" ]] && return 0 + [[ -z $_new_drivers ]] && return 0 if is_fadump_capable; then _old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/fadump-kernel-modules.txt | tr '\n' ' ')" @@ -443,9 +444,9 @@ check_drivers_modified() ddebug "Modules included in old initramfs: '$_old_drivers'" for _driver in $_new_drivers; do # Skip deprecated/invalid driver name or built-in module - _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2>/dev/null) - _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2>/dev/null) - if [[ -z "$_module_name" ]] || [[ -z "$_module_filename" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then + _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2> /dev/null) + _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2> /dev/null) + if [[ -z $_module_name ]] || [[ -z $_module_filename ]] || [[ $_module_filename == *"(builtin)"* ]]; then continue fi if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then @@ -474,21 +475,21 @@ check_fs_modified() _target=$(get_block_dump_target) _new_fstype=$(get_fs_type_from_target "$_target") - if [[ -z "$_target" ]] || [[ -z "$_new_fstype" ]];then + if [[ -z $_target ]] || [[ -z $_new_fstype ]]; then derror "Dump target is invalid" return 2 fi ddebug "_target=$_target _new_fstype=$_new_fstype" _new_dev=$(kdump_get_persistent_dev "$_target") - if [[ -z "$_new_dev" ]]; then + if [[ -z $_new_dev ]]; then perror "Get persistent device name failed" return 2 fi _new_mntpoint="$(get_kdump_mntpoint_from_target "$_target")" _dracut_args=$(lsinitrd "$TARGET_INITRD" -f usr/lib/dracut/build-parameter.txt) - if [[ -z "$_dracut_args" ]];then + if [[ -z $_dracut_args ]]; then dwarn "Warning: No dracut arguments found in initrd" return 0 fi @@ -501,10 +502,10 @@ check_fs_modified() _old_dev=$1 _old_mntpoint=$2 _old_fstype=$3 - [[ $_new_dev = "$_old_dev" && $_new_mntpoint = "$_old_mntpoint" && $_new_fstype = "$_old_fstype" ]] && return 0 + [[ $_new_dev == "$_old_dev" && $_new_mntpoint == "$_old_mntpoint" && $_new_fstype == "$_old_fstype" ]] && return 0 # otherwise rebuild if target device is not a root device else - [[ "$_target" = "$(get_root_fs_device)" ]] && return 0 + [[ $_target == "$(get_root_fs_device)" ]] && return 0 fi dinfo "Detected change in File System" @@ -551,36 +552,36 @@ check_rebuild() force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) force_no_rebuild=${force_no_rebuild:-0} - if [[ "$force_no_rebuild" != "0" ]] && [[ "$force_no_rebuild" != "1" ]];then + if [[ $force_no_rebuild != "0" ]] && [[ $force_no_rebuild != "1" ]]; then derror "Error: force_no_rebuild value is invalid" return 1 fi force_rebuild=$(kdump_get_conf_val force_rebuild) force_rebuild=${force_rebuild:-0} - if [[ "$force_rebuild" != "0" ]] && [[ "$force_rebuild" != "1" ]];then + if [[ $force_rebuild != "0" ]] && [[ $force_rebuild != "1" ]]; then derror "Error: force_rebuild value is invalid" return 1 fi - if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then + if [[ $force_no_rebuild == "1" && $force_rebuild == "1" ]]; then derror "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf" return 1 fi # Will not rebuild kdump initrd - if [[ "$force_no_rebuild" == "1" ]]; then + if [[ $force_no_rebuild == "1" ]]; then return 0 fi #check to see if dependent files has been modified #since last build of the image file if [[ -f $TARGET_INITRD ]]; then - image_time=$(stat -c "%Y" "$TARGET_INITRD" 2>/dev/null) + image_time=$(stat -c "%Y" "$TARGET_INITRD" 2> /dev/null) #in case of fadump mode, check whether the default/target #initrd is already built with dump capture capability - if [[ "$DEFAULT_DUMP_MODE" == "fadump" ]]; then + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$) fi fi @@ -589,17 +590,17 @@ check_rebuild() ret=$? if [[ $ret -eq 2 ]]; then return 1 - elif [[ $ret -eq 1 ]];then + elif [[ $ret -eq 1 ]]; then system_modified="1" fi if [[ $image_time -eq 0 ]]; then dinfo "No kdump initial ramdisk found." - elif [[ "$capture_capable_initrd" == "0" ]]; then + elif [[ $capture_capable_initrd == "0" ]]; then dinfo "Rebuild $TARGET_INITRD with dump capture support" - elif [[ "$force_rebuild" != "0" ]]; then + elif [[ $force_rebuild != "0" ]]; then dinfo "Force rebuild $TARGET_INITRD" - elif [[ "$system_modified" != "0" ]]; then + elif [[ $system_modified != "0" ]]; then : else return 0 @@ -617,13 +618,13 @@ function load_kdump_kernel_key() # this is only called inside is_secure_boot_enforced, # no need to retest - # this is only required if DT /ibm,secure-boot is a file. - # if it is a dir, we are on OpenPower and don't need this. - if ! [[ -f /proc/device-tree/ibm,secure-boot ]]; then - return - fi + # this is only required if DT /ibm,secure-boot is a file. + # if it is a dir, we are on OpenPower and don't need this. + if ! [[ -f /proc/device-tree/ibm,secure-boot ]]; then + return + fi - KDUMP_KEY_ID=$(keyctl padd asymmetric kernelkey-$RANDOM %:.ima < "/usr/share/doc/kernel-keys/$KDUMP_KERNELVER/kernel-signing-ppc.cer") + KDUMP_KEY_ID=$(keyctl padd asymmetric kernelkey-$RANDOM %:.ima < "/usr/share/doc/kernel-keys/$KDUMP_KERNELVER/kernel-signing-ppc.cer") } # remove a previously loaded key. There's no real security implication @@ -631,7 +632,7 @@ function load_kdump_kernel_key() # to be idempotent and so as to reduce the potential for confusion. function remove_kdump_kernel_key() { - if [[ -z "$KDUMP_KEY_ID" ]]; then + if [[ -z $KDUMP_KEY_ID ]]; then return fi @@ -696,7 +697,7 @@ check_ssh_config() case "$config_opt" in sshkey) # remove inline comments after the end of a directive. - if [[ -f "$config_val" ]]; then + if [[ -f $config_val ]]; then # canonicalize the path SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") else @@ -709,14 +710,14 @@ check_ssh_config() ssh) DUMP_TARGET=$config_val ;; - *) - ;; + *) ;; + esac done <<< "$(kdump_read_conf)" #make sure they've configured kdump.conf for ssh dumps SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') - if [[ -z "$SSH_TARGET" ]]; then + if [[ -z $SSH_TARGET ]]; then return 1 fi return 0 @@ -763,7 +764,7 @@ check_and_wait_network_ready() diff=$((cur - start_time)) # 60s time out if [[ $diff -gt 180 ]]; then - break; + break fi sleep 1 done @@ -814,19 +815,19 @@ propagate_ssh_key() show_reserved_mem() { - local mem - local mem_mb + local mem + local mem_mb - mem=$(/dev/null 2>&1; then + if makedumpfile -R "$coredir/vmcore" < "$raw_target" > /dev/null 2>&1; then # dump found dinfo "Dump saved to $coredir/vmcore" # wipe makedumpfile header - dd if=/dev/zero of="$raw_target" bs=1b count=1 2>/dev/null + dd if=/dev/zero of="$raw_target" bs=1b count=1 2> /dev/null else rm -rf "$coredir" fi @@ -897,11 +898,11 @@ path_to_be_relabeled() if is_user_configured_dump_target; then if is_mount_in_dracut_args; then - return; + return fi _target=$(local_fs_dump_target) - if [[ -n "$_target" ]]; then + if [[ -n $_target ]]; then _mnt=$(get_mntpoint_from_target "$_target") if ! is_mounted "$_mnt"; then return @@ -913,8 +914,8 @@ path_to_be_relabeled() _path=$(get_save_path) # if $_path is masked by other mount, we will not relabel it. - _rmnt=$(df "$_mnt/$_path" 2>/dev/null | tail -1 | awk '{ print $NF }') - if [[ "$_rmnt" == "$_mnt" ]]; then + _rmnt=$(df "$_mnt/$_path" 2> /dev/null | tail -1 | awk '{ print $NF }') + if [[ $_rmnt == "$_mnt" ]]; then echo "$_mnt/$_path" fi } @@ -924,14 +925,14 @@ selinux_relabel() local _path _i _attr _path=$(path_to_be_relabeled) - if [[ -z "$_path" ]] || ! [[ -d "$_path" ]] ; then + if [[ -z $_path ]] || ! [[ -d $_path ]]; then return fi while IFS= read -r -d '' _i; do - _attr=$(getfattr -m "security.selinux" "$_i" 2>/dev/null) - if [[ -z "$_attr" ]]; then - restorecon "$_i"; + _attr=$(getfattr -m "security.selinux" "$_i" 2> /dev/null) + if [[ -z $_attr ]]; then + restorecon "$_i" fi done < <(find "$_path" -print0) } @@ -947,7 +948,7 @@ check_fence_kdump_config() nodes=$(kdump_get_conf_val "fence_kdump_nodes") for node in $nodes; do - if [[ "$node" = "$hostname" ]]; then + if [[ $node == "$hostname" ]]; then derror "Option fence_kdump_nodes cannot contain $hostname" return 1 fi @@ -1003,25 +1004,26 @@ check_failure_action_config() default_option=$(kdump_get_conf_val default) failure_action=$(kdump_get_conf_val failure_action) - if [[ -z "$failure_action" ]] && [[ -z "$default_option" ]]; then + if [[ -z $failure_action ]] && [[ -z $default_option ]]; then return 0 - elif [[ -n "$failure_action" ]] && [[ -n "$default_option" ]]; then + elif [[ -n $failure_action ]] && [[ -n $default_option ]]; then derror "Cannot specify 'failure_action' and 'default' option together" return 1 fi - if [[ -n "$default_option" ]]; then + if [[ -n $default_option ]]; then option="default" failure_action="$default_option" fi case "$failure_action" in - reboot|halt|poweroff|shell|dump_to_rootfs) + reboot | halt | poweroff | shell | dump_to_rootfs) return 0 - ;; - *) + ;; + *) dinfo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" return 1 + ;; esac } @@ -1030,16 +1032,17 @@ check_final_action_config() local final_action final_action=$(kdump_get_conf_val final_action) - if [[ -z "$final_action" ]]; then + if [[ -z $final_action ]]; then return 0 else case "$final_action" in - reboot|halt|poweroff) + reboot | halt | poweroff) return 0 - ;; - *) + ;; + *) dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" return 1 + ;; esac fi } @@ -1056,7 +1059,7 @@ start() return 1 fi - if sestatus 2>/dev/null | grep -q "SELinux status.*enabled"; then + if sestatus 2> /dev/null | grep -q "SELinux status.*enabled"; then selinux_relabel fi @@ -1187,7 +1190,8 @@ stop() return 0 } -rebuild() { +rebuild() +{ check_config || return 1 if check_ssh_config; then @@ -1203,33 +1207,34 @@ rebuild() { return $? } -do_estimate() { +do_estimate() +{ local kdump_mods local -A large_mods local baseline local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommended_size - local size_mb=$(( 1024 * 1024 )) + local size_mb=$((1024 * 1024)) setup_initrd - if [[ ! -f "$TARGET_INITRD" ]]; then + if [[ ! -f $TARGET_INITRD ]]; then derror "kdumpctl estimate: kdump initramfs is not built yet." exit 1 fi kdump_mods="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" baseline=$(kdump_get_arch_recommend_size) - if [[ "${baseline: -1}" == "M" ]]; then + if [[ ${baseline: -1} == "M" ]]; then baseline=${baseline%M} - elif [[ "${baseline: -1}" == "G" ]]; then - baseline=$(( ${baseline%G} * 1024 )) - elif [[ "${baseline: -1}" == "T" ]]; then - baseline=$(( ${baseline%Y} * 1048576 )) + elif [[ ${baseline: -1} == "G" ]]; then + baseline=$((${baseline%G} * 1024)) + elif [[ ${baseline: -1} == "T" ]]; then + baseline=$((${baseline%Y} * 1048576)) fi # The default pre-reserved crashkernel value baseline_size=$((baseline * size_mb)) # Current reserved crashkernel size - reserved_size=$(" else echo "" @@ -1294,14 +1299,15 @@ do_estimate() { fi } -reset_crashkernel() { +reset_crashkernel() +{ local kernel=$1 entry crashkernel_default local grub_etc_default="/etc/default/grub" - [[ -z "$kernel" ]] && kernel=$(uname -r) - crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null) + [[ -z $kernel ]] && kernel=$(uname -r) + crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null) - if [[ -z "$crashkernel_default" ]]; then + if [[ -z $crashkernel_default ]]; then derror "$kernel doesn't have a crashkernel.default" exit 1 fi @@ -1318,7 +1324,7 @@ reset_crashkernel() { entry=${entry#\"} entry=${entry%\"} - if [[ -f "$grub_etc_default" ]]; then + if [[ -f $grub_etc_default ]]; then sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default" fi @@ -1328,18 +1334,18 @@ reset_crashkernel() { fi } -if [[ ! -f "$KDUMP_CONFIG_FILE" ]]; then +if [[ ! -f $KDUMP_CONFIG_FILE ]]; then derror "Error: No kdump config file found!" exit 1 fi -main () +main() { # Determine if the dump mode is kdump or fadump determine_dump_mode case "$1" in - start) + start) if [[ -s /proc/vmcore ]]; then save_core reboot @@ -1347,51 +1353,52 @@ main () start fi ;; - stop) + stop) stop ;; - status) + status) EXIT_CODE=0 check_current_status case "$?" in - 0) + 0) dinfo "Kdump is operational" EXIT_CODE=0 ;; - 1) + 1) dinfo "Kdump is not operational" EXIT_CODE=3 ;; esac exit $EXIT_CODE ;; - reload) + reload) reload ;; - restart) + restart) stop start ;; - rebuild) + rebuild) rebuild ;; - condrestart) - ;; - propagate) + condrestart) ;; + + propagate) propagate_ssh_key ;; - showmem) + showmem) show_reserved_mem ;; - estimate) + estimate) do_estimate ;; - reset-crashkernel) + reset-crashkernel) reset_crashkernel "$2" ;; - *) + *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" exit 1 + ;; esac } @@ -1400,6 +1407,9 @@ single_instance_lock # To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main. # So that fd isn't leaking when main is invoking a subshell. -(exec 9<&-; main "$@") +( + exec 9<&- + main "$@" +) exit $? diff --git a/mkdumprd b/mkdumprd index a027e6a..eebbbe1 100644 --- a/mkdumprd +++ b/mkdumprd @@ -27,7 +27,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" ) +dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump") MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." @@ -43,66 +43,71 @@ trap ' # clean up after ourselves no matter how we die. trap 'exit 1;' SIGINT -add_dracut_arg() { - dracut_args+=( "$@" ) +add_dracut_arg() +{ + dracut_args+=("$@") } -add_dracut_mount() { - add_dracut_arg "--mount" "$1" +add_dracut_mount() +{ + add_dracut_arg "--mount" "$1" } -add_dracut_sshkey() { - add_dracut_arg "--sshkey" "$1" +add_dracut_sshkey() +{ + add_dracut_arg "--sshkey" "$1" } # caller should ensure $1 is valid and mounted in 1st kernel -to_mount() { - local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev +to_mount() +{ + local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev - _new_mntpoint=$(get_kdump_mntpoint_from_target "$_target") - _fstype="${_fstype:-$(get_fs_type_from_target "$_target")}" - _options="${_options:-$(get_mntopt_from_target "$_target")}" - _options="${_options:-defaults}" + _new_mntpoint=$(get_kdump_mntpoint_from_target "$_target") + _fstype="${_fstype:-$(get_fs_type_from_target "$_target")}" + _options="${_options:-$(get_mntopt_from_target "$_target")}" + _options="${_options:-defaults}" - if [[ "$_fstype" == "nfs"* ]]; then - _pdev=$_target - _sed_cmd+='s/,addr=[^,]*//;' - _sed_cmd+='s/,proto=[^,]*//;' - _sed_cmd+='s/,clientaddr=[^,]*//;' - else - # for non-nfs _target converting to use udev persistent name - _pdev="$(kdump_get_persistent_dev "$_target")" - if [[ -z $_pdev ]]; then - return 1 - fi - fi + if [[ $_fstype == "nfs"* ]]; then + _pdev=$_target + _sed_cmd+='s/,addr=[^,]*//;' + _sed_cmd+='s/,proto=[^,]*//;' + _sed_cmd+='s/,clientaddr=[^,]*//;' + else + # for non-nfs _target converting to use udev persistent name + _pdev="$(kdump_get_persistent_dev "$_target")" + if [[ -z $_pdev ]]; then + return 1 + fi + fi - # mount fs target as rw in 2nd kernel - _sed_cmd+='s/\(^\|,\)ro\($\|,\)/\1rw\2/g;' - # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd - # kernel, filter it out here. - _sed_cmd+='s/\(^\|,\)noauto\($\|,\)/\1/g;' - # drop nofail or nobootwait - _sed_cmd+='s/\(^\|,\)nofail\($\|,\)/\1/g;' - _sed_cmd+='s/\(^\|,\)nobootwait\($\|,\)/\1/g;' + # mount fs target as rw in 2nd kernel + _sed_cmd+='s/\(^\|,\)ro\($\|,\)/\1rw\2/g;' + # with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd + # kernel, filter it out here. + _sed_cmd+='s/\(^\|,\)noauto\($\|,\)/\1/g;' + # drop nofail or nobootwait + _sed_cmd+='s/\(^\|,\)nofail\($\|,\)/\1/g;' + _sed_cmd+='s/\(^\|,\)nobootwait\($\|,\)/\1/g;' - _options=$(echo "$_options" | sed "$_sed_cmd") + _options=$(echo "$_options" | sed "$_sed_cmd") - echo "$_pdev $_new_mntpoint $_fstype $_options" + echo "$_pdev $_new_mntpoint $_fstype $_options" } #Function: get_ssh_size #$1=dump target #called from while loop and shouldn't read from stdin, so we're using "ssh -n" -get_ssh_size() { - local _out - local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes") +get_ssh_size() +{ + local _out + local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes") - if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then - perror_exit "checking remote ssh server available size failed." - fi + if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then + perror_exit "checking remote ssh server available size failed." + fi - echo -n "$_out" | tail -1 + echo -n "$_out" | tail -1 } #mkdir if save path does not exist on ssh dump target @@ -111,320 +116,323 @@ get_ssh_size() { #called from while loop and shouldn't read from stdin, so we're using "ssh -n" mkdir_save_path_ssh() { - local _opt _dir - _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) - ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &>/dev/null || \ - perror_exit "mkdir failed on $1:$SAVE_PATH" + local _opt _dir + _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) + ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &> /dev/null || + perror_exit "mkdir failed on $1:$SAVE_PATH" - # check whether user has write permission on $1:$SAVE_PATH - _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) || \ - perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" - ssh -qn "${_opt[@]}" "$1" rmdir "$_dir" + # check whether user has write permission on $1:$SAVE_PATH + _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2> /dev/null) || + perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" + ssh -qn "${_opt[@]}" "$1" rmdir "$_dir" - return 0 + return 0 } #Function: get_fs_size #$1=dump target -get_fs_size() { - df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1 +get_fs_size() +{ + df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1 } #Function: get_raw_size #$1=dump target -get_raw_size() { - fdisk -s "$1" +get_raw_size() +{ + fdisk -s "$1" } #Function: check_size #$1: dump type string ('raw', 'fs', 'ssh') #$2: dump target -check_size() { - local avail memtotal +check_size() +{ + local avail memtotal - memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo) - case "$1" in - raw) - avail=$(get_raw_size "$2") - ;; - ssh) - avail=$(get_ssh_size "$2") - ;; - fs) - avail=$(get_fs_size "$2") - ;; - *) - return - esac || perror_exit "Check dump target size failed" + memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo) + case "$1" in + raw) + avail=$(get_raw_size "$2") + ;; + ssh) + avail=$(get_ssh_size "$2") + ;; + fs) + avail=$(get_fs_size "$2") + ;; + *) + return + ;; + esac || perror_exit "Check dump target size failed" - if [[ "$avail" -lt "$memtotal" ]]; then - dwarn "Warning: There might not be enough space to save a vmcore." - dwarn " The size of $2 should be greater than $memtotal kilo bytes." - fi + if [[ $avail -lt $memtotal ]]; then + dwarn "Warning: There might not be enough space to save a vmcore." + dwarn " The size of $2 should be greater than $memtotal kilo bytes." + fi } check_save_path_fs() { - local _path=$1 + local _path=$1 - if [[ ! -d $_path ]]; then - perror_exit "Dump path $_path does not exist." - fi + if [[ ! -d $_path ]]; then + perror_exit "Dump path $_path does not exist." + fi } mount_failure() { - local _target=$1 - local _mnt=$2 - local _fstype=$3 - local msg="Failed to mount $_target" + local _target=$1 + local _mnt=$2 + local _fstype=$3 + local msg="Failed to mount $_target" - if [[ -n "$_mnt" ]]; then - msg="$msg on $_mnt" - fi + if [[ -n $_mnt ]]; then + msg="$msg on $_mnt" + fi - msg="$msg for kdump preflight check." + msg="$msg for kdump preflight check." - if [[ $_fstype = "nfs" ]]; then - msg="$msg Please make sure nfs-utils has been installed." - fi + if [[ $_fstype == "nfs" ]]; then + msg="$msg Please make sure nfs-utils has been installed." + fi - perror_exit "$msg" + perror_exit "$msg" } check_user_configured_target() { - local _target=$1 _cfg_fs_type=$2 _mounted - local _mnt _opt _fstype + local _target=$1 _cfg_fs_type=$2 _mounted + local _mnt _opt _fstype - _mnt=$(get_mntpoint_from_target "$_target") - _opt=$(get_mntopt_from_target "$_target") - _fstype=$(get_fs_type_from_target "$_target") + _mnt=$(get_mntpoint_from_target "$_target") + _opt=$(get_mntopt_from_target "$_target") + _fstype=$(get_fs_type_from_target "$_target") - if [[ -n "$_fstype" ]]; then - # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf - [[ $_fstype = "nfs"* ]] && _fstype=nfs + if [[ -n $_fstype ]]; then + # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf + [[ $_fstype == "nfs"* ]] && _fstype=nfs - if [[ -n "$_cfg_fs_type" ]] && [[ "$_fstype" != "$_cfg_fs_type" ]]; then - perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\"" - fi - else - _fstype="$_cfg_fs_type" - _fstype="$_cfg_fs_type" - fi + if [[ -n $_cfg_fs_type ]] && [[ $_fstype != "$_cfg_fs_type" ]]; then + perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\"" + fi + else + _fstype="$_cfg_fs_type" + _fstype="$_cfg_fs_type" + fi - # For noauto mount, mount it inplace with default value. - # Else use the temporary target directory - if [[ -n "$_mnt" ]]; then - if ! is_mounted "$_mnt"; then - if [[ $_opt = *",noauto"* ]]; then - mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype" - _mounted=$_mnt - else - perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" - fi - fi - else - _mnt=$MKDUMPRD_TMPMNT - mkdir -p "$_mnt" - mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype" - _mounted=$_mnt - fi + # For noauto mount, mount it inplace with default value. + # Else use the temporary target directory + if [[ -n $_mnt ]]; then + if ! is_mounted "$_mnt"; then + if [[ $_opt == *",noauto"* ]]; then + mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype" + _mounted=$_mnt + else + perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\"" + fi + fi + else + _mnt=$MKDUMPRD_TMPMNT + mkdir -p "$_mnt" + mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype" + _mounted=$_mnt + fi - # For user configured target, use $SAVE_PATH as the dump path within the target - if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then - perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\"" - fi + # For user configured target, use $SAVE_PATH as the dump path within the target + if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then + perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\"" + fi - check_size fs "$_target" + check_size fs "$_target" - # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway - if [[ -n "$_mounted" ]]; then - umount -f -- "$_mounted" - fi + # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway + if [[ -n $_mounted ]]; then + umount -f -- "$_mounted" + fi } # $1: core_collector config value -verify_core_collector() { - local _cmd="${1%% *}" - local _params="${1#* }" +verify_core_collector() +{ + local _cmd="${1%% *}" + local _params="${1#* }" - if [[ "$_cmd" != "makedumpfile" ]]; then - if is_raw_dump_target; then - dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." - fi - return - fi + if [[ $_cmd != "makedumpfile" ]]; then + if is_raw_dump_target; then + dwarn "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 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 - # shellcheck disable=SC2086 - if ! $_cmd --check-params $_params; then - perror_exit "makedumpfile parameter check failed." - fi + # shellcheck disable=SC2086 + if ! $_cmd --check-params $_params; then + perror_exit "makedumpfile parameter check failed." + fi } -add_mount() { - local _mnt +add_mount() +{ + local _mnt - _mnt=$(to_mount "$@") || exit 1 + _mnt=$(to_mount "$@") || exit 1 - add_dracut_mount "$_mnt" + add_dracut_mount "$_mnt" } #handle the case user does not specify the dump target explicitly handle_default_dump_target() { - local _target - local _mntpoint + local _target + local _mntpoint - is_user_configured_dump_target && return + is_user_configured_dump_target && return - check_save_path_fs "$SAVE_PATH" + check_save_path_fs "$SAVE_PATH" - _save_path=$(get_bind_mount_source "$SAVE_PATH") - _target=$(get_target_from_path "$_save_path") - _mntpoint=$(get_mntpoint_from_target "$_target") + _save_path=$(get_bind_mount_source "$SAVE_PATH") + _target=$(get_target_from_path "$_save_path") + _mntpoint=$(get_mntpoint_from_target "$_target") - SAVE_PATH=${_save_path##"$_mntpoint"} - add_mount "$_target" - check_size fs "$_target" + SAVE_PATH=${_save_path##"$_mntpoint"} + add_mount "$_target" + check_size fs "$_target" } # $1: function name for_each_block_target() { - local dev majmin + local dev majmin - for dev in $(get_kdump_targets); do - [[ -b "$dev" ]] || continue - majmin=$(get_maj_min "$dev") - check_block_and_slaves "$1" "$majmin" && return 1 - done + for dev in $(get_kdump_targets); do + [[ -b $dev ]] || continue + majmin=$(get_maj_min "$dev") + check_block_and_slaves "$1" "$majmin" && return 1 + done - return 0 + return 0 } #judge if a specific device with $1 is unresettable #return false if unresettable. is_unresettable() { - local path device resettable=1 + local path device resettable=1 - path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" - if [[ -f "$path" ]]; then - resettable="$(<"$path")" - [[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && { - device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') - derror "Error: Can not save vmcore because device $device is unresettable" - return 0 - } - fi + path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" + if [[ -f $path ]]; then + resettable="$(< "$path")" + [[ $resettable -eq 0 ]] && [[ $OVERRIDE_RESETTABLE -eq 0 ]] && { + device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') + derror "Error: Can not save vmcore because device $device is unresettable" + return 0 + } + fi - return 1 + return 1 } #check if machine is resettable. #return true if resettable check_resettable() { - local _target _override_resettable + local _target _override_resettable - _override_resettable=$(kdump_get_conf_val override_resettable) - OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE} - if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then - perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid" - fi + _override_resettable=$(kdump_get_conf_val override_resettable) + OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE} + if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ]; then + perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid" + fi - for_each_block_target is_unresettable && return + for_each_block_target is_unresettable && return - return 1 + return 1 } check_crypt() { - local _dev + local _dev - for _dev in $(get_kdump_targets); do - if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then - derror "Device $_dev is encrypted." && return 1 - fi - done + for _dev in $(get_kdump_targets); do + if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then + derror "Device $_dev is encrypted." && return 1 + fi + done } if ! check_resettable; then - exit 1 + exit 1 fi if ! check_crypt; then - dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." + dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." fi # firstly get right SSH_KEY_LOCATION keyfile=$(kdump_get_conf_val sshkey) -if [[ -f "$keyfile" ]]; then - # canonicalize the path - SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile") +if [[ -f $keyfile ]]; then + # canonicalize the path + SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile") fi -while read -r config_opt config_val; -do - # remove inline comments after the end of a directive. - case "$config_opt" in - extra_modules) - extra_modules="$extra_modules $config_val" - ;; - ext[234]|xfs|btrfs|minix|nfs) - check_user_configured_target "$config_val" "$config_opt" - add_mount "$config_val" "$config_opt" - ;; - raw) - # checking raw disk writable - dd if="$config_val" count=1 of=/dev/null > /dev/null 2>&1 || { - perror_exit "Bad raw disk $config_val" - } - _praw=$(persistent_policy="by-id" kdump_get_persistent_dev "$config_val") - if [[ -z $_praw ]]; then - exit 1 - fi - add_dracut_arg "--device" "$_praw" - check_size raw "$config_val" - ;; - ssh) - if strstr "$config_val" "@"; - then - mkdir_save_path_ssh "$config_val" - check_size ssh "$config_val" - add_dracut_sshkey "$SSH_KEY_LOCATION" - else - perror_exit "Bad ssh dump target $config_val" - fi - ;; - core_collector) - verify_core_collector "$config_val" - ;; - dracut_args) - while read -r dracut_arg; do - add_dracut_arg "$dracut_arg" - done <<< "$(echo "$config_val" | xargs -n 1 echo)" - ;; - *) - ;; - esac +while read -r config_opt config_val; do + # remove inline comments after the end of a directive. + case "$config_opt" in + extra_modules) + extra_modules="$extra_modules $config_val" + ;; + ext[234] | xfs | btrfs | minix | nfs) + check_user_configured_target "$config_val" "$config_opt" + add_mount "$config_val" "$config_opt" + ;; + raw) + # checking raw disk writable + dd if="$config_val" count=1 of=/dev/null > /dev/null 2>&1 || { + perror_exit "Bad raw disk $config_val" + } + _praw=$(persistent_policy="by-id" kdump_get_persistent_dev "$config_val") + if [[ -z $_praw ]]; then + exit 1 + fi + add_dracut_arg "--device" "$_praw" + check_size raw "$config_val" + ;; + ssh) + if strstr "$config_val" "@"; then + mkdir_save_path_ssh "$config_val" + check_size ssh "$config_val" + add_dracut_sshkey "$SSH_KEY_LOCATION" + else + perror_exit "Bad ssh dump target $config_val" + fi + ;; + core_collector) + verify_core_collector "$config_val" + ;; + dracut_args) + while read -r dracut_arg; do + add_dracut_arg "$dracut_arg" + done <<< "$(echo "$config_val" | xargs -n 1 echo)" + ;; + *) ;; + + esac done <<< "$(kdump_read_conf)" handle_default_dump_target -if [[ -n "$extra_modules" ]] -then - add_dracut_arg "--add-drivers" "$extra_modules" +if [[ -n $extra_modules ]]; then + add_dracut_arg "--add-drivers" "$extra_modules" fi # TODO: The below check is not needed anymore with the introduction of @@ -433,11 +441,11 @@ fi # parameter available in fadump case. So, find a way to fix that first # before removing this check. if ! is_fadump_capable; then - # The 2nd rootfs mount stays behind the normal dump target mount, - # so it doesn't affect the logic of check_dump_fs_modified(). - is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")" + # The 2nd rootfs mount stays behind the normal dump target mount, + # so it doesn't affect the logic of check_dump_fs_modified(). + is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")" - add_dracut_arg "--no-hostonly-default-device" + add_dracut_arg "--no-hostonly-default-device" fi dracut "${dracut_args[@]}" "$@" diff --git a/mkfadumprd b/mkfadumprd index 5c96ee7..b890f83 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -44,22 +44,22 @@ fi ### Unpack the initramfs having dump capture capability mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" -if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && \ +if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && popd > /dev/null); then derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" exit 1 fi ### Pack it into the normal boot initramfs with zz-fadumpinit module -_dracut_isolate_args=(\ - --rebuild "$REBUILD_INITRD" --add zz-fadumpinit \ +_dracut_isolate_args=( + --rebuild "$REBUILD_INITRD" --add zz-fadumpinit -i "$MKFADUMPRD_TMPDIR/fadumproot" /fadumproot -i "$MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt" /usr/lib/dracut/fadump-kernel-modules.txt ) if is_squash_available; then - _dracut_isolate_args+=( --add squash ) + _dracut_isolate_args+=(--add squash) fi if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then From a5faa052d4969cb66719d0b795d746449d3c71b7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 14 Sep 2021 03:25:46 +0800 Subject: [PATCH 479/806] kdump-lib-initramfs.sh: prepare to be a POSIX compatible lib Move all functions needed in the second kernel from kdump-lib.sh to kdump-lib-initramfs.sh, and update shebang headers. Now, kdump-lib-initramfs.sh is an independent lib script, no longer depend on kdump-lib.sh, and kdump-lib.sh is no longer needed for the second kernel. In later commits, functions in kdump-lib-initramfs.sh will be reworked to be POSIX compatible, kdump-lib.sh will contain bash only functions. POSIX shell have very limited features, eg. `local` keyword doesn't exist in POSIX but we rely on that heavily. So kdump-lib.sh will use bash syntax and contain the most complex helper and codes. kdump-lib-initramfs.sh will contain the minimum set of helpers, and be shared by both the first and second kernel. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- .editorconfig | 2 +- dracut-module-setup.sh | 1 - kdump-lib-initramfs.sh | 133 ++++++++++++++++++++++++++++++++++++++++- kdump-lib.sh | 131 +--------------------------------------- 4 files changed, 135 insertions(+), 132 deletions(-) diff --git a/.editorconfig b/.editorconfig index bd8fc8c..87c4f98 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,7 +18,7 @@ binary_next_line = false space_redirects = true # Some scripts will only run with bash -[{mkfadumprd,mkdumprd,kdumpctl}] +[{mkfadumprd,mkdumprd,kdumpctl,kdump-lib.sh}] shell_variant = bash # Use dracut code style for *-module-setup.sh diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8bbf0cf..4fb013d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1034,7 +1034,6 @@ install() { inst "/usr/bin/printf" "/sbin/printf" inst "/usr/bin/logger" "/sbin/logger" inst "/usr/bin/chmod" "/sbin/chmod" - inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 50443e5..73b2699 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,8 +1,11 @@ -# These variables and functions are useful in 2nd kernel +#!/bin/sh +# +# Function and variables used in initramfs environment, POSIX compatible +# -. /lib/kdump-lib.sh . /lib/kdump-logger.sh +DEFAULT_PATH="/var/crash/" KDUMP_PATH="/var/crash" KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" CORE_COLLECTOR="" @@ -20,6 +23,7 @@ KDUMP_PRE="" KDUMP_POST="" NEWROOT="/sysroot" OPALCORE="/sys/firmware/opal/mpipl/core" +KDUMP_CONFIG_FILE="/etc/kdump.conf" #initiate the kdump logger dlog_init @@ -28,6 +32,131 @@ if [ $? -ne 0 ]; then exit 1 fi +# Read kdump config in well formated style +kdump_read_conf() +{ + # Following steps are applied in order: strip trailing comment, strip trailing space, + # strip heading space, match non-empty line, remove duplicated spaces between conf name and value + [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE +} + +# Retrieves config value defined in kdump.conf +# $1: config name, sed regexp compatible +kdump_get_conf_val() { + # For lines matching "^\s*$1\s+", remove matched part (config name including space), + # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. + [ -f "$KDUMP_CONFIG_FILE" ] && \ + sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE +} + +is_mounted() +{ + findmnt -k -n $1 &>/dev/null +} + +get_mount_info() +{ + local _info_type=$1 _src_type=$2 _src=$3; shift 3 + local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@) + + [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@) + + echo $_info +} + +is_ipv6_address() +{ + echo $1 | grep -q ":" +} + +is_fs_type_nfs() +{ + [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] +} + +# If $1 contains dracut_args "--mount", return +get_dracut_args_fstype() +{ + echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3 +} + +# If $1 contains dracut_args "--mount", return +get_dracut_args_target() +{ + echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 +} + +get_save_path() +{ + local _save_path=$(kdump_get_conf_val path) + [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH + + # strip the duplicated "/" + echo $_save_path | tr -s / +} + +get_root_fs_device() +{ + findmnt -k -f -n -o SOURCE / +} + +# Return the current underlying device of a path, ignore bind mounts +get_target_from_path() +{ + local _target + + _target=$(df $1 2>/dev/null | tail -1 | awk '{print $1}') + [[ "$_target" == "/dev/root" ]] && [[ ! -e /dev/root ]] && _target=$(get_root_fs_device) + echo $_target +} + +get_fs_type_from_target() +{ + get_mount_info FSTYPE source $1 -f +} + +get_mntpoint_from_target() +{ + # --source is applied to ensure non-bind mount is returned + get_mount_info TARGET source $1 -f +} + +is_ssh_dump_target() +{ + [[ $(kdump_get_conf_val ssh) == *@* ]] +} + +is_raw_dump_target() +{ + [[ $(kdump_get_conf_val raw) ]] +} + +is_nfs_dump_target() +{ + if [[ $(kdump_get_conf_val nfs) ]]; then + return 0; + fi + + if is_fs_type_nfs $(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)"); then + return 0 + fi + + local _save_path=$(get_save_path) + local _target=$(get_target_from_path $_save_path) + local _fstype=$(get_fs_type_from_target $_target) + + if is_fs_type_nfs $_fstype; then + return 0 + fi + + return 1 +} + +is_fs_dump_target() +{ + [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix") ]] +} + get_kdump_confs() { local config_opt config_val diff --git a/kdump-lib.sh b/kdump-lib.sh index 7e620c7..d7cb40e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -1,13 +1,13 @@ -#!/bin/sh +#!/bin/bash # # Kdump common variables and functions # -DEFAULT_PATH="/var/crash/" +. /usr/lib/kdump/kdump-lib-initramfs.sh + FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" -KDUMP_CONFIG_FILE="/etc/kdump.conf" is_fadump_capable() { @@ -35,64 +35,6 @@ perror_exit() { exit 1 } -is_fs_type_nfs() -{ - [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] -} - -is_ssh_dump_target() -{ - [[ $(kdump_get_conf_val ssh) == *@* ]] -} - -is_nfs_dump_target() -{ - if [[ $(kdump_get_conf_val nfs) ]]; then - return 0; - fi - - if is_fs_type_nfs $(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)"); then - return 0 - fi - - local _save_path=$(get_save_path) - local _target=$(get_target_from_path $_save_path) - local _fstype=$(get_fs_type_from_target $_target) - - if is_fs_type_nfs $_fstype; then - return 0 - fi - - return 1 -} - -is_raw_dump_target() -{ - [[ $(kdump_get_conf_val raw) ]] -} - -is_fs_dump_target() -{ - [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix") ]] -} - -# Read kdump config in well formatted style -kdump_read_conf() -{ - # Following steps are applied in order: strip trailing comment, strip trailing space, - # strip heading space, match non-empty line, remove duplicated spaces between conf name and value - [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE -} - -# Retrieves config value defined in kdump.conf -# $1: config name, sed regexp compatible -kdump_get_conf_val() { - # For lines matching "^\s*$1\s+", remove matched part (config name including space), - # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. - [ -f "$KDUMP_CONFIG_FILE" ] && \ - sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE -} - # Check if fence kdump is configured in Pacemaker cluster is_pcs_fence_kdump() { @@ -142,20 +84,6 @@ get_user_configured_dump_disk() [ -b "$_target" ] && echo $_target } -get_root_fs_device() -{ - findmnt -k -f -n -o SOURCE / -} - -get_save_path() -{ - local _save_path=$(kdump_get_conf_val path) - [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH - - # strip the duplicated "/" - echo $_save_path | tr -s / -} - get_block_dump_target() { local _target _path @@ -261,46 +189,10 @@ get_bind_mount_source() echo $_mnt$_fsroot$_path } -# Return the current underlaying device of a path, ignore bind mounts -get_target_from_path() -{ - local _target - - _target=$(df $1 2>/dev/null | tail -1 | awk '{print $1}') - [[ "$_target" == "/dev/root" ]] && [[ ! -e /dev/root ]] && _target=$(get_root_fs_device) - echo $_target -} - -is_mounted() -{ - findmnt -k -n $1 &>/dev/null -} - -get_mount_info() -{ - local _info_type=$1 _src_type=$2 _src=$3; shift 3 - local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@) - - [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@) - - echo $_info -} - -get_fs_type_from_target() -{ - get_mount_info FSTYPE source $1 -f -} - get_mntopt_from_target() { get_mount_info OPTIONS source $1 -f } -# Find the general mount point of a dump target, not the bind mount point -get_mntpoint_from_target() -{ - # Expcilitly specify --source to findmnt could ensure non-bind mount is returned - get_mount_info TARGET source $1 -f -} # Get the path where the target will be mounted in kdump kernel # $1: kdump target device @@ -345,11 +237,6 @@ is_atomic() grep -q "ostree" /proc/cmdline } -is_ipv6_address() -{ - echo $1 | grep -q ":" -} - # get ip address or hostname from nfs/ssh config value get_remote_host() { @@ -562,18 +449,6 @@ is_mount_in_dracut_args() [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] } -# If $1 contains dracut_args "--mount", return -get_dracut_args_fstype() -{ - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3 -} - -# If $1 contains dracut_args "--mount", return -get_dracut_args_target() -{ - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 -} - check_crash_mem_reserved() { local mem_reserved From e7118d1de84b604b25b2f6332f4ae071a9dc08fd Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 2 Aug 2021 00:50:22 +0800 Subject: [PATCH 480/806] Merge kdump-error-handler.sh into kdump.sh kdump-error-handler.sh does nothing except calling three functions, it can be easily merged into kdump.sh by using a parameter to run the error handling routine. kdump-lib-initramfs.sh was created to hold the three shared functions and related code, so by merging these two files, kdump-lib-initramfs.sh can be simplified by a lot. Following up commits will clean up kdump-lib-initramfs.sh. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump-emergency.service | 2 +- dracut-kdump-error-handler.sh | 10 ---------- dracut-kdump.sh | 21 ++++++++++++++++----- dracut-module-setup.sh | 1 - kexec-tools.spec | 2 -- 5 files changed, 17 insertions(+), 19 deletions(-) delete mode 100755 dracut-kdump-error-handler.sh diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service index f2f6fad..0cf7051 100644 --- a/dracut-kdump-emergency.service +++ b/dracut-kdump-emergency.service @@ -12,7 +12,7 @@ Environment=HOME=/ Environment=DRACUT_SYSTEMD=1 Environment=NEWROOT=/sysroot WorkingDirectory=/ -ExecStart=/bin/kdump-error-handler.sh +ExecStart=/bin/kdump.sh --error-handler ExecStopPost=-/bin/rm -f -- /.console_lock Type=oneshot StandardInput=tty-force diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh deleted file mode 100755 index fc2b932..0000000 --- a/dracut-kdump-error-handler.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -. /lib/kdump-lib-initramfs.sh - -set -o pipefail -export PATH=$PATH:$KDUMP_SCRIPT_DIR - -get_kdump_confs -do_failure_action -do_final_action diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 3c165b3..352cad5 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -1,9 +1,7 @@ #!/bin/sh - -# continue here only if we have to save dump. -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then - exit 0 -fi +# +# The main kdump routine in capture kernel +# . /lib/dracut-lib.sh . /lib/kdump-lib-initramfs.sh @@ -288,6 +286,19 @@ fence_kdump_notify() fi } +if [ "$1" = "--error-handler" ]; then + get_kdump_confs + do_failure_action + do_final_action + + exit $? +fi + +# continue here only if we have to save dump. +if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then + exit 0 +fi + read_kdump_confs fence_kdump_notify diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4fb013d..d6011ee 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1039,7 +1039,6 @@ install() { inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service - inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh" # Replace existing emergency service and emergency target cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" diff --git a/kexec-tools.spec b/kexec-tools.spec index 7db9f9c..f71ff81 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -52,7 +52,6 @@ Source36: kdump-restart.sh Source100: dracut-kdump.sh Source101: dracut-module-setup.sh Source102: dracut-monitor_dd_progress -Source103: dracut-kdump-error-handler.sh Source104: dracut-kdump-emergency.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target @@ -241,7 +240,6 @@ mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} -cp %{SOURCE103} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE103}} cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} From a1205effaa98c08974c39c3283d191c70337857a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 5 Aug 2021 00:59:29 +0800 Subject: [PATCH 481/806] kdump-lib-initramfs.sh: move dump related functions to kdump.sh These dump related functions are only used by dracut-kdump.sh. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 288 ++++++++++++++++++++++++++++++++++++++++ kdump-lib-initramfs.sh | 289 ----------------------------------------- 2 files changed, 288 insertions(+), 289 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 352cad5..a785ab9 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -4,13 +4,301 @@ # . /lib/dracut-lib.sh +. /lib/kdump-logger.sh . /lib/kdump-lib-initramfs.sh +#initiate the kdump logger +dlog_init +if [ $? -ne 0 ]; then + echo "failed to initiate the kdump logger." + exit 1 +fi + +KDUMP_PATH="/var/crash" +KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" +CORE_COLLECTOR="" +DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31" +DMESG_COLLECTOR="/sbin/vmcore-dmesg" +FAILURE_ACTION="systemctl reboot -f" +DATEDIR=`date +%Y-%m-%d-%T` +HOST_IP='127.0.0.1' +DUMP_INSTRUCTION="" +SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +KDUMP_SCRIPT_DIR="/kdumpscripts" +DD_BLKSIZE=512 +FINAL_ACTION="systemctl reboot -f" +KDUMP_PRE="" +KDUMP_POST="" +NEWROOT="/sysroot" +OPALCORE="/sys/firmware/opal/mpipl/core" + set -o pipefail DUMP_RETVAL=0 export PATH=$PATH:$KDUMP_SCRIPT_DIR +get_kdump_confs() +{ + local config_opt config_val + + while read config_opt config_val; + do + # remove inline comments after the end of a directive. + case "$config_opt" in + path) + KDUMP_PATH="$config_val" + ;; + core_collector) + [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" + ;; + sshkey) + if [ -f "$config_val" ]; then + SSH_KEY_LOCATION=$config_val + fi + ;; + kdump_pre) + KDUMP_PRE="$config_val" + ;; + kdump_post) + KDUMP_POST="$config_val" + ;; + fence_kdump_args) + FENCE_KDUMP_ARGS="$config_val" + ;; + fence_kdump_nodes) + FENCE_KDUMP_NODES="$config_val" + ;; + failure_action|default) + case $config_val in + shell) + FAILURE_ACTION="kdump_emergency_shell" + ;; + reboot) + FAILURE_ACTION="systemctl reboot -f && exit" + ;; + halt) + FAILURE_ACTION="halt && exit" + ;; + poweroff) + FAILURE_ACTION="systemctl poweroff -f && exit" + ;; + dump_to_rootfs) + FAILURE_ACTION="dump_to_rootfs" + ;; + esac + ;; + final_action) + case $config_val in + reboot) + FINAL_ACTION="systemctl reboot -f" + ;; + halt) + FINAL_ACTION="halt" + ;; + poweroff) + FINAL_ACTION="systemctl poweroff -f" + ;; + esac + ;; + esac + done <<< "$(kdump_read_conf)" + + if [ -z "$CORE_COLLECTOR" ]; then + CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" + if is_ssh_dump_target || is_raw_dump_target; then + CORE_COLLECTOR="$CORE_COLLECTOR -F" + fi + fi +} + +# store the kexec kernel log to a file. +save_log() +{ + dmesg -T > $KDUMP_LOG_FILE + + if command -v journalctl > /dev/null; then + journalctl -ab >> $KDUMP_LOG_FILE + fi + chmod 600 $KDUMP_LOG_FILE +} + +# dump_fs +dump_fs() +{ + local _exitcode + local _mp=$1 + local _op=$(get_mount_info OPTIONS target $_mp -f) + ddebug "dump_fs _mp=$_mp _opts=$_op" + + if ! is_mounted "$_mp"; then + dinfo "dump path \"$_mp\" is not mounted, trying to mount..." + mount --target $_mp + if [ $? -ne 0 ]; then + derror "failed to dump to \"$_mp\", it's not a mount point!" + return 1 + fi + fi + + # Remove -F in makedumpfile case. We don't want a flat format dump here. + [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"` + + local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) + + dinfo "saving to $_dump_path" + + # Only remount to read-write mode if the dump target is mounted read-only. + if [[ "$_op" = "ro"* ]]; then + dinfo "Remounting the dump target in rw mode." + mount -o remount,rw $_mp || return 1 + fi + + mkdir -p $_dump_path || return 1 + + save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path" + save_opalcore_fs "$_dump_path" + + dinfo "saving vmcore" + $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete + _exitcode=$? + if [ $_exitcode -eq 0 ]; then + mv $_dump_path/vmcore-incomplete $_dump_path/vmcore + sync + dinfo "saving vmcore complete" + else + derror "saving vmcore failed, _exitcode:$_exitcode" + fi + + dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/" + save_log + mv $KDUMP_LOG_FILE $_dump_path/ + if [ $_exitcode -ne 0 ]; then + return 1 + fi + + # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure + return 0 +} + +save_vmcore_dmesg_fs() { + local _dmesg_collector=$1 + local _path=$2 + + dinfo "saving vmcore-dmesg.txt to ${_path}" + $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt + _exitcode=$? + if [ $_exitcode -eq 0 ]; then + mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt + chmod 600 ${_path}/vmcore-dmesg.txt + + # Make sure file is on disk. There have been instances where later + # saving vmcore failed and system rebooted without sync and there + # was no vmcore-dmesg.txt available. + sync + dinfo "saving vmcore-dmesg.txt complete" + else + if [ -f ${_path}/vmcore-dmesg-incomplete.txt ]; then + chmod 600 ${_path}/vmcore-dmesg-incomplete.txt + fi + derror "saving vmcore-dmesg.txt failed" + fi +} + +save_opalcore_fs() { + local _path=$1 + + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi + + dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore" + cp $OPALCORE ${_path}/opalcore + if [ $? -ne 0 ]; then + derror "saving opalcore failed" + return 1 + fi + + sync + dinfo "saving opalcore complete" + return 0 +} + +dump_to_rootfs() +{ + + if [[ $(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p") == "inactive" ]]; then + dinfo "Trying to bring up initqueue for rootfs mount" + systemctl start dracut-initqueue + fi + + dinfo "Clean up dead systemd services" + systemctl cancel + dinfo "Waiting for rootfs mount, will timeout after 90 seconds" + systemctl start --no-block sysroot.mount + + _loop=0 + while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do + sleep 1 + _loop=$((_loop + 1)) + done + + if ! is_mounted /sysroot; then + derror "Failed to mount rootfs" + return + fi + + ddebug "NEWROOT=$NEWROOT" + dump_fs $NEWROOT +} + +kdump_emergency_shell() +{ + ddebug "Switching to kdump emergency shell..." + + [ -f /etc/profile ] && . /etc/profile + export PS1='kdump:${PWD}# ' + + . /lib/dracut-lib.sh + if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2>/dev/null + fi + + source_conf /etc/conf.d + + type plymouth >/dev/null 2>&1 && plymouth quit + + source_hook "emergency" + while read _tty rest; do + ( + echo + echo + echo 'Entering kdump emergency mode.' + echo 'Type "journalctl" to view system logs.' + echo 'Type "rdsosreport" to generate a sosreport, you can then' + echo 'save it elsewhere and attach it to a bug report.' + echo + echo + ) > /dev/$_tty + done < /proc/consoles + sh -i -l + /bin/rm -f -- /.console_lock +} + +do_failure_action() +{ + dinfo "Executing failure action $FAILURE_ACTION" + eval $FAILURE_ACTION +} + +do_final_action() +{ + dinfo "Executing final action $FINAL_ACTION" + eval $FINAL_ACTION +} do_dump() { local _ret diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 73b2699..b30b024 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -3,35 +3,9 @@ # Function and variables used in initramfs environment, POSIX compatible # -. /lib/kdump-logger.sh - DEFAULT_PATH="/var/crash/" -KDUMP_PATH="/var/crash" -KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" -CORE_COLLECTOR="" -DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31" -DMESG_COLLECTOR="/sbin/vmcore-dmesg" -FAILURE_ACTION="systemctl reboot -f" -DATEDIR=`date +%Y-%m-%d-%T` -HOST_IP='127.0.0.1' -DUMP_INSTRUCTION="" -SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -KDUMP_SCRIPT_DIR="/kdumpscripts" -DD_BLKSIZE=512 -FINAL_ACTION="systemctl reboot -f" -KDUMP_PRE="" -KDUMP_POST="" -NEWROOT="/sysroot" -OPALCORE="/sys/firmware/opal/mpipl/core" KDUMP_CONFIG_FILE="/etc/kdump.conf" -#initiate the kdump logger -dlog_init -if [ $? -ne 0 ]; then - echo "failed to initiate the kdump logger." - exit 1 -fi - # Read kdump config in well formated style kdump_read_conf() { @@ -156,266 +130,3 @@ is_fs_dump_target() { [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix") ]] } - -get_kdump_confs() -{ - local config_opt config_val - - while read config_opt config_val; - do - # remove inline comments after the end of a directive. - case "$config_opt" in - path) - KDUMP_PATH="$config_val" - ;; - core_collector) - [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" - ;; - sshkey) - if [ -f "$config_val" ]; then - SSH_KEY_LOCATION=$config_val - fi - ;; - kdump_pre) - KDUMP_PRE="$config_val" - ;; - kdump_post) - KDUMP_POST="$config_val" - ;; - fence_kdump_args) - FENCE_KDUMP_ARGS="$config_val" - ;; - fence_kdump_nodes) - FENCE_KDUMP_NODES="$config_val" - ;; - failure_action|default) - case $config_val in - shell) - FAILURE_ACTION="kdump_emergency_shell" - ;; - reboot) - FAILURE_ACTION="systemctl reboot -f && exit" - ;; - halt) - FAILURE_ACTION="halt && exit" - ;; - poweroff) - FAILURE_ACTION="systemctl poweroff -f && exit" - ;; - dump_to_rootfs) - FAILURE_ACTION="dump_to_rootfs" - ;; - esac - ;; - final_action) - case $config_val in - reboot) - FINAL_ACTION="systemctl reboot -f" - ;; - halt) - FINAL_ACTION="halt" - ;; - poweroff) - FINAL_ACTION="systemctl poweroff -f" - ;; - esac - ;; - esac - done <<< "$(kdump_read_conf)" - - if [ -z "$CORE_COLLECTOR" ]; then - CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" - if is_ssh_dump_target || is_raw_dump_target; then - CORE_COLLECTOR="$CORE_COLLECTOR -F" - fi - fi -} - -# store the kexec kernel log to a file. -save_log() -{ - dmesg -T > $KDUMP_LOG_FILE - - if command -v journalctl > /dev/null; then - journalctl -ab >> $KDUMP_LOG_FILE - fi - chmod 600 $KDUMP_LOG_FILE -} - -# dump_fs -dump_fs() -{ - local _exitcode - local _mp=$1 - local _op=$(get_mount_info OPTIONS target $_mp -f) - ddebug "dump_fs _mp=$_mp _opts=$_op" - - if ! is_mounted "$_mp"; then - dinfo "dump path \"$_mp\" is not mounted, trying to mount..." - mount --target $_mp - if [ $? -ne 0 ]; then - derror "failed to dump to \"$_mp\", it's not a mount point!" - return 1 - fi - fi - - # Remove -F in makedumpfile case. We don't want a flat format dump here. - [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"` - - local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) - - dinfo "saving to $_dump_path" - - # Only remount to read-write mode if the dump target is mounted read-only. - if [[ "$_op" = "ro"* ]]; then - dinfo "Remounting the dump target in rw mode." - mount -o remount,rw $_mp || return 1 - fi - - mkdir -p $_dump_path || return 1 - - save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path" - save_opalcore_fs "$_dump_path" - - dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete - _exitcode=$? - if [ $_exitcode -eq 0 ]; then - mv $_dump_path/vmcore-incomplete $_dump_path/vmcore - sync - dinfo "saving vmcore complete" - else - derror "saving vmcore failed, _exitcode:$_exitcode" - fi - - dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/" - save_log - mv $KDUMP_LOG_FILE $_dump_path/ - if [ $_exitcode -ne 0 ]; then - return 1 - fi - - # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure - return 0 -} - -save_vmcore_dmesg_fs() { - local _dmesg_collector=$1 - local _path=$2 - - dinfo "saving vmcore-dmesg.txt to ${_path}" - $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt - _exitcode=$? - if [ $_exitcode -eq 0 ]; then - mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt - chmod 600 ${_path}/vmcore-dmesg.txt - - # Make sure file is on disk. There have been instances where later - # saving vmcore failed and system rebooted without sync and there - # was no vmcore-dmesg.txt available. - sync - dinfo "saving vmcore-dmesg.txt complete" - else - if [ -f ${_path}/vmcore-dmesg-incomplete.txt ]; then - chmod 600 ${_path}/vmcore-dmesg-incomplete.txt - fi - derror "saving vmcore-dmesg.txt failed" - fi -} - -save_opalcore_fs() { - local _path=$1 - - if [ ! -f $OPALCORE ]; then - # Check if we are on an old kernel that uses a different path - if [ -f /sys/firmware/opal/core ]; then - OPALCORE="/sys/firmware/opal/core" - else - return 0 - fi - fi - - dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore" - cp $OPALCORE ${_path}/opalcore - if [ $? -ne 0 ]; then - derror "saving opalcore failed" - return 1 - fi - - sync - dinfo "saving opalcore complete" - return 0 -} - -dump_to_rootfs() -{ - - if [[ $(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p") == "inactive" ]]; then - dinfo "Trying to bring up initqueue for rootfs mount" - systemctl start dracut-initqueue - fi - - dinfo "Clean up dead systemd services" - systemctl cancel - dinfo "Waiting for rootfs mount, will timeout after 90 seconds" - systemctl start --no-block sysroot.mount - - _loop=0 - while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do - sleep 1 - _loop=$((_loop + 1)) - done - - if ! is_mounted /sysroot; then - derror "Failed to mount rootfs" - return - fi - - ddebug "NEWROOT=$NEWROOT" - dump_fs $NEWROOT -} - -kdump_emergency_shell() -{ - ddebug "Switching to kdump emergency shell..." - - [ -f /etc/profile ] && . /etc/profile - export PS1='kdump:${PWD}# ' - - . /lib/dracut-lib.sh - if [ -f /dracut-state.sh ]; then - . /dracut-state.sh 2>/dev/null - fi - - source_conf /etc/conf.d - - type plymouth >/dev/null 2>&1 && plymouth quit - - source_hook "emergency" - while read _tty rest; do - ( - echo - echo - echo 'Entering kdump emergency mode.' - echo 'Type "journalctl" to view system logs.' - echo 'Type "rdsosreport" to generate a sosreport, you can then' - echo 'save it elsewhere and attach it to a bug report.' - echo - echo - ) > /dev/$_tty - done < /proc/consoles - sh -i -l - /bin/rm -f -- /.console_lock -} - -do_failure_action() -{ - dinfo "Executing failure action $FAILURE_ACTION" - eval $FAILURE_ACTION -} - -do_final_action() -{ - dinfo "Executing final action $FINAL_ACTION" - eval $FINAL_ACTION -} From 0675edbadb2320b8809aa8751b356ccafc78d857 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 2 Aug 2021 01:19:44 +0800 Subject: [PATCH 482/806] dracut-kdump.sh: don't put KDUMP_SCRIPT_DIR in PATH monitor_dd_progress is the only extra binary in KDUMP_SCRIPT_DIR, no need to change PATH environment variable, just call it directly. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index a785ab9..54e9713 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -24,7 +24,6 @@ DATEDIR=`date +%Y-%m-%d-%T` HOST_IP='127.0.0.1' DUMP_INSTRUCTION="" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" -KDUMP_SCRIPT_DIR="/kdumpscripts" DD_BLKSIZE=512 FINAL_ACTION="systemctl reboot -f" KDUMP_PRE="" @@ -35,8 +34,6 @@ OPALCORE="/sys/firmware/opal/mpipl/core" set -o pipefail DUMP_RETVAL=0 -export PATH=$PATH:$KDUMP_SCRIPT_DIR - get_kdump_confs() { local config_opt config_val @@ -378,7 +375,7 @@ dump_raw() if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then _src_size=`ls -l /proc/vmcore | cut -d' ' -f5` _src_size_mb=$(($_src_size / 1048576)) - monitor_dd_progress $_src_size_mb & + /kdumpscripts/monitor_dd_progress $_src_size_mb & fi dinfo "saving vmcore" From 8f89e890713c382c88a7e00420ef3b98c2dc708d Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 2 Aug 2021 01:25:17 +0800 Subject: [PATCH 483/806] dracut-kdump.sh: remove add_dump_code `add_dump_code ""` is just `DUMP_INSTRUCTION=""`, no need a extra wrapper for that. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 54e9713..7cfa31b 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -36,9 +36,7 @@ DUMP_RETVAL=0 get_kdump_confs() { - local config_opt config_val - - while read config_opt config_val; + while read -r config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in @@ -359,11 +357,6 @@ do_kdump_post() fi } -add_dump_code() -{ - DUMP_INSTRUCTION=$1 -} - dump_raw() { local _raw=$1 @@ -547,18 +540,18 @@ read_kdump_confs() config_val=$(get_dracut_args_target "$config_val") if [ -n "$config_val" ]; then config_val=$(get_mntpoint_from_target "$config_val") - add_dump_code "dump_fs $config_val" + DUMP_INSTRUCTION="dump_fs $config_val" fi ;; ext[234]|xfs|btrfs|minix|nfs) config_val=$(get_mntpoint_from_target "$config_val") - add_dump_code "dump_fs $config_val" + DUMP_INSTRUCTION="dump_fs $config_val" ;; raw) - add_dump_code "dump_raw $config_val" + DUMP_INSTRUCTION="dump_raw $config_val" ;; ssh) - add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" + DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac done <<< "$(kdump_read_conf)" @@ -594,7 +587,7 @@ if [ $? -ne 0 ]; then fi if [ -z "$DUMP_INSTRUCTION" ]; then - add_dump_code "dump_fs $NEWROOT" + DUMP_INSTRUCTION="dump_fs $NEWROOT" fi do_kdump_pre From 7a9823b42e13cb9ff535009f28f89d197b14bbb0 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 3 Aug 2021 13:23:26 +0800 Subject: [PATCH 484/806] dracut-kdump.sh: simplify dump_ssh There is a workaround for `scp` that it expects IPv6 address to be quoted with [ ... ], only apply the workaround once and store the updated `scp` address to reuse it. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 7cfa31b..b92854e 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -387,29 +387,25 @@ dump_ssh() local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" local _host=$2 local _vmcore="vmcore" - local _ipv6_addr="" _username="" + + if is_ipv6_address "$_host"; then + _scp_address=${_host%@*}@"[${_host#*@}]" + else + _scp_address=$_host + fi dinfo "saving to $_host:$_dir" cat /var/lib/random-seed > /dev/urandom ssh -q $_opt $_host mkdir -p $_dir || return 1 - save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $_host - save_opalcore_ssh ${_dir} "${_opt}" $_host - + save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" "$_host" dinfo "saving vmcore" - if is_ipv6_address "$_host"; then - _username=${_host%@*} - _ipv6_addr="[${_host#*@}]" - fi + save_opalcore_ssh ${_dir} "${_opt}" "$_host" "$_scp_address" if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then - scp -q $_opt /proc/vmcore "$_username@$_ipv6_addr:$_dir/vmcore-incomplete" - else - scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete" - fi + scp -q $_opt /proc/vmcore "$_scp_address:$_dir/vmcore-incomplete" _exitcode=$? else $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "umask 0077 && dd bs=512 of=$_dir/vmcore-incomplete" @@ -431,11 +427,7 @@ dump_ssh() dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/" save_log - if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then - scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/" - else - scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/" - fi + scp -q $_opt $KDUMP_LOG_FILE "$_scp_address:$_dir/" _ret=$? if [ $_ret -ne 0 ]; then derror "saving log file failed, _exitcode:$_ret" @@ -452,7 +444,7 @@ save_opalcore_ssh() { local _path=$1 local _opts="$2" local _location=$3 - local _user_name="" _ipv6addr="" + local _scp_address=$4 ddebug "_path=$_path _opts=$_opts _location=$_location" @@ -465,18 +457,9 @@ save_opalcore_ssh() { fi fi - if is_ipv6_address "$_host"; then - _user_name=${_location%@*} - _ipv6addr="[${_location#*@}]" - fi - dinfo "saving opalcore:$OPALCORE to $_location:$_path" - if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then - scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete - else - scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete - fi + scp $_opts $OPALCORE $_scp_address:$_path/opalcore-incomplete if [ $? -ne 0 ]; then derror "saving opalcore failed" return 1 From b1c794a2cf1a4ed6c8fc2588d1e03ffcde07813c Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 14 Sep 2021 03:00:48 +0800 Subject: [PATCH 485/806] dracut-kdump.sh: Use stat instead of ls to get vmcore size ls output is fragile, so use stat instead. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 2 +- dracut-module-setup.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b92854e..25972e4 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -366,7 +366,7 @@ dump_raw() dinfo "saving to raw disk $_raw" if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then - _src_size=`ls -l /proc/vmcore | cut -d' ' -f5` + _src_size=$(stat --format %s /proc/vmcore) _src_size_mb=$(($_src_size / 1048576)) /kdumpscripts/monitor_dd_progress $_src_size_mb & fi diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d6011ee..80b5582 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1029,6 +1029,7 @@ install() { inst "/bin/head" "/bin/head" inst "/bin/awk" "/bin/awk" inst "/bin/sed" "/bin/sed" + inst "/bin/stat" "/bin/stat" inst "/sbin/makedumpfile" "/sbin/makedumpfile" inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" inst "/usr/bin/printf" "/sbin/printf" From 725027b735e6f27e51572c570b34c0c7186203ef Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 12 Aug 2021 02:55:32 +0800 Subject: [PATCH 486/806] dracut-kdump.sh: POSIX doesn't support pipefail Set pipefail will cause POSIX shell to exit with failure. So only do that in bash. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 25972e4..3c1b080 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -31,7 +31,10 @@ KDUMP_POST="" NEWROOT="/sysroot" OPALCORE="/sys/firmware/opal/mpipl/core" -set -o pipefail +# POSIX doesn't have pipefail, only apply when using bash +# shellcheck disable=SC3040 +[ -n "$BASH" ] && set -o pipefail + DUMP_RETVAL=0 get_kdump_confs() From b1339c3b8a006f95d8414c6e113fbec78bc03123 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 18 Aug 2021 21:06:52 +0800 Subject: [PATCH 487/806] dracut-kdump.sh: make it POSIX compatible POSIX doesn't support keyword `local`, so this commit reduced variable usage. Heredoc ("<<<") operation is also not supported, so kdump.conf is now pre-parse into a temp file. Also fixes many POSIX syntax errors. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 260 ++++++++++++++++++++++-------------------------- 1 file changed, 121 insertions(+), 139 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 3c1b080..5cd7ad4 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -8,8 +8,7 @@ . /lib/kdump-lib-initramfs.sh #initiate the kdump logger -dlog_init -if [ $? -ne 0 ]; then +if ! dlog_init; then echo "failed to initiate the kdump logger." exit 1 fi @@ -20,7 +19,7 @@ CORE_COLLECTOR="" DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31" DMESG_COLLECTOR="/sbin/vmcore-dmesg" FAILURE_ACTION="systemctl reboot -f" -DATEDIR=`date +%Y-%m-%d-%T` +DATEDIR=$(date +%Y-%m-%d-%T) HOST_IP='127.0.0.1' DUMP_INSTRUCTION="" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" @@ -30,6 +29,7 @@ KDUMP_PRE="" KDUMP_POST="" NEWROOT="/sysroot" OPALCORE="/sys/firmware/opal/mpipl/core" +KDUMP_CONF_PARSED="/tmp/kdump.conf.$$" # POSIX doesn't have pipefail, only apply when using bash # shellcheck disable=SC3040 @@ -37,10 +37,11 @@ OPALCORE="/sys/firmware/opal/mpipl/core" DUMP_RETVAL=0 +kdump_read_conf > $KDUMP_CONF_PARSED + get_kdump_confs() { - while read -r config_opt config_val; - do + while read -r config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in path) @@ -99,7 +100,7 @@ get_kdump_confs() esac ;; esac - done <<< "$(kdump_read_conf)" + done < "$KDUMP_CONF_PARSED" if [ -z "$CORE_COLLECTOR" ]; then CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" @@ -120,56 +121,58 @@ save_log() chmod 600 $KDUMP_LOG_FILE } -# dump_fs +# $1: dump path, must be a mount point dump_fs() { - local _exitcode - local _mp=$1 - local _op=$(get_mount_info OPTIONS target $_mp -f) - ddebug "dump_fs _mp=$_mp _opts=$_op" + ddebug "dump_fs _mp=$1" - if ! is_mounted "$_mp"; then - dinfo "dump path \"$_mp\" is not mounted, trying to mount..." - mount --target $_mp - if [ $? -ne 0 ]; then - derror "failed to dump to \"$_mp\", it's not a mount point!" + if ! is_mounted "$1"; then + dinfo "dump path '$1' is not mounted, trying to mount..." + if ! mount --target "$1"; then + derror "failed to dump to '$1', it's not a mount point!" return 1 fi fi # Remove -F in makedumpfile case. We don't want a flat format dump here. - [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo $CORE_COLLECTOR | sed -e "s/-F//g"` + case $CORE_COLLECTOR in + *makedumpfile* ) + CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") + ;; + esac - local _dump_path=$(echo "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) - - dinfo "saving to $_dump_path" + _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) + dinfo "saving to $_dump_fs_path" # Only remount to read-write mode if the dump target is mounted read-only. - if [[ "$_op" = "ro"* ]]; then - dinfo "Remounting the dump target in rw mode." - mount -o remount,rw $_mp || return 1 - fi + _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) + case $_dump_mnt_op in + ro* ) + dinfo "Remounting the dump target in rw mode." + mount -o remount,rw "$1" || return 1 + ;; + esac - mkdir -p $_dump_path || return 1 + mkdir -p "$_dump_fs_path" || return 1 - save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_path" - save_opalcore_fs "$_dump_path" + save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" + save_opalcore_fs "$_dump_fs_path" dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore $_dump_path/vmcore-incomplete - _exitcode=$? - if [ $_exitcode -eq 0 ]; then - mv $_dump_path/vmcore-incomplete $_dump_path/vmcore + $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" + _dump_exitcode=$? + if [ $_dump_exitcode -eq 0 ]; then + mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" sync dinfo "saving vmcore complete" else - derror "saving vmcore failed, _exitcode:$_exitcode" + derror "saving vmcore failed, exitcode:$_dump_exitcode" fi - dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/" + dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/" save_log - mv $KDUMP_LOG_FILE $_dump_path/ - if [ $_exitcode -ne 0 ]; then + mv "$KDUMP_LOG_FILE" "$_dump_fs_path/" + if [ $_dump_exitcode -ne 0 ]; then return 1 fi @@ -177,16 +180,13 @@ dump_fs() return 0 } +# $1: dmesg collector +# $2: dump path save_vmcore_dmesg_fs() { - local _dmesg_collector=$1 - local _path=$2 - - dinfo "saving vmcore-dmesg.txt to ${_path}" - $_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt - _exitcode=$? - if [ $_exitcode -eq 0 ]; then - mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt - chmod 600 ${_path}/vmcore-dmesg.txt + dinfo "saving vmcore-dmesg.txt to $2" + if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then + mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" + chmod 600 "$2/vmcore-dmesg.txt" # Make sure file is on disk. There have been instances where later # saving vmcore failed and system rebooted without sync and there @@ -194,16 +194,15 @@ save_vmcore_dmesg_fs() { sync dinfo "saving vmcore-dmesg.txt complete" else - if [ -f ${_path}/vmcore-dmesg-incomplete.txt ]; then - chmod 600 ${_path}/vmcore-dmesg-incomplete.txt + if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then + chmod 600 "$2/vmcore-dmesg-incomplete.txt" fi derror "saving vmcore-dmesg.txt failed" fi } +# $1: dump path save_opalcore_fs() { - local _path=$1 - if [ ! -f $OPALCORE ]; then # Check if we are on an old kernel that uses a different path if [ -f /sys/firmware/opal/core ]; then @@ -213,9 +212,8 @@ save_opalcore_fs() { fi fi - dinfo "saving opalcore:$OPALCORE to ${_path}/opalcore" - cp $OPALCORE ${_path}/opalcore - if [ $? -ne 0 ]; then + dinfo "saving opalcore:$OPALCORE to $1/opalcore" + if ! cp $OPALCORE "$1/opalcore"; then derror "saving opalcore failed" return 1 fi @@ -228,7 +226,7 @@ save_opalcore_fs() { dump_to_rootfs() { - if [[ $(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p") == "inactive" ]]; then + if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then dinfo "Trying to bring up initqueue for rootfs mount" systemctl start dracut-initqueue fi @@ -270,7 +268,7 @@ kdump_emergency_shell() type plymouth >/dev/null 2>&1 && plymouth quit source_hook "emergency" - while read _tty rest; do + while read -r _tty rest; do ( echo echo @@ -280,7 +278,7 @@ kdump_emergency_shell() echo 'save it elsewhere and attach it to a bug report.' echo echo - ) > /dev/$_tty + ) > "/dev/$_tty" done < /proc/consoles sh -i -l /bin/rm -f -- /.console_lock @@ -297,10 +295,9 @@ do_final_action() dinfo "Executing final action $FINAL_ACTION" eval $FINAL_ACTION } + do_dump() { - local _ret - eval $DUMP_INSTRUCTION _ret=$? @@ -313,8 +310,6 @@ do_dump() do_kdump_pre() { - local _ret - if [ -n "$KDUMP_PRE" ]; then "$KDUMP_PRE" _ret=$? @@ -339,8 +334,6 @@ do_kdump_pre() do_kdump_post() { - local _ret - if [ -d /etc/kdump/post.d ]; then for file in /etc/kdump/post.d/*; do "$file" "$1" @@ -360,97 +353,86 @@ do_kdump_post() fi } +# $1: block target, eg. /dev/sda dump_raw() { - local _raw=$1 + [ -b "$1" ] || return 1 - [ -b "$_raw" ] || return 1 + dinfo "saving to raw disk $1" - dinfo "saving to raw disk $_raw" - - if ! $(echo -n $CORE_COLLECTOR|grep -q makedumpfile); then + if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then _src_size=$(stat --format %s /proc/vmcore) - _src_size_mb=$(($_src_size / 1048576)) + _src_size_mb=$((_src_size / 1048576)) /kdumpscripts/monitor_dd_progress $_src_size_mb & fi dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore | dd of=$_raw bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 + $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 sync dinfo "saving vmcore complete" return 0 } +# $1: ssh key file +# $2: ssh address in @ format dump_ssh() { - local _ret=0 - local _exitcode=0 _exitcode2=0 - local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" - local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" - local _host=$2 - local _vmcore="vmcore" - - if is_ipv6_address "$_host"; then - _scp_address=${_host%@*}@"[${_host#*@}]" + _ret=0 + _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" + _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" + if is_ipv6_address "$2"; then + _scp_address=${2%@*}@"[${2#*@}]" else - _scp_address=$_host + _scp_address=$2 fi - dinfo "saving to $_host:$_dir" + dinfo "saving to $2:$_ssh_dir" cat /var/lib/random-seed > /dev/urandom - ssh -q $_opt $_host mkdir -p $_dir || return 1 + ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 - save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" "$_host" + save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" dinfo "saving vmcore" - save_opalcore_ssh ${_dir} "${_opt}" "$_host" "$_scp_address" + save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - scp -q $_opt /proc/vmcore "$_scp_address:$_dir/vmcore-incomplete" - _exitcode=$? + scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" + _ret=$? + _vmcore="vmcore" else - $CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "umask 0077 && dd bs=512 of=$_dir/vmcore-incomplete" - _exitcode=$? + $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" + _ret=$? _vmcore="vmcore.flat" fi - if [ $_exitcode -eq 0 ]; then - ssh $_opt $_host "mv $_dir/vmcore-incomplete $_dir/$_vmcore" - _exitcode2=$? - if [ $_exitcode2 -ne 0 ]; then - derror "moving vmcore failed, _exitcode:$_exitcode2" + if [ $_ret -eq 0 ]; then + ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "moving vmcore failed, exitcode:$_ret" else dinfo "saving vmcore complete" fi else - derror "saving vmcore failed, _exitcode:$_exitcode" + derror "saving vmcore failed, exitcode:$_ret" fi - dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/" + dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/" save_log - scp -q $_opt $KDUMP_LOG_FILE "$_scp_address:$_dir/" - _ret=$? - if [ $_ret -ne 0 ]; then + if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then derror "saving log file failed, _exitcode:$_ret" fi - if [ $_exitcode -ne 0 ] || [ $_exitcode2 -ne 0 ];then - return 1 - fi - - return 0 + return $_ret } +# $1: dump path +# $2: ssh opts +# $3: ssh address in @ format +# $4: scp address, similar with ssh address but IPv6 addresses are quoted save_opalcore_ssh() { - local _path=$1 - local _opts="$2" - local _location=$3 - local _scp_address=$4 - - ddebug "_path=$_path _opts=$_opts _location=$_location" - if [ ! -f $OPALCORE ]; then # Check if we are on an old kernel that uses a different path if [ -f /sys/firmware/opal/core ]; then @@ -460,31 +442,26 @@ save_opalcore_ssh() { fi fi - dinfo "saving opalcore:$OPALCORE to $_location:$_path" + dinfo "saving opalcore:$OPALCORE to $3:$1" - scp $_opts $OPALCORE $_scp_address:$_path/opalcore-incomplete - if [ $? -ne 0 ]; then + if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then derror "saving opalcore failed" - return 1 + return 1 fi - ssh $_opts $_location mv $_path/opalcore-incomplete $_path/opalcore + ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" dinfo "saving opalcore complete" return 0 } +# $1: dmesg collector +# $2: dump path +# $3: ssh opts +# $4: ssh address in @ format save_vmcore_dmesg_ssh() { - local _dmesg_collector=$1 - local _path=$2 - local _opts="$3" - local _location=$4 - - dinfo "saving vmcore-dmesg.txt to $_location:$_path" - $_dmesg_collector /proc/vmcore | ssh $_opts $_location "umask 0077 && dd of=$_path/vmcore-dmesg-incomplete.txt" - _exitcode=$? - - if [ $_exitcode -eq 0 ]; then - ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt + dinfo "saving vmcore-dmesg.txt to $4:$2" + if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then + ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" dinfo "saving vmcore-dmesg.txt complete" else derror "saving vmcore-dmesg.txt failed" @@ -493,17 +470,24 @@ save_vmcore_dmesg_ssh() { get_host_ip() { - local _host if is_nfs_dump_target || is_ssh_dump_target then kdumpnic=$(getarg kdumpnic=) - [ -z "$kdumpnic" ] && derror "failed to get kdumpnic!" && return 1 - _host=`ip addr show dev $kdumpnic|grep '[ ]*inet'` - [ $? -ne 0 ] && derror "wrong kdumpnic: $kdumpnic" && return 1 - _host=`echo $_host | head -n 1 | cut -d' ' -f2` - _host="${_host%%/*}" - [ -z "$_host" ] && derror "wrong kdumpnic: $kdumpnic" && return 1 - HOST_IP=$_host + if [ -z "$kdumpnic" ]; then + derror "failed to get kdumpnic!" + return 1 + fi + if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then + derror "wrong kdumpnic: $kdumpnic" + return 1 + fi + kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}') + kdumphost="${kdumphost%%/*}" + if [ -z "$kdumphost" ]; then + derror "wrong kdumpnic: $kdumpnic" + return 1 + fi + HOST_IP=$kdumphost fi return 0 } @@ -518,7 +502,7 @@ read_kdump_confs() get_kdump_confs # rescan for add code for dump target - while read config_opt config_val; + while read -r config_opt config_val; do # remove inline comments after the end of a directive. case "$config_opt" in @@ -540,12 +524,13 @@ read_kdump_confs() DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac - done <<< "$(kdump_read_conf)" + done < "$KDUMP_CONF_PARSED" } fence_kdump_notify() { if [ -n "$FENCE_KDUMP_NODES" ]; then + # shellcheck disable=SC2086 $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & fi } @@ -566,8 +551,7 @@ fi read_kdump_confs fence_kdump_notify -get_host_ip -if [ $? -ne 0 ]; then +if ! get_host_ip; then derror "get_host_ip exited with non-zero status!" exit 1 fi @@ -576,8 +560,7 @@ if [ -z "$DUMP_INSTRUCTION" ]; then DUMP_INSTRUCTION="dump_fs $NEWROOT" fi -do_kdump_pre -if [ $? -ne 0 ]; then +if ! do_kdump_pre; then derror "kdump_pre script exited with non-zero status!" do_final_action # During systemd service to reboot the machine, stop this shell script running @@ -587,8 +570,7 @@ make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' do_dump DUMP_RETVAL=$? -do_kdump_post $DUMP_RETVAL -if [ $? -ne 0 ]; then +if ! do_kdump_post $DUMP_RETVAL; then derror "kdump_post script exited with non-zero status!" fi From 7c76611abba248e58172fdf170739a3c0f40e2c6 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 15 Sep 2021 23:10:07 +0800 Subject: [PATCH 488/806] dracut-kdump.sh: reformat with shfmt This is done with `shfmt -w -s dracut-kdump.sh`. There is no behaviour change. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 768 ++++++++++++++++++++++++------------------------ 1 file changed, 385 insertions(+), 383 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 5cd7ad4..969ea94 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -9,8 +9,8 @@ #initiate the kdump logger if ! dlog_init; then - echo "failed to initiate the kdump logger." - exit 1 + echo "failed to initiate the kdump logger." + exit 1 fi KDUMP_PATH="/var/crash" @@ -41,541 +41,543 @@ kdump_read_conf > $KDUMP_CONF_PARSED get_kdump_confs() { - while read -r config_opt config_val; do - # remove inline comments after the end of a directive. - case "$config_opt" in - path) - KDUMP_PATH="$config_val" - ;; - core_collector) - [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" - ;; - sshkey) - if [ -f "$config_val" ]; then - SSH_KEY_LOCATION=$config_val - fi - ;; - kdump_pre) - KDUMP_PRE="$config_val" - ;; - kdump_post) - KDUMP_POST="$config_val" - ;; - fence_kdump_args) - FENCE_KDUMP_ARGS="$config_val" - ;; - fence_kdump_nodes) - FENCE_KDUMP_NODES="$config_val" - ;; - failure_action|default) - case $config_val in - shell) - FAILURE_ACTION="kdump_emergency_shell" - ;; - reboot) - FAILURE_ACTION="systemctl reboot -f && exit" - ;; - halt) - FAILURE_ACTION="halt && exit" - ;; - poweroff) - FAILURE_ACTION="systemctl poweroff -f && exit" - ;; - dump_to_rootfs) - FAILURE_ACTION="dump_to_rootfs" - ;; - esac - ;; - final_action) - case $config_val in - reboot) - FINAL_ACTION="systemctl reboot -f" - ;; - halt) - FINAL_ACTION="halt" - ;; - poweroff) - FINAL_ACTION="systemctl poweroff -f" - ;; - esac - ;; - esac - done < "$KDUMP_CONF_PARSED" + while read -r config_opt config_val; do + # remove inline comments after the end of a directive. + case "$config_opt" in + path) + KDUMP_PATH="$config_val" + ;; + core_collector) + [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" + ;; + sshkey) + if [ -f "$config_val" ]; then + SSH_KEY_LOCATION=$config_val + fi + ;; + kdump_pre) + KDUMP_PRE="$config_val" + ;; + kdump_post) + KDUMP_POST="$config_val" + ;; + fence_kdump_args) + FENCE_KDUMP_ARGS="$config_val" + ;; + fence_kdump_nodes) + FENCE_KDUMP_NODES="$config_val" + ;; + failure_action | default) + case $config_val in + shell) + FAILURE_ACTION="kdump_emergency_shell" + ;; + reboot) + FAILURE_ACTION="systemctl reboot -f && exit" + ;; + halt) + FAILURE_ACTION="halt && exit" + ;; + poweroff) + FAILURE_ACTION="systemctl poweroff -f && exit" + ;; + dump_to_rootfs) + FAILURE_ACTION="dump_to_rootfs" + ;; + esac + ;; + final_action) + case $config_val in + reboot) + FINAL_ACTION="systemctl reboot -f" + ;; + halt) + FINAL_ACTION="halt" + ;; + poweroff) + FINAL_ACTION="systemctl poweroff -f" + ;; + esac + ;; + esac + done < "$KDUMP_CONF_PARSED" - if [ -z "$CORE_COLLECTOR" ]; then - CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" - if is_ssh_dump_target || is_raw_dump_target; then - CORE_COLLECTOR="$CORE_COLLECTOR -F" - fi - fi + if [ -z "$CORE_COLLECTOR" ]; then + CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" + if is_ssh_dump_target || is_raw_dump_target; then + CORE_COLLECTOR="$CORE_COLLECTOR -F" + fi + fi } # store the kexec kernel log to a file. save_log() { - dmesg -T > $KDUMP_LOG_FILE + dmesg -T > $KDUMP_LOG_FILE - if command -v journalctl > /dev/null; then - journalctl -ab >> $KDUMP_LOG_FILE - fi - chmod 600 $KDUMP_LOG_FILE + if command -v journalctl > /dev/null; then + journalctl -ab >> $KDUMP_LOG_FILE + fi + chmod 600 $KDUMP_LOG_FILE } # $1: dump path, must be a mount point dump_fs() { - ddebug "dump_fs _mp=$1" + ddebug "dump_fs _mp=$1" - if ! is_mounted "$1"; then - dinfo "dump path '$1' is not mounted, trying to mount..." - if ! mount --target "$1"; then - derror "failed to dump to '$1', it's not a mount point!" - return 1 - fi - fi + if ! is_mounted "$1"; then + dinfo "dump path '$1' is not mounted, trying to mount..." + if ! mount --target "$1"; then + derror "failed to dump to '$1', it's not a mount point!" + return 1 + fi + fi - # Remove -F in makedumpfile case. We don't want a flat format dump here. - case $CORE_COLLECTOR in - *makedumpfile* ) - CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") - ;; - esac + # Remove -F in makedumpfile case. We don't want a flat format dump here. + case $CORE_COLLECTOR in + *makedumpfile*) + CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") + ;; + esac - _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) - dinfo "saving to $_dump_fs_path" + _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) + dinfo "saving to $_dump_fs_path" - # Only remount to read-write mode if the dump target is mounted read-only. - _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) - case $_dump_mnt_op in - ro* ) - dinfo "Remounting the dump target in rw mode." - mount -o remount,rw "$1" || return 1 - ;; - esac + # Only remount to read-write mode if the dump target is mounted read-only. + _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) + case $_dump_mnt_op in + ro*) + dinfo "Remounting the dump target in rw mode." + mount -o remount,rw "$1" || return 1 + ;; + esac - mkdir -p "$_dump_fs_path" || return 1 + mkdir -p "$_dump_fs_path" || return 1 - save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" - save_opalcore_fs "$_dump_fs_path" + save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" + save_opalcore_fs "$_dump_fs_path" - dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" - _dump_exitcode=$? - if [ $_dump_exitcode -eq 0 ]; then - mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" - sync - dinfo "saving vmcore complete" - else - derror "saving vmcore failed, exitcode:$_dump_exitcode" - fi + dinfo "saving vmcore" + $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" + _dump_exitcode=$? + if [ $_dump_exitcode -eq 0 ]; then + mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" + sync + dinfo "saving vmcore complete" + else + derror "saving vmcore failed, exitcode:$_dump_exitcode" + fi - dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/" - save_log - mv "$KDUMP_LOG_FILE" "$_dump_fs_path/" - if [ $_dump_exitcode -ne 0 ]; then - return 1 - fi + dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/" + save_log + mv "$KDUMP_LOG_FILE" "$_dump_fs_path/" + if [ $_dump_exitcode -ne 0 ]; then + return 1 + fi - # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure - return 0 + # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure + return 0 } # $1: dmesg collector # $2: dump path -save_vmcore_dmesg_fs() { - dinfo "saving vmcore-dmesg.txt to $2" - if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then - mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" - chmod 600 "$2/vmcore-dmesg.txt" +save_vmcore_dmesg_fs() +{ + dinfo "saving vmcore-dmesg.txt to $2" + if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then + mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" + chmod 600 "$2/vmcore-dmesg.txt" - # Make sure file is on disk. There have been instances where later - # saving vmcore failed and system rebooted without sync and there - # was no vmcore-dmesg.txt available. - sync - dinfo "saving vmcore-dmesg.txt complete" - else - if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then - chmod 600 "$2/vmcore-dmesg-incomplete.txt" - fi - derror "saving vmcore-dmesg.txt failed" - fi + # Make sure file is on disk. There have been instances where later + # saving vmcore failed and system rebooted without sync and there + # was no vmcore-dmesg.txt available. + sync + dinfo "saving vmcore-dmesg.txt complete" + else + if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then + chmod 600 "$2/vmcore-dmesg-incomplete.txt" + fi + derror "saving vmcore-dmesg.txt failed" + fi } # $1: dump path -save_opalcore_fs() { - if [ ! -f $OPALCORE ]; then - # Check if we are on an old kernel that uses a different path - if [ -f /sys/firmware/opal/core ]; then - OPALCORE="/sys/firmware/opal/core" - else - return 0 - fi - fi +save_opalcore_fs() +{ + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi - dinfo "saving opalcore:$OPALCORE to $1/opalcore" - if ! cp $OPALCORE "$1/opalcore"; then - derror "saving opalcore failed" - return 1 - fi + dinfo "saving opalcore:$OPALCORE to $1/opalcore" + if ! cp $OPALCORE "$1/opalcore"; then + derror "saving opalcore failed" + return 1 + fi - sync - dinfo "saving opalcore complete" - return 0 + sync + dinfo "saving opalcore complete" + return 0 } dump_to_rootfs() { - if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then - dinfo "Trying to bring up initqueue for rootfs mount" - systemctl start dracut-initqueue - fi + if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then + dinfo "Trying to bring up initqueue for rootfs mount" + systemctl start dracut-initqueue + fi - dinfo "Clean up dead systemd services" - systemctl cancel - dinfo "Waiting for rootfs mount, will timeout after 90 seconds" - systemctl start --no-block sysroot.mount + dinfo "Clean up dead systemd services" + systemctl cancel + dinfo "Waiting for rootfs mount, will timeout after 90 seconds" + systemctl start --no-block sysroot.mount - _loop=0 - while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do - sleep 1 - _loop=$((_loop + 1)) - done + _loop=0 + while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do + sleep 1 + _loop=$((_loop + 1)) + done - if ! is_mounted /sysroot; then - derror "Failed to mount rootfs" - return - fi + if ! is_mounted /sysroot; then + derror "Failed to mount rootfs" + return + fi - ddebug "NEWROOT=$NEWROOT" - dump_fs $NEWROOT + ddebug "NEWROOT=$NEWROOT" + dump_fs $NEWROOT } kdump_emergency_shell() { - ddebug "Switching to kdump emergency shell..." + ddebug "Switching to kdump emergency shell..." - [ -f /etc/profile ] && . /etc/profile - export PS1='kdump:${PWD}# ' + [ -f /etc/profile ] && . /etc/profile + export PS1='kdump:${PWD}# ' - . /lib/dracut-lib.sh - if [ -f /dracut-state.sh ]; then - . /dracut-state.sh 2>/dev/null - fi + . /lib/dracut-lib.sh + if [ -f /dracut-state.sh ]; then + . /dracut-state.sh 2> /dev/null + fi - source_conf /etc/conf.d + source_conf /etc/conf.d - type plymouth >/dev/null 2>&1 && plymouth quit + type plymouth > /dev/null 2>&1 && plymouth quit - source_hook "emergency" - while read -r _tty rest; do - ( - echo - echo - echo 'Entering kdump emergency mode.' - echo 'Type "journalctl" to view system logs.' - echo 'Type "rdsosreport" to generate a sosreport, you can then' - echo 'save it elsewhere and attach it to a bug report.' - echo - echo - ) > "/dev/$_tty" - done < /proc/consoles - sh -i -l - /bin/rm -f -- /.console_lock + source_hook "emergency" + while read -r _tty rest; do + ( + echo + echo + echo 'Entering kdump emergency mode.' + echo 'Type "journalctl" to view system logs.' + echo 'Type "rdsosreport" to generate a sosreport, you can then' + echo 'save it elsewhere and attach it to a bug report.' + echo + echo + ) > "/dev/$_tty" + done < /proc/consoles + sh -i -l + /bin/rm -f -- /.console_lock } do_failure_action() { - dinfo "Executing failure action $FAILURE_ACTION" - eval $FAILURE_ACTION + dinfo "Executing failure action $FAILURE_ACTION" + eval $FAILURE_ACTION } do_final_action() { - dinfo "Executing final action $FINAL_ACTION" - eval $FINAL_ACTION + dinfo "Executing final action $FINAL_ACTION" + eval $FINAL_ACTION } do_dump() { - eval $DUMP_INSTRUCTION - _ret=$? + eval $DUMP_INSTRUCTION + _ret=$? - if [ $_ret -ne 0 ]; then - derror "saving vmcore failed" - fi + if [ $_ret -ne 0 ]; then + derror "saving vmcore failed" + fi - return $_ret + return $_ret } do_kdump_pre() { - if [ -n "$KDUMP_PRE" ]; then - "$KDUMP_PRE" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$KDUMP_PRE exited with $_ret status" - return $_ret - fi - fi + if [ -n "$KDUMP_PRE" ]; then + "$KDUMP_PRE" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "$KDUMP_PRE exited with $_ret status" + return $_ret + fi + fi - # if any script fails, it just raises warning and continues - if [ -d /etc/kdump/pre.d ]; then - for file in /etc/kdump/pre.d/*; do - "$file" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$file exited with $_ret status" - fi - done - fi - return 0 + # if any script fails, it just raises warning and continues + if [ -d /etc/kdump/pre.d ]; then + for file in /etc/kdump/pre.d/*; do + "$file" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "$file exited with $_ret status" + fi + done + fi + return 0 } do_kdump_post() { - if [ -d /etc/kdump/post.d ]; then - for file in /etc/kdump/post.d/*; do - "$file" "$1" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$file exited with $_ret status" - fi - done - fi + if [ -d /etc/kdump/post.d ]; then + for file in /etc/kdump/post.d/*; do + "$file" "$1" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "$file exited with $_ret status" + fi + done + fi - if [ -n "$KDUMP_POST" ]; then - "$KDUMP_POST" "$1" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$KDUMP_POST exited with $_ret status" - fi - fi + if [ -n "$KDUMP_POST" ]; then + "$KDUMP_POST" "$1" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "$KDUMP_POST exited with $_ret status" + fi + fi } # $1: block target, eg. /dev/sda dump_raw() { - [ -b "$1" ] || return 1 + [ -b "$1" ] || return 1 - dinfo "saving to raw disk $1" + dinfo "saving to raw disk $1" - if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then - _src_size=$(stat --format %s /proc/vmcore) - _src_size_mb=$((_src_size / 1048576)) - /kdumpscripts/monitor_dd_progress $_src_size_mb & - fi + if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then + _src_size=$(stat --format %s /proc/vmcore) + _src_size_mb=$((_src_size / 1048576)) + /kdumpscripts/monitor_dd_progress $_src_size_mb & + fi - dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 - sync + dinfo "saving vmcore" + $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 + sync - dinfo "saving vmcore complete" - return 0 + dinfo "saving vmcore complete" + return 0 } # $1: ssh key file # $2: ssh address in @ format dump_ssh() { - _ret=0 - _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" - _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" - if is_ipv6_address "$2"; then - _scp_address=${2%@*}@"[${2#*@}]" - else - _scp_address=$2 - fi + _ret=0 + _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" + _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" + if is_ipv6_address "$2"; then + _scp_address=${2%@*}@"[${2#*@}]" + else + _scp_address=$2 + fi - dinfo "saving to $2:$_ssh_dir" + dinfo "saving to $2:$_ssh_dir" - cat /var/lib/random-seed > /dev/urandom - ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 + cat /var/lib/random-seed > /dev/urandom + ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 - save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" - dinfo "saving vmcore" + save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" + dinfo "saving vmcore" - save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" + save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" - if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" - _ret=$? - _vmcore="vmcore" - else - $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" - _ret=$? - _vmcore="vmcore.flat" - fi + if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then + scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" + _ret=$? + _vmcore="vmcore" + else + $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" + _ret=$? + _vmcore="vmcore.flat" + fi - if [ $_ret -eq 0 ]; then - ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "moving vmcore failed, exitcode:$_ret" - else - dinfo "saving vmcore complete" - fi - else - derror "saving vmcore failed, exitcode:$_ret" - fi + if [ $_ret -eq 0 ]; then + ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" + _ret=$? + if [ $_ret -ne 0 ]; then + derror "moving vmcore failed, exitcode:$_ret" + else + dinfo "saving vmcore complete" + fi + else + derror "saving vmcore failed, exitcode:$_ret" + fi - dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/" - save_log - if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then - derror "saving log file failed, _exitcode:$_ret" - fi + dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/" + save_log + if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then + derror "saving log file failed, _exitcode:$_ret" + fi - return $_ret + return $_ret } # $1: dump path # $2: ssh opts # $3: ssh address in @ format # $4: scp address, similar with ssh address but IPv6 addresses are quoted -save_opalcore_ssh() { - if [ ! -f $OPALCORE ]; then - # Check if we are on an old kernel that uses a different path - if [ -f /sys/firmware/opal/core ]; then - OPALCORE="/sys/firmware/opal/core" - else - return 0 - fi - fi +save_opalcore_ssh() +{ + if [ ! -f $OPALCORE ]; then + # Check if we are on an old kernel that uses a different path + if [ -f /sys/firmware/opal/core ]; then + OPALCORE="/sys/firmware/opal/core" + else + return 0 + fi + fi - dinfo "saving opalcore:$OPALCORE to $3:$1" + dinfo "saving opalcore:$OPALCORE to $3:$1" - if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then - derror "saving opalcore failed" - return 1 - fi + if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then + derror "saving opalcore failed" + return 1 + fi - ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" - dinfo "saving opalcore complete" - return 0 + ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" + dinfo "saving opalcore complete" + return 0 } # $1: dmesg collector # $2: dump path # $3: ssh opts # $4: ssh address in @ format -save_vmcore_dmesg_ssh() { - dinfo "saving vmcore-dmesg.txt to $4:$2" - if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then - ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" - dinfo "saving vmcore-dmesg.txt complete" - else - derror "saving vmcore-dmesg.txt failed" - fi +save_vmcore_dmesg_ssh() +{ + dinfo "saving vmcore-dmesg.txt to $4:$2" + if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then + ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" + dinfo "saving vmcore-dmesg.txt complete" + else + derror "saving vmcore-dmesg.txt failed" + fi } get_host_ip() { - if is_nfs_dump_target || is_ssh_dump_target - then - kdumpnic=$(getarg kdumpnic=) - if [ -z "$kdumpnic" ]; then - derror "failed to get kdumpnic!" - return 1 - fi - if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}') - kdumphost="${kdumphost%%/*}" - if [ -z "$kdumphost" ]; then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - HOST_IP=$kdumphost - fi - return 0 + if is_nfs_dump_target || is_ssh_dump_target; then + kdumpnic=$(getarg kdumpnic=) + if [ -z "$kdumpnic" ]; then + derror "failed to get kdumpnic!" + return 1 + fi + if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then + derror "wrong kdumpnic: $kdumpnic" + return 1 + fi + kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}') + kdumphost="${kdumphost%%/*}" + if [ -z "$kdumphost" ]; then + derror "wrong kdumpnic: $kdumpnic" + return 1 + fi + HOST_IP=$kdumphost + fi + return 0 } read_kdump_confs() { - if [ ! -f "$KDUMP_CONFIG_FILE" ]; then - derror "$KDUMP_CONFIG_FILE not found" - return - fi + if [ ! -f "$KDUMP_CONFIG_FILE" ]; then + derror "$KDUMP_CONFIG_FILE not found" + return + fi - get_kdump_confs + get_kdump_confs - # rescan for add code for dump target - while read -r config_opt config_val; - do - # remove inline comments after the end of a directive. - case "$config_opt" in - dracut_args) - config_val=$(get_dracut_args_target "$config_val") - if [ -n "$config_val" ]; then - config_val=$(get_mntpoint_from_target "$config_val") - DUMP_INSTRUCTION="dump_fs $config_val" - fi - ;; - ext[234]|xfs|btrfs|minix|nfs) - config_val=$(get_mntpoint_from_target "$config_val") - DUMP_INSTRUCTION="dump_fs $config_val" - ;; - raw) - DUMP_INSTRUCTION="dump_raw $config_val" - ;; - ssh) - DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" - ;; - esac - done < "$KDUMP_CONF_PARSED" + # rescan for add code for dump target + while read -r config_opt config_val; do + # remove inline comments after the end of a directive. + case "$config_opt" in + dracut_args) + config_val=$(get_dracut_args_target "$config_val") + if [ -n "$config_val" ]; then + config_val=$(get_mntpoint_from_target "$config_val") + DUMP_INSTRUCTION="dump_fs $config_val" + fi + ;; + ext[234] | xfs | btrfs | minix | nfs) + config_val=$(get_mntpoint_from_target "$config_val") + DUMP_INSTRUCTION="dump_fs $config_val" + ;; + raw) + DUMP_INSTRUCTION="dump_raw $config_val" + ;; + ssh) + DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" + ;; + esac + done < "$KDUMP_CONF_PARSED" } fence_kdump_notify() { - if [ -n "$FENCE_KDUMP_NODES" ]; then - # shellcheck disable=SC2086 - $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & - fi + if [ -n "$FENCE_KDUMP_NODES" ]; then + # shellcheck disable=SC2086 + $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & + fi } if [ "$1" = "--error-handler" ]; then - get_kdump_confs - do_failure_action - do_final_action + get_kdump_confs + do_failure_action + do_final_action - exit $? + exit $? fi # continue here only if we have to save dump. if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then - exit 0 + exit 0 fi read_kdump_confs fence_kdump_notify if ! get_host_ip; then - derror "get_host_ip exited with non-zero status!" - exit 1 + derror "get_host_ip exited with non-zero status!" + exit 1 fi if [ -z "$DUMP_INSTRUCTION" ]; then - DUMP_INSTRUCTION="dump_fs $NEWROOT" + DUMP_INSTRUCTION="dump_fs $NEWROOT" fi if ! do_kdump_pre; then - derror "kdump_pre script exited with non-zero status!" - do_final_action - # During systemd service to reboot the machine, stop this shell script running - exit 1 + derror "kdump_pre script exited with non-zero status!" + do_final_action + # During systemd service to reboot the machine, stop this shell script running + exit 1 fi make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' do_dump DUMP_RETVAL=$? if ! do_kdump_post $DUMP_RETVAL; then - derror "kdump_post script exited with non-zero status!" + derror "kdump_post script exited with non-zero status!" fi if [ $DUMP_RETVAL -ne 0 ]; then - exit 1 + exit 1 fi do_final_action From 5debf397fef03931c0736d473a55ebcf6dc08380 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 14 Sep 2021 03:04:08 +0800 Subject: [PATCH 489/806] kdump-lib-initramfs.sh: make it POSIX compatible POSIX doesn't support keyword local, so add double underscore and prefix to variable names, and reduce variable usage, to avoid any variable name conflict. Also reformat the code with `shfmt -s -w kdump-lib-initramfs.sh`. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib-initramfs.sh | 92 +++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index b30b024..0cdb465 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -9,124 +9,122 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" # Read kdump config in well formated style kdump_read_conf() { - # Following steps are applied in order: strip trailing comment, strip trailing space, - # strip heading space, match non-empty line, remove duplicated spaces between conf name and value - [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE + # Following steps are applied in order: strip trailing comment, strip trailing space, + # strip heading space, match non-empty line, remove duplicated spaces between conf name and value + [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE } # Retrieves config value defined in kdump.conf # $1: config name, sed regexp compatible -kdump_get_conf_val() { - # For lines matching "^\s*$1\s+", remove matched part (config name including space), - # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. - [ -f "$KDUMP_CONFIG_FILE" ] && \ - sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE +kdump_get_conf_val() +{ + # For lines matching "^\s*$1\s+", remove matched part (config name including space), + # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. + [ -f "$KDUMP_CONFIG_FILE" ] && + sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE } is_mounted() { - findmnt -k -n $1 &>/dev/null + findmnt -k -n "$1" > /dev/null 2>&1 } +# $1: info type +# $2: mount source type +# $3: mount source +# $4: extra args get_mount_info() { - local _info_type=$1 _src_type=$2 _src=$3; shift 3 - local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@) + __kdump_mnt=$(findmnt -k -n -r -o "$1" "--$2" "$3" $4) - [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@) + [ -z "$__kdump_mnt" ] && [ -e "/etc/fstab" ] && __kdump_mnt=$(findmnt -s -n -r -o "$1" "--$2" "$3" $4) - echo $_info + echo "$__kdump_mnt" } is_ipv6_address() { - echo $1 | grep -q ":" + echo "$1" | grep -q ":" } is_fs_type_nfs() { - [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] + [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] } # If $1 contains dracut_args "--mount", return get_dracut_args_fstype() { - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3 + echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3 } # If $1 contains dracut_args "--mount", return get_dracut_args_target() { - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 + echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 } get_save_path() { - local _save_path=$(kdump_get_conf_val path) - [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH + __kdump_path=$(kdump_get_conf_val path) + [ -z "$__kdump_path" ] && __kdump_path=$DEFAULT_PATH - # strip the duplicated "/" - echo $_save_path | tr -s / + # strip the duplicated "/" + echo "$__kdump_path" | tr -s / } get_root_fs_device() { - findmnt -k -f -n -o SOURCE / + findmnt -k -f -n -o SOURCE / } # Return the current underlying device of a path, ignore bind mounts get_target_from_path() { - local _target - - _target=$(df $1 2>/dev/null | tail -1 | awk '{print $1}') - [[ "$_target" == "/dev/root" ]] && [[ ! -e /dev/root ]] && _target=$(get_root_fs_device) - echo $_target + __kdump_target=$(df "$1" 2> /dev/null | tail -1 | awk '{print $1}') + [ "$__kdump_target" = "/dev/root" ] && [ ! -e /dev/root ] && __kdump_target=$(get_root_fs_device) + echo "$__kdump_target" } get_fs_type_from_target() { - get_mount_info FSTYPE source $1 -f + get_mount_info FSTYPE source "$1" -f } get_mntpoint_from_target() { - # --source is applied to ensure non-bind mount is returned - get_mount_info TARGET source $1 -f + # --source is applied to ensure non-bind mount is returned + get_mount_info TARGET source "$1" -f } is_ssh_dump_target() { - [[ $(kdump_get_conf_val ssh) == *@* ]] + kdump_get_conf_val ssh | grep -q @ } is_raw_dump_target() { - [[ $(kdump_get_conf_val raw) ]] + [ -n "$(kdump_get_conf_val raw)" ] } is_nfs_dump_target() { - if [[ $(kdump_get_conf_val nfs) ]]; then - return 0; - fi + if [ -n "$(kdump_get_conf_val nfs)" ]; then + return 0 + fi - if is_fs_type_nfs $(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)"); then - return 0 - fi + if is_fs_type_nfs "$(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)")"; then + return 0 + fi - local _save_path=$(get_save_path) - local _target=$(get_target_from_path $_save_path) - local _fstype=$(get_fs_type_from_target $_target) + if is_fs_type_nfs "$(get_fs_type_from_target "$(get_target_from_path "$(get_save_path)")")"; then + return 0 + fi - if is_fs_type_nfs $_fstype; then - return 0 - fi - - return 1 + return 1 } is_fs_dump_target() { - [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix") ]] + [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix")" ] } From 30090f3a15d266937bba6ef2429876e26b5e92d7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 Sep 2021 01:17:05 +0800 Subject: [PATCH 490/806] kdump-lib.sh: replace '[ ]' with '[[ ]]' and get rid of legacy `` Updated file syntax with following command: sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdump-lib.sh (replace '[ ]' with '[[ ]]') sed -i -e 's/`\([^`]*\)`/\$(\1)/g' kdump-lib.sh (replace `...` with $(...)) And manually updated [[ ... -a ... ]] and [[ ... -o ... ]] with && and ||. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 148 +++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d7cb40e..0dbf485 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -13,16 +13,16 @@ is_fadump_capable() { # Check if firmware-assisted dump is enabled # if no, fallback to kdump check - if [ -f $FADUMP_ENABLED_SYS_NODE ]; then - rc=`cat $FADUMP_ENABLED_SYS_NODE` - [ $rc -eq 1 ] && return 0 + if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then + rc=$(cat $FADUMP_ENABLED_SYS_NODE) + [[ $rc -eq 1 ]] && return 0 fi return 1 } is_squash_available() { for kmodule in squashfs overlay loop; do - if [ -z "$KDUMP_KERNELVER" ]; then + if [[ -z "$KDUMP_KERNELVER" ]]; then modprobe --dry-run $kmodule &>/dev/null || return 1 else modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 @@ -40,7 +40,7 @@ is_pcs_fence_kdump() { # no pcs or fence_kdump_send executables installed? type -P pcs > /dev/null || return 1 - [ -x $FENCE_KDUMP_SEND ] || return 1 + [[ -x $FENCE_KDUMP_SEND ]] || return 1 # fence kdump not configured? (pcs cluster cib | grep 'type="fence_kdump"') &> /dev/null || return 1 @@ -49,7 +49,7 @@ is_pcs_fence_kdump() # Check if fence_kdump is configured using kdump options is_generic_fence_kdump() { - [ -x $FENCE_KDUMP_SEND ] || return 1 + [[ -x $FENCE_KDUMP_SEND ]] || return 1 [[ $(kdump_get_conf_val fence_kdump_nodes) ]] } @@ -59,10 +59,10 @@ to_dev_name() { case "$dev" in UUID=*) - dev=`blkid -U "${dev#UUID=}"` + dev=$(blkid -U "${dev#UUID=}") ;; LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` + dev=$(blkid -L "${dev#LABEL=}") ;; esac echo $dev @@ -78,10 +78,10 @@ get_user_configured_dump_disk() local _target _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") - [ -n "$_target" ] && echo $_target && return + [[ -n "$_target" ]] && echo $_target && return _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") - [ -b "$_target" ] && echo $_target + [[ -b "$_target" ]] && echo $_target } get_block_dump_target() @@ -93,12 +93,12 @@ get_block_dump_target() fi _target=$(get_user_configured_dump_disk) - [ -n "$_target" ] && echo $(to_dev_name $_target) && return + [[ -n "$_target" ]] && echo $(to_dev_name $_target) && return # Get block device name from local save path _path=$(get_save_path) _target=$(get_target_from_path $_path) - [ -b "$_target" ] && echo $(to_dev_name $_target) + [[ -b "$_target" ]] && echo $(to_dev_name $_target) } is_dump_to_rootfs() @@ -113,7 +113,7 @@ get_failure_action_target() if is_dump_to_rootfs; then # Get rootfs device name _target=$(get_root_fs_device) - [ -b "$_target" ] && echo $(to_dev_name $_target) && return + [[ -b "$_target" ]] && echo $(to_dev_name $_target) && return # Then, must be nfs root echo "nfs" fi @@ -126,7 +126,7 @@ get_kdump_targets() local kdump_targets _target=$(get_block_dump_target) - if [ -n "$_target" ]; then + if [[ -n "$_target" ]]; then kdump_targets=$_target elif is_ssh_dump_target; then kdump_targets="ssh" @@ -136,7 +136,7 @@ get_kdump_targets() # Add the root device if dump_to_rootfs is specified. _root=$(get_failure_action_target) - if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then + if [[ -n "$_root" ]] && [[ "$kdump_targets" != "$_root" ]]; then kdump_targets="$kdump_targets $_root" fi @@ -204,10 +204,10 @@ get_kdump_mntpoint_from_target() # mount under /kdumproot if dump target is not mounted in first kernel # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. # systemd will be in charge to umount it. - if [ -z "$_mntpoint" ];then + if [[ -z "$_mntpoint" ]];then _mntpoint="/kdumproot" else - if [ "$_mntpoint" = "/" ];then + if [[ "$_mntpoint" = "/" ]];then _mntpoint="/sysroot" else _mntpoint="/kdumproot/$_mntpoint" @@ -223,10 +223,10 @@ kdump_get_persistent_dev() { case "$dev" in UUID=*) - dev=`blkid -U "${dev#UUID=}"` + dev=$(blkid -U "${dev#UUID=}") ;; LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` + dev=$(blkid -L "${dev#LABEL=}") ;; esac echo $(get_persistent_dev "$dev") @@ -253,9 +253,9 @@ get_remote_host() is_hostname() { - local _hostname=`echo $1 | grep ":"` + local _hostname=$(echo $1 | grep ":") - if [ -n "$_hostname" ]; then + if [[ -n "$_hostname" ]]; then return 1 fi echo $1 | grep -q "[a-zA-Z]" @@ -264,9 +264,9 @@ is_hostname() # Copied from "/etc/sysconfig/network-scripts/network-functions" get_hwaddr() { - if [ -f "/sys/class/net/${1}/address" ]; then + if [[ -f "/sys/class/net/${1}/address" ]]; then awk '{ print toupper($0) }' < /sys/class/net/${1}/address - elif [ -d "/sys/class/net/${1}" ]; then + elif [[ -d "/sys/class/net/${1}" ]]; then LC_ALL= LANG= ip -o link show ${1} 2>/dev/null | \ awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, "\\1", 1)); }' @@ -347,7 +347,7 @@ get_ifcfg_by_name() is_nm_running() { - [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ] + [[ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]] } is_nm_handling() @@ -371,7 +371,7 @@ get_ifcfg_nmcli() nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \ | grep "${1}" | head -1 | cut -d':' -f1) ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") - [ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") + [[ -z "${ifcfg_file}" ]] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") fi echo -n "${ifcfg_file}" @@ -383,15 +383,15 @@ get_ifcfg_legacy() local ifcfg_file ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" - [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return ifcfg_file=$(get_ifcfg_by_name "${1}") - [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return local hwaddr=$(get_hwaddr "${1}") - if [ -n "$hwaddr" ]; then + if [[ -n "$hwaddr" ]]; then ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") - [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return + [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return fi ifcfg_file=$(get_ifcfg_by_device "${1}") @@ -405,7 +405,7 @@ get_ifcfg_filename() { local ifcfg_file ifcfg_file=$(get_ifcfg_nmcli "${1}") - if [ -z "${ifcfg_file}" ]; then + if [[ -z "${ifcfg_file}" ]]; then ifcfg_file=$(get_ifcfg_legacy "${1}") fi @@ -432,11 +432,11 @@ is_dracut_mod_omitted() { is_wdt_active() { local active - [ -d /sys/class/watchdog ] || return 1 + [[ -d /sys/class/watchdog ]] || return 1 for dir in /sys/class/watchdog/*; do - [ -f "$dir/state" ] || continue + [[ -f "$dir/state" ]] || continue active=$(< "$dir/state") - [ "$active" = "active" ] && return 0 + [[ "$active" = "active" ]] && return 0 done return 1 } @@ -454,7 +454,7 @@ check_crash_mem_reserved() local mem_reserved mem_reserved=$(cat /sys/kernel/kexec_crash_size) - if [ $mem_reserved -eq 0 ]; then + if [[ $mem_reserved -eq 0 ]]; then derror "No memory reserved for crash kernel" return 1 fi @@ -464,7 +464,7 @@ check_crash_mem_reserved() check_kdump_feasibility() { - if [ ! -e /sys/kernel/kexec_crash_loaded ]; then + if [[ ! -e /sys/kernel/kexec_crash_loaded ]]; then derror "Kdump is not supported on this kernel" return 1 fi @@ -474,13 +474,13 @@ check_kdump_feasibility() check_current_kdump_status() { - if [ ! -f /sys/kernel/kexec_crash_loaded ];then + if [[ ! -f /sys/kernel/kexec_crash_loaded ]];then derror "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" return 1 fi - rc=`cat /sys/kernel/kexec_crash_loaded` - if [ $rc == 1 ]; then + rc=$(cat /sys/kernel/kexec_crash_loaded) + if [[ $rc == 1 ]]; then return 0 else return 1 @@ -496,11 +496,11 @@ remove_cmdline_param() shift for arg in $@; do - cmdline=`echo $cmdline | \ + cmdline=$(echo "$cmdline" | \ sed -e "s/\b$arg=[^ ]*//g" \ -e "s/^$arg\b//g" \ -e "s/[[:space:]]$arg\b//g" \ - -e "s/\s\+/ /g"` + -e "s/\s\+/ /g") done echo $cmdline } @@ -529,7 +529,7 @@ append_cmdline() local newstr=${cmdline/$2/""} # unchanged str implies argument wasn't there - if [ "$cmdline" == "$newstr" ]; then + if [[ "$cmdline" == "$newstr" ]]; then cmdline="${cmdline} ${2}=${3}" fi @@ -540,8 +540,8 @@ append_cmdline() # 4GB of ram available. Returns 1 if we do, 0 if we dont need_64bit_headers() { - return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ - print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` + return "$(tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); + print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }')" } # Check if secure boot is being enforced. @@ -561,11 +561,11 @@ is_secure_boot_enforced() # On powerpc, secure boot is enforced if: # host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists # guest secure boot: /ibm,secure-boot >= 2 - if [ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]; then + if [[ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]]; then return 0 fi - if [ -f /proc/device-tree/ibm,secure-boot ] && \ - [ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]; then + if [[ -f /proc/device-tree/ibm,secure-boot ]] && \ + [[ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]]; then return 0 fi @@ -573,11 +573,11 @@ is_secure_boot_enforced() secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) - if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then + if [[ -f "$secure_boot_file" ]] && [[ -f "$setup_mode_file" ]]; then secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) - if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then + if [[ "$secure_boot_byte" = "1" ]] && [[ "$setup_mode_byte" = "0" ]]; then return 0 fi fi @@ -599,22 +599,22 @@ prepare_kexec_args() local kexec_args=$1 local found_elf_args - ARCH=`uname -m` - if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] + ARCH=$(uname -m) + if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]] then need_64bit_headers - if [ $? == 1 ] + if [[ $? == 1 ]] then - found_elf_args=`echo $kexec_args | grep elf32-core-headers` - if [ -n "$found_elf_args" ] + found_elf_args=$(echo $kexec_args | grep elf32-core-headers) + if [[ -n "$found_elf_args" ]] then dwarn "Warning: elf32-core-headers overrides correct elf64 setting" else kexec_args="$kexec_args --elf64-core-headers" fi else - found_elf_args=`echo $kexec_args | grep elf64-core-headers` - if [ -z "$found_elf_args" ] + found_elf_args=$(echo $kexec_args | grep elf64-core-headers) + if [[ -z "$found_elf_args" ]] then kexec_args="$kexec_args --elf32-core-headers" fi @@ -635,7 +635,7 @@ prepare_kdump_bootinfo() local boot_imglist boot_dirlist boot_initrdlist curr_kver="$(uname -r)" local machine_id - if [ -z "$KDUMP_KERNELVER" ]; then + if [[ -z "$KDUMP_KERNELVER" ]]; then KDUMP_KERNELVER="$(uname -r)" fi @@ -645,20 +645,20 @@ prepare_kdump_bootinfo() # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format local boot_img="$(cat /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/")" - if [ -n "$boot_img" ]; then + if [[ -n "$boot_img" ]]; then boot_imglist="$boot_img $boot_imglist" fi for dir in $boot_dirlist; do for img in $boot_imglist; do - if [ -f "$dir/$img" ]; then + if [[ -f "$dir/$img" ]]; then KDUMP_KERNEL=$(echo $dir/$img | tr -s '/') break 2 fi done done - if ! [ -e "$KDUMP_KERNEL" ]; then + if ! [[ -e "$KDUMP_KERNEL" ]]; then derror "Failed to detect kdump kernel location" return 1 fi @@ -669,7 +669,7 @@ prepare_kdump_bootinfo() # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" for initrd in $boot_initrdlist; do - if [ -f "$KDUMP_BOOTDIR/$initrd" ]; then + if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then defaut_initrd_base="$initrd" DEFAULT_INITRD="$KDUMP_BOOTDIR/$defaut_initrd_base" break @@ -687,7 +687,7 @@ prepare_kdump_bootinfo() kdump_initrd_base=${defaut_initrd_base}kdump fi - # Place kdump initrd in `/var/lib/kdump` if `KDUMP_BOOTDIR` not writable + # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable if [[ ! -w "$KDUMP_BOOTDIR" ]];then var_target_initrd_dir="/var/lib/kdump" mkdir -p "$var_target_initrd_dir" @@ -724,7 +724,7 @@ prepare_cmdline() { local cmdline id - if [ -z "$1" ]; then + if [[ -z "$1" ]]; then cmdline=$(cat /proc/cmdline) else cmdline="$1" @@ -754,7 +754,7 @@ prepare_cmdline() cmdline="${cmdline} $3" id=$(get_bootcpu_apicid) - if [ ! -z ${id} ] ; then + if [[ ! -z ${id} ]] ; then cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) fi @@ -803,7 +803,7 @@ get_recommend_size() last_unit="" start=${_ck_cmdline: :1} - if [ $mem_size -lt $start ]; then + if [[ $mem_size -lt $start ]]; then echo "0M" return fi @@ -813,10 +813,10 @@ get_recommend_size() recommend=$(echo $i | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $2 }') size=${end: : -1} unit=${end: -1} - if [ $unit == 'T' ]; then + if [[ $unit == 'T' ]]; then let size=$size*1024 fi - if [ $mem_size -lt $size ]; then + if [[ $mem_size -lt $size ]]; then echo $recommend IFS="$OLDIFS" return @@ -826,28 +826,28 @@ get_recommend_size() } # return recommended size based on current system RAM size -# $1: kernel version, if not set, will defaults to `uname -r` +# $1: kernel version, if not set, will defaults to $(uname -r) kdump_get_arch_recommend_size() { local kernel=$1 arch - if ! [ -r "/proc/iomem" ] ; then + if ! [[ -r "/proc/iomem" ]] ; then echo "Error, can not access /proc/iomem." return 1 fi - [ -z "$kernel" ] && kernel=$(uname -r) + [[ -z "$kernel" ]] && kernel=$(uname -r) ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2>/dev/null) - if [ -n "$ck_cmdline" ]; then + if [[ -n "$ck_cmdline" ]]; then ck_cmdline=${ck_cmdline#crashkernel=} else arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') - if [ "$arch" = "X86_64" ] || [ "$arch" = "S390X" ]; then + if [[ "$arch" = "X86_64" ]] || [[ "$arch" = "S390X" ]]; then ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" - elif [ "$arch" = "AARCH64" ]; then + elif [[ "$arch" = "AARCH64" ]]; then ck_cmdline="2G-:448M" - elif [ "$arch" = "PPC64LE" ]; then + elif [[ "$arch" = "PPC64LE" ]]; then if is_fadump_capable; then ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" else @@ -923,7 +923,7 @@ try_decompress() # "grep" that report the byte offset of the line instead of the pattern. # Try to find the header ($1) and decompress from here - for pos in `tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"` + for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2") do if ! type -P $3 > /dev/null; then ddebug "Signiature detected but '$3' is missing, skip this decompressor" From 58d3e6db3a2f066ea8e48fe9a8c77a6bb8ca7159 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 15:20:42 +0800 Subject: [PATCH 491/806] kdump-lib.sh: rework nmcli related functions This fixes word splitting issue with nmcli args. Current kexec-tools scripts won't call nmcli with correct arguments when there are space in network interface name. nmcli expects multiple parameters, but get_nmcli_value_by_field only accepts two params and depends on shell word splitting to split the _nm_show_cmd into multiple params, which is very fragile. So switch the param order, simplified this function and now multiple params can be used properly. And get_nmcli_connection_show_cmd_by_ifname returns multiple nmcli params in a single variable, it depend on shell word splitting to split the words when calling nmcli. But this is very fragile and break easily when there are any special character in the connection path. This function is only introduced to get and cache the nmcli command which contains the "connection name". Actually only cache the "connection path" is enough. Callers should just call get_nmcli_connection_apath_by_ifname to cache the path, and a new helper get_nmcli_field_by_conpath is introduced here to get value from nmcli. This way "connection path" can contain any character. Also get rid of another nmcli_cmd usage in get_nmcli_connection_apath_by_ifname which stores multiple params in a single bash variable separated by space. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-module-setup.sh | 37 ++++++++++++++++++------------------- kdump-lib.sh | 32 ++++++++++---------------------- 2 files changed, 28 insertions(+), 41 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 80b5582..a5e4b67 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -84,14 +84,13 @@ source_ifcfg_file() { fi } -# $1: nmcli connection show output kdump_setup_dns() { local _netdev="$1" - local _nm_show_cmd="$2" + local _conpath="$2" local _nameserver _dns _tmp array local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") + _tmp=$(get_nmcli_field_by_conpath "IP4.DNS" "$_conpath") # shellcheck disable=SC2206 array=(${_tmp//|/ }) if [[ ${array[*]} ]]; then @@ -355,7 +354,7 @@ kdump_setup_bridge() { _dev=${_dev##*/} _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - (kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") || exit 1 + (kdump_setup_bond "$_dev" "$(get_nmcli_connection_apath_by_ifname "$_dev")") || exit 1 elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then @@ -375,7 +374,7 @@ kdump_setup_bridge() { # bond=bond0:eth0,eth1:mode=balance-rr kdump_setup_bond() { local _netdev="$1" - local _nm_show_cmd="$2" + local _conpath="$2" local _dev _mac _slaves _kdumpdev _bondoptions for _dev in $(cat "/sys/class/net/$_netdev/bonding/slaves"); do _mac=$(kdump_get_perm_addr "$_dev") @@ -385,7 +384,7 @@ kdump_setup_bond() { done echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf" - _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") + _bondoptions=$(get_nmcli_field_by_conpath "bond.options" "$_conpath") if [[ -z $_bondoptions ]]; then dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." @@ -436,7 +435,7 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") || exit 1 + (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_apath_by_ifname "$_phydev")") || exit 1 echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else _kdumpdev="$(kdump_setup_ifname "$_phydev")" @@ -474,18 +473,18 @@ find_online_znet_device() { # setup s390 znet cmdline # $1: netdev (ifname) -# $2: nmcli connection show output +# $2: nmcli connection path kdump_setup_znet() { local _netdev="$1" - local _nmcli_cmd="$2" + local _conpath="$2" local s390_prefix="802-3-ethernet.s390-" local _options="" local NETTYPE local SUBCHANNELS - NETTYPE=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}nettype") - SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels") - _options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options") + NETTYPE=$(get_nmcli_field_by_conpath "${s390_prefix}nettype" "$_conpath") + SUBCHANNELS=$(get_nmcli_field_by_conpath "${s390_prefix}subchannels" "$_conpath") + _options=$(get_nmcli_field_by_conpath "${s390_prefix}options" "$_conpath") if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." @@ -532,22 +531,22 @@ kdump_get_remote_ip() { # initramfs accessing giving destination # $1: destination host kdump_install_net() { - local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic + local _destaddr _srcaddr _route _netdev _conpath kdumpnic local _static _proto _ip_conf _ip_opts _ifname_opts - local _znet_netdev _nm_show_cmd_znet + local _znet_netdev _znet_conpath _destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") - _nm_show_cmd=$(get_nmcli_connection_show_cmd_by_ifname "$_netdev") + _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev") _netmac=$(kdump_get_mac_addr "$_netdev") kdumpnic=$(kdump_setup_ifname "$_netdev") _znet_netdev=$(find_online_znet_device) if [[ -n $_znet_netdev ]]; then - _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") - if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then + _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") + if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then derror "Failed to set up znet" exit 1 fi @@ -577,7 +576,7 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - (kdump_setup_bond "$_netdev" "$_nm_show_cmd") || exit 1 + (kdump_setup_bond "$_netdev" "$_conpath") || exit 1 elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then @@ -587,7 +586,7 @@ kdump_install_net() { echo "$_ifname_opts" >> "$_ip_conf" fi - kdump_setup_dns "$_netdev" "$_nm_show_cmd" + kdump_setup_dns "$_netdev" "$_conpath" if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then # network-manager module needs this parameter diff --git a/kdump-lib.sh b/kdump-lib.sh index 0dbf485..24a02b5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -275,6 +275,7 @@ get_hwaddr() # Get value by a field using "nmcli -g" +# Usage: get_nmcli_value_by_field # # "nmcli --get-values" allows us to retrive value(s) by field, for example, # nmcli --get-values connection show /org/freedesktop/NetworkManager/ActiveConnection/1 @@ -285,12 +286,16 @@ get_hwaddr() # bond.options "mode=balance-rr" get_nmcli_value_by_field() { - local _nm_show_cmd=$1 - local _field=$2 + LANG=C nmcli --get-values "$@" +} - local val=$(LANG=C nmcli --get-values $_field $_nm_show_cmd) +# Get nmcli field value of an connection apath (a D-Bus active connection path) +# Usage: get_nmcli_field_by_apath +get_nmcli_field_by_conpath() +{ + local _field=$1 _apath=$2 - echo -n "$val" + get_nmcli_value_by_field "$_field" connection show "$_apath" } # Get nmcli connection apath (a D-Bus active connection path ) by ifname @@ -300,25 +305,8 @@ get_nmcli_value_by_field() get_nmcli_connection_apath_by_ifname() { local _ifname=$1 - local _nm_show_cmd="device show $_ifname" - local _apath=$(get_nmcli_value_by_field "$_nm_show_cmd" "GENERAL.CON-PATH") - - echo -n "$_apath" -} - -# Get nmcli connection show cmd by ifname -# -# "$_apath" is supposed to not contain any chracter that -# need to be escapded, e.g. space. Otherwise get_nmcli_value_by_field -# would fail. -get_nmcli_connection_show_cmd_by_ifname() -{ - local _ifname="$1" - local _apath=$(get_nmcli_connection_apath_by_ifname "$_ifname") - local _nm_show_cmd="connection show $_apath" - - echo -n "$_nm_show_cmd" + get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" } get_ifcfg_by_device() From 53813e8b9af280315962ac6656318f94b1daf563 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 02:48:17 +0800 Subject: [PATCH 492/806] kdump-lib.sh: remove useless echo and cat Replace echo "$(cmd)" and "var=$(cmd); echo $var" with just `cmd`. And remove some useless cat. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 24a02b5..8624e19 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -14,7 +14,7 @@ is_fadump_capable() # Check if firmware-assisted dump is enabled # if no, fallback to kdump check if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then - rc=$(cat $FADUMP_ENABLED_SYS_NODE) + rc=$(<$FADUMP_ENABLED_SYS_NODE) [[ $rc -eq 1 ]] && return 0 fi return 1 @@ -59,13 +59,14 @@ to_dev_name() { case "$dev" in UUID=*) - dev=$(blkid -U "${dev#UUID=}") + blkid -U "${dev#UUID=}" ;; LABEL=*) - dev=$(blkid -L "${dev#LABEL=}") + blkid -L "${dev#LABEL=}" ;; + *) + echo "$dev" esac - echo $dev } is_user_configured_dump_target() @@ -93,12 +94,12 @@ get_block_dump_target() fi _target=$(get_user_configured_dump_disk) - [[ -n "$_target" ]] && echo $(to_dev_name $_target) && return + [[ -n "$_target" ]] && to_dev_name $_target && return # Get block device name from local save path _path=$(get_save_path) _target=$(get_target_from_path $_path) - [[ -b "$_target" ]] && echo $(to_dev_name $_target) + [[ -b "$_target" ]] && to_dev_name $_target } is_dump_to_rootfs() @@ -113,7 +114,7 @@ get_failure_action_target() if is_dump_to_rootfs; then # Get rootfs device name _target=$(get_root_fs_device) - [[ -b "$_target" ]] && echo $(to_dev_name $_target) && return + [[ -b "$_target" ]] && to_dev_name $_target && return # Then, must be nfs root echo "nfs" fi @@ -441,7 +442,7 @@ check_crash_mem_reserved() { local mem_reserved - mem_reserved=$(cat /sys/kernel/kexec_crash_size) + mem_reserved=$( Date: Wed, 8 Sep 2021 13:31:31 +0800 Subject: [PATCH 493/806] kdump-lib.sh: fix arithmetic operation syntax Get rid of let, and remove useless '$' on arithmetic variables. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 8624e19..aff395b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -777,7 +777,7 @@ get_system_size() # replace '-' with '+0x' and '+' with '-0x' sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' ) size=$(printf "%d\n" $(($sum))) - let size=$size/1024/1024/1024 + size=$((size / 1024 / 1024 / 1024)) echo $size } @@ -803,7 +803,7 @@ get_recommend_size() size=${end: : -1} unit=${end: -1} if [[ $unit == 'T' ]]; then - let size=$size*1024 + size=$((size * 1024)) fi if [[ $mem_size -lt $size ]]; then echo $recommend @@ -899,7 +899,7 @@ get_vmlinux_size() local size=0 while read _type _offset _virtaddr _physaddr _fsize _msize _flg _aln; do - size=$(( $size + $_msize )) + size=$(( size + _msize )) done <<< $(readelf -l -W $1 | grep "^ LOAD" 2>/dev/stderr) echo $size @@ -954,7 +954,7 @@ get_kernel_size() # Fallback to use iomem local _size=0 for _seg in $(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1); do - _size=$(( $_size + 0x${_seg#*-} - 0x${_seg%-*} )) + _size=$(( _size + 0x${_seg#*-} - 0x${_seg%-*} )) done echo $_size } From 319219d23b003310f457e3ba549bf0fa0254d7da Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 Sep 2021 01:17:23 +0800 Subject: [PATCH 494/806] kdump-lib.sh: fix a few ambiguous or redundant code Fix a few ambiguous syntax issues and remove some unused variables. Also refactor some code to make it more robust. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index aff395b..6705f27 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -176,7 +176,7 @@ get_bind_mount_source() echo $_mnt$_path && return fi - local _fsroot=${_src#$_src_nofsroot[} + local _fsroot=${_src#${_src_nofsroot}[} _fsroot=${_fsroot%]} _mnt=$(get_mount_info TARGET source $_src_nofsroot -f) @@ -621,14 +621,14 @@ prepare_kexec_args() # prepare_kdump_bootinfo() { - local boot_imglist boot_dirlist boot_initrdlist curr_kver="$(uname -r)" + local boot_imglist boot_dirlist boot_initrdlist local machine_id if [[ -z "$KDUMP_KERNELVER" ]]; then KDUMP_KERNELVER="$(uname -r)" fi - read machine_id < /etc/machine-id + read -r machine_id < /etc/machine-id boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG" @@ -743,8 +743,8 @@ prepare_cmdline() cmdline="${cmdline} $3" id=$(get_bootcpu_apicid) - if [[ ! -z ${id} ]] ; then - cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) + if [[ -n ${id} ]] ; then + cmdline=$(append_cmdline "$cmdline" disable_cpu_apicid "$id") fi # If any watchdog is used, set it's pretimeout to 0. pretimeout let @@ -775,7 +775,7 @@ get_system_size() result=$(grep "System RAM" /proc/iomem | awk -F ":" '{ print $1 }' | tr [:lower:] [:upper:] | paste -sd+) result="+$result" # replace '-' with '+0x' and '+' with '-0x' - sum=$( echo $result | sed -e 's/-/K0x/g' | sed -e 's/+/-0x/g' | sed -e 's/K/+/g' ) + sum=$(echo "$result" | sed -e 's/-/K0x/g' -e 's/+/-0x/g' -e 's/K/+/g') size=$(printf "%d\n" $(($sum))) size=$((size / 1024 / 1024 / 1024)) @@ -788,9 +788,6 @@ get_recommend_size() local _ck_cmdline=$2 local OLDIFS="$IFS" - last_sz="" - last_unit="" - start=${_ck_cmdline: :1} if [[ $mem_size -lt $start ]]; then echo "0M" @@ -845,7 +842,7 @@ kdump_get_arch_recommend_size() fi fi - ck_cmdline=$(echo $ck_cmdline | sed -e 's/-:/-102400T:/g') + ck_cmdline=${ck_cmdline//-:/-102400T:} sys_mem=$(get_system_size) get_recommend_size "$sys_mem" "$ck_cmdline" @@ -896,11 +893,11 @@ check_vmlinux() get_vmlinux_size() { - local size=0 + local size=0 _msize - while read _type _offset _virtaddr _physaddr _fsize _msize _flg _aln; do + while read -r _msize; do size=$(( size + _msize )) - done <<< $(readelf -l -W $1 | grep "^ LOAD" 2>/dev/stderr) + done <<< "$(readelf -l -W "$1" | awk '/^ LOAD/{print $6}' 2>/dev/stderr)" echo $size } @@ -952,9 +949,9 @@ get_kernel_size() [[ $? -eq 0 ]] && get_vmlinux_size $tmp && return 0 # Fallback to use iomem - local _size=0 - for _seg in $(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1); do - _size=$(( _size + 0x${_seg#*-} - 0x${_seg%-*} )) - done + local _size=0 _seg + while read -r _seg; do + _size=$(( _size + 0x${_seg#*-} - 0x${_seg%-*} )) + done <<< "$(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1)" echo $_size } From 4f01cb1b0a4e1ea9467e9ace34d14dcb2fbe135a Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 Sep 2021 01:18:04 +0800 Subject: [PATCH 495/806] kdump-lib.sh: fix variable quoting issue Fixed quoting issues found by shellcheck, no feature change. This should fix many errors when there is space in any shell variables. And fixed how remove_cmdline_param is being called in prepare_cmdline. Kernel parameters can have space like: param="spaces in here". So currently remove_cmdline_param is broken since its args always get split by space. But prepare_cmdline is expecting remove_cmdline_param to split its args by space and passing a list of kernel args separated by space as a whole arg. So fix that by using `xargs` to parse and split the args properly, then call remove_cmdline_param. Following quoting related issues are fixed (check the link for example code and what could go wrong): https://github.com/koalaman/shellcheck/wiki/SC1007 https://github.com/koalaman/shellcheck/wiki/SC2046 https://github.com/koalaman/shellcheck/wiki/SC2053 https://github.com/koalaman/shellcheck/wiki/SC2060 https://github.com/koalaman/shellcheck/wiki/SC2068 https://github.com/koalaman/shellcheck/wiki/SC2086 Signed-off-by: Kairui Song --- kdump-lib.sh | 132 ++++++++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 6705f27..64c6e4f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -25,7 +25,7 @@ is_squash_available() { if [[ -z "$KDUMP_KERNELVER" ]]; then modprobe --dry-run $kmodule &>/dev/null || return 1 else - modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1 + modprobe -S "$KDUMP_KERNELVER" --dry-run $kmodule &>/dev/null || return 1 fi done } @@ -79,10 +79,10 @@ get_user_configured_dump_disk() local _target _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") - [[ -n "$_target" ]] && echo $_target && return + [[ -n "$_target" ]] && echo "$_target" && return _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") - [[ -b "$_target" ]] && echo $_target + [[ -b "$_target" ]] && echo "$_target" } get_block_dump_target() @@ -94,12 +94,12 @@ get_block_dump_target() fi _target=$(get_user_configured_dump_disk) - [[ -n "$_target" ]] && to_dev_name $_target && return + [[ -n "$_target" ]] && to_dev_name "$_target" && return # Get block device name from local save path _path=$(get_save_path) - _target=$(get_target_from_path $_path) - [[ -b "$_target" ]] && to_dev_name $_target + _target=$(get_target_from_path "$_path") + [[ -b "$_target" ]] && to_dev_name "$_target" } is_dump_to_rootfs() @@ -114,7 +114,7 @@ get_failure_action_target() if is_dump_to_rootfs; then # Get rootfs device name _target=$(get_root_fs_device) - [[ -b "$_target" ]] && to_dev_name $_target && return + [[ -b "$_target" ]] && to_dev_name "$_target" && return # Then, must be nfs root echo "nfs" fi @@ -158,27 +158,27 @@ get_kdump_targets() # part is the bind mounted directory which quotes by bracket "[]". get_bind_mount_source() { - local _mnt=$(df $1 | tail -1 | awk '{print $NF}') + local _mnt=$(df "$1" | tail -1 | awk '{print $NF}') local _path=${1#$_mnt} - local _src=$(get_mount_info SOURCE target $_mnt -f) - local _opt=$(get_mount_info OPTIONS target $_mnt -f) - local _fstype=$(get_mount_info FSTYPE target $_mnt -f) + local _src=$(get_mount_info SOURCE target "$_mnt" -f) + local _opt=$(get_mount_info OPTIONS target "$_mnt" -f) + local _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) # bind mount in fstab if [[ -d "$_src" ]] && [[ "$_fstype" = none ]] && (echo "$_opt" | grep -q "\bbind\b"); then - echo $_src$_path && return + echo "$_src$_path" && return fi # direct mount - local _src_nofsroot=$(get_mount_info SOURCE target $_mnt -v -f) - if [[ $_src_nofsroot = $_src ]]; then - echo $_mnt$_path && return + local _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) + if [[ $_src_nofsroot = "$_src" ]]; then + echo "$_mnt$_path" && return fi local _fsroot=${_src#${_src_nofsroot}[} _fsroot=${_fsroot%]} - _mnt=$(get_mount_info TARGET source $_src_nofsroot -f) + _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) # for btrfs, _fsroot will also contain the subvol value as well, strip it if [[ "$_fstype" = btrfs ]]; then @@ -187,19 +187,19 @@ get_bind_mount_source() _subvol=${_subvol%,*} _fsroot=${_fsroot#$_subvol} fi - echo $_mnt$_fsroot$_path + echo "$_mnt$_fsroot$_path" } get_mntopt_from_target() { - get_mount_info OPTIONS source $1 -f + get_mount_info OPTIONS source "$1" -f } # Get the path where the target will be mounted in kdump kernel # $1: kdump target device get_kdump_mntpoint_from_target() { - local _mntpoint=$(get_mntpoint_from_target $1) + local _mntpoint=$(get_mntpoint_from_target "$1") # mount under /sysroot if dump to root disk or mount under # mount under /kdumproot if dump target is not mounted in first kernel @@ -249,26 +249,26 @@ get_remote_host() _config_val=${_config_val%:/*} _config_val=${_config_val#[} _config_val=${_config_val%]} - echo $_config_val + echo "$_config_val" } is_hostname() { - local _hostname=$(echo $1 | grep ":") + local _hostname=$(echo "$1" | grep ":") if [[ -n "$_hostname" ]]; then return 1 fi - echo $1 | grep -q "[a-zA-Z]" + echo "$1" | grep -q "[a-zA-Z]" } # Copied from "/etc/sysconfig/network-scripts/network-functions" get_hwaddr() { - if [[ -f "/sys/class/net/${1}/address" ]]; then - awk '{ print toupper($0) }' < /sys/class/net/${1}/address - elif [[ -d "/sys/class/net/${1}" ]]; then - LC_ALL= LANG= ip -o link show ${1} 2>/dev/null | \ + if [[ -f "/sys/class/net/$1/address" ]]; then + awk '{ print toupper($0) }' < "/sys/class/net/$1/address" + elif [[ -d "/sys/class/net/$1" ]]; then + LC_ALL="" LANG="" ip -o link show "$1" 2>/dev/null | \ awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, "\\1", 1)); }' fi @@ -484,14 +484,14 @@ remove_cmdline_param() local cmdline=$1 shift - for arg in $@; do + for arg in "$@"; do cmdline=$(echo "$cmdline" | \ sed -e "s/\b$arg=[^ ]*//g" \ -e "s/^$arg\b//g" \ -e "s/[[:space:]]$arg\b//g" \ -e "s/\s\+/ /g") done - echo $cmdline + echo "$cmdline" } # @@ -522,7 +522,7 @@ append_cmdline() cmdline="${cmdline} ${2}=${3}" fi - echo $cmdline + echo "$cmdline" } # This function check iomem and determines if we have more than @@ -559,12 +559,12 @@ is_secure_boot_enforced() fi # Detect secure boot on x86 and arm64 - secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) + secure_boot_file=$(find /sys/firmware/efi/efivars -name "SecureBoot-*" 2>/dev/null) + setup_mode_file=$(find /sys/firmware/efi/efivars -name "SetupMode-*" 2>/dev/null) if [[ -f "$secure_boot_file" ]] && [[ -f "$setup_mode_file" ]]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) + secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' "$secure_boot_file" | cut -d' ' -f 5) + setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' "$setup_mode_file" | cut -d' ' -f 5) if [[ "$secure_boot_byte" = "1" ]] && [[ "$setup_mode_byte" = "0" ]]; then return 0 @@ -594,7 +594,7 @@ prepare_kexec_args() need_64bit_headers if [[ $? == 1 ]] then - found_elf_args=$(echo $kexec_args | grep elf32-core-headers) + found_elf_args=$(echo "$kexec_args" | grep elf32-core-headers) if [[ -n "$found_elf_args" ]] then dwarn "Warning: elf32-core-headers overrides correct elf64 setting" @@ -602,14 +602,14 @@ prepare_kexec_args() kexec_args="$kexec_args --elf64-core-headers" fi else - found_elf_args=$(echo $kexec_args | grep elf64-core-headers) + found_elf_args=$(echo "$kexec_args" | grep elf64-core-headers) if [[ -z "$found_elf_args" ]] then kexec_args="$kexec_args --elf32-core-headers" fi fi fi - echo $kexec_args + echo "$kexec_args" } # @@ -641,7 +641,7 @@ prepare_kdump_bootinfo() for dir in $boot_dirlist; do for img in $boot_imglist; do if [[ -f "$dir/$img" ]]; then - KDUMP_KERNEL=$(echo $dir/$img | tr -s '/') + KDUMP_KERNEL=$(echo "$dir/$img" | tr -s '/') break 2 fi done @@ -653,7 +653,7 @@ prepare_kdump_bootinfo() fi # Set KDUMP_BOOTDIR to where kernel image is stored - KDUMP_BOOTDIR=$(dirname $KDUMP_KERNEL) + KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL") # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" @@ -694,7 +694,7 @@ get_watchdog_drvs() # device/modalias will return driver of this device [[ -f "$_dir/device/modalias" ]] || continue _drv=$(< "$_dir/device/modalias") - _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R $_drv 2>/dev/null) + _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R "$_drv" 2>/dev/null) for i in $_drv; do if ! [[ " $_wdtdrvs " == *" $i "* ]]; then _wdtdrvs="$_wdtdrvs $i" @@ -702,7 +702,7 @@ get_watchdog_drvs() done done - echo $_wdtdrvs + echo "$_wdtdrvs" } # @@ -711,7 +711,7 @@ get_watchdog_drvs() # Store the final result in global $KDUMP_COMMANDLINE. prepare_cmdline() { - local cmdline id + local cmdline id arg if [[ -z "$1" ]]; then cmdline=$(/dev/null || return 1 + readelf -h "$1" &>/dev/null || return 1 } get_vmlinux_size() @@ -910,14 +912,14 @@ try_decompress() # Try to find the header ($1) and decompress from here for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2") do - if ! type -P $3 > /dev/null; then + if ! type -P "$3" > /dev/null; then ddebug "Signiature detected but '$3' is missing, skip this decompressor" break fi pos=${pos%%:*} - tail -c+$pos "$img" | $3 > $5 2> /dev/null - if check_vmlinux $5; then + tail "-c+$pos" "$img" | $3 > "$5" 2> /dev/null + if check_vmlinux "$5"; then ddebug "Kernel is extracted with '$3'" return 0 fi @@ -931,22 +933,22 @@ get_kernel_size() { # Prepare temp files: local img=$1 tmp=$(mktemp /tmp/vmlinux-XXX) - trap "rm -f $tmp" 0 + trap 'rm -f "$tmp"' 0 # Try to check if it's a vmlinux already - check_vmlinux $img && get_vmlinux_size $img && return 0 + check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 # That didn't work, so retry after decompression. - try_decompress '\037\213\010' xy gunzip $img $tmp || \ - try_decompress '\3757zXZ\000' abcde unxz $img $tmp || \ - try_decompress 'BZh' xy bunzip2 $img $tmp || \ - try_decompress '\135\0\0\0' xxx unlzma $img $tmp || \ - try_decompress '\211\114\132' xy 'lzop -d' $img $tmp || \ - try_decompress '\002!L\030' xxx 'lz4 -d' $img $tmp || \ - try_decompress '(\265/\375' xxx unzstd $img $tmp + try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || \ + try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || \ + try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || \ + try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || \ + try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || \ + try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || \ + try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" # Finally check for uncompressed images or objects: - [[ $? -eq 0 ]] && get_vmlinux_size $tmp && return 0 + [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 # Fallback to use iomem local _size=0 _seg From 20089dddd5b2dcf233483e3b5b8142f33e5ab7f1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 8 Sep 2021 03:48:19 +0800 Subject: [PATCH 496/806] kdump-lib.sh: declare and assign separately See: https://github.com/koalaman/shellcheck/wiki/SC2155 Signed-off-by: Kairui Song --- kdump-lib.sh | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 64c6e4f..ac36592 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -158,12 +158,15 @@ get_kdump_targets() # part is the bind mounted directory which quotes by bracket "[]". get_bind_mount_source() { - local _mnt=$(df "$1" | tail -1 | awk '{print $NF}') - local _path=${1#$_mnt} + local _mnt _path _src _opt _fstype + local _fsroot _src_nofsroot - local _src=$(get_mount_info SOURCE target "$_mnt" -f) - local _opt=$(get_mount_info OPTIONS target "$_mnt" -f) - local _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) + _mnt=$(df "$1" | tail -1 | awk '{print $NF}') + _path=${1#$_mnt} + + _src=$(get_mount_info SOURCE target "$_mnt" -f) + _opt=$(get_mount_info OPTIONS target "$_mnt" -f) + _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) # bind mount in fstab if [[ -d "$_src" ]] && [[ "$_fstype" = none ]] && (echo "$_opt" | grep -q "\bbind\b"); then @@ -171,12 +174,12 @@ get_bind_mount_source() fi # direct mount - local _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) + _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) if [[ $_src_nofsroot = "$_src" ]]; then echo "$_mnt$_path" && return fi - local _fsroot=${_src#${_src_nofsroot}[} + _fsroot=${_src#${_src_nofsroot}[} _fsroot=${_fsroot%]} _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) @@ -199,8 +202,9 @@ get_mntopt_from_target() # $1: kdump target device get_kdump_mntpoint_from_target() { - local _mntpoint=$(get_mntpoint_from_target "$1") + local _mntpoint + _mntpoint=$(get_mntpoint_from_target "$1") # mount under /sysroot if dump to root disk or mount under # mount under /kdumproot if dump target is not mounted in first kernel # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. @@ -254,8 +258,9 @@ get_remote_host() is_hostname() { - local _hostname=$(echo "$1" | grep ":") + local _hostname + _hostname=$(echo "$1" | grep ":") if [[ -n "$_hostname" ]]; then return 1 fi @@ -369,7 +374,7 @@ get_ifcfg_nmcli() # $1: netdev name get_ifcfg_legacy() { - local ifcfg_file + local ifcfg_file hwaddr ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return @@ -377,7 +382,7 @@ get_ifcfg_legacy() ifcfg_file=$(get_ifcfg_by_name "${1}") [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return - local hwaddr=$(get_hwaddr "${1}") + hwaddr=$(get_hwaddr "${1}") if [[ -n "$hwaddr" ]]; then ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return @@ -621,7 +626,7 @@ prepare_kexec_args() # prepare_kdump_bootinfo() { - local boot_imglist boot_dirlist boot_initrdlist + local boot_img boot_imglist boot_dirlist boot_initrdlist local machine_id if [[ -z "$KDUMP_KERNELVER" ]]; then @@ -633,7 +638,7 @@ prepare_kdump_bootinfo() boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG" # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format - local boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)" + boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)" if [[ -n "$boot_img" ]]; then boot_imglist="$boot_img $boot_imglist" fi @@ -855,9 +860,11 @@ kdump_get_arch_recommend_size() # $1: the block device to be checked in maj:min format get_luks_crypt_dev() { + local _type + [[ -b /dev/block/$1 ]] || return 1 - local _type=$(eval "$(blkid -u filesystem,crypto -o export -- "/dev/block/$1"); echo \$TYPE") + _type=$(eval "$(blkid -u filesystem,crypto -o export -- "/dev/block/$1"); echo \$TYPE") [[ $_type == "crypto_LUKS" ]] && echo "$1" for _x in "/sys/dev/block/$1/slaves/"*; do @@ -932,7 +939,9 @@ try_decompress() get_kernel_size() { # Prepare temp files: - local img=$1 tmp=$(mktemp /tmp/vmlinux-XXX) + local tmp img=$1 + + tmp=$(mktemp /tmp/vmlinux-XXX) trap 'rm -f "$tmp"' 0 # Try to check if it's a vmlinux already From 4cdce1f48915c1f46ef01af4b50d000c5858cbdf Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 14 Sep 2021 03:09:30 +0800 Subject: [PATCH 497/806] kdump-lib.sh: reformat with shfmt This is a batch update done with: shfmt -s -w kdump-lib.sh Clean up code style and reduce code base size, no behaviour change. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-lib.sh | 1110 +++++++++++++++++++++++++------------------------- 1 file changed, 557 insertions(+), 553 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index ac36592..2e2775c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -11,137 +11,141 @@ FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" is_fadump_capable() { - # Check if firmware-assisted dump is enabled - # if no, fallback to kdump check - if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then - rc=$(<$FADUMP_ENABLED_SYS_NODE) - [[ $rc -eq 1 ]] && return 0 - fi - return 1 + # Check if firmware-assisted dump is enabled + # if no, fallback to kdump check + if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then + rc=$(< $FADUMP_ENABLED_SYS_NODE) + [[ $rc -eq 1 ]] && return 0 + fi + return 1 } -is_squash_available() { - for kmodule in squashfs overlay loop; do - if [[ -z "$KDUMP_KERNELVER" ]]; then - modprobe --dry-run $kmodule &>/dev/null || return 1 - else - modprobe -S "$KDUMP_KERNELVER" --dry-run $kmodule &>/dev/null || return 1 - fi - done +is_squash_available() +{ + for kmodule in squashfs overlay loop; do + if [[ -z $KDUMP_KERNELVER ]]; then + modprobe --dry-run $kmodule &> /dev/null || return 1 + else + modprobe -S "$KDUMP_KERNELVER" --dry-run $kmodule &> /dev/null || return 1 + fi + done } -perror_exit() { - derror "$@" - exit 1 +perror_exit() +{ + derror "$@" + exit 1 } # Check if fence kdump is configured in Pacemaker cluster is_pcs_fence_kdump() { - # no pcs or fence_kdump_send executables installed? - type -P pcs > /dev/null || return 1 - [[ -x $FENCE_KDUMP_SEND ]] || return 1 + # no pcs or fence_kdump_send executables installed? + type -P pcs > /dev/null || return 1 + [[ -x $FENCE_KDUMP_SEND ]] || return 1 - # fence kdump not configured? - (pcs cluster cib | grep 'type="fence_kdump"') &> /dev/null || return 1 + # fence kdump not configured? + (pcs cluster cib | grep 'type="fence_kdump"') &> /dev/null || return 1 } # Check if fence_kdump is configured using kdump options is_generic_fence_kdump() { - [[ -x $FENCE_KDUMP_SEND ]] || return 1 + [[ -x $FENCE_KDUMP_SEND ]] || return 1 - [[ $(kdump_get_conf_val fence_kdump_nodes) ]] + [[ $(kdump_get_conf_val fence_kdump_nodes) ]] } -to_dev_name() { - local dev="${1//\"/}" +to_dev_name() +{ + local dev="${1//\"/}" - case "$dev" in - UUID=*) - blkid -U "${dev#UUID=}" - ;; - LABEL=*) - blkid -L "${dev#LABEL=}" - ;; - *) - echo "$dev" - esac + case "$dev" in + UUID=*) + blkid -U "${dev#UUID=}" + ;; + LABEL=*) + blkid -L "${dev#LABEL=}" + ;; + *) + echo "$dev" + ;; + esac } is_user_configured_dump_target() { - [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh") ]] || is_mount_in_dracut_args + [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh") ]] || is_mount_in_dracut_args } get_user_configured_dump_disk() { - local _target + local _target - _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") - [[ -n "$_target" ]] && echo "$_target" && return + _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") + [[ -n $_target ]] && echo "$_target" && return - _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") - [[ -b "$_target" ]] && echo "$_target" + _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") + [[ -b $_target ]] && echo "$_target" } get_block_dump_target() { - local _target _path + local _target _path - if is_ssh_dump_target || is_nfs_dump_target; then - return - fi + if is_ssh_dump_target || is_nfs_dump_target; then + return + fi - _target=$(get_user_configured_dump_disk) - [[ -n "$_target" ]] && to_dev_name "$_target" && return + _target=$(get_user_configured_dump_disk) + [[ -n $_target ]] && to_dev_name "$_target" && return - # Get block device name from local save path - _path=$(get_save_path) - _target=$(get_target_from_path "$_path") - [[ -b "$_target" ]] && to_dev_name "$_target" + # Get block device name from local save path + _path=$(get_save_path) + _target=$(get_target_from_path "$_path") + [[ -b $_target ]] && to_dev_name "$_target" } is_dump_to_rootfs() { - [[ $(kdump_get_conf_val "failure_action|default") == dump_to_rootfs ]] + [[ $(kdump_get_conf_val "failure_action|default") == dump_to_rootfs ]] } get_failure_action_target() { - local _target + local _target - if is_dump_to_rootfs; then - # Get rootfs device name - _target=$(get_root_fs_device) - [[ -b "$_target" ]] && to_dev_name "$_target" && return - # Then, must be nfs root - echo "nfs" - fi + if is_dump_to_rootfs; then + # Get rootfs device name + _target=$(get_root_fs_device) + [[ -b $_target ]] && to_dev_name "$_target" && return + # Then, must be nfs root + echo "nfs" + fi } # Get kdump targets(including root in case of dump_to_rootfs). get_kdump_targets() { - local _target _root - local kdump_targets + local _target _root + local kdump_targets - _target=$(get_block_dump_target) - if [[ -n "$_target" ]]; then - kdump_targets=$_target - elif is_ssh_dump_target; then - kdump_targets="ssh" - else - kdump_targets="nfs" - fi + _target=$(get_block_dump_target) + if [[ -n $_target ]]; then + kdump_targets=$_target + elif is_ssh_dump_target; then + kdump_targets="ssh" + else + kdump_targets="nfs" + fi - # Add the root device if dump_to_rootfs is specified. - _root=$(get_failure_action_target) - if [[ -n "$_root" ]] && [[ "$kdump_targets" != "$_root" ]]; then - kdump_targets="$kdump_targets $_root" - fi + # Add the root device if dump_to_rootfs is specified. + _root=$(get_failure_action_target) + if [[ -n $_root ]] && [[ $kdump_targets != "$_root" ]]; then + kdump_targets="$kdump_targets $_root" + fi - echo "$kdump_targets" + echo "$kdump_targets" } # Return the bind mount source path, return the path itself if it's not bind mounted @@ -158,128 +162,128 @@ get_kdump_targets() # part is the bind mounted directory which quotes by bracket "[]". get_bind_mount_source() { - local _mnt _path _src _opt _fstype - local _fsroot _src_nofsroot + local _mnt _path _src _opt _fstype + local _fsroot _src_nofsroot - _mnt=$(df "$1" | tail -1 | awk '{print $NF}') - _path=${1#$_mnt} + _mnt=$(df "$1" | tail -1 | awk '{print $NF}') + _path=${1#$_mnt} - _src=$(get_mount_info SOURCE target "$_mnt" -f) - _opt=$(get_mount_info OPTIONS target "$_mnt" -f) - _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) + _src=$(get_mount_info SOURCE target "$_mnt" -f) + _opt=$(get_mount_info OPTIONS target "$_mnt" -f) + _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) - # bind mount in fstab - if [[ -d "$_src" ]] && [[ "$_fstype" = none ]] && (echo "$_opt" | grep -q "\bbind\b"); then - echo "$_src$_path" && return - fi + # bind mount in fstab + if [[ -d $_src ]] && [[ $_fstype == none ]] && (echo "$_opt" | grep -q "\bbind\b"); then + echo "$_src$_path" && return + fi - # direct mount - _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) - if [[ $_src_nofsroot = "$_src" ]]; then - echo "$_mnt$_path" && return - fi + # direct mount + _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) + if [[ $_src_nofsroot == "$_src" ]]; then + echo "$_mnt$_path" && return + fi - _fsroot=${_src#${_src_nofsroot}[} - _fsroot=${_fsroot%]} - _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) + _fsroot=${_src#${_src_nofsroot}[} + _fsroot=${_fsroot%]} + _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) - # for btrfs, _fsroot will also contain the subvol value as well, strip it - if [[ "$_fstype" = btrfs ]]; then - local _subvol - _subvol=${_opt#*subvol=} - _subvol=${_subvol%,*} - _fsroot=${_fsroot#$_subvol} - fi - echo "$_mnt$_fsroot$_path" + # for btrfs, _fsroot will also contain the subvol value as well, strip it + if [[ $_fstype == btrfs ]]; then + local _subvol + _subvol=${_opt#*subvol=} + _subvol=${_subvol%,*} + _fsroot=${_fsroot#$_subvol} + fi + echo "$_mnt$_fsroot$_path" } get_mntopt_from_target() { - get_mount_info OPTIONS source "$1" -f + get_mount_info OPTIONS source "$1" -f } # Get the path where the target will be mounted in kdump kernel # $1: kdump target device get_kdump_mntpoint_from_target() { - local _mntpoint + local _mntpoint - _mntpoint=$(get_mntpoint_from_target "$1") - # mount under /sysroot if dump to root disk or mount under - # mount under /kdumproot if dump target is not mounted in first kernel - # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. - # systemd will be in charge to umount it. - if [[ -z "$_mntpoint" ]];then - _mntpoint="/kdumproot" - else - if [[ "$_mntpoint" = "/" ]];then - _mntpoint="/sysroot" - else - _mntpoint="/kdumproot/$_mntpoint" - fi - fi + _mntpoint=$(get_mntpoint_from_target "$1") + # mount under /sysroot if dump to root disk or mount under + # mount under /kdumproot if dump target is not mounted in first kernel + # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. + # systemd will be in charge to umount it. + if [[ -z $_mntpoint ]]; then + _mntpoint="/kdumproot" + else + if [[ $_mntpoint == "/" ]]; then + _mntpoint="/sysroot" + else + _mntpoint="/kdumproot/$_mntpoint" + fi + fi - # strip duplicated "/" - echo $_mntpoint | tr -s "/" + # strip duplicated "/" + echo $_mntpoint | tr -s "/" } -kdump_get_persistent_dev() { - local dev="${1//\"/}" +kdump_get_persistent_dev() +{ + local dev="${1//\"/}" - case "$dev" in - UUID=*) - dev=$(blkid -U "${dev#UUID=}") - ;; - LABEL=*) - dev=$(blkid -L "${dev#LABEL=}") - ;; - esac - echo $(get_persistent_dev "$dev") + case "$dev" in + UUID=*) + dev=$(blkid -U "${dev#UUID=}") + ;; + LABEL=*) + dev=$(blkid -L "${dev#LABEL=}") + ;; + esac + echo $(get_persistent_dev "$dev") } is_atomic() { - grep -q "ostree" /proc/cmdline + grep -q "ostree" /proc/cmdline } # get ip address or hostname from nfs/ssh config value get_remote_host() { - local _config_val=$1 + local _config_val=$1 - # ipv6 address in kdump.conf is around with "[]", - # factor out the ipv6 address - _config_val=${_config_val#*@} - _config_val=${_config_val%:/*} - _config_val=${_config_val#[} - _config_val=${_config_val%]} - echo "$_config_val" + # ipv6 address in kdump.conf is around with "[]", + # factor out the ipv6 address + _config_val=${_config_val#*@} + _config_val=${_config_val%:/*} + _config_val=${_config_val#[} + _config_val=${_config_val%]} + echo "$_config_val" } is_hostname() { - local _hostname + local _hostname - _hostname=$(echo "$1" | grep ":") - if [[ -n "$_hostname" ]]; then - return 1 - fi - echo "$1" | grep -q "[a-zA-Z]" + _hostname=$(echo "$1" | grep ":") + if [[ -n $_hostname ]]; then + return 1 + fi + echo "$1" | grep -q "[a-zA-Z]" } # Copied from "/etc/sysconfig/network-scripts/network-functions" get_hwaddr() { - if [[ -f "/sys/class/net/$1/address" ]]; then - awk '{ print toupper($0) }' < "/sys/class/net/$1/address" - elif [[ -d "/sys/class/net/$1" ]]; then - LC_ALL="" LANG="" ip -o link show "$1" 2>/dev/null | \ - awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, + if [[ -f "/sys/class/net/$1/address" ]]; then + awk '{ print toupper($0) }' < "/sys/class/net/$1/address" + elif [[ -d "/sys/class/net/$1" ]]; then + LC_ALL="" LANG="" ip -o link show "$1" 2> /dev/null | + awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, "\\1", 1)); }' - fi + fi } - # Get value by a field using "nmcli -g" # Usage: get_nmcli_value_by_field # @@ -292,16 +296,16 @@ get_hwaddr() # bond.options "mode=balance-rr" get_nmcli_value_by_field() { - LANG=C nmcli --get-values "$@" + LANG=C nmcli --get-values "$@" } # Get nmcli field value of an connection apath (a D-Bus active connection path) # Usage: get_nmcli_field_by_apath get_nmcli_field_by_conpath() { - local _field=$1 _apath=$2 + local _field=$1 _apath=$2 - get_nmcli_value_by_field "$_field" connection show "$_apath" + get_nmcli_value_by_field "$_field" connection show "$_apath" } # Get nmcli connection apath (a D-Bus active connection path ) by ifname @@ -310,129 +314,133 @@ get_nmcli_field_by_conpath() # $ nmcli connection show $apath get_nmcli_connection_apath_by_ifname() { - local _ifname=$1 + local _ifname=$1 - get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" + get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" } get_ifcfg_by_device() { - grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 + grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 } get_ifcfg_by_hwaddr() { - grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 + grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 } get_ifcfg_by_uuid() { - grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 + grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 } get_ifcfg_by_name() { - grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1 + grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \ + /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 } is_nm_running() { - [[ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]] + [[ "$(LANG=C nmcli -t --fields running general status 2> /dev/null)" == "running" ]] } is_nm_handling() { - LANG=C nmcli -t --fields device,state dev status 2>/dev/null \ - | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$" + LANG=C nmcli -t --fields device,state dev status 2> /dev/null | + grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$" } # $1: netdev name get_ifcfg_nmcli() { - local nm_uuid nm_name - local ifcfg_file + local nm_uuid nm_name + local ifcfg_file - # Get the active nmcli config name of $1 - if is_nm_running && is_nm_handling "${1}" ; then - # The configuration "uuid" and "name" generated by nm is wrote to - # the ifcfg file as "UUID=" and "NAME=". - nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \ - | grep "${1}" | head -1 | cut -d':' -f1) - nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \ - | grep "${1}" | head -1 | cut -d':' -f1) - ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") - [[ -z "${ifcfg_file}" ]] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") - fi + # Get the active nmcli config name of $1 + if is_nm_running && is_nm_handling "${1}"; then + # The configuration "uuid" and "name" generated by nm is wrote to + # the ifcfg file as "UUID=" and "NAME=". + nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2> /dev/null | + grep "${1}" | head -1 | cut -d':' -f1) + nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2> /dev/null | + grep "${1}" | head -1 | cut -d':' -f1) + ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") + [[ -z ${ifcfg_file} ]] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") + fi - echo -n "${ifcfg_file}" + echo -n "${ifcfg_file}" } # $1: netdev name get_ifcfg_legacy() { - local ifcfg_file hwaddr + local ifcfg_file hwaddr - ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" - [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return + ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" + [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - ifcfg_file=$(get_ifcfg_by_name "${1}") - [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return + ifcfg_file=$(get_ifcfg_by_name "${1}") + [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - hwaddr=$(get_hwaddr "${1}") - if [[ -n "$hwaddr" ]]; then - ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") - [[ -f "${ifcfg_file}" ]] && echo -n "${ifcfg_file}" && return - fi + hwaddr=$(get_hwaddr "${1}") + if [[ -n $hwaddr ]]; then + ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") + [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return + fi - ifcfg_file=$(get_ifcfg_by_device "${1}") + ifcfg_file=$(get_ifcfg_by_device "${1}") - echo -n "${ifcfg_file}" + echo -n "${ifcfg_file}" } # $1: netdev name # Return the ifcfg file whole name(including the path) of $1 if any. -get_ifcfg_filename() { - local ifcfg_file +get_ifcfg_filename() +{ + local ifcfg_file - ifcfg_file=$(get_ifcfg_nmcli "${1}") - if [[ -z "${ifcfg_file}" ]]; then - ifcfg_file=$(get_ifcfg_legacy "${1}") - fi + ifcfg_file=$(get_ifcfg_nmcli "${1}") + if [[ -z ${ifcfg_file} ]]; then + ifcfg_file=$(get_ifcfg_legacy "${1}") + fi - echo -n "${ifcfg_file}" + echo -n "${ifcfg_file}" } # returns 0 when omission of a module is desired in dracut_args # returns 1 otherwise -is_dracut_mod_omitted() { - local dracut_args dracut_mod=$1 +is_dracut_mod_omitted() +{ + local dracut_args dracut_mod=$1 - set -- $(kdump_get_conf_val dracut_args) - while [ $# -gt 0 ]; do - case $1 in - -o|--omit) - [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 - esac - shift - done + set -- $(kdump_get_conf_val dracut_args) + while [ $# -gt 0 ]; do + case $1 in + -o | --omit) + [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 + ;; + esac + shift + done - return 1 + return 1 } -is_wdt_active() { - local active +is_wdt_active() +{ + local active - [[ -d /sys/class/watchdog ]] || return 1 - for dir in /sys/class/watchdog/*; do - [[ -f "$dir/state" ]] || continue - active=$(< "$dir/state") - [[ "$active" = "active" ]] && return 0 - done - return 1 + [[ -d /sys/class/watchdog ]] || return 1 + for dir in /sys/class/watchdog/*; do + [[ -f "$dir/state" ]] || continue + active=$(< "$dir/state") + [[ $active == "active" ]] && return 0 + done + return 1 } # If "dracut_args" contains "--mount" information, use it @@ -440,45 +448,45 @@ is_wdt_active() { # its correctness). is_mount_in_dracut_args() { - [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] + [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] } check_crash_mem_reserved() { - local mem_reserved + local mem_reserved - mem_reserved=$( [] ... [] @@ -486,17 +494,17 @@ check_current_kdump_status() # For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. remove_cmdline_param() { - local cmdline=$1 - shift + local cmdline=$1 + shift - for arg in "$@"; do - cmdline=$(echo "$cmdline" | \ - sed -e "s/\b$arg=[^ ]*//g" \ - -e "s/^$arg\b//g" \ - -e "s/[[:space:]]$arg\b//g" \ - -e "s/\s\+/ /g") - done - echo "$cmdline" + for arg in "$@"; do + cmdline=$(echo "$cmdline" | + sed -e "s/\b$arg=[^ ]*//g" \ + -e "s/^$arg\b//g" \ + -e "s/[[:space:]]$arg\b//g" \ + -e "s/\s\+/ /g") + done + echo "$cmdline" } # @@ -505,12 +513,12 @@ remove_cmdline_param() # get_bootcpu_apicid() { - awk ' \ + awk ' \ BEGIN { CPU = "-1"; } \ $1=="processor" && $2==":" { CPU = $NF; } \ CPU=="0" && /^apicid/ { print $NF; } \ - ' \ - /proc/cpuinfo + ' \ + /proc/cpuinfo } # @@ -519,22 +527,22 @@ get_bootcpu_apicid() # append_cmdline() { - local cmdline=$1 - local newstr=${cmdline/$2/""} + local cmdline=$1 + local newstr=${cmdline/$2/""} - # unchanged str implies argument wasn't there - if [[ "$cmdline" == "$newstr" ]]; then - cmdline="${cmdline} ${2}=${3}" - fi + # unchanged str implies argument wasn't there + if [[ $cmdline == "$newstr" ]]; then + cmdline="${cmdline} ${2}=${3}" + fi - echo "$cmdline" + echo "$cmdline" } # This function check iomem and determines if we have more than # 4GB of ram available. Returns 1 if we do, 0 if we dont need_64bit_headers() { - return "$(tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); + return "$(tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }')" } @@ -549,39 +557,39 @@ need_64bit_headers() # Assume efivars is mounted at /sys/firmware/efi/efivars. is_secure_boot_enforced() { - local secure_boot_file setup_mode_file - local secure_boot_byte setup_mode_byte + local secure_boot_file setup_mode_file + local secure_boot_byte setup_mode_byte - # On powerpc, secure boot is enforced if: - # host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists - # guest secure boot: /ibm,secure-boot >= 2 - if [[ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]]; then + # On powerpc, secure boot is enforced if: + # host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists + # guest secure boot: /ibm,secure-boot >= 2 + if [[ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]]; then return 0 - fi - if [[ -f /proc/device-tree/ibm,secure-boot ]] && \ - [[ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]]; then + fi + if [[ -f /proc/device-tree/ibm,secure-boot ]] && + [[ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]]; then return 0 - fi + fi - # Detect secure boot on x86 and arm64 - secure_boot_file=$(find /sys/firmware/efi/efivars -name "SecureBoot-*" 2>/dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name "SetupMode-*" 2>/dev/null) + # Detect secure boot on x86 and arm64 + secure_boot_file=$(find /sys/firmware/efi/efivars -name "SecureBoot-*" 2> /dev/null) + setup_mode_file=$(find /sys/firmware/efi/efivars -name "SetupMode-*" 2> /dev/null) - if [[ -f "$secure_boot_file" ]] && [[ -f "$setup_mode_file" ]]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' "$secure_boot_file" | cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' "$setup_mode_file" | cut -d' ' -f 5) + if [[ -f $secure_boot_file ]] && [[ -f $setup_mode_file ]]; then + secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' "$secure_boot_file" | cut -d' ' -f 5) + setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' "$setup_mode_file" | cut -d' ' -f 5) - if [[ "$secure_boot_byte" = "1" ]] && [[ "$setup_mode_byte" = "0" ]]; then - return 0 - fi - fi + if [[ $secure_boot_byte == "1" ]] && [[ $setup_mode_byte == "0" ]]; then + return 0 + fi + fi - # Detect secure boot on s390x - if [[ -e "/sys/firmware/ipl/secure" && "$( initramfs-5.7.9-200.fc32.x86_64kdump.img - # initrd => initrdkdump - if [[ -z "$defaut_initrd_base" ]]; then - kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img - elif [[ $defaut_initrd_base == *.* ]]; then - kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} - else - kdump_initrd_base=${defaut_initrd_base}kdump - fi + # Create kdump initrd basename from default initrd basename + # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img + # initrd => initrdkdump + if [[ -z $defaut_initrd_base ]]; then + kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img + elif [[ $defaut_initrd_base == *.* ]]; then + kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} + else + kdump_initrd_base=${defaut_initrd_base}kdump + fi - # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable - if [[ ! -w "$KDUMP_BOOTDIR" ]];then - var_target_initrd_dir="/var/lib/kdump" - mkdir -p "$var_target_initrd_dir" - KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base" - else - KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base" - fi + # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable + if [[ ! -w $KDUMP_BOOTDIR ]]; then + var_target_initrd_dir="/var/lib/kdump" + mkdir -p "$var_target_initrd_dir" + KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base" + else + KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base" + fi } get_watchdog_drvs() { - local _wdtdrvs _drv _dir + local _wdtdrvs _drv _dir - for _dir in /sys/class/watchdog/*; do - # device/modalias will return driver of this device - [[ -f "$_dir/device/modalias" ]] || continue - _drv=$(< "$_dir/device/modalias") - _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R "$_drv" 2>/dev/null) - for i in $_drv; do - if ! [[ " $_wdtdrvs " == *" $i "* ]]; then - _wdtdrvs="$_wdtdrvs $i" - fi - done - done + for _dir in /sys/class/watchdog/*; do + # device/modalias will return driver of this device + [[ -f "$_dir/device/modalias" ]] || continue + _drv=$(< "$_dir/device/modalias") + _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R "$_drv" 2> /dev/null) + for i in $_drv; do + if ! [[ " $_wdtdrvs " == *" $i "* ]]; then + _wdtdrvs="$_wdtdrvs $i" + fi + done + done - echo "$_wdtdrvs" + echo "$_wdtdrvs" } # @@ -716,143 +720,143 @@ get_watchdog_drvs() # Store the final result in global $KDUMP_COMMANDLINE. prepare_cmdline() { - local cmdline id arg + local cmdline id arg - if [[ -z "$1" ]]; then - cmdline=$(/dev/null) + [[ -z $kernel ]] && kernel=$(uname -r) + ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null) - if [[ -n "$ck_cmdline" ]]; then - ck_cmdline=${ck_cmdline#crashkernel=} - else - arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') - if [[ "$arch" = "X86_64" ]] || [[ "$arch" = "S390X" ]]; then - ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" - elif [[ "$arch" = "AARCH64" ]]; then - ck_cmdline="2G-:448M" - elif [[ "$arch" = "PPC64LE" ]]; then - if is_fadump_capable; then - ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" - else - ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" - fi - fi - fi + if [[ -n $ck_cmdline ]]; then + ck_cmdline=${ck_cmdline#crashkernel=} + else + arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') + if [[ $arch == "X86_64" ]] || [[ $arch == "S390X" ]]; then + ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" + elif [[ $arch == "AARCH64" ]]; then + ck_cmdline="2G-:448M" + elif [[ $arch == "PPC64LE" ]]; then + if is_fadump_capable; then + ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" + else + ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + fi + fi + fi - ck_cmdline=${ck_cmdline//-:/-102400T:} - sys_mem=$(get_system_size) + ck_cmdline=${ck_cmdline//-:/-102400T:} + sys_mem=$(get_system_size) - get_recommend_size "$sys_mem" "$ck_cmdline" + get_recommend_size "$sys_mem" "$ck_cmdline" } # Print all underlying crypt devices of a block device @@ -860,18 +864,18 @@ kdump_get_arch_recommend_size() # $1: the block device to be checked in maj:min format get_luks_crypt_dev() { - local _type + local _type - [[ -b /dev/block/$1 ]] || return 1 + [[ -b /dev/block/$1 ]] || return 1 - _type=$(eval "$(blkid -u filesystem,crypto -o export -- "/dev/block/$1"); echo \$TYPE") - [[ $_type == "crypto_LUKS" ]] && echo "$1" + _type=$(eval "$(blkid -u filesystem,crypto -o export -- "/dev/block/$1"); echo \$TYPE") + [[ $_type == "crypto_LUKS" ]] && echo "$1" - for _x in "/sys/dev/block/$1/slaves/"*; do - [[ -f $_x/dev ]] || continue - [[ $_x/subsystem -ef /sys/class/block ]] || continue - get_luks_crypt_dev "$(< "$_x/dev")" - done + for _x in "/sys/dev/block/$1/slaves/"*; do + [[ -f $_x/dev ]] || continue + [[ $_x/subsystem -ef /sys/class/block ]] || continue + get_luks_crypt_dev "$(< "$_x/dev")" + done } # kdump_get_maj_min @@ -879,90 +883,90 @@ get_luks_crypt_dev() # Example: # $ get_maj_min /dev/sda2 # 8:2 -kdump_get_maj_min() { - local _majmin - _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" - printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" +kdump_get_maj_min() +{ + local _majmin + _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" + printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" } get_all_kdump_crypt_dev() { - local _dev + local _dev - for _dev in $(get_block_dump_target); do - get_luks_crypt_dev "$(kdump_get_maj_min "$_dev")" - done + for _dev in $(get_block_dump_target); do + get_luks_crypt_dev "$(kdump_get_maj_min "$_dev")" + done } check_vmlinux() { - # Use readelf to check if it's a valid ELF - readelf -h "$1" &>/dev/null || return 1 + # Use readelf to check if it's a valid ELF + readelf -h "$1" &> /dev/null || return 1 } get_vmlinux_size() { - local size=0 _msize + local size=0 _msize - while read -r _msize; do - size=$(( size + _msize )) - done <<< "$(readelf -l -W "$1" | awk '/^ LOAD/{print $6}' 2>/dev/stderr)" + while read -r _msize; do + size=$((size + _msize)) + done <<< "$(readelf -l -W "$1" | awk '/^ LOAD/{print $6}' 2> /dev/stderr)" - echo $size + echo $size } try_decompress() { - # The obscure use of the "tr" filter is to work around older versions of - # "grep" that report the byte offset of the line instead of the pattern. + # The obscure use of the "tr" filter is to work around older versions of + # "grep" that report the byte offset of the line instead of the pattern. - # Try to find the header ($1) and decompress from here - for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2") - do - if ! type -P "$3" > /dev/null; then - ddebug "Signiature detected but '$3' is missing, skip this decompressor" - break - fi + # Try to find the header ($1) and decompress from here + for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"); do + if ! type -P "$3" > /dev/null; then + ddebug "Signiature detected but '$3' is missing, skip this decompressor" + break + fi - pos=${pos%%:*} - tail "-c+$pos" "$img" | $3 > "$5" 2> /dev/null - if check_vmlinux "$5"; then - ddebug "Kernel is extracted with '$3'" - return 0 - fi - done + pos=${pos%%:*} + tail "-c+$pos" "$img" | $3 > "$5" 2> /dev/null + if check_vmlinux "$5"; then + ddebug "Kernel is extracted with '$3'" + return 0 + fi + done - return 1 + return 1 } # Borrowed from linux/scripts/extract-vmlinux get_kernel_size() { - # Prepare temp files: - local tmp img=$1 + # Prepare temp files: + local tmp img=$1 - tmp=$(mktemp /tmp/vmlinux-XXX) - trap 'rm -f "$tmp"' 0 + tmp=$(mktemp /tmp/vmlinux-XXX) + trap 'rm -f "$tmp"' 0 - # Try to check if it's a vmlinux already - check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 + # Try to check if it's a vmlinux already + check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 - # That didn't work, so retry after decompression. - try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || \ - try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || \ - try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || \ - try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || \ - try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || \ - try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || \ - try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" + # That didn't work, so retry after decompression. + try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || + try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || + try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || + try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || + try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || + try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || + try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" - # Finally check for uncompressed images or objects: - [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 + # Finally check for uncompressed images or objects: + [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 - # Fallback to use iomem - local _size=0 _seg - while read -r _seg; do - _size=$(( _size + 0x${_seg#*-} - 0x${_seg%-*} )) - done <<< "$(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1)" - echo $_size + # Fallback to use iomem + local _size=0 _seg + while read -r _seg; do + _size=$((_size + 0x${_seg#*-} - 0x${_seg%-*})) + done <<< "$(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1)" + echo $_size } From 8cd57e5565142553b1fe739afe90723359b18498 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 11 Aug 2021 19:19:59 +0800 Subject: [PATCH 498/806] kdump-logger.sh: make it POSIX compatible Refactor to remove some bash only syntax. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- kdump-logger.sh | 117 +++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 56 deletions(-) diff --git a/kdump-logger.sh b/kdump-logger.sh index 370e5e8..98c4eea 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # This comes from the dracut-logger.sh # @@ -53,11 +53,12 @@ fi # get_kdump_loglvl() { - (type -p getarg) && kdump_sysloglvl=$(getarg rd.kdumploglvl) + [ -f /lib/dracut-lib.sh ] && kdump_sysloglvl=$(getarg rd.kdumploglvl) [ -z "$kdump_sysloglvl" ] && return 1; - (type -p isdigit) && isdigit $kdump_sysloglvl - [ $? -ne 0 ] && return 1; + if [ -f /lib/dracut-lib.sh ] && ! isdigit "$kdump_sysloglvl"; then + return 1 + fi return 0 } @@ -83,11 +84,10 @@ check_loglvl() # @retval 0 on success. # dlog_init() { - local ret=0; local errmsg + ret=0 if [ -s /proc/vmcore ];then - get_kdump_loglvl - if [ $? -ne 0 ];then + if ! get_kdump_loglvl; then logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)." kdump_sysloglvl=3 fi @@ -104,8 +104,7 @@ dlog_init() { [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do - check_loglvl "$loglvl" - if [ $? -ne 0 ]; then + if ! check_loglvl "$loglvl"; then echo "Illegal log level: $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl" return 1 fi @@ -114,21 +113,21 @@ dlog_init() { # Skip initialization if it's already done. [ -n "$kdump_maxloglvl" ] && return 0 - if [[ $UID -ne 0 ]]; then + if [ "$UID" -ne 0 ]; then kdump_kmsgloglvl=0 kdump_sysloglvl=0 fi - if [[ $kdump_sysloglvl -gt 0 ]]; then - if [[ -d /run/systemd/journal ]] \ - && type -P systemd-cat &>/dev/null \ - && systemctl --quiet is-active systemd-journald.socket &>/dev/null; then + if [ "$kdump_sysloglvl" -gt 0 ]; then + if [ -d /run/systemd/journal ] \ + && systemd-cat --version 1>/dev/null 2>&1 \ + && systemctl --quiet is-active systemd-journald.socket 1>/dev/null 2>&1; then readonly _systemdcatfile="/var/tmp/systemd-cat" - mkfifo "$_systemdcatfile" &>/dev/null + mkfifo "$_systemdcatfile" 1>/dev/null 2>&1 readonly _dlogfd=15 systemd-cat -t 'kdump' --level-prefix=true <"$_systemdcatfile" & exec 15>"$_systemdcatfile" - elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then + elif ! [ -S /dev/log ] && [ -w /dev/log ] || ! command -v logger >/dev/null; then # We cannot log to syslog, so turn this facility off. kdump_kmsgloglvl=$kdump_sysloglvl kdump_sysloglvl=0 @@ -137,31 +136,31 @@ dlog_init() { fi fi - local lvl; local maxloglvl_l=0 - for lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do - [[ $lvl -gt $maxloglvl_l ]] && maxloglvl_l=$lvl + kdump_maxloglvl=0 + for _dlog_lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do + [ $_dlog_lvl -gt $kdump_maxloglvl ] && kdump_maxloglvl=$_dlog_lvl done - readonly kdump_maxloglvl=$maxloglvl_l + readonly kdump_maxloglvl export kdump_maxloglvl - if [[ $kdump_stdloglvl -lt 4 ]] && [[ $kdump_kmsgloglvl -lt 4 ]] && [[ $kdump_sysloglvl -lt 4 ]]; then + if [ $kdump_stdloglvl -lt 4 ] && [ $kdump_kmsgloglvl -lt 4 ] && [ $kdump_sysloglvl -lt 4 ]; then unset ddebug ddebug() { :; }; fi - if [[ $kdump_stdloglvl -lt 3 ]] && [[ $kdump_kmsgloglvl -lt 3 ]] && [[ $kdump_sysloglvl -lt 3 ]]; then + if [ $kdump_stdloglvl -lt 3 ] && [ $kdump_kmsgloglvl -lt 3 ] && [ $kdump_sysloglvl -lt 3 ]; then unset dinfo dinfo() { :; }; fi - if [[ $kdump_stdloglvl -lt 2 ]] && [[ $kdump_kmsgloglvl -lt 2 ]] && [[ $kdump_sysloglvl -lt 2 ]]; then + if [ $kdump_stdloglvl -lt 2 ] && [ $kdump_kmsgloglvl -lt 2 ] && [ $kdump_sysloglvl -lt 2 ]; then unset dwarn dwarn() { :; }; unset dwarning dwarning() { :; }; fi - if [[ $kdump_stdloglvl -lt 1 ]] && [[ $kdump_kmsgloglvl -lt 1 ]] && [[ $kdump_sysloglvl -lt 1 ]]; then + if [ $kdump_stdloglvl -lt 1 ] && [ $kdump_kmsgloglvl -lt 1 ] && [ $kdump_sysloglvl -lt 1 ]; then unset derror derror() { :; }; fi @@ -173,7 +172,7 @@ dlog_init() { ## @brief Converts numeric level to logger priority defined by POSIX.2. # -# @param lvl Numeric logging level in range from 1 to 4. +# @param $1: Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes logger priority. @@ -189,7 +188,7 @@ _lvl2syspri() { ## @brief Converts logger numeric level to syslog log level # -# @param lvl Numeric logging level in range from 1 to 4. +# @param $1: Numeric logging level in range from 1 to 4. # @retval 1 if @a lvl is out of range. # @retval 0 if @a lvl is correct. # @result Echoes kernel console numeric log level @@ -209,27 +208,25 @@ _lvl2syspri() { # # @see /usr/include/sys/syslog.h _dlvl2syslvl() { - local lvl - case "$1" in - 1) lvl=3;; - 2) lvl=4;; - 3) lvl=6;; - 4) lvl=7;; + 1) set -- 3;; + 2) set -- 4;; + 3) set -- 6;; + 4) set -- 7;; *) return 1;; esac # The number is constructed by multiplying the facility by 8 and then # adding the level. # About The Syslog Protocol, please refer to the RFC5424 for more details. - echo $((24+$lvl)) + echo $((24 + $1)) } ## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with # given level (priority). # -# @param lvl Numeric logging level. -# @param msg Message. +# @param $1: Numeric logging level. +# @param $2: Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use @@ -251,27 +248,24 @@ _dlvl2syslvl() { # - @c INFO to @c info # - @c DEBUG to @c debug _do_dlog() { - local lvl="$1"; shift - local msg="$*" + [ "$1" -le $kdump_stdloglvl ] && printf -- 'kdump: %s\n' "$2" >&2 - [[ $lvl -le $kdump_stdloglvl ]] && printf -- 'kdump: %s\n' "$msg" >&2 - - if [[ $lvl -le $kdump_sysloglvl ]]; then - if [[ "$_dlogfd" ]]; then - printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd + if [ "$1" -le $kdump_sysloglvl ]; then + if [ "$_dlogfd" ]; then + printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$1") & 7))" "$2" 1>&$_dlogfd else - logger -t "kdump[$$]" -p $(_lvl2syspri $lvl) -- "$msg" + logger -t "kdump[$$]" -p "$(_lvl2syspri "$1")" -- "$2" fi fi - [[ $lvl -le $kdump_kmsgloglvl ]] && \ - echo "<$(_dlvl2syslvl $lvl)>kdump[$$] $msg" >/dev/kmsg + [ "$1" -le $kdump_kmsgloglvl ] && \ + echo "<$(_dlvl2syslvl "$1")>kdump[$$] $2" >/dev/kmsg } ## @brief Internal helper function for _do_dlog() # -# @param lvl Numeric logging level. -# @param msg Message. +# @param $1: Numeric logging level. +# @param $2 [...]: Message. # @retval 0 It's always returned, even if logging failed. # # @note This function is not supposed to be called manually. Please use @@ -286,12 +280,13 @@ _do_dlog() { # echo "This is a warning" | dwarn dlog() { [ -z "$kdump_maxloglvl" ] && return 0 - [[ $1 -le $kdump_maxloglvl ]] || return 0 + [ "$1" -le "$kdump_maxloglvl" ] || return 0 - if [[ $# -gt 1 ]]; then - _do_dlog "$@" + if [ $# -gt 1 ]; then + _dlog_lvl=$1; shift + _do_dlog "$_dlog_lvl" "$*" else - while read line || [ -n "$line" ]; do + while read -r line || [ -n "$line" ]; do _do_dlog "$1" "$line" done fi @@ -304,7 +299,9 @@ dlog() { ddebug() { set +x dlog 4 "$@" - [ -n "$debug" ] && set -x || : + if [ -n "$debug" ]; then + set -x + fi } ## @brief Logs message at INFO level (3) @@ -314,7 +311,9 @@ ddebug() { dinfo() { set +x dlog 3 "$@" - [ -n "$debug" ] && set -x || : + if [ -n "$debug" ]; then + set -x + fi } ## @brief Logs message at WARN level (2) @@ -324,7 +323,9 @@ dinfo() { dwarn() { set +x dlog 2 "$@" - [ -n "$debug" ] && set -x || : + if [ -n "$debug" ]; then + set -x + fi } ## @brief It's an alias to dwarn() function. @@ -334,7 +335,9 @@ dwarn() { dwarning() { set +x dwarn "$@" - [ -n "$debug" ] && set -x || : + if [ -n "$debug" ]; then + set -x + fi } ## @brief Logs message at ERROR level (1) @@ -344,5 +347,7 @@ dwarning() { derror() { set +x dlog 1 "$@" - [ -n "$debug" ] && set -x || : + if [ -n "$debug" ]; then + set -x + fi } From 4b4d045b8c0a7d7bf9d09b5b29bc81885e63ed2b Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 11 Aug 2021 19:55:19 +0800 Subject: [PATCH 499/806] mkdumprd: allow using dash All non-POSIX syntax in second kernel are gone, tested on Fedora 34 with latest dracut, dash now works fine. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index eebbbe1..c6cb001 100644 --- a/mkdumprd +++ b/mkdumprd @@ -27,7 +27,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump") +dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth resume ifcfg earlykdump") MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." From ee337c6f497a92a12848a85dcce468c1a4bcd14f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 Sep 2021 03:38:14 +0800 Subject: [PATCH 500/806] Add header comment for POSIX compliant scripts To make things cleaner and more human readable, add a short comment for the POSIX scripts. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-kdump.sh | 4 ++-- kdump-lib-initramfs.sh | 4 ++-- kdump-logger.sh | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 969ea94..b69bc98 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# The main kdump routine in capture kernel -# +# The main kdump routine in capture kernel, bash may not be the +# default shell. Any code added must be POSIX compliant. . /lib/dracut-lib.sh . /lib/kdump-logger.sh diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 0cdb465..c1fd75f 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Function and variables used in initramfs environment, POSIX compatible -# +# The code in this file will be used in initramfs environment, bash may +# not be the default shell. Any code added must be POSIX compliant. DEFAULT_PATH="/var/crash/" KDUMP_CONFIG_FILE="/etc/kdump.conf" diff --git a/kdump-logger.sh b/kdump-logger.sh index 98c4eea..3fd433d 100755 --- a/kdump-logger.sh +++ b/kdump-logger.sh @@ -34,6 +34,8 @@ # First of all you have to start with dlog_init() function which initializes # required variables. Don't call any other logging function before that one! # +# The code in this file might be run in an environment without bash. +# Any code added must be POSIX compliant. # Define vairables for the log levels in this module. kdump_stdloglvl="" From 4c39ad9a0c9808a9b791a3e446d0b209ceccdc5e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 13 Sep 2021 16:40:25 +0800 Subject: [PATCH 501/806] dracut-early-kdump.sh: make it POSIX compatible Refactor and remove bash only syntax. Signed-off-by: Kairui Song Acked-by: Philipp Rudo --- dracut-early-kdump.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 129841e..45ee6dc 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -14,9 +14,8 @@ EARLY_KEXEC_ARGS="" . /lib/kdump-lib.sh . /lib/kdump-logger.sh -#initiate the kdump logger -dlog_init -if [ $? -ne 0 ]; then +# initiate the kdump logger +if ! dlog_init; then echo "failed to initiate the kdump logger." exit 1 fi @@ -30,8 +29,7 @@ prepare_parameters() early_kdump_load() { - check_kdump_feasibility - if [ $? -ne 0 ]; then + if ! check_kdump_feasibility; then return 1 fi @@ -40,8 +38,7 @@ early_kdump_load() return 1 fi - check_current_kdump_status - if [ $? == 0 ]; then + if check_current_kdump_status; then return 1 fi @@ -61,10 +58,9 @@ early_kdump_load() --command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \ $EARLY_KDUMP_KERNEL" - $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ + if $KEXEC $EARLY_KEXEC_ARGS $standard_kexec_args \ --command-line="$EARLY_KDUMP_CMDLINE" \ - --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL - if [ $? == 0 ]; then + --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL; then dinfo "kexec: loaded early-kdump kernel" return 0 else From f6e6aa45518aab0bfbbe8fa4fc94eb3f33036aa1 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Wed, 1 Sep 2021 17:38:50 +0800 Subject: [PATCH 502/806] 92-crashkernel.install: fix exit code The return value of set_ck_kernel or set_grub_ck is wrongly being used as the exit code. This hook should exit with 0 or it may result in unexpected behavior of kernel-install. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- 92-crashkernel.install | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/92-crashkernel.install b/92-crashkernel.install index de5b2fb..78365ff 100755 --- a/92-crashkernel.install +++ b/92-crashkernel.install @@ -120,8 +120,9 @@ add) if [[ "$boot_ck_cmdline" != "$inst_ck_default" ]] && [[ "$boot_ck_cmdline" == "$boot_ck_default" ]]; then set_kernel_ck "$KERNEL_VERSION" "$inst_ck_default" fi - ;; + exit 0 + ;; remove) # If grub default value is upgraded when this kernel was installed, try downgrade it grub_etc_ck=$(get_grub_etc_ck) @@ -139,5 +140,7 @@ remove) set_grub_ck "$highest_ck_default" fi fi + + exit 0 ;; esac From 6ea954d5182a7cbd42e0888e0c09ef9770eb9e88 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Thu, 16 Sep 2021 23:46:28 +0800 Subject: [PATCH 503/806] Release 2.0.22-8 Signed-off-by: Kairui Song --- kexec-tools.spec | 60 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f71ff81..5dbf625 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.22 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -382,6 +382,64 @@ done %endif %changelog +* Thu Sep 16 2021 Kairui Song - 2.0.22-8 +- 92-crashkernel.install: fix exit code +- dracut-early-kdump.sh: make it POSIX compatible +- Add header comment for POSIX compliant scripts +- mkdumprd: allow using dash +- kdump-logger.sh: make it POSIX compatible +- kdump-lib.sh: reformat with shfmt +- kdump-lib.sh: declare and assign separately +- kdump-lib.sh: fix variable quoting issue +- kdump-lib.sh: fix a few ambiguous or redundant code +- kdump-lib.sh: fix arithmetic operation syntax +- kdump-lib.sh: remove useless echo and cat +- kdump-lib.sh: rework nmcli related functions +- kdump-lib.sh: replace '[ ]' with '[[ ]]' and get rid of legacy `` +- kdump-lib-initramfs.sh: make it POSIX compatible +- dracut-kdump.sh: reformat with shfmt +- dracut-kdump.sh: make it POSIX compatible +- dracut-kdump.sh: POSIX doesn't support pipefail +- dracut-kdump.sh: Use stat instead of ls to get vmcore size +- dracut-kdump.sh: simplify dump_ssh +- dracut-kdump.sh: remove add_dump_code +- dracut-kdump.sh: don't put KDUMP_SCRIPT_DIR in PATH +- kdump-lib-initramfs.sh: move dump related functions to kdump.sh +- Merge kdump-error-handler.sh into kdump.sh +- kdump-lib-initramfs.sh: prepare to be a POSIX compatible lib +- bash scripts: reformat with shfmt +- bash scripts: declare and assign separately +- bash scripts: fix redundant exit code check +- bash scripts: fix variable quoting issue +- bash scripts: replace '[ ]' with '[[ ]]' for bash scripts +- bash scripts: use $(...) notation instead of legacy `...` +- bash scripts: always use "read -r" +- bash scripts: get rid of unnecessary sed calls +- bash scripts: get rid of expr and let +- bash scripts: remove useless cat +- dracut-module-setup.sh: remove surrounding $() for subshell +- dracut-module-setup.sh: make iscsi check fail early if cd failed +- dracut-module-setup.sh: fix a loop over ls issue +- dracut-module-setup.sh: fix a ambiguous variable reference +- dracut-module-setup.sh: use "*" to expend array as string +- dracut-module-setup.sh: fix _bondoptions wrong references +- dracut-module-setup.sh: remove an unused variable +- dracut-module-setup.sh: rework kdump_get_ip_route_field +- mkfadumprd: make _dracut_isolate_args an array +- mkdumprd: use array to store ssh arguments in mkdir_save_path_ssh +- mkdumprd: remove an awk call in get_fs_size +- mkdumprd: fix multiple issues with get_ssh_size +- mkdumprd: remove some redundant echo +- mkdumprd: make dracut_args an array again +- mkdumprd: use kdump_get_conf_val to read config values +- kdumpctl: refine grep usage +- kdumpctl: fix fragile loops over find output +- kdumpctl: use kdump_get_conf_val to read config values +- kdump-lib.sh: use kdump_get_conf_val to read config values +- kdump-lib.sh: add a config value retrive helper +- kdump-lib.sh: add a config format and read helper +- Add a .editorconfig file + * Tue Aug 31 2021 Adam Williamson - 2.0.22-7 - Don't exit 1 from 92-crashkernel.install if zipl is absent (#1993505) From 294c965ca36927fc082402716d81abc24aa48e59 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 21 Jun 2021 09:18:11 +0800 Subject: [PATCH 504/806] selftest: kill VM reliably by recursively kill children processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qemu is launched in nested subprocess and can't be killed by simply killing the job ids, PID Command 2269634 │ ├─ sshd: root [priv] 2269637 │ │ └─ sshd: root@pts/0 2269638 │ │ └─ -bash 2269744 │ │ └─ make test-run V=1 2273117 │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh 2273712 │ │ ├─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh 2273714 │ │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh 2273737 │ │ │ └─ timeout --foreground 10m /root/kexec-tools-300/tests/scripts/run-qemu -nodefaults -nographic -smp 2 -m 768M -monitor no 2273738 │ │ │ └─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial stdio 2273746 │ │ │ ├─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial std 2273797 │ │ ├─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh 2273798 │ │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh 2273831 │ │ │ └─ timeout --foreground 10m /root/kexec-tools-300/tests/scripts/run-qemu -nodefaults -nographic -smp 2 -m 768M -monitor no 2273832 │ │ │ └─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial stdio 2273840 │ │ │ ├─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial std This led to the error "qemu-system-x86_64: can't bind ip=0.0.0.0 to socket: Address already in use". This patch will kill qemu by killing all the children of the job id. Signed-off-by: Coiby Xu Acked-by: Kairui Song --- tests/scripts/run-test.sh | 33 +++++++++++++++++++++++++++++++-- tests/scripts/test-lib.sh | 3 +-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index a68504d..c3e94a3 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -1,9 +1,38 @@ #!/bin/bash +_kill_if_valid_pid() { + local _pid="$1" + if ps -p "$_pid" > /dev/null + then + kill "$_pid" + fi +} + +_recursive_kill() { + local _pid="$1" + local _children _child + + _children=$(pgrep -P "$_pid") + if [ -n "$_children" ]; then + for _child in $_children + do + _recursive_kill "$_child" + _kill_if_valid_pid "$_child" + done + fi + _kill_if_valid_pid "$_pid" +} + _kill_all_jobs() { local _jobs=$(jobs -r -p) + local _job - [ -n "$_jobs" ] && kill $_jobs + if [ -n "$_jobs" ]; then + for _job in $_jobs + do + _recursive_kill "$_job" + done + fi } trap ' @@ -121,7 +150,7 @@ for test_case in $testcases; do [ $? -ne 0 ] && ret=$(expr $ret + 1) results[$test_case]="$res" - + _kill_all_jobs echo -e "-------- Test finished: $test_case $res --------" for script in $scripts; do script="$testdir/$script" diff --git a/tests/scripts/test-lib.sh b/tests/scripts/test-lib.sh index f8a2249..8b24b2a 100644 --- a/tests/scripts/test-lib.sh +++ b/tests/scripts/test-lib.sh @@ -146,8 +146,7 @@ watch_test_outputs() { ret=$? if [ $ret -ne 255 ]; then - # Test finished, kill VMs - kill $(jobs -p) + # Test finished break 2 fi done From 727251e52efe833b8bb428b5567fca34f8c74b3d Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Tue, 26 Oct 2021 22:03:28 +0800 Subject: [PATCH 505/806] mkdumprd: drop mountaddr/mountproto nfs mount options nfs service will append extra mount options to kernel mount options. Such as mountaddr/mountproto options. These options only represent current mounting details of the 1st kernel, but may not appropriate for the 2nd kernel for the same reason as commit d4f04afa47dea89ad5ca42ad0b2ddc355ce93a64 ("mkdumprd: drop some nfs mount options when reading from kernel"). This patch will remove these options. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- mkdumprd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index c6cb001..d87d588 100644 --- a/mkdumprd +++ b/mkdumprd @@ -70,8 +70,8 @@ to_mount() if [[ $_fstype == "nfs"* ]]; then _pdev=$_target - _sed_cmd+='s/,addr=[^,]*//;' - _sed_cmd+='s/,proto=[^,]*//;' + _sed_cmd+='s/,\(mount\)\?addr=[^,]*//g;' + _sed_cmd+='s/,\(mount\)\?proto=[^,]*//g;' _sed_cmd+='s/,clientaddr=[^,]*//;' else # for non-nfs _target converting to use udev persistent name From 6936fbc1b220f35b45b3114f04c6889a2b5e16a2 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 1 Nov 2021 14:13:16 +0800 Subject: [PATCH 506/806] fix broken extra_bins when installing multiple binaries When there more than one binaries, quoting "$val" would make dracut-install treat multiple binaries as one binary. Take "extra_bins /usr/sbin/ping /usr/sbin/ip" as an example, the following error would occur when building initrd, dracut-install: ERROR: installing '/usr/sbin/ping /usr/sbin/ip' dracut: FAILED: /usr/lib/dracut/dracut-install -D /var/tmp/dracut.ODrioZ/initramfs -a /usr/sbin/ping /usr/sbin/ip Fix it by not quoting the variable and bypassing SC2086 shellcheck. Fixes: commit 86538ca6e2e555caa8cdd2bcfcc3c5e94ac6bf58 ("bash scripts: fix variable quoting issue") Acked-by: Tao Liu Signed-off-by: Coiby Xu --- dracut-module-setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a5e4b67..1ea0d95 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -686,7 +686,8 @@ kdump_install_conf() { fi ;; kdump_pre | kdump_post | extra_bins) - dracut_install "$_val" + # shellcheck disable=SC2086 + dracut_install $_val ;; core_collector) dracut_install "${_val%%[[:blank:]]*}" From 8b9948df33e48f714409c6fa3af65a72f73416a5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 1 Nov 2021 14:13:16 +0800 Subject: [PATCH 507/806] Update makedumpfile to 1.7.0 Signed-off-by: Coiby Xu --- ...e-Increase-SECTION_MAP_LAST_BIT-to-5.patch | 42 ------------- ...ss-proc-kcore-when-finding-max_paddr.patch | 60 ------------------- ...-proc-kcore-when-making-ELF-dumpfile.patch | 43 ------------- kexec-tools.spec | 9 +-- sources | 2 +- 5 files changed, 2 insertions(+), 154 deletions(-) delete mode 100644 kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch delete mode 100644 kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch delete mode 100644 kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch diff --git a/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch b/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch deleted file mode 100644 index a59bef1..0000000 --- a/kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 646456862df8926ba10dd7330abf3bf0f887e1b6 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Wed, 26 May 2021 14:31:26 +0900 -Subject: [PATCH] Increase SECTION_MAP_LAST_BIT to 5 - -* Required for kernel 5.12 - -Kernel commit 1f90a3477df3 ("mm: teach pfn_to_online_page() about -ZONE_DEVICE section collisions") added a section flag -(SECTION_TAINT_ZONE_DEVICE) and causes makedumpfile an error on -some machines like this: - - __vtop4_x86_64: Can't get a valid pmd_pte. - readmem: Can't convert a virtual address(ffffe2bdc2000000) to physical address. - readmem: type_addr: 0, addr:ffffe2bdc2000000, size:32768 - __exclude_unnecessary_pages: Can't read the buffer of struct page. - create_2nd_bitmap: Can't exclude unnecessary pages. - -Increase SECTION_MAP_LAST_BIT to 5 to fix this. The bit had not -been used until the change, so we can just increase the value. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.9/makedumpfile.h b/makedumpfile-1.6.9/makedumpfile.h -index 93aa774..79046f2 100644 ---- a/makedumpfile-1.6.9/makedumpfile.h -+++ b/makedumpfile-1.6.9/makedumpfile.h -@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) - * 2. it has been verified that (1UL<<2) was never set, so it is - * safe to mask that bit off even in old kernels. - */ --#define SECTION_MAP_LAST_BIT (1UL<<4) -+#define SECTION_MAP_LAST_BIT (1UL<<5) - #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) - #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) - #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) --- -2.29.2 - diff --git a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch deleted file mode 100644 index f79ea55..0000000 --- a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 38d921a2ef50ebd36258097553626443ffe27496 Mon Sep 17 00:00:00 2001 -From: Coiby Xu -Date: Tue, 15 Jun 2021 18:26:31 +0800 -Subject: [PATCH] check for invalid physical address of /proc/kcore - when finding max_paddr - -Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore: -update physical address for kcore ram and text") sets an invalid paddr -(0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped -regions: - - $ readelf -l /proc/kcore - ... - Program Headers: - Type Offset VirtAddr PhysAddr - FileSiz MemSiz Flags Align - NOTE 0x0000000000000120 0x0000000000000000 0x0000000000000000 - 0x0000000000002320 0x0000000000000000 0x0 - LOAD 0x1000000000010000 0xd000000000000000 0xffffffffffffffff - ^^^^^^^^^^^^^^^^^^ - 0x0001f80000000000 0x0001f80000000000 RWE 0x10000 - -makedumpfile uses max_paddr to calculate the number of sections for -sparse memory model thus wrong number is obtained based on max_paddr -(-1). This error could lead to the failure of copying /proc/kcore -for RHEL-8.5 on ppc64le machine [1]: - - $ makedumpfile /proc/kcore vmcore1 - get_mem_section: Could not validate mem_section. - get_mm_sparsemem: Can't get the address of mem_section. - - makedumpfile Failed. - -Let's check if the phys_start of the segment is a valid physical -address to fix this problem. - -[1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267 - -Reported-by: Xiaoying Yan -Signed-off-by: Coiby Xu ---- - elf_info.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.9/elf_info.c b/makedumpfile-1.6.9/elf_info.c -index e8affb7..bc24083 100644 ---- a/makedumpfile-1.6.9/elf_info.c -+++ b/makedumpfile-1.6.9/elf_info.c -@@ -628,7 +628,7 @@ get_max_paddr(void) - - for (i = 0; i < num_pt_loads; i++) { - pls = &pt_loads[i]; -- if (max_paddr < pls->phys_end) -+ if (pls->phys_start != NOT_PADDR && max_paddr < pls->phys_end) - max_paddr = pls->phys_end; - } - return max_paddr; --- -2.29.2 - diff --git a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch deleted file mode 100644 index 8cf780c..0000000 --- a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001 -From: Tao Liu -Date: Fri, 18 Jun 2021 18:28:04 +0800 -Subject: [PATCH] check for invalid physical address of /proc/kcore - when making ELF dumpfile - -Previously when executing makedumpfile with -E option against -/proc/kcore, makedumpfile will fail: - - # makedumpfile -E -d 31 /proc/kcore kcore.dump - ... - write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset. - - makedumpfile Failed. - -It's because /proc/kcore contains PT_LOAD program headers which have -physaddr (0xffffffffffffffff). With -E option, makedumpfile will -try to convert the physaddr to an offset and fails. - -Skip the PT_LOAD program headers which have such physaddr. - -Signed-off-by: Tao Liu -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.9/makedumpfile.c b/makedumpfile-1.6.9/makedumpfile.c -index 894c88e..fcb571f 100644 ---- a/makedumpfile-1.6.9/makedumpfile.c -+++ b/makedumpfile-1.6.9/makedumpfile.c -@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) - if (!get_phdr_memory(i, &load)) - return FALSE; - -- if (load.p_type != PT_LOAD) -+ if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR) - continue; - - off_memory= load.p_offset; --- -2.29.2 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 5dbf625..1f25779 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.6.9 +%global mkdf_ver 1.7.0 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools @@ -108,9 +108,6 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # -Patch601: ./kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch -Patch602: ./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch -Patch603: ./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -126,10 +123,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch601 -p1 -%patch602 -p1 -%patch603 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif diff --git a/sources b/sources index 80b4d4e..2a1c797 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 SHA512 (kexec-tools-2.0.22.tar.xz) = 7580860f272eee5af52139809f12961e5a5d3a65f4e191183ca9c845410425d25818945ac14ed04a60e6ce474dc2656fc6a14041177b0bf703f450820c7d6aba -SHA512 (makedumpfile-1.6.9.tar.gz) = 9982985498ae641d390c3b87d92aecd263a502f1a4a9e96e145d86d8778b9e778e4ee98034ef4dbe12ed5586c57278917ea5f3c9ae2989ad1ac051215e03b3d9 +SHA512 (makedumpfile-1.7.0.tar.gz) = 579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7 From 267a088b2a15af26d431bfb10ae85d4d7fd1f98b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 8 Nov 2021 14:09:13 +0800 Subject: [PATCH 508/806] Release 2.0.23-1 Signed-off-by: Coiby Xu --- kexec-tools.spec | 11 +++++++++-- sources | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1f25779..331d61d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.22 -Release: 8%{?dist} +Version: 2.0.23 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -375,6 +375,13 @@ done %endif %changelog +* Mon Nov 18 2021 Coiby - 2.0.23-1 +- Update kexec-tools to 2.0.23 +- Rebase makedumpfile to 1.7.0 +- fix broken extra_bins when installing multiple binaries +- mkdumprd: drop mountaddr/mountproto nfs mount options +- selftest: kill VM reliably by recursively kill children processes + * Thu Sep 16 2021 Kairui Song - 2.0.22-8 - 92-crashkernel.install: fix exit code - dracut-early-kdump.sh: make it POSIX compatible diff --git a/sources b/sources index 2a1c797..5069108 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 -SHA512 (kexec-tools-2.0.22.tar.xz) = 7580860f272eee5af52139809f12961e5a5d3a65f4e191183ca9c845410425d25818945ac14ed04a60e6ce474dc2656fc6a14041177b0bf703f450820c7d6aba +SHA512 (kexec-tools-2.0.23.tar.xz) = b6e3b967cacc31c434b185d25da4d53c822ae4bbcec26ef9d6cb171f294fdcc80913d381e686a0a41e025187835f4dc088052ff88efe75a021d7624c8b1a1ed8 SHA512 (makedumpfile-1.7.0.tar.gz) = 579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7 From 9ffda5bc1c789d00737ebe9b554691d029ecf492 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 10 Nov 2021 16:56:53 +0800 Subject: [PATCH 509/806] Enable zstd compression for makedumpfile in kexec-tools.spec The Zstandard (zstd) compression method is not enabled: $ makedumpfile -v makedumpfile: version 1.7.0 (released on 8 Nov 2021) lzo enabled snappy enabled zstd disabled This patch will enable it when building kexec-tools rpm package. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- kexec-tools.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 331d61d..8efc17a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -71,7 +71,7 @@ Requires: dracut-squash >= 050 Requires: ethtool Recommends: grubby BuildRequires: make -BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel +BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool @@ -151,7 +151,7 @@ cp %{SOURCE34} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic-%{eppic_ver}/libeppic -make -C makedumpfile-%{mkdf_ver} LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-%{mkdf_ver} LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so %endif From 960a132c31facf574a6d48dc2d25771aaee56c5f Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 21 Oct 2021 10:17:01 +0800 Subject: [PATCH 510/806] sysconfig: make kexec_file_load as default option on aarch64 Signed-off-by: Pingfan Liu Acked-by: Coiby Xu --- kdump.sysconfig.aarch64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index fedd3bc..67a2af7 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" +KEXEC_ARGS="-s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From c59dfe938e1620b6ad264da0c8a59ed7996418e1 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 21 Oct 2021 10:17:02 +0800 Subject: [PATCH 511/806] sysconfig: make kexec_file_load as default option on ppc64le Signed-off-by: Pingfan Liu Acked-by: Coiby Xu --- kdump.sysconfig.ppc64le | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index ebb22f6..270a2cf 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -28,7 +28,7 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_di # # Example: # KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="--dt-no-old-root" +KEXEC_ARGS="--dt-no-old-root -s" #Where to find the boot image #KDUMP_BOOTDIR="/boot" From 8cc51f3ab922cad5e857e37440d65466b1b8c2fd Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 15 Nov 2021 22:23:42 +0800 Subject: [PATCH 512/806] Document/kexec-kdump-howto.txt: improve notes for kdump_pre and kdump_post scripts Signed-off-by: Pingfan Liu Acked-by: Coiby Xu --- kdump.conf.5 | 14 ++++++++++---- kexec-kdump-howto.txt | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/kdump.conf.5 b/kdump.conf.5 index 2c5a2bc..6e6cafa 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -118,8 +118,11 @@ All files under /etc/kdump/post.d are collectively sorted and executed in lexical order, before binary or script specified kdump_post parameter is executed. .PP -Note that scripts written for use with this directive must use -the /bin/bash interpreter. +Note that scripts written for use with this directive must use the /bin/bash +interpreter. And since these scripts run in kdump enviroment, the reference to +the storage or network device in the scripts should adhere to the section +'Supported dump target types and requirements' in kexec-kdump-howto.txt. + .RE .B kdump_pre @@ -139,8 +142,11 @@ kdump_pre parameter is executed. Even if the binary or script in /etc/kdump/pre.d directory returns non 0 exit status, the processing is continued. .PP -Note that scripts written for this directive must use -the /bin/bash interpreter. +Note that scripts written for use with this directive must use the /bin/bash +interpreter. And since these scripts run in kdump enviroment, the reference to +the storage or network device in the scripts should adhere to the section +'Supported dump target types and requirements' in kexec-kdump-howto.txt. + .RE .B extra_bins diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 88af607..1aeffc7 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -621,6 +621,9 @@ If /etc/kdump/post.d directory exist, All files in the directory are collectively sorted and executed in lexical order, before binary or script specified kdump_post parameter is executed. +In these scripts, the reference to the storage or network device should adhere +to the section 'Supported dump target types and requirements' + Kdump Pre-Capture Executable ---------------------------- @@ -634,6 +637,9 @@ kdump_pre parameter is executed. Even if the binary or script in /etc/kdump/pre.d directory returns non 0 exit status, the processing is continued. +In these scripts, the reference to the storage or network device should adhere +to the section 'Supported dump target types and requirements' + Extra Binaries -------------- From c3c8df3745a711992f1aa952e24eef0790924400 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 18 Nov 2021 12:26:01 +0800 Subject: [PATCH 513/806] add keytuils as a weak dependency for POWER When secureboot is enabled, kdumpctl needs to use keyctl to add/remove a key to/from the .ima keyring. Fixes: commit 596fa0a07f089a9dd54cf631124d88653b4d77ec ("kdumpctl: enable secure boot on ppc64le LPARs") Signed-off-by: Coiby Xu --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8efc17a..dcab391 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -63,6 +63,7 @@ Source201: dracut-fadump-module-setup.sh %ifarch ppc64 ppc64le Requires(post): servicelog +Recommends: keyutils %endif Requires(pre): coreutils sed zlib Requires: dracut >= 050 From f0892eeceb96072822f74e7a9ad491f61867f343 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 1 Dec 2021 15:37:06 +0800 Subject: [PATCH 514/806] kdump/ppc64: suppress the error message "Could not find a registered notification tool" from servicelog_notify When kexec-tools is newly installed, kdump migration action hasn't registered and the following error could occur, INF dnf.rpm: Could not find a registered notification tool with the specified command ('/usr/lib/kdump/kdump-migrate-action.sh'). "servicelog_notify --list" could list registered notification tools for a command but it outputs the above error as well. So simply redirect the error to /dev/null when running "servicelog_notify --remove". Fixes: commit 146f66262222e96bca47b691ed243fa5097aa55c ("kdump/ppc64: migration action registration clean up") Acked-by: Tao Liu Acked-by: Hari Bathini Signed-off-by: Coiby Xu --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index dcab391..ab7f41f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -265,7 +265,7 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d touch /etc/kdump.conf %ifarch ppc64 ppc64le -servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh +servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin %endif From 163c02970e4ddcf238b2ac09eadf380744e01ba2 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 20 Dec 2021 09:29:02 +0800 Subject: [PATCH 515/806] ppc64/ppc64le: drop cpu online rule in 40-redhat.rules in kdump initramfs Onlining secondary cpus breaks kdump completely on KVM on Power hosts Though we use maxcpus=1 by default but 40-redhat.rules will bring up all possible cpus by default. Thus before we get the kernel fix and the systemd rule fix let's remove the cpu rule in 40-redhat.rules for ppc64/ppc64le kdump initramfs. This is back ported from RHEL, and original credit goes to Dave Young Signed-off-by: Pingfan Liu Acked-by: Tao Liu --- dracut-module-setup.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1ea0d95..c319fc2 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1010,11 +1010,29 @@ kdump_install_systemd_conf() { echo "ForwardToConsole=yes" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" } +remove_cpu_online_rule() { + local file=${initdir}/usr/lib/udev/rules.d/40-redhat.rules + + sed -i '/SUBSYSTEM=="cpu"/d' "$file" +} + install() { + local arch + kdump_module_init kdump_install_conf remove_sysctl_conf + # Onlining secondary cpus breaks kdump completely on KVM on Power hosts + # Though we use maxcpus=1 by default but 40-redhat.rules will bring up all + # possible cpus by default. (rhbz1270174 rhbz1266322) + # Thus before we get the kernel fix and the systemd rule fix let's remove + # the cpu online rule in kdump initramfs. + arch=$(uname -m) + if [[ "$arch" = "ppc64le" ]] || [[ "$arch" = "ppc64" ]]; then + remove_cpu_online_rule + fi + if is_ssh_dump_target; then kdump_install_random_seed fi From 004daebefffcc81993413c4d4ce1f501294e3226 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 18 Dec 2021 16:14:44 +0800 Subject: [PATCH 516/806] dracut-early-kdump-module-setup.sh: install xargs and kdump-lib-initramfs.sh For earlykdump, kdump-lib-initramfs.sh is sourced by kdump-lib.sh, however it is not installed in dracut-early-kdump-module-setup.sh. Same as xargs, which is used by kdump-lib.sh. Otherwise earlykdump will report file not found errors. Fixes: a5faa052d4969cb66719d0b795d746449d3c71b7 ("kdump-lib-initramfs.sh: prepare to be a POSIX compatible lib") Fixes: 4f01cb1b0a4e1ea9467e9ace34d14dcb2fbe135a ("kdump-lib.sh: fix variable quoting issue") Signed-off-by: Tao Liu Acked-by: Coiby Xu --- dracut-early-kdump-module-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 0e46823..0451118 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -50,7 +50,9 @@ install() { inst_binary "/usr/bin/gawk" "/usr/bin/awk" inst_binary "/usr/bin/logger" "/usr/bin/logger" inst_binary "/usr/bin/printf" "/usr/bin/printf" + inst_binary "/usr/bin/xargs" "/usr/bin/xargs" inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" + inst_script "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump/kdump-lib-initramfs.sh" inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" inst_hook cmdline 00 "$moddir/early-kdump.sh" inst_binary "$KDUMP_KERNEL" From 546c81a2050c4d65a95f1bbe563b76a19c13780f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 28 Dec 2021 14:47:46 +0800 Subject: [PATCH 517/806] kdumpctl: remove some legacy code It seems the save_core function and vmcore detection was used a long time ago when kdump shares same userspace in first and second kernel. It's now heavily deprecated (only support cp, hardcoded path, dumpoops no longer exists) and not used. Now vmcore will never show up in first kernel for both kdump and fadump case, and kdumpctl is only used in first kernel, so just remove them. Signed-off-by: Kairui Song Acked-by: Coiby Xu --- kdumpctl | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/kdumpctl b/kdumpctl index 59ec068..ed2b963 100755 --- a/kdumpctl +++ b/kdumpctl @@ -72,32 +72,6 @@ determine_dump_mode() ddebug "DEFAULT_DUMP_MODE=$DEFAULT_DUMP_MODE" } -save_core() -{ - coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" - - mkdir -p "$coredir" - ddebug "cp --sparse=always /proc/vmcore $coredir/vmcore-incomplete" - if cp --sparse=always /proc/vmcore "$coredir/vmcore-incomplete"; then - mv "$coredir/vmcore-incomplete" "$coredir/vmcore" - dinfo "saved a vmcore to $coredir" - else - derror "failed to save a vmcore to $coredir" - fi - - # pass the dmesg to Abrt tool if exists, in order - # to collect the kernel oops message. - # https://fedorahosted.org/abrt/ - if [[ -x /usr/bin/dumpoops ]]; then - ddebug "makedumpfile --dump-dmesg $coredir/vmcore $coredir/dmesg" - makedumpfile --dump-dmesg "$coredir/vmcore" "$coredir/dmesg" > /dev/null 2>&1 - ddebug "dumpoops -d $coredir/dmesg" - if dumpoops -d "$coredir/dmesg" > /dev/null 2>&1; then - dinfo "kernel oops has been collected by abrt tool" - fi - fi -} - rebuild_fadump_initrd() { if ! $MKFADUMPRD "$DEFAULT_INITRD_BAK" "$TARGET_INITRD" --kver "$KDUMP_KERNELVER"; then @@ -1346,12 +1320,7 @@ main() case "$1" in start) - if [[ -s /proc/vmcore ]]; then - save_core - reboot - else - start - fi + start ;; stop) stop From 34d27c4c308d9eddc35ff2c81bfe3b1cef5749a5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 16 Nov 2021 09:12:49 +0800 Subject: [PATCH 518/806] update default crashkernel value It has been decided to increase default crashkernel value to reduce the possibility of OOM. Fixes: 7b7ddab ("kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default") Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 2e2775c..b8f6c96 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -841,7 +841,7 @@ kdump_get_arch_recommend_size() else arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') if [[ $arch == "X86_64" ]] || [[ $arch == "S390X" ]]; then - ck_cmdline="1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M" + ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" elif [[ $arch == "AARCH64" ]]; then ck_cmdline="2G-:448M" elif [[ $arch == "PPC64LE" ]]; then From 105c01691ac200e7ce71795b2f41b64dd6cf3b58 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 16 Nov 2021 11:26:31 +0800 Subject: [PATCH 519/806] factor out kdump_get_arch_recommend_crashkernel Factor out kdump_get_arch_recommend_crashkernel to prepare for kdump-anaconda-plugin for example to retrieve the default crashkernel value. Note the support of crashkenrel.default is dropped. Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdump-lib.sh | 60 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index b8f6c96..b28db44 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -822,40 +822,52 @@ get_recommend_size() IFS="$OLDIFS" } +# get default crashkernel +# $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable +kdump_get_arch_recommend_crashkernel() +{ + local _arch _ck_cmdline _dump_mode + + if [[ -z "$1" ]]; then + if is_fadump_capable; then + _dump_mode=fadump + else + _dump_mode=kdump + fi + else + _dump_mode=$1 + fi + + _arch=$(uname -m) + + if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then + _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" + elif [[ $_arch == "aarch64" ]]; then + _ck_cmdline="2G-:448M" + elif [[ $_arch == "ppc64le" ]]; then + if [[ $_dump_mode == "fadump" ]]; then + _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" + else + _ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" + fi + fi + + _ck_cmdline=${_ck_cmdline//-:/-102400T:} + echo -n "$_ck_cmdline" +} + # return recommended size based on current system RAM size # $1: kernel version, if not set, will defaults to $(uname -r) kdump_get_arch_recommend_size() { - local kernel=$1 arch + local _ck_cmdline if ! [[ -r "/proc/iomem" ]]; then echo "Error, can not access /proc/iomem." return 1 fi - - [[ -z $kernel ]] && kernel=$(uname -r) - ck_cmdline=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null) - - if [[ -n $ck_cmdline ]]; then - ck_cmdline=${ck_cmdline#crashkernel=} - else - arch=$(lscpu | grep Architecture | awk -F ":" '{ print $2 }' | tr '[:lower:]' '[:upper:]') - if [[ $arch == "X86_64" ]] || [[ $arch == "S390X" ]]; then - ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" - elif [[ $arch == "AARCH64" ]]; then - ck_cmdline="2G-:448M" - elif [[ $arch == "PPC64LE" ]]; then - if is_fadump_capable; then - ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" - else - ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" - fi - fi - fi - - ck_cmdline=${ck_cmdline//-:/-102400T:} sys_mem=$(get_system_size) - + _ck_cmdline=$(kdump_get_arch_recommend_crashkernel) get_recommend_size "$sys_mem" "$ck_cmdline" } From 796d0f6fd2932fd7c009f4517133b1a9c39501e5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 16 Nov 2021 12:23:02 +0800 Subject: [PATCH 520/806] provide kdumpctl get-default-crashkernel for kdump_anaconda_addon and RPM scriptlet Provide "kdumpctl get-default-crashkernel" for kdump_anaconda_addon so crashkernel.default isn't needed. When fadump is on, kdump_anaconda_addon would need to specify the dump mode, i.e. "kdumpctl get-default-crashkernel fadump". This interface would also be used by RPM scriptlet [1] to fetch default crashkernel value. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/ Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kdumpctl b/kdumpctl index ed2b963..48aca00 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1273,6 +1273,13 @@ do_estimate() fi } +get_default_crashkernel() +{ + local _dump_mode=$1 + + kdump_get_arch_recommend_crashkernel "$_dump_mode" +} + reset_crashkernel() { local kernel=$1 entry crashkernel_default @@ -1361,6 +1368,9 @@ main() estimate) do_estimate ;; + get-default-crashkernel) + get_default_crashkernel "$2" + ;; reset-crashkernel) reset_crashkernel "$2" ;; From fb9e6838abef1e3a2ba43966f58a1f146989b148 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 16 Nov 2021 06:48:40 +0800 Subject: [PATCH 521/806] add a helper function to read kernel cmdline parameter from grubby --info This helper function will be used to retrieve the value of kernel cmdline parameters including crashkernel, fadump, swiotlb and etc. Suggested-by: Philipp Rudo Reviewed-by: Pingfan Liu Signed-off-by: Coiby Xu --- kdumpctl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kdumpctl b/kdumpctl index 48aca00..6f6bdd2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1280,6 +1280,17 @@ get_default_crashkernel() kdump_get_arch_recommend_crashkernel "$_dump_mode" } +# Read kernel cmdline parameter for a specific kernel +# $1: kernel path, DEFAULT or kernel path, ALL not accepted +# $2: kernel cmldine parameter +get_grub_kernel_boot_parameter() +{ + local _kernel_path=$1 _para=$2 + + [[ $_kernel_path == ALL ]] && derror "kernel_path=ALL invalid for get_grub_kernel_boot_parameter" && return 1 + grubby --info="$_kernel_path" | sed -En -e "/^args=.*$/{s/^.*(\s|\")${_para}=(\S*).*\"$/\2/p;q}" +} + reset_crashkernel() { local kernel=$1 entry crashkernel_default From 3d2079c31cd80741ea6d44eb7f13d7f08be74a94 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 1 Dec 2021 16:57:15 +0800 Subject: [PATCH 522/806] add helper functions to get dump mode Add a helper function to get dump mode. The dump mode would be - fadump if fadump=on or fadump=nocma - kdump if fadump=off or empty fadump Otherwise return 1. Also add another helper function to return a kernel's dump mode. Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/kdumpctl b/kdumpctl index 6f6bdd2..a72b71b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1291,6 +1291,40 @@ get_grub_kernel_boot_parameter() grubby --info="$_kernel_path" | sed -En -e "/^args=.*$/{s/^.*(\s|\")${_para}=(\S*).*\"$/\2/p;q}" } +# get dump mode by fadump value +# return +# - fadump, if fadump=on or fadump=nocma +# - kdump, if fadump=off or empty fadump, return kdump +# - error if otherwise +get_dump_mode_by_fadump_val() +{ + local _fadump_val=$1 + + if [[ -z $_fadump_val ]] || [[ $_fadump_val == off ]]; then + echo -n kdump + elif [[ $_fadump_val == on ]] || [[ $_fadump_val == nocma ]]; then + echo -n fadump + else + derror "invalid fadump=$_fadump_val" + return 1 + fi +} + +# get dump mode of a specific kernel +# based on its fadump kernel cmdline parameter +get_dump_mode_by_kernel() +{ + local _kernel_path=$1 _fadump_val _dump_mode + + _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel_path" fadump) + if _dump_mode=$(get_dump_mode_by_fadump_val "$_fadump_val"); then + echo -n "$_dump_mode" + else + derror "failed to get dump mode for kernel $_kernel_path" + exit + fi +} + reset_crashkernel() { local kernel=$1 entry crashkernel_default From 945cbbd59b34739c4a6b2f228c33f76e2981a18a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 7 Dec 2021 15:16:07 +0800 Subject: [PATCH 523/806] add helper functions to get kernel path by kernel release and the path of current running kernel grubby --info=kernel-path or --add-kernel=kernel-path accepts a kernel path (e.g. /boot/vmlinuz-5.14.14-200.fc34.x86_64) instead of kernel release (e.g 5.14.14-200.fc34.x86_64). So we need to know the kernel path given a kernel release. Although for Fedora/RHEL, the kernel path is "/boot/vmlinuz-", a path kernel could also be /boot///vmlinuz. So the most reliable way to find the kernel path given a kernel release is to use "grubby --info". For osbuild, a kernel path may not yet exist but it's valid for "grubby --update-kernel=KERNEL_PATH". For example, "grubby -info" may output something as follows, index=0 kernel="/var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/vmlinuz-5.15.10-100.fc34.x86_64" args="ro no_timer_check net.ifnames=0 console=tty1 console=ttyS0,115200n8" root="UUID=76a22bf4-f153-4541-b6c7-0332c0dfaeac" initrd="/var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/initramfs-5.15.10-100.fc34.x86_64.img" There is no need to check if path like /var/cache/osbuild-worker/osbuild-store/tmp/tmp2prywdy5object/tree/boot/vmlinuz-5.15.10-100.fc34.x86_64 physically exists. Note these helper functions doesn't support CoreOS/Atomic/Silverblue since grubby isn't used by them. Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kdumpctl b/kdumpctl index a72b71b..2ace803 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1325,6 +1325,36 @@ get_dump_mode_by_kernel() fi } +_filter_grubby_kernel_str() +{ + local _grubby_kernel_str=$1 + echo -n "$_grubby_kernel_str" | sed -n -e 's/^kernel="\(.*\)"/\1/p' +} + +_find_kernel_path_by_release() +{ + local _release="$1" _grubby_kernel_str _kernel_path + _grubby_kernel_str=$(grubby --info ALL | grep "^kernel=.*$_release") + _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") + if [[ -z $_kernel_path ]]; then + derror "kernel $_release doesn't exist" + return 1 + fi + echo -n "$_kernel_path" +} + +_get_current_running_kernel_path() +{ + local _release _path + + _release=$(uname -r) + if _path=$(_find_kernel_path_by_release "$_release"); then + echo -n "$_path" + else + return 1 + fi +} + reset_crashkernel() { local kernel=$1 entry crashkernel_default From 12ecbce359adb621da3e65fed689632a39599ce6 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 13 Dec 2021 10:57:13 +0800 Subject: [PATCH 524/806] fix incorrect usage of rpm-ostree to update kernel command line parameters CoreOS/Atomic/Silverblue use "rpm-ostree kargs" to manage kernel command line parameters. Fixes: 86130ec ("kdumpctl: Add kdumpctl reset-crashkernel") Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 2ace803..dd87693 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1370,9 +1370,9 @@ reset_crashkernel() if is_atomic; then if rpm-ostree kargs | grep -q "crashkernel="; then - rpm-ostree --replace="crashkernel=$crashkernel_default" + rpm-ostree kargs --replace="crashkernel=$crashkernel_default" else - rpm-ostree --append="crashkernel=$crashkernel_default" + rpm-ostree kargs --append="crashkernel=$crashkernel_default" fi else entry=$(grubby --info ALL | grep "^kernel=.*$kernel") From 140da74a340f872b2579fc75b50a36fe7015c0ba Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 1 Dec 2021 13:39:40 +0800 Subject: [PATCH 525/806] rewrite reset_crashkernel to support fadump and to used by RPM scriptlet Rewrite kdumpctl reset-crashkernel KERNEL_PATH as kdumpctl reset-crashkernel [--fadump=[on|off|nocma]] [--kernel=path_to_kernel] [--reboot] This interface would reset a specific kernel to the default crashkernel value given the kernel path. And it also supports grubby's syntax so there are the following special cases, - if --kernel not specified, - use KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump - otherwise use current running kernel, i.e. `uname -r` - if --kernel=DEFAULT, the default boot kernel is chosen - if --kernel=ALL, all kernels would have its crashkernel reset to the default value and the /etc/default/grub is updated as well --fadump=[on|off|nocma] toggles fadump on/off for the kernel provided in KERNEL_PATH. If --fadump is omitted, the dump mode is determined by parsing the kernel command line for the kernel(s) to update. CoreOS/Atomic/Silverblue needs to be treated as a special case because, - "rpm-ostree kargs" is used to manage kernel command line parameters so --kernel doesn't make sense and there is no need to find current running kernel - "rpm-ostree kargs" itself would prompt the user to reboot the system after modify the kernel command line parameter - POWER is not supported so we can assume the dump mode is always kdump This interface will also be called by kexec-tools RPM scriptlets [1] to reset crashkernel. Note the support of crashkenrel.default is dropped. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/ Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 203 +++++++++++++++++++++++++++++++++++++++++++++++------ kdumpctl.8 | 19 +++-- 2 files changed, 192 insertions(+), 30 deletions(-) diff --git a/kdumpctl b/kdumpctl index dd87693..1518e5c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1355,38 +1355,194 @@ _get_current_running_kernel_path() fi } -reset_crashkernel() +_update_grub() { - local kernel=$1 entry crashkernel_default - local grub_etc_default="/etc/default/grub" - - [[ -z $kernel ]] && kernel=$(uname -r) - crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null) - - if [[ -z $crashkernel_default ]]; then - derror "$kernel doesn't have a crashkernel.default" - exit 1 - fi + local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4 if is_atomic; then if rpm-ostree kargs | grep -q "crashkernel="; then - rpm-ostree kargs --replace="crashkernel=$crashkernel_default" + rpm-ostree kargs --replace="crashkernel=$_crashkernel" else - rpm-ostree kargs --append="crashkernel=$crashkernel_default" + rpm-ostree kargs --append="crashkernel=$_crashkernel" fi else - entry=$(grubby --info ALL | grep "^kernel=.*$kernel") - entry=${entry#kernel=} - entry=${entry#\"} - entry=${entry%\"} + [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" + grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path" $zipl_arg + if [[ $_dump_mode == kdump ]]; then + grubby --remove-args="fadump" --update-kernel "$_kernel_path" + else + grubby --args="fadump=$_fadump_val" --update-kernel "$_kernel_path" + fi + fi + [[ $zipl_arg ]] && zipl > /dev/null +} - if [[ -f $grub_etc_default ]]; then - sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default" +_valid_grubby_kernel_path() +{ + [[ -n "$1" ]] && grubby --info="$1" > /dev/null 2>&1 +} + +_get_all_kernels_from_grubby() +{ + local _kernels _line _kernel_path _grubby_kernel_path=$1 + + for _line in $(grubby --info "$_grubby_kernel_path" | grep "^kernel="); do + _kernel_path=$(_filter_grubby_kernel_str "$_line") + _kernels="$_kernels $_kernel_path" + done + echo -n "$_kernels" +} + +GRUB_ETC_DEFAULT="/etc/default/grub" +# modify the kernel command line parameter in default grub conf +# +# $1: the name of the kernel command line parameter +# $2: new value. If empty, the parameter would be removed +_update_kernel_cmdline_in_grub_etc_default() +{ + local _para=$1 _val=$2 _para_val _regex + + if [[ -n $_val ]]; then + _para_val="$_para=$_val" + fi + + _regex='^(GRUB_CMDLINE_LINUX=.*)([[:space:]"])'"$_para"'=[^[:space:]"]*(.*)$' + if grep -q -E "$_regex" "$GRUB_ETC_DEFAULT"; then + sed -i -E 's/'"$_regex"'/\1\2'"$_para_val"'\3/' "$GRUB_ETC_DEFAULT" + elif [[ -n $_para_val ]]; then + # If the kernel parameter doesn't exist, put it in the first + sed -i -E 's/^(GRUB_CMDLINE_LINUX=")/\1'"$_para_val"' /' "$GRUB_ETC_DEFAULT" + fi +} + +reset_crashkernel() +{ + local _opt _val _dump_mode _fadump_val _reboot _grubby_kernel_path _kernel _kernels + local _old_crashkernel _new_crashkernel _new_dump_mode _crashkernel_changed + local _new_fadump_val _old_fadump_val _what_is_updated + + for _opt in "$@"; do + case "$_opt" in + --fadump=*) + _val=${_opt#*=} + if _dump_mode=$(get_dump_mode_by_fadump_val $_val); then + _fadump_val=$_val + else + derror "failed to determine dump mode" + exit + fi + ;; + --kernel=*) + _val=${_opt#*=} + if ! _valid_grubby_kernel_path $_val; then + derror "Invalid $_opt, please specify a valid kernel path, ALL or DEFAULT" + exit + fi + _grubby_kernel_path=$_val + ;; + --reboot) + _reboot=yes + ;; + *) + derror "$_opt not recognized" + exit 1 + ;; + esac + done + + # 1. CoreOS uses "rpm-ostree kargs" instead of grubby to manage kernel command + # line. --kernel=ALL doesn't make sense for CoreOS. + # 2. CoreOS doesn't support POWER so the dump mode is always kdump. + # 3. "rpm-ostree kargs" would prompt the user to reboot the system after + # modifying the kernel command line so there is no need for kexec-tools + # to repeat it. + if is_atomic; then + _old_crashkernel=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') + _new_dump_mode=kdump + _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") + if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then + _update_grub "" "$_new_crashkernel" "$_new_dump_mode" "" + if [[ $_reboot == yes ]]; then + systemctl reboot + fi + fi + return + fi + + # For non-ppc64le systems, the dump mode is always kdump since only ppc64le + # has FADump. + if [[ -z $_dump_mode && $(uname -m) != ppc64le ]]; then + _dump_mode=kdump + _fadump_val=off + fi + + # If the dump mode is determined, we can also know the default crashkernel value + if [[ -n $_dump_mode ]]; then + _crashkernel=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") + fi + + # If --kernel-path=ALL, update GRUB_CMDLINE_LINUX in /etc/default/grub. + # + # An exception case is when the ppc64le user doesn't specify the fadump value. + # In this case, the dump mode would be determined by parsing the kernel + # command line of the kernel(s) to be updated thus don't update GRUB_CMDLINE_LINUX. + # + # The following code has been simplified because of what has been done early, + # - set the dump mode as kdump for non-ppc64le cases + # - retrieved the default crashkernel value for given dump mode + if [[ $_grubby_kernel_path == ALL && -n $_dump_mode ]]; then + _update_kernel_cmdline_in_grub_etc_default crashkernel "$_crashkernel" + # remove the fadump if fadump is disabled + [[ $_fadump_val == off ]] && _fadump_val="" + _update_kernel_cmdline_in_grub_etc_default fadump "$_fadump_val" + fi + + # If kernel-path not specified, either + # - use KDUMP_KERNELVER if it's defined + # - use current running kernel + if [[ -z $_grubby_kernel_path ]]; then + if [[ -z $KDUMP_KERNELVER ]] || + ! _kernel_path=$(_find_kernel_path_by_release "$KDUMP_KERNELVER"); then + if ! _kernel_path=$(_get_current_running_kernel_path); then + derror "no running kernel found" + exit 1 + fi + fi + _kernels=$_kernel_path + else + _kernels=$(_get_all_kernels_from_grubby "$_grubby_kernel_path") + fi + + for _kernel in $_kernels; do + if [[ -z $_dump_mode ]]; then + _new_dump_mode=$(get_dump_mode_by_kernel "$_kernel") + _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") + _new_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + else + _new_dump_mode=$_dump_mode + _new_crashkernel=$_crashkernel + _new_fadump_val=$_fadump_val fi - [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" - grubby --args "$crashkernel_default" --update-kernel "$entry" $zipl_arg - [[ $zipl_arg ]] && zipl > /dev/null + _old_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + _old_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + if [[ $_old_crashkernel != "$_new_crashkernel" || $_old_fadump_val != "$_new_fadump_val" ]]; then + _update_grub "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val" + if [[ $_reboot != yes ]]; then + if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then + _what_is_updated="Updated crashkernel=$_new_crashkernel" + else + # This case happens only when switching between fadump=on and fadump=nocma + _what_is_updated="Updated fadump=$_new_fadump_val" + fi + dwarn "$_what_is_updated for kernel=$_kernel. Please reboot the system for the change to take effect." + fi + _crashkernel_changed=yes + fi + done + + if [[ $_reboot == yes && $_crashkernel_changed == yes ]]; then + reboot fi } @@ -1447,7 +1603,8 @@ main() get_default_crashkernel "$2" ;; reset-crashkernel) - reset_crashkernel "$2" + shift + reset_crashkernel "$@" ;; *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" diff --git a/kdumpctl.8 b/kdumpctl.8 index 74be062..067117b 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -50,14 +50,19 @@ Estimate a suitable crashkernel value for current machine. This is a best-effort estimate. It will print a recommanded crashkernel value based on current kdump setup, and list some details of memory usage. .TP -.I reset-crashkernel [KERNEL] -Reset crashkernel value to default value. kdumpctl will try to read -from /usr/lib/modules//crashkernel.default and reset specified -kernel's crashkernel cmdline value. If no kernel is -specified, will reset current running kernel's crashkernel value. -If /usr/lib/modules//crashkernel.default doesn't exist, will -simply exit return 1. +.I reset-crashkernel [--kernel=path_to_kernel] [--reboot] +Reset crashkernel to default value recommended by kexec-tools. If no kernel +is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump +or current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can +also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as +grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and +supports an additonal [--fadump=[on|off|nocma]] parameter to toggle FADump +on/off. +Note: The memory requirements for kdump varies heavily depending on the +used hardware and system configuration. Thus the recommended +crashkernel might not work for your specific setup. Please test if +kdump works after resetting the crashkernel value. .SH "SEE ALSO" .BR kdump.conf (5), From 73ced7f451a725f4a2f7db5f0e1c6e7918538204 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 15 Nov 2021 15:45:59 +0800 Subject: [PATCH 526/806] introduce the auto_reset_crashkernel option to kdump.conf This option will 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. Default to yes. Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdump.conf | 7 +++++++ kdump.conf.5 | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/kdump.conf b/kdump.conf index dea2e94..d4fc78b 100644 --- a/kdump.conf +++ b/kdump.conf @@ -11,6 +11,12 @@ # # Supported options: # +# auto_reset_crashkernel +# - 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. +# The default value is yes. +# # raw # - Will dd /proc/vmcore into . # Use persistent device names for partition devices, @@ -170,6 +176,7 @@ #ssh user@my.server.com #ssh user@2001:db8::1:2:3:4 #sshkey /root/.ssh/kdump_id_rsa +auto_reset_crashkernel yes path /var/crash core_collector makedumpfile -l --message-level 7 -d 31 #core_collector scp diff --git a/kdump.conf.5 b/kdump.conf.5 index 6e6cafa..e3e9900 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -26,6 +26,12 @@ understand how this configuration file affects the behavior of kdump. .SH OPTIONS +.B auto_reset_crashkernel +.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 + .B raw .RS Will dd /proc/vmcore into . Use persistent device names for From 0adb0f4a8c4c69ba54171f0113a4fbfc1729900f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 1 Dec 2021 15:33:13 +0800 Subject: [PATCH 527/806] try to reset kernel crashkernel when kexec-tools updates the default crashkernel value kexec-tools could update the default crashkernel value. When auto_reset_crashkernel=yes, reset kernel to new crashkernel value in the following two cases, - crashkernel=auto is found in the kernel cmdline - the kernel crashkernel was previously set by kexec-tools i.e. the kernel is using old default crashkernel value To tell if the user is using a custom value for the kernel crashkernel or not, we assume the user would never use the default crashkernel value as custom value. When kexec-tools gets updated, 1. save the default crashkernel value of the older package to /tmp/crashkernel (for POWER system, /tmp/crashkernel_fadump is saved as well). 2. If auto_reset_crashkernel=yes, iterate all installed kernels. For each kernel, compare its crashkernel value with the old default crashkernel and reset it if yes The implementation makes use of two RPM scriptlets [2], - %pre is run before a package is installed so we can use it to save old default crashkernel value - %post is run after a package installed so we can use it to try to reset kernel crashkernel There are several problems when running kdumpctl in the RPM scripts for CoreOS/Atomic/Silverblue, for example, the lock can't be acquired by kdumpctl, "rpm-ostree kargs" can't be run and etc.. So don't enable this feature for CoreOS/Atomic/Silverblue. Note latest shellcheck (0.8.0) gives false positives about the associative array as of this commit. And Fedora's shellcheck is 0.7.2 and can't even correctly parse the shell code because of the associative array. [1] https://github.com/koalaman/shellcheck/issues/2399 [2] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/ Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 35 +++++++++++++++++++++++++++++++++++ kexec-tools.spec | 22 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/kdumpctl b/kdumpctl index 1518e5c..07e6f8b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1546,6 +1546,36 @@ reset_crashkernel() fi } +# shellcheck disable=SC2154 # false positive when dereferencing an array +reset_crashkernel_after_update() +{ + local _kernel _crashkernel _dump_mode _fadump_val _old_default_crashkernel _new_default_crashkernel + declare -A _crashkernel_vals + + _crashkernel_vals[old_kdump]=$(cat /tmp/old_default_crashkernel 2> /dev/null) + _crashkernel_vals[old_fadump]=$(cat /tmp/old_default_crashkernel_fadump 2> /dev/null) + _crashkernel_vals[new_kdump]=$(get_default_crashkernel kdump) + _crashkernel_vals[new_fadump]=$(get_default_crashkernel fadump) + + for _kernel in $(_get_all_kernels_from_grubby); do + _crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + if [[ $_crashkernel == auto ]]; then + reset_crashkernel "--kernel=$_kernel" + elif [[ -n $_crashkernel ]]; then + _dump_mode=$(get_dump_mode_by_kernel "$_kernel") + _old_default_crashkernel=${_crashkernel_vals[old_${_dump_mode}]} + _new_default_crashkernel=${_crashkernel_vals[new_${_dump_mode}]} + if [[ $_crashkernel == "$_old_default_crashkernel" ]] && + [[ $_new_default_crashkernel != "$_old_default_crashkernel" ]]; then + _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + if _update_grub "$_kernel" "$_new_default_crashkernel" "$_dump_mode" "$_fadump_val"; then + echo "For kernel=$_kernel, crashkernel=$_new_default_crashkernel now." + fi + fi + fi + done +} + if [[ ! -f $KDUMP_CONFIG_FILE ]]; then derror "Error: No kdump config file found!" exit 1 @@ -1606,6 +1636,11 @@ main() shift reset_crashkernel "$@" ;; + reset-crashkernel-after-update) + if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then + reset_crashkernel_after_update + fi + ;; *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" exit 1 diff --git a/kexec-tools.spec b/kexec-tools.spec index ab7f41f..b2a0e20 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -258,6 +258,15 @@ chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpini mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ +%pre +# save the old default crashkernel values to /tmp/ when upgrading the package +if ! grep -q "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then + kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null +%ifarch ppc64 ppc64le + kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null +%endif +fi + %post # Initial installation %systemd_post kdump.service @@ -291,6 +300,19 @@ then mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump fi +# try to reset kernel crashkernel value to new default value when upgrading +# the package +if ! grep -q "ostree" /proc/cmdline && [ $1 == 2 ]; then + kdumpctl reset-crashkernel-after-update + rm /tmp/old_default_crashkernel 2>/dev/null +%ifarch ppc64 ppc64le + rm /tmp/old_default_crashkernel_fadump 2>/dev/null +%endif + # dnf would complain about the exit code not being 0. To keep it happy, + # always return 0 + : +fi + %postun %systemd_postun_with_restart kdump.service From 5e8c751c39a5ec9d10009cba1c2bd554a5763b90 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 2 Dec 2021 17:19:50 +0800 Subject: [PATCH 528/806] reset kernel crashkernel for the special case where the kernel is updated right after kexec-tools When kexec-tools updates the default crashkernel value, it will try to reset the existing installed kernels including the currently running kernel. So the running kernel could have different kernel cmdline parameters from /proc/cmdline. When installing a kernel after updating kexec-tools, /usr/lib/kernel/install.d/20-grub.install would be called by kernel-install [1] which would use /proc/cmdline to set up new kernel's cmdline. To address this special case, reset the new kernel's crashkernel and fadump value to the value that would be used by running kernel after rebooting by the installation hook. One side effect of this commit is it would reset the installed kernel's crashkernel even currently running kernel don't use the default crashkernel value after rebooting. But I think this side effect is a benefit for the user. The implementation depends on kernel-install which run the scripts in /usr/lib/kernel/install.d passing the following arguments, add KERNEL-VERSION $BOOT/MACHINE-ID/KERNEL-VERSION/ KERNEL-IMAGE [INITRD-FILE ...] An concrete example is given as follows, add 5.11.12-300.fc34.x86_64 /boot/e986846f63134c7295458cf36300ba5b/5.11.12-300.fc34.x86_64 /lib/modules/5.11.12-300.fc34.x86_64/vmlinuz kernel-install could be started by the kernel package's RPM scriplet [2]. As mentioned in previous commit "try to reset kernel crashkernel when kexec-tools updates the default crashkernel value", kdumpctl has difficulty running in RPM scriptlet fore CoreOS. But rpm-ostree ignores all kernel hooks, there is no need to disable the kernel hook for CoreOS/Atomic/Silverblue. But a collaboration between rpm-ostree and kexec-tools is needed [3] to take care of this special case. Note the crashkernel.default support is dropped. [1] https://www.freedesktop.org/software/systemd/man/kernel-install.html [2] https://src.fedoraproject.org/rpms/kernel/blob/rawhide/f/kernel.spec#_2680 [3] https://github.com/coreos/rpm-ostree/issues/2894 Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- 92-crashkernel.install | 135 +---------------------------------------- kdumpctl | 31 ++++++++++ 2 files changed, 32 insertions(+), 134 deletions(-) diff --git a/92-crashkernel.install b/92-crashkernel.install index 78365ff..1d67a13 100755 --- a/92-crashkernel.install +++ b/92-crashkernel.install @@ -5,142 +5,9 @@ KERNEL_VERSION="$2" KDUMP_INITRD_DIR_ABS="$3" KERNEL_IMAGE="$4" -grub_etc_default="/etc/default/grub" - -ver_lt() { - [[ "$(echo -e "$1\n$2" | sort -V)" == $1$'\n'* ]] && [[ $1 != "$2" ]] -} - -# Read crashkernel= value in /etc/default/grub -get_grub_etc_ck() { - [[ -e $grub_etc_default ]] && \ - sed -n -e "s/^GRUB_CMDLINE_LINUX=.*\(crashkernel=[^\ \"]*\)[\ \"].*$/\1/p" $grub_etc_default -} - -# Read crashkernel.default value of specified kernel -get_ck_default() { - ck_file="/usr/lib/modules/$1/crashkernel.default" - [[ -f "$ck_file" ]] && cat "$ck_file" -} - -# Iterate installed kernels, find the kernel with the highest version that has a -# valid crashkernel.default file, exclude current installing/removing kernel -# -# $1: a string representing a crashkernel= cmdline. If given, will also check the -# content of crashkernel.default, only crashkernel.default with the same value will match -get_highest_ck_default_kver() { - for kernel in $(find /usr/lib/modules -maxdepth 1 -mindepth 1 -printf "%f\n" | sort --version-sort -r); do - [[ $kernel == "$KERNEL_VERSION" ]] && continue - [[ -s "/usr/lib/modules/$kernel/crashkernel.default" ]] || continue - - echo "$kernel" - return 0 - done - - return 1 -} - -set_grub_ck() { - sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$1\2/" "$grub_etc_default" -} - -# Set specified kernel's crashkernel cmdline value -set_kernel_ck() { - kernel=$1 - ck_cmdline=$2 - - entry=$(grubby --info ALL | grep "^kernel=.*$kernel") - entry=${entry#kernel=} - entry=${entry#\"} - entry=${entry%\"} - - if [[ -z "$entry" ]]; then - echo "$0: failed to find boot entry for kernel $kernel" - return 1 - fi - - [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" - grubby --args "$ck_cmdline" --update-kernel "$entry" $zipl_arg - [[ $zipl_arg ]] && zipl > /dev/null ||: -} - case "$COMMAND" in add) - # - If current boot kernel is using default crashkernel value, update - # installing kernel's crashkernel value to its default value, - # - If intalling a higher version kernel, and /etc/default/grub's - # crashkernel value is using default value, update it to installing - # kernel's default value. - inst_ck_default=$(get_ck_default "$KERNEL_VERSION") - # If installing kernel doesn't have crashkernel.default, just exit. - [[ -z "$inst_ck_default" ]] && exit 0 - - boot_kernel=$(uname -r) - boot_ck_cmdline=$(sed -n -e "s/^.*\(crashkernel=\S*\).*$/\1/p" /proc/cmdline) - highest_ck_default_kver=$(get_highest_ck_default_kver) - highest_ck_default=$(get_ck_default "$highest_ck_default_kver") - - # Try update /etc/default/grub if present, else grub2-mkconfig could - # override crashkernel value. - grub_etc_ck=$(get_grub_etc_ck) - if [[ -n "$grub_etc_ck" ]]; then - if [[ -z "$highest_ck_default_kver" ]]; then - # None of installed kernel have a crashkernel.default, - # check for 'crashkernel=auto' in case of legacy kernel - [[ "$grub_etc_ck" == "crashkernel=auto" ]] && \ - set_grub_ck "$inst_ck_default" - else - # There is a valid crashkernel.default, check if installing kernel - # have a higher version and grub config is using default value - ver_lt "$highest_ck_default_kver" "$KERNEL_VERSION" && \ - [[ "$grub_etc_ck" == "$highest_ck_default" ]] && \ - [[ "$grub_etc_ck" != "$inst_ck_default" ]] && \ - set_grub_ck "$inst_ck_default" - fi - fi - - # Exit if crashkernel is not used in current cmdline - [[ -z $boot_ck_cmdline ]] && exit 0 - - # Get current boot kernel's default value - boot_ck_default=$(get_ck_default "$boot_kernel") - if [[ $boot_ck_cmdline == "crashkernel=auto" ]]; then - # Legacy RHEL kernel defaults to "auto" - boot_ck_default="$boot_ck_cmdline" - fi - - # If boot kernel doesn't have a crashkernel.default, check - # if it's using any installed kernel's crashkernel.default - if [[ -z $boot_ck_default ]]; then - [[ $(get_highest_ck_default_kver "$boot_ck_cmdline") ]] && boot_ck_default="$boot_ck_cmdline" - fi - - # If boot kernel is using a default crashkernel, update - # installing kernel's crashkernel to new default value - if [[ "$boot_ck_cmdline" != "$inst_ck_default" ]] && [[ "$boot_ck_cmdline" == "$boot_ck_default" ]]; then - set_kernel_ck "$KERNEL_VERSION" "$inst_ck_default" - fi - - exit 0 - ;; -remove) - # If grub default value is upgraded when this kernel was installed, try downgrade it - grub_etc_ck=$(get_grub_etc_ck) - [[ $grub_etc_ck ]] || exit 0 - - removing_ck_conf=$(get_ck_default "$KERNEL_VERSION") - [[ $removing_ck_conf ]] || exit 0 - - highest_ck_default_kver=$(get_highest_ck_default_kver) || exit 0 - highest_ck_default=$(get_ck_default "$highest_ck_default_kver") - [[ $highest_ck_default ]] || exit 0 - - if ver_lt "$highest_ck_default_kver" "$KERNEL_VERSION"; then - if [[ $grub_etc_ck == "$removing_ck_conf" ]] && [[ $grub_etc_ck != "$highest_ck_default" ]]; then - set_grub_ck "$highest_ck_default" - fi - fi - + kdumpctl reset-crashkernel-for-installed_kernel "$KERNEL_VERSION" exit 0 ;; esac diff --git a/kdumpctl b/kdumpctl index 07e6f8b..66eefa5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1576,6 +1576,32 @@ reset_crashkernel_after_update() done } +reset_crashkernel_for_installed_kernel() +{ + local _installed_kernel _running_kernel _crashkernel _crashkernel_running + local _dump_mode_running _fadump_val_running + + if ! _installed_kernel=$(_find_kernel_path_by_release "$1"); then + exit 1 + fi + + if ! _running_kernel=$(_get_current_running_kernel_path); then + derror "Couldn't find current running kernel" + exit + fi + + _crashkernel=$(get_grub_kernel_boot_parameter "$_installed_kernel" crashkernel) + _crashkernel_running=$(get_grub_kernel_boot_parameter "$_running_kernel" crashkernel) + _dump_mode_running=$(get_dump_mode_by_kernel "$_running_kernel") + _fadump_val_running=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + + if [[ $_crashkernel != "$_crashkernel_running" ]]; then + if _update_grub "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then + echo "kexec-tools has reset $_installed_kernel to use the new default crashkernel value $_crashkernel_running" + fi + fi +} + if [[ ! -f $KDUMP_CONFIG_FILE ]]; then derror "Error: No kdump config file found!" exit 1 @@ -1641,6 +1667,11 @@ main() reset_crashkernel_after_update fi ;; + reset-crashkernel-for-installed_kernel) + if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then + reset_crashkernel_for_installed_kernel "$2" + fi + ;; *) dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" exit 1 From ddd428a1d0d72bee2a8459b1a81541bcd0676873 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 15 Dec 2021 21:45:18 +0800 Subject: [PATCH 529/806] set up kernel crashkernel for osbuild in kernel hook osbuild is a tool to build OS images. It uses bwrap to install packages inside a sandbox/container. Since the kernel package recommends kexec-tools which in turn recommends grubby, the installation order would be grubby -> kexec-tools -> kernel. So we can use the kernel hook 92-crashkernel.install provided by kexec-tools to set up kernel crashkernel for the target OS image. But in osbuild's case, there is no current running kernel and running `uname -r` in the container/sandbox actually returns the host kernel release. To set up kernel crashkernel for the OS image built by osbuild, a different logic is needed. We will check if kernel hook is running inside the osbuild container then set up kernel crashkernel only if osbuild hasn't specified a custome value. osbuild exposes [1] the container=bwrap-osbuild environment variable. According to [2], the environment variable is not inherited down the process tree, so we need to check /proc/1/environ to detect this environment variable to tell if the kernel hook is running inside a bwrap-osbuild container. After that we need to know if osbuild wants to use custom crashkernel value. This is done by checking if /etc/kernel/cmdline has crashkernel set [3]. /etc/kernel/cmdline is written before packages are installed. [1] https://github.com/osbuild/osbuild/pull/926 [2] https://systemd.io/CONTAINER_INTERFACE/ [3] https://bugzilla.redhat.com/show_bug.cgi?id=2024976#c5 Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kdumpctl b/kdumpctl index 66eefa5..a17bb34 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1576,6 +1576,11 @@ reset_crashkernel_after_update() done } +_is_osbuild() +{ + [[ $(sed -n -E 's/.*(^|\s)container=(\S*).*/\2/p' < /proc/1/environ) == bwrap-osbuild ]] +} + reset_crashkernel_for_installed_kernel() { local _installed_kernel _running_kernel _crashkernel _crashkernel_running @@ -1585,6 +1590,11 @@ reset_crashkernel_for_installed_kernel() exit 1 fi + if _is_osbuild && ! grep -q crashkernel= /etc/kernel/cmdline; then + reset_crashkernel "--kernel=$_installed_kernel" + return + fi + if ! _running_kernel=$(_get_current_running_kernel_path); then derror "Couldn't find current running kernel" exit From 0e162120b61c9b29a5ecbe7f3e447484b0a27b39 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 13 Dec 2021 12:44:14 +0800 Subject: [PATCH 530/806] update crashkernel-howto Update crashkernel-howto since crashkernel.default has been removed. The documentation is also simplified as a result. Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- crashkernel-howto.txt | 125 +++++++----------------------------------- 1 file changed, 20 insertions(+), 105 deletions(-) diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt index 20f50e0..1ba79ab 100644 --- a/crashkernel-howto.txt +++ b/crashkernel-howto.txt @@ -13,13 +13,14 @@ kdump after you updated the `crashkernel=` value or changed the dump target. Default crashkernel value ========================= -Latest kernel packages include a `crashkernel.default` file installed in kernel -modules folder, available as: +Latest kexec-tools provides "kdumpctl get-default-crashkernel" to retrieve +the default crashkernel value, - /usr/lib/modules//crashkernel.default + $ echo $(kdumpctl get-default-crashkernel) + 1G-4G:192M,4G-64G:256M,64G-102400T:512M -The content of the file will be taken as the default value of 'crashkernel=', or -take this file as a reference for setting crashkernel value manually. +It will be taken as the default value of 'crashkernel=', you can use +this value as a reference for setting crashkernel value manually. New installed system @@ -27,7 +28,7 @@ New installed system Anaconda is the OS installer which sets all the kernel boot cmdline on a newly installed system. If kdump is enabled during Anaconda installation, Anaconda -will use the `crashkernel.default` file as the default `crashkernel=` value on +will use the default crashkernel value as the default `crashkernel=` value on the newly installed system. Users can override the value during Anaconda installation manually. @@ -36,20 +37,11 @@ Users can override the value during Anaconda installation manually. Auto update of crashkernel boot parameter ========================================= -Following context in this section assumes all kernel packages have a -`crashkernel.default` file bundled, which is true for the latest official kernel -packages. For kexec-tools behavior with a kernel that doesn't have a -`crashkernel.default` file, please refer to the “Custom Kernel” section of this -doc. - -When `crashkernel=` is using the default value, kexec-tools will need to update -the `crashkernel=` value of new installed kernels, since the default value may -change in new kernel packages. - -kexec-tools does so by adding a kernel installation hook, which gets triggered -every time a new kernel is installed, so kexec-tools can do necessary checks and -updates. - +A new release of kexec-tools could update the default crashkernel value. +By default, kexec-tools would reset crashkernel to the new default value if it +detects old default crashkernel value is used by installed kernels. If you don't +want kexec-tools to update the old default crashkernel to the new default +crashkernel, you can change auto_reset_crashkernel to no in kdump.conf. Supported Bootloaders --------------------- @@ -59,92 +51,13 @@ on `grubby`. If other boot loaders are used, the user will have to update the `crashkernel=` value manually. -Updating kernel package ------------------------ - -When a new version of package kernel is released in the official repository, the -package will always come with a `crashkernel.default` file bundled. Kexec-tools -will act with following rules: - -If current boot kernel is using the default `crashkernel=` boot param value from -its `crashkernel.default` file, then kexec-tools will update new installed -kernel’s `crashkernel=` boot param using the value from the new installed -kernel’s `crashkernel.default` file. This ensures `crashkernel=` is always using -the latest default value. - -If current boot kernel's `crashkernel=` value is set to a non-default value, the -new installed kernel simply inherits this value. - -On systems using GRUB2 as the bootloader, each kernel has its own boot entry, -making it possible to set different `crashkernel=` boot param values for -different kernels. So kexec-tools won’t touch any already installed kernel's -boot param, only new installed kernel's `crashkernel=` boot param value will be -updated. - -But some utilities like `grub2-mkconfig` and `grubby` can override all boot -entry's boot params with the boot params value from the GRUB config file -`/etc/defaults/grub`, so kexec-tools will also update the GRUB config file in -case old `crashkernel=` value overrides new installed kernel’s boot param. - - -Downgrading kernel package --------------------------- - -When upgrading a kernel package, kexec-tools may update the `crashkernel=` value -in GRUB2 config file to the new value. So when downgrading the kernel package, -kexec-tools will also try to revert that update by setting GRUB2 config file’s -`crashkernel=` value back to the default value in the older kernel package. This -will only occur when the GRUB2 config file is using the default `crashkernel=` -value. - - -Custom kernel -============= - -To make auto crashkernel update more robust, kexec-tools will try to keep -tracking the default 'crashkernel=` value with kernels that don’t have a -`crashkernel.default` file, such kernels are referred to as “custom kernel” in -this doc. This is only a best-effort support to make it easier debugging and -testing the system. - -When installing a custom kernel that doesn’t have a `crashkernel.default` file, -the `crashkernel=` value will be simply inherited from the current boot kernel. - -When installing a new official kernel package and current boot kernel is a -custom kernel, since the boot kernel doesn’t have a `crashkernel.default` file, -kexec-tools will iterate installed kernels and check if the boot kernel -inherited the default value from any other existing kernels’ -`crashkernel.default` file. If a matching `crashkernel.default` file is found, -kexec-tools will update the new installed kernel `crashkernel=` boot param using -the value from the new installed kernel’s `crashkernel.default` file, ensures -the auto crashkernel value update won’t break over one or two custom kernel -installations. - -It is possible that the auto crashkernel value update will fail when custom -kernels are used. One example is a custom kernel inheriting the default -`crashkernel=` value from an older official kernel package, but later that -kernel package is uninstalled. So when booted with the custom kernel, -kexec-tools can't determine if the boot kernel is inheriting a default -`crashkernel=` value from any official build. In such a case, please refer to -the "Reset crashkernel to default value" section of this doc. - - Reset crashkernel to default value ================================== kexec-tools only perform the auto update of crashkernel value when it can confirm the boot kernel's crashkernel value is using its corresponding default -value or inherited from any installed kernel. - -kexec-tools may fail to determine if the boot kernel is using default -crashkernel value in some use cases: -- kexec-tools package is absent during a kernel package upgrade, and the new - kernel package’s `crashkernel.default` value has changed. -- Custom kernel is used and the kernel it inherits `crashkernel=` value from is - uninstalled. - -So it's recommended to reset the crashkernel value if users have uninstalled -kexec-tools or using a custom kernel. +value and auto_reset_crashkernel=yes in kdump.conf. In other cases, the user +can reset the crashkernel value by themselves. Reset using kdumpctl -------------------- @@ -152,21 +65,23 @@ Reset using kdumpctl To make it easier to reset the `crashkernel=` kernel cmdline to this default value properly, `kdumpctl` also provides a sub-command: - `kdumpctl reset-crashkernel []` + `kdumpctl reset-crashkernel [--kernel=path_to_kernel] [--reboot]` This command will read from the `crashkernel.default` file and reset bootloader's kernel cmdline to the default value. It will also update bootloader config if the bootloader has a standalone config file. User will have to reboot -the machine after this command to make it take effect. +the machine after this command to make it take effect if --reboot is not specified. +For ppc64le, an optional "[--fadump=[on|off|nocma]]" can also be specified to toggle +FADump on/off. Reset manually -------------- To reset the crashkernel value manually, it's recommended to use utils like `grubby`. A one liner script for resetting `crashkernel=` value of all installed -kernels to current boot kernel's crashkernel.default` is: +kernels to current boot kernel's crashkernel.default` is: - grubby --update-kernel ALL --args "$(cat /usr/lib/modules/$(uname -r)/crashkernel.default)" + grubby --update-kernel ALL --args "crashkernel=$(kdumpctl get-default-crashkernel)" Estimate crashkernel ==================== From 0311f6e25bec9994de2c6b156b5a568583aa8aae Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 5 Jan 2022 17:42:12 +0800 Subject: [PATCH 531/806] Set zstd as the default compression method for kdump initrd zstd has better compression ratio and time consumption balance. When no customized compression method specified in kdump.conf, we will use zstd as the default compression method. **The test method: I installed kexec-tools with and without the patch, executing the following command for 4 times, and calculate the averange time: $ rm -f /boot/initramfs-*kdump.img && time kdumpctl rebuild && \ ls -ail /boot/initramfs-*kdump.img **The test result: Bare metal x86_64 machine: dracut with squash module zlib lzo xz lz4 zstd real 10.6282 11.0398 11.395 8.6424 10.1676 user 9.8932 11.9072 14.2304 2.8286 8.6468 sys 3.523 3.4626 3.6028 3.5 3.4942 size of kdump.img 30575616 31419392 27102208 36666368 29236224 dracut without squash module zlib lzo xz lz4 zstd real 9.509 19.4876 11.6724 9.0338 10.267 user 10.6028 14.516 17.8662 4.0476 9.0936 sys 2.942 2.9184 3.0662 2.9232 3.0662 size of kdump.img 19247949 19958120 14505056 21112544 17007764 PowerVM hosted ppc64le VM: dracut with squash module | dracut without sqaush module zlib zstd | zlib zstd real 10.6742 10.7572 | 9.7676 10.5722 user 18.754 19.8338 | 20.7932 13.179 sys 1.8358 1.864 | 1.637 1.663 | size of | kdump.img 36917248 35467264 | 21441323 19007108 **discussion zstd has a better compression ratio and time consumption balance. v1 -> v2: Use kdump_get_conf_val() to get dracut_args values of kdump.conf v2 -> v3: Attached testing benchmark v3 -> v4: Re-measured and re-attached the testing benchmark of x86_64 and ppc64le. Changed regex '.*[[:space:]]' to '(^|[[:space:]])' v4 -> v5: Attacked lzo/xz/lz4 testing benchmark. v5 -> v6: Add zstd as required in kexec-tools.spec Hello Coiby, you may use "RELEASE=34 make test-run", for CONFIG_RD_ZSTD is enabled since fc-cloud-34 Acked-by: Coiby Xu Signed-off-by: Tao Liu --- kdump-lib.sh | 6 ++++++ kexec-tools.spec | 1 + mkdumprd | 4 ++++ mkfadumprd | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index b28db44..2d0e061 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -443,6 +443,12 @@ is_wdt_active() return 1 } +have_compression_in_dracut_args() +{ + [[ "$(kdump_get_conf_val dracut_args)" =~ \ + (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress)([[:space:]]|$) ]] +} + # If "dracut_args" contains "--mount" information, use it # directly without any check(users are expected to ensure # its correctness). diff --git a/kexec-tools.spec b/kexec-tools.spec index b2a0e20..381a13d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -70,6 +70,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool +Requires: zstd Recommends: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel diff --git a/mkdumprd b/mkdumprd index d87d588..9c26ecc 100644 --- a/mkdumprd +++ b/mkdumprd @@ -431,6 +431,10 @@ done <<< "$(kdump_read_conf)" handle_default_dump_target +if ! have_compression_in_dracut_args; then + add_dracut_arg "--compress" "zstd" +fi + if [[ -n $extra_modules ]]; then add_dracut_arg "--add-drivers" "$extra_modules" fi diff --git a/mkfadumprd b/mkfadumprd index b890f83..16fdacc 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -62,6 +62,10 @@ if is_squash_available; then _dracut_isolate_args+=(--add squash) fi +if ! have_compression_in_dracut_args; then + _dracut_isolate_args+=(--compress zstd) +fi + if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability" fi From 2bd59ee156ee7646e4c9fcacb72667e016e07ffe Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 6 Jan 2022 11:46:54 +0800 Subject: [PATCH 532/806] kdump-lib.sh: Escape '|' for 'failure_action|default' in is_dump_to_rootfs The '|' in 'failure_action|default' should be replaced with '\|' when passed to kdump_get_conf_val function. Because '|' needs to be escaped to mean OR operation in sed regex, otherwise it will consider 'failure_action|default' as a whole string. Fixes: ab1ef78 ("kdump-lib.sh: use kdump_get_conf_val to read config values") v1 -> v2: Rephased the commit message. Replaced " with '. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 2d0e061..1db55fd 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -108,7 +108,7 @@ get_block_dump_target() is_dump_to_rootfs() { - [[ $(kdump_get_conf_val "failure_action|default") == dump_to_rootfs ]] + [[ $(kdump_get_conf_val 'failure_action\|default') == dump_to_rootfs ]] } get_failure_action_target() From d5c31605f364e258fdef60e8482498941644ad6a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 6 Jan 2022 09:48:17 +0800 Subject: [PATCH 533/806] use grep -s to suppress error messages about nonexistent or unreadable files When a file doesn't exist or isn't readable, grep complains as follows, grep: /proc/cmdline: No such file or directory grep: /etc/kernel/cmdline: No such file or directory /proc/cmdline doesn't exist when installing package for an OS image and /etc/kernel/cmdline may not exist if osbuild doesn't want set custom kernel cmdline. Use "-s" to suppress the error messages. Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Fixes: ddd428a ("set up kernel crashkernel for osbuild in kernel hook") Signed-off-by: Coiby Xu Acked-by: Tao Liu --- kdumpctl | 2 +- kexec-tools.spec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kdumpctl b/kdumpctl index a17bb34..331af2f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1590,7 +1590,7 @@ reset_crashkernel_for_installed_kernel() exit 1 fi - if _is_osbuild && ! grep -q crashkernel= /etc/kernel/cmdline; then + if _is_osbuild && ! grep -qs crashkernel= /etc/kernel/cmdline; then reset_crashkernel "--kernel=$_installed_kernel" return fi diff --git a/kexec-tools.spec b/kexec-tools.spec index 381a13d..dffcce0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -261,7 +261,7 @@ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{d %pre # save the old default crashkernel values to /tmp/ when upgrading the package -if ! grep -q "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then +if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null @@ -303,7 +303,7 @@ fi # try to reset kernel crashkernel value to new default value when upgrading # the package -if ! grep -q "ostree" /proc/cmdline && [ $1 == 2 ]; then +if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ]; then kdumpctl reset-crashkernel-after-update rm /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le From ae0cbdf34a51b6b7f12d11f62d45339130750d01 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 7 Jan 2022 10:45:40 +0800 Subject: [PATCH 534/806] fix "kdump: Invalid kdump config option auto_reset_crashkernel" error kdumpctl only accepts a specified set of options. Add auto_reset_crashkernel to this set. Fixes: 73ced7f ("introduce the auto_reset_crashkernel option to kdump.conf") Signed-off-by: Coiby Xu Acked-by: Tao Liu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 331af2f..8107487 100755 --- a/kdumpctl +++ b/kdumpctl @@ -209,7 +209,7 @@ check_config() ext[234] | minix | btrfs | xfs | nfs | ssh) config_opt=_target ;; - sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes) ;; + sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; net | options | link_delay | disk_timeout | debug_mem_level | blacklist) derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." From 7de4a0d6c87375d6b980fce323e17e637296c0b0 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 10 Jan 2022 21:51:16 +0800 Subject: [PATCH 535/806] Set zstd as recommented for kexec-tools This patch will make zstd as recommended instead of required for kexec-tools. If zstd command/package is unavaliable, it can failback to invoke gzip when making kdump initramfs. Fixes: 0311f6e ("Set zstd as the default compression method for kdump initrd") Signed-off-by: Tao Liu Acked-by: Coiby Xu --- kdump-lib.sh | 5 +++++ kexec-tools.spec | 2 +- mkdumprd | 7 ++++++- mkfadumprd | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 1db55fd..ca086d7 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -31,6 +31,11 @@ is_squash_available() done } +is_zstd_command_available() +{ + [[ -x "$(command -v zstd)" ]] +} + perror_exit() { derror "$@" diff --git a/kexec-tools.spec b/kexec-tools.spec index dffcce0..7419723 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -70,7 +70,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool -Requires: zstd +Recommends: zstd Recommends: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel diff --git a/mkdumprd b/mkdumprd index 9c26ecc..593ec77 100644 --- a/mkdumprd +++ b/mkdumprd @@ -432,7 +432,12 @@ done <<< "$(kdump_read_conf)" handle_default_dump_target if ! have_compression_in_dracut_args; then - add_dracut_arg "--compress" "zstd" + # Here zstd is set as the default compression method. If squash module + # is available for dracut, libzstd will be used by mksquashfs. If + # squash module is unavailable, command zstd will be used instead. + if is_squash_available || is_zstd_command_available; then + add_dracut_arg "--compress" "zstd" + fi fi if [[ -n $extra_modules ]]; then diff --git a/mkfadumprd b/mkfadumprd index 16fdacc..86dfcee 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -62,8 +62,11 @@ if is_squash_available; then _dracut_isolate_args+=(--add squash) fi +# Same as setting zstd in mkdumprd if ! have_compression_in_dracut_args; then - _dracut_isolate_args+=(--compress zstd) + if is_squash_available || is_zstd_command_available; then + _dracut_isolate_args+=(--compress zstd) + fi fi if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then From 1e569fd8a88ea146ca31bd0ac467fe657521f9eb Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 13 Jan 2022 14:41:03 +0800 Subject: [PATCH 536/806] Release 2.0.23-2 --- kexec-tools.spec | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 7419723..849d09c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -399,6 +399,34 @@ done %endif %changelog +* Thu Jan 13 2022 Coiby - 2.0.23-2 +- fix "kdump: Invalid kdump config option auto_reset_crashkernel" error +- use grep -s to suppress error messages about nonexistent or unreadable files +- kdump-lib.sh: Escape '|' for 'failure_action|default' in is_dump_to_rootfs +- Set zstd as the default compression method for kdump initrd +- (origin/auto_reset_crashkernel, auto_reset_crashkernel) update crashkernel-howto +- set up kernel crashkernel for osbuild in kernel hook +- reset kernel crashkernel for the special case where the kernel is updated right after kexec-tools +- try to reset kernel crashkernel when kexec-tools updates the default crashkernel value +- introduce the auto_reset_crashkernel option to kdump.conf +- rewrite reset_crashkernel to support fadump and to used by RPM scriptlet +- fix incorrect usage of rpm-ostree to update kernel command line parameters +- add helper functions to get kernel path by kernel release and the path of current running kernel +- add helper functions to get dump mode +- add a helper function to read kernel cmdline parameter from grubby --info +- provide kdumpctl get-default-crashkernel for kdump_anaconda_addon and RPM scriptlet +- factor out kdump_get_arch_recommend_crashkernel +- update default crashkernel value +- kdumpctl: remove some legacy code +- dracut-early-kdump-module-setup.sh: install xargs and kdump-lib-initramfs.sh +- ppc64/ppc64le: drop cpu online rule in 40-redhat.rules in kdump initramfs +- kdump/ppc64: suppress the error message "Could not find a registered notification tool" from servicelog_notify +- add keytuils as a weak dependency for POWER +- Document/kexec-kdump-howto.txt: improve notes for kdump_pre and kdump_post scripts +- sysconfig: make kexec_file_load as default option on ppc64le +- sysconfig: make kexec_file_load as default option on aarch64 +- Enable zstd compression for makedumpfile in kexec-tools.spec + * Mon Nov 18 2021 Coiby - 2.0.23-1 - Update kexec-tools to 2.0.23 - Rebase makedumpfile to 1.7.0 From 72ef6929a6e309b0c9ded72442075a6ec773beb3 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 18 Jan 2022 10:42:00 +0800 Subject: [PATCH 537/806] move variable FENCE_KDUMP_SEND from kdump-lib.sh to kdump-lib-initramfs.sh Since kdump-lib-initramfs.sh is included by kdump-lib.sh, and FENCE_KDUMP_SEND is used by both 1st and 2nd kernel, moving FENCE_KDUMP_SEND from kdump-lib.sh to kdump-lib-initramfs.sh. Signed-off-by: Pingfan Liu Acked-by: Tao Liu --- kdump-lib-initramfs.sh | 2 ++ kdump-lib.sh | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c1fd75f..9be0fe9 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -5,6 +5,8 @@ DEFAULT_PATH="/var/crash/" KDUMP_CONFIG_FILE="/etc/kdump.conf" +FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" +FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" # Read kdump config in well formated style kdump_read_conf() diff --git a/kdump-lib.sh b/kdump-lib.sh index ca086d7..0e64f22 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -5,8 +5,6 @@ . /usr/lib/kdump/kdump-lib-initramfs.sh -FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" -FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" is_fadump_capable() From c480be7ccf8d63bed81f167bb4da7645f68c52a7 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Wed, 12 Jan 2022 19:24:26 +0800 Subject: [PATCH 538/806] spec: add hostname.rpm into Recommends list kexec-tools runs hostname binary in the case of fence_kdump. Since this is a trival dependency and should not block the kexec-tools installation if non-existent, using weak-dependency to resolve it. Signed-off-by: Pingfan Liu Acked-by: Tao Liu --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index 849d09c..9f7118b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -72,6 +72,7 @@ Requires: dracut-squash >= 050 Requires: ethtool Recommends: zstd Recommends: grubby +Recommends: hostname BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel BuildRequires: pkgconfig intltool gettext From bb380a92fa65e69a2303cd8c99d47165faa39112 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jan 2022 14:26:44 +0000 Subject: [PATCH 539/806] - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9f7118b..a1fbb97 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -400,6 +400,9 @@ done %endif %changelog +* Thu Jan 20 2022 Fedora Release Engineering - 2.0.23-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + * Thu Jan 13 2022 Coiby - 2.0.23-2 - fix "kdump: Invalid kdump config option auto_reset_crashkernel" error - use grep -s to suppress error messages about nonexistent or unreadable files From f4ab396574c7842ccbb366e95f8445e44e2b5f0f Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 30 Dec 2021 11:26:42 +0800 Subject: [PATCH 540/806] selftest: run-test.sh: wait for subprocess instead of kill it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run tests with 2 VMs, for example nfs/ssh kdump tests, client VM will do the crash and dump, server VM will do vmcore saving and if-vmcore-exists check. Previously, when client VM finishes running, run-test.sh will kill the lead background process, and then check if server VM has outputted "TEST PASSED" or "TEST FAILED" string. However it didn't wait for server VM to finish. As a result, the server VM's final outputs are not collected and checked, leaving the test result as "TEST RESULT NOT FOUND" sometimes. For example, the following is the pstree status of $(jobs -p) before it gets killed. We can see the server VM is still running: run-test.sh,172455 /root/kexec-tools/tests/scripts/run-test.sh --console nfs-early-kdump └─run-test.sh,172457 /root/kexec-tools/tests/scripts/run-test.sh --console... └─timeout,172480 --foreground 10m /root/kexec-tools/tests/scripts/run-qemu... └─qemu-system-x86,172481 -enable-kvm -cpu host -nodefaults... ├─{qemu-system-x86},172489 ├─{qemu-system-x86},172492 ├─{qemu-system-x86},172493 ├─{qemu-system-x86},172628 └─{qemu-system-x86},172629 In this patch, we will wait for $(jobs -p) to finish, in order to get the complete output of test results. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- tests/scripts/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index c3e94a3..1501db4 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -140,7 +140,7 @@ for test_case in $testcases; do if [ $console -eq 1 ]; then run_test_sync $script | tee $(get_test_console_file $script) - [ -n "$(jobs -p)" ] && kill $(jobs -p) + [ -n "$(jobs -p)" ] && wait $(jobs -p) else $(run_test_sync $script > $(get_test_console_file $script)) & watch_test_outputs $test_outputs From aa9e70349b9c1735a52549f863efc9b3dd87f94c Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 30 Dec 2021 11:26:43 +0800 Subject: [PATCH 541/806] selftest: Add early kdump test This patch will introduce early kdump test. It reuses the code of nfs kdump test, in order to setup 2 seperated VMs, one(the client) for trigger the early kdump and crash, the other(the server) for saving vmcore and check if vmcore exists. In order to minimize the repetted code, a soft link is made to copy the same server side code. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- .../testcases/nfs-early-kdump/0-server.sh | 1 + .../testcases/nfs-early-kdump/1-client.sh | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 120000 tests/scripts/testcases/nfs-early-kdump/0-server.sh create mode 100755 tests/scripts/testcases/nfs-early-kdump/1-client.sh diff --git a/tests/scripts/testcases/nfs-early-kdump/0-server.sh b/tests/scripts/testcases/nfs-early-kdump/0-server.sh new file mode 120000 index 0000000..3f888ce --- /dev/null +++ b/tests/scripts/testcases/nfs-early-kdump/0-server.sh @@ -0,0 +1 @@ +../nfs-kdump/0-server.sh \ No newline at end of file diff --git a/tests/scripts/testcases/nfs-early-kdump/1-client.sh b/tests/scripts/testcases/nfs-early-kdump/1-client.sh new file mode 100755 index 0000000..dfef4d8 --- /dev/null +++ b/tests/scripts/testcases/nfs-early-kdump/1-client.sh @@ -0,0 +1,46 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57" +} + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.77.1 + local earlykdump_path="/usr/lib/dracut/modules.d/99earlykdump/early-kdump.sh" + local tmp_file="/tmp/.tmp-file" + + if [[ ! -f $earlykdump_path ]]; then + test_failed "early-kdump.sh not exist!" + fi + + if [ $boot_count -eq 1 ]; then + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 7 -d 31 +final_action poweroff +EOF + + while ! ping -c 1 $nfs_server -W 1; do + sleep 1 + done + + kdumpctl start \ + || test_failed "Failed to start kdump" + grubby --update-kernel=ALL --args=rd.earlykdump + + cat << EOF > $tmp_file +echo 1 > /proc/sys/kernel/sysrq +echo c > /proc/sysrq-trigger +EOF + sed -i "/early_kdump_load$/r $tmp_file" $earlykdump_path + dracut -f --add earlykdump + kdumpctl restart \ + || test_failed "Failed to start earlykdump" + + sync + reboot + else + test_failed "Unexpected reboot" + fi +} From 748eb3a2a6b41bc74748f1f1845b91b77548e1d8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 9 Jan 2022 18:03:35 +0800 Subject: [PATCH 542/806] spec: only install mkfadumprd for ppc fadump is a ppc only feature, mkfadumprd is only needed for fadump, drop it for other arch. Reviewed-by: Philipp Rudo Signed-off-by: Kairui Song --- kexec-tools.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a1fbb97..0ef93f9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -188,7 +188,6 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd -install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 @@ -197,6 +196,7 @@ install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh %ifarch ppc64 ppc64le +install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd install -m 755 %{SOURCE35} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-migrate-action.sh install -m 755 %{SOURCE36} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-restart.sh %endif @@ -352,8 +352,10 @@ done %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 /usr/sbin/makedumpfile %endif -/usr/sbin/mkdumprd +%ifarch ppc64 ppc64le /usr/sbin/mkfadumprd +%endif +/usr/sbin/mkdumprd /usr/sbin/vmcore-dmesg %{_bindir}/* %{_datadir}/kdump From 99de77bba7ff7668edab3da723aad7c1c8395b5f Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Fri, 21 Jan 2022 16:08:47 +0800 Subject: [PATCH 543/806] Revert "Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel" There is a mechanism to keep memory consumption minimum, i.e. equal to trace_buf_size=1, until tracing by ftrace is actually started: tracing: keep ring buffer to minimum size till used https://github.com/torvalds/linux/commit/73c5162aa362a543793f4a957c6c536dcbaa89ce Since ftrace is usually never used in the kdump 2nd kernel, the kdump 2nd kernel behaves in the same way with or without trace_buf_size=1. So the issue which the patch want to solve never exists. Let's revert the patch for better maintainance and avoid confusion. ref link: https://bugzilla.redhat.com/show_bug.cgi?id=2034501#c20 This reverts commit f39000f. Signed-off-by: Tao Liu Acked-by: Coiby Xu --- kdump-lib.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 0e64f22..3256581 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -782,10 +782,6 @@ prepare_cmdline() fi done - # Remove trace_buf_size, trace_event - cmdline=$(remove_cmdline_param "$cmdline" trace_buf_size trace_event) - cmdline="${cmdline} trace_buf_size=1" - echo "$cmdline" } From ca5a33855ff637d53c70e71282e73f3c67d85c86 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Tue, 25 Jan 2022 10:54:49 +0100 Subject: [PATCH 544/806] s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel() Resolves: bz2025860 Upstream: git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git commit 186e7b0752d8fce1618fa37519671c834c46340e Author: Alexander Egorenkov Date: Wed Dec 15 18:48:53 2021 +0100 s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel() Starting with gcc 11.3, the C compiler will generate PLT-relative function calls even if they are local and do not require it. Later on during linking, the linker will replace all PLT-relative calls to local functions with PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is not being linked as a regular executable or shared library would have been, and therefore, all PLT-relative addresses remain in the generated purgatory object code unresolved. This in turn lets kexec-tools fail with "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types. Furthermore, the clang C compiler has always behaved like described above and this commit should fix the purgatory code built with the latter. Because the purgatory code is no regular executable or shared library, contains only calls to local functions and has no PLT, all R_390_PLT32DBL relocation entries can be resolved just like a R_390_PC32DBL one. * https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.html#AEN1699 Relocation entries of purgatory code generated with gcc 11.3 ------------------------------------------------------------ $ readelf -r purgatory/purgatory.o Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: Offset Info Type Sym. Value Sym. Name + Addend 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2 ... 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000 verify_sha256_digest + 2 000000000142 001700000014 R_390_PLT32DBL 0000000000000000 post_verification[...] + 2 Relocation entries of purgatory code generated with gcc 11.2 ------------------------------------------------------------ $ readelf -r purgatory/purgatory.o Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: Offset Info Type Sym. Value Sym. Name + Addend 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2 ... 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122 000000000130 000f00000013 R_390_PC32DBL 0000000000000000 verify_sha256_digest + 2 000000000146 001700000013 R_390_PC32DBL 0000000000000000 post_verification[...] + 2 Corresponding s390 kernel discussion: * https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux.ibm.com/T/#u Signed-off-by: Alexander Egorenkov Reported-by: Tao Liu Suggested-by: Philipp Rudo Reviewed-by: Philipp Rudo [hca@linux.ibm.com: changed commit message as requested by Philipp Rudo] Signed-off-by: Heiko Carstens Signed-off-by: Simon Horman v2: - Moved patch 601 -> 401 Signed-off-by: Philipp Rudo Acked-by: Coiby Xu --- ...oc_entries_in_machine_apply_elf_rel_.patch | 95 +++++++++++++++++++ kexec-tools.spec | 3 + 2 files changed, 98 insertions(+) create mode 100644 kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch diff --git a/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch b/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch new file mode 100644 index 0000000..10bc5ef --- /dev/null +++ b/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch @@ -0,0 +1,95 @@ +commit 186e7b0752d8fce1618fa37519671c834c46340e +Author: Alexander Egorenkov +Date: Wed Dec 15 18:48:53 2021 +0100 + + s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel() + + Starting with gcc 11.3, the C compiler will generate PLT-relative function + calls even if they are local and do not require it. Later on during linking, + the linker will replace all PLT-relative calls to local functions with + PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is + not being linked as a regular executable or shared library would have been, + and therefore, all PLT-relative addresses remain in the generated purgatory + object code unresolved. This in turn lets kexec-tools fail with + "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types. + + Furthermore, the clang C compiler has always behaved like described above + and this commit should fix the purgatory code built with the latter. + + Because the purgatory code is no regular executable or shared library, + contains only calls to local functions and has no PLT, all R_390_PLT32DBL + relocation entries can be resolved just like a R_390_PC32DBL one. + + * https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.html#AEN1699 + + Relocation entries of purgatory code generated with gcc 11.3 + ------------------------------------------------------------ + + $ readelf -r purgatory/purgatory.o + + Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 + 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2 + 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2 + 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2 + 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 + 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2 + ... + 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2 + 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 + 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000 verify_sha256_digest + 2 + 000000000142 001700000014 R_390_PLT32DBL 0000000000000000 + post_verification[...] + 2 + + Relocation entries of purgatory code generated with gcc 11.2 + ------------------------------------------------------------ + + $ readelf -r purgatory/purgatory.o + + Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: + Offset Info Type Sym. Value Sym. Name + Addend + 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 + 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2 + 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2 + 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2 + 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 + 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2 + ... + 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2 + 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122 + 000000000130 000f00000013 R_390_PC32DBL 0000000000000000 verify_sha256_digest + 2 + 000000000146 001700000013 R_390_PC32DBL 0000000000000000 post_verification[...] + 2 + + Corresponding s390 kernel discussion: + * https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux.ibm.com/T/#u + + Signed-off-by: Alexander Egorenkov + Reported-by: Tao Liu + Suggested-by: Philipp Rudo + Reviewed-by: Philipp Rudo + [hca@linux.ibm.com: changed commit message as requested by Philipp Rudo] + Signed-off-by: Heiko Carstens + Signed-off-by: Simon Horman + +diff --git a/kexec/arch/s390/kexec-elf-rel-s390.c b/kexec/arch/s390/kexec-elf-rel-s390.c +index a5e1b73455785ae3bc3aa72b3beee13ae202e82f..91ba86a9991dad4271b834fc3b24861c40309e52 100644 +--- a/kexec/arch/s390/kexec-elf-rel-s390.c ++++ b/kexec/arch/s390/kexec-elf-rel-s390.c +@@ -56,6 +56,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), + case R_390_PC16: /* PC relative 16 bit. */ + case R_390_PC16DBL: /* PC relative 16 bit shifted by 1. */ + case R_390_PC32DBL: /* PC relative 32 bit shifted by 1. */ ++ case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */ + case R_390_PC32: /* PC relative 32 bit. */ + case R_390_PC64: /* PC relative 64 bit. */ + val -= address; +@@ -63,7 +64,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), + *(unsigned short *) loc = val; + else if (r_type == R_390_PC16DBL) + *(unsigned short *) loc = val >> 1; +- else if (r_type == R_390_PC32DBL) ++ else if (r_type == R_390_PC32DBL || r_type == R_390_PLT32DBL) + *(unsigned int *) loc = val >> 1; + else if (r_type == R_390_PC32) + *(unsigned int *) loc = val; diff --git a/kexec-tools.spec b/kexec-tools.spec index 0ef93f9..aabb369 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -103,6 +103,7 @@ Requires: systemd-udev%{?_isa} # # Patches 401 through 500 are meant for s390 kexec-tools enablement # +Patch401: ./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch # # Patches 501 through 600 are meant for ARM kexec-tools enablement @@ -126,6 +127,8 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch401 -p1 + %ifarch ppc %define archdef ARCH=ppc %endif From 6a3ce83a60c7107112d576223175410b180a41a0 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 19 Jan 2022 11:16:29 +0800 Subject: [PATCH 545/806] fix the error of parsing the container environ variable for osbuild The environment variable entries in /proc/[pid]/environ are separated by null bytes instead of by spaces. Update the sed regex to fix this issue. Note that, 1. this patch also fixes a issue which is kdumpctl would try to reset crashkernel even osbuild has provided custom crashkernel value. 2. kernel hook 92-crashkernel.install installed by kexec-tools is guaranteed to be ran by kernel-install. kexec-tools doesn't recommend kernel so there is no guarantee kernel is installed after kexec-tools. But dnf invokes kernel-install in the posttrans scriptlet (of kernel-core) which is always ran after all packages including kexec-tools and kernel in a dnf transaction. 3. To be able to do unit tests, the logic of reading environment variable has been extracted as a separate function. Fixes: ddd428a ("set up kernel crashkernel for osbuild in kernel hook") Signed-off-by: Coiby Xu Reviewed-by: Pingfan Liu Reviewed-by: Philipp Rudo --- kdumpctl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kdumpctl b/kdumpctl index 8107487..3ccfa97 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1576,9 +1576,19 @@ reset_crashkernel_after_update() done } +# read the value of an environ variable from given environ file path +# +# The environment variable entries in /proc/[pid]/environ are separated +# by null bytes instead of by spaces. +read_proc_environ_var() +{ + local _environ_path=$1 _var=$2 + sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path" +} + _is_osbuild() { - [[ $(sed -n -E 's/.*(^|\s)container=(\S*).*/\2/p' < /proc/1/environ) == bwrap-osbuild ]] + [[ $(read_proc_environ_var container /proc/1/environ) == bwrap-osbuild ]] } reset_crashkernel_for_installed_kernel() @@ -1590,8 +1600,10 @@ reset_crashkernel_for_installed_kernel() exit 1 fi - if _is_osbuild && ! grep -qs crashkernel= /etc/kernel/cmdline; then - reset_crashkernel "--kernel=$_installed_kernel" + if _is_osbuild; then + if ! grep -qs crashkernel= /etc/kernel/cmdline; then + reset_crashkernel "--kernel=$_installed_kernel" + fi return fi From c67a836cde781fecc8b785128132f4c8c2fd0190 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 25 Jan 2022 16:16:58 +0800 Subject: [PATCH 546/806] remove the upper bound of 102400T for the range in default crashkernel This patch makes the default crashkernel value consistent with previous one. Fixes: 105c016 ("factor out kdump_get_arch_recommend_crashkernel") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 3256581..c6bdd2e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -857,7 +857,6 @@ kdump_get_arch_recommend_crashkernel() fi fi - _ck_cmdline=${_ck_cmdline//-:/-102400T:} echo -n "$_ck_cmdline" } @@ -873,6 +872,7 @@ kdump_get_arch_recommend_size() fi sys_mem=$(get_system_size) _ck_cmdline=$(kdump_get_arch_recommend_crashkernel) + _ck_cmdline=${_ck_cmdline//-:/-102400T:} get_recommend_size "$sys_mem" "$ck_cmdline" } From 2df55984f66bc2a67c881eab0e33139d2ddc0461 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 26 Jan 2022 08:48:18 +0800 Subject: [PATCH 547/806] fix broken kdump_get_arch_recommend_size shellcheck finds the following problem, $ shellcheck kdump-lib.sh In kdump-lib.sh line 876: get_recommend_size "$sys_mem" "$ck_cmdline" ^---------^ SC2154: ck_cmdline is referenced but not assigned (did you mean '_ck_cmdline'?). s/ck_cmdline/_ck_cmdline to fix kdump_get_arch_recommend_size. Note s/sys_mem/_sys_mem as well to make the changes consistent. Fixes: 105c016 ("factor out kdump_get_arch_recommend_crashkernel") Signed-off-by: Coiby Xu Acked-by: Tao Liu --- kdump-lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index c6bdd2e..3e912cc 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -864,16 +864,16 @@ kdump_get_arch_recommend_crashkernel() # $1: kernel version, if not set, will defaults to $(uname -r) kdump_get_arch_recommend_size() { - local _ck_cmdline + local _ck_cmdline _sys_mem if ! [[ -r "/proc/iomem" ]]; then echo "Error, can not access /proc/iomem." return 1 fi - sys_mem=$(get_system_size) + _sys_mem=$(get_system_size) _ck_cmdline=$(kdump_get_arch_recommend_crashkernel) _ck_cmdline=${_ck_cmdline//-:/-102400T:} - get_recommend_size "$sys_mem" "$ck_cmdline" + get_recommend_size "$_sys_mem" "$_ck_cmdline" } # Print all underlying crypt devices of a block device From d6298a1dec83aa83df19cd994d7ace976822d3b9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 26 Jan 2022 15:10:50 +0800 Subject: [PATCH 548/806] Release 2.0.23-4 --- kexec-tools.spec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index aabb369..1750db0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -405,6 +405,16 @@ done %endif %changelog +* Wed Jan 26 2022 Coiby - 2.0.23-4 +- fix broken kdump_get_arch_recommend_size +- remove the upper bound of 102400T for the range in default crashkernel +- fix the error of parsing the container environ variable for osbuild +- s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel() +- Revert "Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel" +- spec: only install mkfadumprd for ppc +- selftest: Add early kdump test +- selftest: run-test.sh: wait for subprocess instead of kill it + * Thu Jan 20 2022 Fedora Release Engineering - 2.0.23-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild From 5111c01334046dd4176d4446075b02106fb9db4a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 7 Feb 2022 08:08:01 +0800 Subject: [PATCH 549/806] fix the mistake of swapping function parameters of read_proc_environ_var _is_osbuild fails because it expects the 1st and 2nd function parameter to be the environment variable and environ file path respectively. Fix it by swapping the parameters in read_proc_environ_var. Note the osbuild environ file path is defined in _OSBUILD_ENVIRON_PATH so _is_osbuild can be unit-tested by overwriting _OSBUILD_ENVIRON_PATH. Fixes: 6a3ce83 ("fix the error of parsing the container environ variable for osbuild") Signed-off-by: Coiby Xu Reviewed-by: Pingfan Liu --- kdumpctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 3ccfa97..bf74c75 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1580,15 +1580,19 @@ reset_crashkernel_after_update() # # The environment variable entries in /proc/[pid]/environ are separated # by null bytes instead of by spaces. +# +# $1: environment variable +# $2: environ file path read_proc_environ_var() { - local _environ_path=$1 _var=$2 + local _var=$1 _environ_path=$2 sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path" } +_OSBUILD_ENVIRON_PATH='/proc/1/environ' _is_osbuild() { - [[ $(read_proc_environ_var container /proc/1/environ) == bwrap-osbuild ]] + [[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]] } reset_crashkernel_for_installed_kernel() From 41b8f9528c8ed89c68ad59750c18f032b5675a06 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 9 Feb 2022 08:04:39 +0800 Subject: [PATCH 550/806] fix incorrect usage of _get_all_kernels_from_grubby It's found that the kernel cmdline crashkernel=auto doesn't get updated when upgrading kexec-tools. This happens because _get_all_kernels_from_grubby is called with no argument by reset_crashkernel_after_update. When retrieving all kernel paths on the system, "grubby --info ALL" should be used. Fix this error by passing "ALL" argument. Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Reported-by: Jie Li Signed-off-by: Coiby Xu Reviewed-by: Tao Liu --- kdumpctl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index bf74c75..9fd76ac 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1382,6 +1382,11 @@ _valid_grubby_kernel_path() [[ -n "$1" ]] && grubby --info="$1" > /dev/null 2>&1 } +# return all the kernel paths given a grubby kernel-path +# +# $1: kernel path accepted by grubby, e.g. DEFAULT, ALL, +# /boot/vmlinuz-`uname -r` +# return: kernel paths separated by space _get_all_kernels_from_grubby() { local _kernels _line _kernel_path _grubby_kernel_path=$1 @@ -1557,7 +1562,7 @@ reset_crashkernel_after_update() _crashkernel_vals[new_kdump]=$(get_default_crashkernel kdump) _crashkernel_vals[new_fadump]=$(get_default_crashkernel fadump) - for _kernel in $(_get_all_kernels_from_grubby); do + for _kernel in $(_get_all_kernels_from_grubby ALL); do _crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) if [[ $_crashkernel == auto ]]; then reset_crashkernel "--kernel=$_kernel" From 59fcb8ae5b13d776f5a1966173b57d6404699aae Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 14 Feb 2022 12:07:08 +0800 Subject: [PATCH 551/806] Release 2.0.23-5 Signed-off-by: Coiby Xu --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1750db0..ac134da 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -405,6 +405,10 @@ done %endif %changelog +* Mon Feb 14 2022 Coiby - 2.0.23-5 +- fix incorrect usage of _get_all_kernels_from_grubby +- fix the mistake of swapping function parameters of read_proc_environ_var + * Wed Jan 26 2022 Coiby - 2.0.23-4 - fix broken kdump_get_arch_recommend_size - remove the upper bound of 102400T for the range in default crashkernel From 2bbc7512a2f2cf953ea047f54bd590d4d285b658 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 16 Feb 2022 14:26:38 +0800 Subject: [PATCH 552/806] kdump-lib.sh: Check the output of blkid with sed instead of eval Previously the output of blkid is not checked. If the output is empty, the eval will report the following error message: /lib/kdump/kdump-lib.sh: eval: line 925: syntax error near unexpected token `;' /lib/kdump/kdump-lib.sh: eval: line 925: `; echo $TYPE' For example, we can observe such a failing when blkid is invoked against a lvm thinpool block device: $ blkid -u filesystem,crypto -o export -- "/dev/block/253\:2" $ echo $? 2 $ udevadm info /dev/block/253\:2|grep S\: S: mapper/vg00-thinpoll_tmeta In this patch, we will use sed instead of eval, to output the fstype of block device if any. Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 3e912cc..4ed5035 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -885,7 +885,8 @@ get_luks_crypt_dev() [[ -b /dev/block/$1 ]] || return 1 - _type=$(eval "$(blkid -u filesystem,crypto -o export -- "/dev/block/$1"); echo \$TYPE") + _type=$(blkid -u filesystem,crypto -o export -- "/dev/block/$1" | \ + sed -n -E "s/^TYPE=(.*)$/\1/p") [[ $_type == "crypto_LUKS" ]] && echo "$1" for _x in "/sys/dev/block/$1/slaves/"*; do From 311b5b100b512134cddb189f46c8bb85d74f9275 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 11 Feb 2022 13:11:17 +0800 Subject: [PATCH 553/806] update kernel crashkernel in posttrans RPM scriptlet when updating kexec-tools When doing in-place upgrading using leapp on x86_64, kdumpcl can't acquire instance lock when running in %post RPM scriplet on x86_64, localhost upgrade[1306]: /bin/kdumpctl: line 49: /var/lock/kdump: No such file or directory localhost upgrade[1306]: kdump: Create file lock failed and running "touch /var/lock/dkump" also fails with "No such file or directory". Thus kdumpctl can't be run in %post scriptlet. But kdumpctl can be run in %posttrans RPM scriplet. Besides, it's better to update crashkernel after the kernel has been updated. So let's update kernel crashkernel in the %posttrans scriptlet which will be run in the end of a transaction i.e. after the kernel has been updated. Note for %posttrans scriptlet, "$1 == 1" means both installing a new package and upgrading a package. [1] https://github.com/apptainer/singularity/issues/2386#issuecomment-474747054 Reported-by: Jie Li Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kexec-tools.spec | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index ac134da..6b7ef14 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -305,19 +305,6 @@ then mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump fi -# try to reset kernel crashkernel value to new default value when upgrading -# the package -if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ]; then - kdumpctl reset-crashkernel-after-update - rm /tmp/old_default_crashkernel 2>/dev/null -%ifarch ppc64 ppc64le - rm /tmp/old_default_crashkernel_fadump 2>/dev/null -%endif - # dnf would complain about the exit code not being 0. To keep it happy, - # always return 0 - : -fi - %postun %systemd_postun_with_restart kdump.service @@ -350,6 +337,21 @@ do fi done +%posttrans +# try to reset kernel crashkernel value to new default value when upgrading +# the package +if ! grep -qs "ostree" /proc/cmdline && [ $1 == 1 ]; then + kdumpctl reset-crashkernel-after-update + rm /tmp/old_default_crashkernel 2>/dev/null +%ifarch ppc64 ppc64le + rm /tmp/old_default_crashkernel_fadump 2>/dev/null +%endif + # dnf would complain about the exit code not being 0. To keep it happy, + # always return 0 + : +fi + + %files /usr/sbin/kexec %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 From 37f4f2c1f6f1304e1b58604a788c57c51508eead Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 15 Feb 2022 13:24:19 +0800 Subject: [PATCH 554/806] address the case where there are multiple values for the same kernel arg There is the case where there are multiple entries of the same parameter on the command line, e.g. GRUB_CMDLINE_LINUX="crashkernel=110M crashkernel=220M fadump=on crashkernel=330M". In such an situation _update_kernel_cmdline_in_grub_etc_default only updates/removes the last entry which is usually not what you want as the kernel (for crashkernel) takes the last entry it can find. Thus make sure the case with multiple entries of the same parameter is handled properly by removing all occurrences of given parameter first. Note 1. sed command group and conditional control has been used to get rid of grep. 2. Fully supporting kernel cmdline as documented in Documentation/admin-guide/kernel-parameters.rst is complex and in foreseeable future a full implementation is not needed. So simply document the unsupported cases instead. Fixes: 140da74 ("rewrite reset_crashkernel to support fadump and to used by RPM scriptlet") Reported-by: Philipp Rudo Suggested-by: Philipp Rudo Reviewed-by: Philipp Rudo --- kdumpctl | 54 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/kdumpctl b/kdumpctl index 9fd76ac..1c94405 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1399,25 +1399,49 @@ _get_all_kernels_from_grubby() } GRUB_ETC_DEFAULT="/etc/default/grub" -# modify the kernel command line parameter in default grub conf +# Update a kernel parameter in default grub conf +# +# If a value is specified, it will be inserted in the end. Otherwise it +# would remove given kernel parameter. +# +# Note this function doesn't address the following cases, +# 1. The kernel ignores everything on the command line after a '--'. So +# simply adding the new entry to the end will fail if the cmdline +# contains a --. +# 2. If the value for a parameter contains spaces it can be quoted using +# double quotes, for example param="value with spaces". This will +# break the [^[:space:]\"] regex for the value. +# 3. Dashes and underscores in the parameter name are equivalent. So +# some_parameter and some-parameter are identical. +# 4. Some parameters, e.g. efivar_ssdt, can be given multiple times. +# 5. Some kernel parameters, e.g. quiet, doesn't have value # # $1: the name of the kernel command line parameter -# $2: new value. If empty, the parameter would be removed -_update_kernel_cmdline_in_grub_etc_default() +# $2: new value. If empty, given parameter would be removed +_update_kernel_arg_in_grub_etc_default() { - local _para=$1 _val=$2 _para_val _regex + local _para=$1 _val=$2 _para_val if [[ -n $_val ]]; then _para_val="$_para=$_val" fi - _regex='^(GRUB_CMDLINE_LINUX=.*)([[:space:]"])'"$_para"'=[^[:space:]"]*(.*)$' - if grep -q -E "$_regex" "$GRUB_ETC_DEFAULT"; then - sed -i -E 's/'"$_regex"'/\1\2'"$_para_val"'\3/' "$GRUB_ETC_DEFAULT" - elif [[ -n $_para_val ]]; then - # If the kernel parameter doesn't exist, put it in the first - sed -i -E 's/^(GRUB_CMDLINE_LINUX=")/\1'"$_para_val"' /' "$GRUB_ETC_DEFAULT" - fi + # Update the command line /etc/default/grub, i.e. + # on the line that starts with 'GRUB_CMDLINE_LINUX=', + # 1) remove $para=$val if the it's the first arg + # 2) remove all occurences of $para=$val + # 3) insert $_para_val to end + # 4) remove duplicate spaces left over by 1) or 2) or 3) + # 5) remove space at the beginning of the string left over by 1) or 2) or 3) + # 6) remove space at the end of the string left over by 1) or 2) or 3) + sed -i -E "/^GRUB_CMDLINE_LINUX=/ { + s/\"${_para}=[^[:space:]\"]*/\"/g; + s/[[:space:]]+${_para}=[^[:space:]\"]*/ /g; + s/\"$/ ${_para_val}\"/ + s/[[:space:]]+/ /g; + s/(\")[[:space:]]+/\1/g; + s/[[:space:]]+(\")/\1/g; + }" "$GRUB_ETC_DEFAULT" } reset_crashkernel() @@ -1496,10 +1520,12 @@ reset_crashkernel() # - set the dump mode as kdump for non-ppc64le cases # - retrieved the default crashkernel value for given dump mode if [[ $_grubby_kernel_path == ALL && -n $_dump_mode ]]; then - _update_kernel_cmdline_in_grub_etc_default crashkernel "$_crashkernel" + _update_kernel_arg_in_grub_etc_default crashkernel "$_crashkernel" # remove the fadump if fadump is disabled - [[ $_fadump_val == off ]] && _fadump_val="" - _update_kernel_cmdline_in_grub_etc_default fadump "$_fadump_val" + if [[ $_fadump_val == off ]]; then + _fadump_val="" + fi + _update_kernel_arg_in_grub_etc_default fadump "$_fadump_val" fi # If kernel-path not specified, either From 6d4062a936694b7cab7e0c536414b4d5b6ab8668 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 16 Feb 2022 09:42:54 +0800 Subject: [PATCH 555/806] try to update the crashkernel in GRUB_ETC_DEFAULT after kexec-tools updates the default crashkernel value If GRUB_ETC_DEFAULT use crashkernel=auto or crashkernel=OLD_DEFAULT_CRASHKERNEL, it should be updated as well. Add a helper function to read kernel cmdline parameter from GRUB_ETC_DEFAULT. This function is used to read kernel cmdline parameter like fadump or crashkernel. Reviewed-by: Philipp Rudo --- kdumpctl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/kdumpctl b/kdumpctl index 1c94405..ac6ffeb 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1444,6 +1444,16 @@ _update_kernel_arg_in_grub_etc_default() }" "$GRUB_ETC_DEFAULT" } +# Read the kernel arg in default grub conf. + +# Note reading a kernel parameter that doesn't have a value isn't supported. +# +# $1: the name of the kernel command line parameter +_read_kernel_arg_in_grub_etc_default() +{ + sed -n -E "s/^GRUB_CMDLINE_LINUX=.*[[:space:]\"]${1}=([^[:space:]\"]*).*$/\1/p" "$GRUB_ETC_DEFAULT" +} + reset_crashkernel() { local _opt _val _dump_mode _fadump_val _reboot _grubby_kernel_path _kernel _kernels @@ -1577,6 +1587,34 @@ reset_crashkernel() 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 + + _crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel) + + 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" + fi +} + # shellcheck disable=SC2154 # false positive when dereferencing an array reset_crashkernel_after_update() { @@ -1605,6 +1643,8 @@ reset_crashkernel_after_update() fi fi done + + update_crashkernel_in_grub_etc_default_after_update } # read the value of an environ variable from given environ file path From 7141d044c8880815f308e61f612b710b7bc8a9a3 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 1 Mar 2022 13:09:00 +0800 Subject: [PATCH 556/806] kdumpctl: sync the $TARGET_INITRD after rebuild There is a system-wide sync call at the end of mkdumprd, move it to kdumpctl after rebuild initrd and add another one for mkfadumprd. Sync only the $TARGET_INITRD to avoid a system-wide sync taking too long on a system with high disk activity. Also update the sync in kdumpctl:restore_default_initrd which will mv the $DEFAULT_INITRD_BAK to $DEFAULT_INITRD. Signed-off-by: Lichen Liu Reviewed-by: Philipp Rudo --- kdumpctl | 4 +++- mkdumprd | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index ac6ffeb..1869753 100755 --- a/kdumpctl +++ b/kdumpctl @@ -79,6 +79,7 @@ rebuild_fadump_initrd() return 1 fi + sync -f "$TARGET_INITRD" return 0 } @@ -100,6 +101,7 @@ rebuild_kdump_initrd() dwarn "Tips: If early kdump is enabled, also require rebuilding the system initramfs to make the changes take effect for early kdump." fi + sync -f "$TARGET_INITRD" return 0 } @@ -180,7 +182,7 @@ restore_default_initrd() rm -f $INITRD_CHECKSUM_LOCATION if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then derror "Restoring original initrd as fadump mode is disabled." - sync + sync -f "$DEFAULT_INITRD" fi fi fi diff --git a/mkdumprd b/mkdumprd index 593ec77..5996d50 100644 --- a/mkdumprd +++ b/mkdumprd @@ -458,7 +458,3 @@ if ! is_fadump_capable; then fi dracut "${dracut_args[@]}" "$@" - -_rc=$? -sync -exit $_rc From 8736aa5bb359e0fccbb07919e49f68c22299c55a Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 16:19:40 +0100 Subject: [PATCH 557/806] kdumpctl/estimate: Fix unnecessary warning do_estimate prints the warning that the reserved crashkernel is lower than the recommended one even then when both values are identical. This might cause confusion. So omit printing the warning when both values are equal. Signed-off-by: Philipp Rudo Acked-by: Coiby Xu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 1869753..b7922a6 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1270,7 +1270,7 @@ do_estimate() done fi - if [[ $reserved_size -le $recommended_size ]]; then + if [[ $reserved_size -lt $recommended_size ]]; then echo "WARNING: Current crashkernel size is lower than recommended size $((recommended_size / size_mb))M." fi } From 5947707682e7de478aa1e1b41006ce50f84699cc Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:46:58 +0100 Subject: [PATCH 558/806] kdump-capture.service: switch to journal for stdout Using syslog for StandardOutput in a service file was deprecated in systemd v246 with commit f3dc6af20f ("core: automatically update StandardOuput=syslog to =journal (and similar for StandardError=)"). Thus the following warnings are printed in the crash kernel when creating a dump. systemd[1]: /usr/lib/systemd/system/kdump-capture.service:23: Standard output type syslog is obsolete, automatically updating to journal. Please update your unit file, and consider removing the setting altogether. systemd[1]: /usr/lib/systemd/system/kdump-capture.service:24: Standard output type syslog+console is obsolete, automatically updating to journal+console. Please update your unit file, and consider removing the setting altogether. Fix this by redirecting the stdout and stderr to the journal. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- dracut-kdump-capture.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service index 3f20aba..7109169 100644 --- a/dracut-kdump-capture.service +++ b/dracut-kdump-capture.service @@ -20,8 +20,8 @@ Environment=NEWROOT=/sysroot Type=oneshot ExecStart=/bin/kdump.sh StandardInput=null -StandardOutput=syslog -StandardError=syslog+console +StandardOutput=journal +StandardError=journal+console KillMode=process RemainAfterExit=yes From aa9bb8f8cef734fb1f6ab36ccaaa8936edb4f467 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:46:59 +0100 Subject: [PATCH 559/806] kdump-lib: fix typo in variable name in prepare_kdump_bootinfo s/defaut/default/. While at it declare it with the other local variables as local. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdump-lib.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 4ed5035..5b1656e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -640,7 +640,7 @@ prepare_kexec_args() prepare_kdump_bootinfo() { local boot_img boot_imglist boot_dirlist boot_initrdlist - local machine_id + local machine_id dir img default_initrd_base var_target_initrd_dir if [[ -z $KDUMP_KERNELVER ]]; then KDUMP_KERNELVER="$(uname -r)" @@ -677,8 +677,8 @@ prepare_kdump_bootinfo() boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" for initrd in $boot_initrdlist; do if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then - defaut_initrd_base="$initrd" - DEFAULT_INITRD="$KDUMP_BOOTDIR/$defaut_initrd_base" + default_initrd_base="$initrd" + DEFAULT_INITRD="$KDUMP_BOOTDIR/$default_initrd_base" break fi done @@ -686,12 +686,12 @@ prepare_kdump_bootinfo() # Create kdump initrd basename from default initrd basename # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img # initrd => initrdkdump - if [[ -z $defaut_initrd_base ]]; then + if [[ -z $default_initrd_base ]]; then kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img - elif [[ $defaut_initrd_base == *.* ]]; then - kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} + elif [[ $default_initrd_base == *.* ]]; then + kdump_initrd_base=${default_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} else - kdump_initrd_base=${defaut_initrd_base}kdump + kdump_initrd_base=${default_initrd_base}kdump fi # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable From b49083126fcdd5be8cb7d84e0048ac2adddb6aed Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:00 +0100 Subject: [PATCH 560/806] kdumpctl: remove unnecessary uses of $? Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/kdumpctl b/kdumpctl index b7922a6..35fd6e0 100755 --- a/kdumpctl +++ b/kdumpctl @@ -86,7 +86,6 @@ rebuild_fadump_initrd() check_earlykdump_is_enabled() { grep -q -w "rd.earlykdump" /proc/cmdline - return $? } rebuild_kdump_initrd() @@ -117,8 +116,6 @@ rebuild_initrd() else rebuild_kdump_initrd fi - - return $? } #$1: the files to be checked with IFS=' ' @@ -584,7 +581,6 @@ check_rebuild() dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd - return $? } # On ppc64le LPARs, the keys trusted by firmware do not end up in @@ -815,8 +811,6 @@ check_current_status() else check_current_kdump_status fi - - return $? } save_raw() @@ -945,7 +939,6 @@ check_dump_feasibility() fi check_kdump_feasibility - return $? } start_fadump() @@ -967,8 +960,6 @@ start_dump() else load_kdump fi - - return $? } check_failure_action_config() @@ -1077,7 +1068,7 @@ reload() if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then reload_fadump - return $? + return else if ! stop_kdump; then derror "Stopping kdump: [FAILED]" @@ -1141,7 +1132,7 @@ reload_fadump() # to handle such scenario. if stop_fadump; then start_fadump - return $? + return fi fi @@ -1180,7 +1171,6 @@ rebuild() dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd - return $? } do_estimate() @@ -1787,5 +1777,3 @@ single_instance_lock exec 9<&- main "$@" ) - -exit $? From 7cd3f232d50c76bb5c6bf0b3175cc2c36c2f3351 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:01 +0100 Subject: [PATCH 561/806] kdump-lib-initramfs: merge definitions for default ssh key There are currently three identical definitions for the default ssh key. Combine them into one in kdump-lib-initramfs.sh. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- dracut-kdump.sh | 2 +- kdump-lib-initramfs.sh | 1 + kdumpctl | 2 +- mkdumprd | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b69bc98..b17455a 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -22,7 +22,7 @@ FAILURE_ACTION="systemctl reboot -f" DATEDIR=$(date +%Y-%m-%d-%T) HOST_IP='127.0.0.1' DUMP_INSTRUCTION="" -SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +SSH_KEY_LOCATION=$DEFAULT_SSHKEY DD_BLKSIZE=512 FINAL_ACTION="systemctl reboot -f" KDUMP_PRE="" diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 9be0fe9..84e6bf7 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -4,6 +4,7 @@ # not be the default shell. Any code added must be POSIX compliant. DEFAULT_PATH="/var/crash/" +DEFAULT_SSHKEY="/root/.ssh/kdump_id_rsa" KDUMP_CONFIG_FILE="/etc/kdump.conf" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" diff --git a/kdumpctl b/kdumpctl index 35fd6e0..7b01cd3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -10,7 +10,7 @@ MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" SAVE_PATH=/var/crash -SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +SSH_KEY_LOCATION=$DEFAULT_SSHKEY INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DUMP_TARGET="" DEFAULT_INITRD="" diff --git a/mkdumprd b/mkdumprd index 5996d50..3e250e0 100644 --- a/mkdumprd +++ b/mkdumprd @@ -22,7 +22,7 @@ if ! dlog_init; then exit 1 fi -SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +SSH_KEY_LOCATION=$DEFAULT_SSHKEY SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 From 247b3dd297f1ee2224af2d3b838019af428c387e Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:02 +0100 Subject: [PATCH 562/806] kdumpctl: fix comment in check_and_wait_network_ready The time out was increased to 180 seconds in 680c0d3 ("kdumpctl: distinguish the failed reason of ssh"). Update the comment to reflect that change. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 7b01cd3..7d40f76 100755 --- a/kdumpctl +++ b/kdumpctl @@ -734,7 +734,7 @@ check_and_wait_network_ready() cur=$(date +%s) diff=$((cur - start_time)) - # 60s time out + # time out after 180s if [[ $diff -gt 180 ]]; then break fi From b802dbff9f0da8b5cd6eebf28dd3e7fd207cc45c Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:03 +0100 Subject: [PATCH 563/806] kdumpctl: forbid aliases from ssh config For ssh targets kdumpctl only verifies that the config value has the correct @ format itself. For all other tests, e.g. if the destination can be reached, it relies on ssh. This allows users to provide a that isn't the proper hostname but an alias defined in the ssh_config without failing the tests. If this is done dracut-module-setup.sh:kdump_get_remote_ip will fail to obtain the targets ip address. This failure is not detected and thus will not fail the initramfs creation. The resulting initramfs however doesn't have the necessary information for setting up the network and thus will fail to boot. Prevent the use of alias hostnames by verifying that the given hostname is the same one ssh would use after parsing the ssh_config. Note: Don't use getent ahosts to verify that the given host can be resolved as this requires the network to be up which cannot be guaranteed when the kdump.conf is parsed. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7d40f76..8ad6e4c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -663,7 +663,7 @@ load_kdump() check_ssh_config() { - local SSH_TARGET + local target while read -r config_opt config_val; do case "$config_opt" in @@ -687,11 +687,14 @@ check_ssh_config() esac done <<< "$(kdump_read_conf)" - #make sure they've configured kdump.conf for ssh dumps - SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') - if [[ -z $SSH_TARGET ]]; then + [[ -n $DUMP_TARGET ]] || return 1 + [[ $DUMP_TARGET =~ .*@.* ]] || return 1 + target=$(ssh -G "$DUMP_TARGET" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p") + if [[ ${DUMP_TARGET#*@} != "$target" ]]; then + derror "Invalid ssh destination $DUMP_TARGET provided." return 1 fi + return 0 } From e3fa3678404e161be27914b91c69693613b1fcfe Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:04 +0100 Subject: [PATCH 564/806] kdumpctl: simplify propagate_ssh_key The function has multiple problems: 1) SSH_{USER,SERVER} aren't defined local 2) Weird use of cut and sed to parse the DUMP_TARGET for the user and host although check_ssh_config guarantees that it has the format @. 3) Unnecessary use of a variable for the return value 4) Weird behavior to first unpack the DUMP_TARGET to SSH_USER and SSH_SERVER and then putting it back together again 5) Definition of variable errmsg that is only used once but breaks grep-ability of error message. 6) Wrong order when redirecting output of ssh-keygen, see SC2069 [1] Fix them now. While at it also improve the error messages in the function. [1] https://www.shellcheck.net/wiki/SC2069 Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/kdumpctl b/kdumpctl index 8ad6e4c..e6d5066 100755 --- a/kdumpctl +++ b/kdumpctl @@ -755,35 +755,32 @@ check_ssh_target() propagate_ssh_key() { + local SSH_USER SSH_SERVER + if ! check_ssh_config; then - derror "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate" + derror "No ssh destination defined in $KDUMP_CONFIG_FILE." + derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh @' and that it is properly formatted." exit 1 fi local KEYFILE=$SSH_KEY_LOCATION - local errmsg="Failed to propagate ssh key" #Check to see if we already created key, if not, create it. if [[ -f $KEYFILE ]]; then dinfo "Using existing keys..." else dinfo "Generating new ssh keys... " - /usr/bin/ssh-keygen -t rsa -f "$KEYFILE" -N "" 2>&1 > /dev/null + /usr/bin/ssh-keygen -t rsa -f "$KEYFILE" -N "" &> /dev/null dinfo "done." fi - #now find the target ssh user and server to contact. - SSH_USER=$(echo "$DUMP_TARGET" | cut -d@ -f1) - SSH_SERVER=$(echo "$DUMP_TARGET" | sed -e's/\(.*@\)\(.*$\)/\2/') - - #now send the found key to the found server - ssh-copy-id -i "$KEYFILE" "$SSH_USER@$SSH_SERVER" - RET=$? - if [[ $RET == 0 ]]; then + SSH_USER=${DUMP_TARGET%@*} + SSH_SERVER=${DUMP_TARGET#*@} + if ssh-copy-id -i "$KEYFILE" "$DUMP_TARGET"; then dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER" return 0 else - derror "$errmsg, $KEYFILE failed in transfer to $SSH_SERVER" + derror "Failed to propagate ssh key, could not transfer $KEYFILE to $SSH_SERVER" exit 1 fi } From 4adf6d3cc85811d47ddc90c89a6f47b699350410 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:05 +0100 Subject: [PATCH 565/806] kdumpctl: merge check_ssh_config into check_config check_config and check_ssh_config both parse /etc/kdump.conf and are usually used together. The difference between both is that check_ssh_config does some extra checks on the format of the provided ssh destination but ignores invalid or deprecated options in the config. Thus merge check_ssh_config into check_config. Leave the additional checks on the ssh destination in check_ssh_config but treat it like the checks done for e.g. the failure_action. This slightly changes the behavior of 'kdumpctl propagate', which now fails if kdump.conf contains an invalid value unrelated to ssh. This change in behavior isn't problematic because 'kdumpctl propagate' always needs to be followed by a 'kdumpctl start' to have a working kdump environment. For the situations where 'propagate' fails now the 'start' would have failed in the past. So the failure only moved one step ahead in the sequence. While at it drop check_ssh_target and call check_and_wait_network_ready directly. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 71 ++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/kdumpctl b/kdumpctl index e6d5066..85ea7aa 100755 --- a/kdumpctl +++ b/kdumpctl @@ -205,10 +205,27 @@ check_config() fi config_opt=_target ;; - ext[234] | minix | btrfs | xfs | nfs | ssh) + ext[234] | minix | btrfs | xfs | nfs ) config_opt=_target ;; - sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; + ssh) + config_opt=_target + DUMP_TARGET=$config_val + ;; + sshkey) + if [[ -z $config_val ]]; then + derror "Invalid kdump config value for option '$config_opt'" + return 1 + elif [[ -f $config_val ]]; then + SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") + else + dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" + fi + ;; + path) + SAVE_PATH=$config_val + ;; + core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; net | options | link_delay | disk_timeout | debug_mem_level | blacklist) derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." @@ -242,6 +259,7 @@ check_config() check_failure_action_config || return 1 check_final_action_config || return 1 check_fence_kdump_config || return 1 + check_ssh_config || return 1 return 0 } @@ -665,29 +683,8 @@ check_ssh_config() { local target - while read -r config_opt config_val; do - case "$config_opt" in - sshkey) - # remove inline comments after the end of a directive. - if [[ -f $config_val ]]; then - # canonicalize the path - SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") - else - dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" - fi - ;; - path) - SAVE_PATH=$config_val - ;; - ssh) - DUMP_TARGET=$config_val - ;; - *) ;; + [[ -n $DUMP_TARGET ]] || return 0 - esac - done <<< "$(kdump_read_conf)" - - [[ -n $DUMP_TARGET ]] || return 1 [[ $DUMP_TARGET =~ .*@.* ]] || return 1 target=$(ssh -G "$DUMP_TARGET" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p") if [[ ${DUMP_TARGET#*@} != "$target" ]]; then @@ -710,6 +707,8 @@ check_and_wait_network_ready() local retval local errmsg + [[ -n $DUMP_TARGET ]] || return 0 + start_time=$(date +%s) while true; do errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "$SAVE_PATH" 2>&1) @@ -748,16 +747,13 @@ check_and_wait_network_ready() return 1 } -check_ssh_target() -{ - check_and_wait_network_ready -} - propagate_ssh_key() { local SSH_USER SSH_SERVER - if ! check_ssh_config; then + check_config || return 1 + + if [[ -z $DUMP_TARGET ]] ; then derror "No ssh destination defined in $KDUMP_CONFIG_FILE." derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh @' and that it is properly formatted." exit 1 @@ -1040,11 +1036,9 @@ start() return 0 fi - if check_ssh_config; then - if ! check_ssh_target; then - derror "Starting kdump: [FAILED]" - return 1 - fi + if ! check_and_wait_network_ready; then + derror "Starting kdump: [FAILED]" + return 1 fi if ! check_rebuild; then @@ -1160,12 +1154,7 @@ stop() rebuild() { check_config || return 1 - - if check_ssh_config; then - if ! check_ssh_target; then - return 1 - fi - fi + check_and_wait_network_ready || return 1 setup_initrd || return 1 From edb1d04425605db53637f698422017b609efe2b4 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:06 +0100 Subject: [PATCH 566/806] kdumpctl: reduce file operations on kdump.conf Every call to kdump_get_conf_val parses kdump.conf although the file has already been parsed in check_config. Thus store the values parsed in check_config in an array and use them later instead of re-parsing the file over and over again. While at it rename check_config to parse_config. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 73 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/kdumpctl b/kdumpctl index 85ea7aa..0b57384 100755 --- a/kdumpctl +++ b/kdumpctl @@ -27,6 +27,8 @@ standard_kexec_args="-d -p" # Some default values in case /etc/sysconfig/kdump doesn't include KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug" +declare -A OPT + if [[ -f /etc/sysconfig/kdump ]]; then . /etc/sysconfig/kdump fi @@ -185,9 +187,29 @@ restore_default_initrd() fi } -check_config() +_set_config() +{ + local opt=$1 + local val=$2 + + if [[ -z $val ]]; then + derror "Invalid kdump config value for option '$opt'" + return 1 + fi + + if [[ -n ${OPT[$opt]} ]]; then + if [[ $opt == _target ]]; then + derror "More than one dump targets specified" + else + derror "Duplicated kdump config value of option $opt" + fi + return 1 + fi + OPT[$opt]="$val" +} + +parse_config() { - local -A _opt_rec while read -r config_opt config_val; do case "$config_opt" in dracut_args) @@ -196,7 +218,7 @@ check_config() derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi - config_opt=_target + _set_config _target "$(get_dracut_args_target "$config_val")" || return 1 fi ;; raw) @@ -240,20 +262,7 @@ check_config() ;; esac - if [[ -z $config_val ]]; then - derror "Invalid kdump config value for option '$config_opt'" - return 1 - fi - - if [[ -n ${_opt_rec[$config_opt]} ]]; then - if [[ $config_opt == _target ]]; then - derror "More than one dump targets specified" - else - derror "Duplicated kdump config value of option $config_opt" - fi - return 1 - fi - _opt_rec[$config_opt]="$config_val" + _set_config "$config_opt" "$config_val" || return 1 done <<< "$(kdump_read_conf)" check_failure_action_config || return 1 @@ -321,8 +330,8 @@ check_files_modified() #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. modified_files=$(get_pcs_cluster_modified_files) - EXTRA_BINS=$(kdump_get_conf_val kdump_post) - CHECK_FILES=$(kdump_get_conf_val kdump_pre) + EXTRA_BINS=${OPT[kdump_post]} + CHECK_FILES=${OPT[kdump_pre]} HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" if [[ -d /etc/kdump/post.d ]]; then for file in /etc/kdump/post.d/*; do @@ -339,17 +348,17 @@ check_files_modified() done fi HOOKS="$HOOKS $POST_FILES $PRE_FILES" - CORE_COLLECTOR=$(kdump_get_conf_val core_collector | awk '{print $1}') + CORE_COLLECTOR=$(echo "${OPT[core_collector]}" | awk '{print $1}') CORE_COLLECTOR=$(type -P "$CORE_COLLECTOR") # POST_FILES and PRE_FILES are already checked against executable, need not to check again. EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - CHECK_FILES=$(kdump_get_conf_val extra_bins) + CHECK_FILES=${OPT[extra_bins]} EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" files="$KDUMP_CONFIG_FILE $KDUMP_KERNEL $EXTRA_BINS $CORE_COLLECTOR" [[ -e /etc/fstab ]] && files="$files /etc/fstab" # Check for any updated extra module - EXTRA_MODULES="$(kdump_get_conf_val extra_modules)" + EXTRA_MODULES="${OPT[extra_modules]}" if [[ -n $EXTRA_MODULES ]]; then if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" @@ -541,14 +550,14 @@ check_rebuild() setup_initrd || return 1 - force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) + force_no_rebuild=${OPT[force_no_rebuild]} force_no_rebuild=${force_no_rebuild:-0} if [[ $force_no_rebuild != "0" ]] && [[ $force_no_rebuild != "1" ]]; then derror "Error: force_no_rebuild value is invalid" return 1 fi - force_rebuild=$(kdump_get_conf_val force_rebuild) + force_rebuild=${OPT[force_rebuild]} force_rebuild=${force_rebuild:-0} if [[ $force_rebuild != "0" ]] && [[ $force_rebuild != "1" ]]; then derror "Error: force_rebuild value is invalid" @@ -751,7 +760,7 @@ propagate_ssh_key() { local SSH_USER SSH_SERVER - check_config || return 1 + parse_config || return 1 if [[ -z $DUMP_TARGET ]] ; then derror "No ssh destination defined in $KDUMP_CONFIG_FILE." @@ -825,7 +834,7 @@ save_raw() dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." return 0 fi - kdump_dir=$(kdump_get_conf_val path) + kdump_dir=${OPT[path]} if [[ -z ${kdump_dir} ]]; then coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" else @@ -911,7 +920,7 @@ check_fence_kdump_config() hostname=$(hostname) ipaddrs=$(hostname -I) - nodes=$(kdump_get_conf_val "fence_kdump_nodes") + nodes=${OPT[fence_kdump_nodes]} for node in $nodes; do if [[ $node == "$hostname" ]]; then @@ -964,8 +973,8 @@ check_failure_action_config() local failure_action local option="failure_action" - default_option=$(kdump_get_conf_val default) - failure_action=$(kdump_get_conf_val failure_action) + default_option=${OPT[default]} + failure_action=${OPT[failure_action]} if [[ -z $failure_action ]] && [[ -z $default_option ]]; then return 0 @@ -994,7 +1003,7 @@ check_final_action_config() { local final_action - final_action=$(kdump_get_conf_val final_action) + final_action=${OPT[final_action]} if [[ -z $final_action ]]; then return 0 else @@ -1017,7 +1026,7 @@ start() return 1 fi - if ! check_config; then + if ! parse_config; then derror "Starting kdump: [FAILED]" return 1 fi @@ -1153,7 +1162,7 @@ stop() rebuild() { - check_config || return 1 + parse_config || return 1 check_and_wait_network_ready || return 1 setup_initrd || return 1 From 0460f0a7686334a14c5b17ef00721ad25c54324b Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:07 +0100 Subject: [PATCH 567/806] kdumpctl: drop SAVE_PATH variable The variable is only used for ssh dump targets. Furthermore it is identical to the value stored in ${OPT[path]}. Thus drop SAVE_PATH and use ${OPT[path]} instead. Also make sure that ${OPT[path]} is always set to the default value when no entry in kdump.conf is found. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/kdumpctl b/kdumpctl index 0b57384..876561e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -9,7 +9,6 @@ KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" -SAVE_PATH=/var/crash SSH_KEY_LOCATION=$DEFAULT_SSHKEY INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DUMP_TARGET="" @@ -244,10 +243,7 @@ parse_config() dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" fi ;; - path) - SAVE_PATH=$config_val - ;; - core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; + path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; net | options | link_delay | disk_timeout | debug_mem_level | blacklist) derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." @@ -265,6 +261,8 @@ parse_config() _set_config "$config_opt" "$config_val" || return 1 done <<< "$(kdump_read_conf)" + OPT[path]=${OPT[path]:-$DEFAULT_PATH} + check_failure_action_config || return 1 check_final_action_config || return 1 check_fence_kdump_config || return 1 @@ -720,21 +718,21 @@ check_and_wait_network_ready() start_time=$(date +%s) while true; do - errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "$SAVE_PATH" 2>&1) + errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "${OPT[path]}" 2>&1) retval=$? # ssh exits with the exit status of the remote command or with 255 if an error occurred if [[ $retval -eq 0 ]]; then return 0 elif [[ $retval -ne 255 ]]; then - derror "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" + derror "Could not create $DUMP_TARGET:${OPT[path]}, you should check the privilege on server side" return 1 fi # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" if echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed"; then - derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" + derror "Could not create $DUMP_TARGET:${OPT[path]}, you probably need to run \"kdumpctl propagate\"" return 1 fi @@ -752,7 +750,7 @@ check_and_wait_network_ready() sleep 1 done - dinfo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" + dinfo "Could not create $DUMP_TARGET:${OPT[path]}, ipaddr is not ready yet. You should check network connection" return 1 } @@ -820,7 +818,6 @@ check_current_status() save_raw() { - local kdump_dir local raw_target raw_target=$(kdump_get_conf_val raw) @@ -834,13 +831,8 @@ save_raw() dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss is expected." return 0 fi - kdump_dir=${OPT[path]} - if [[ -z ${kdump_dir} ]]; then - coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" - else - coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")" - fi + coredir="${OPT[path]}/$(date +"%Y-%m-%d-%H:%M")" mkdir -p "$coredir" [[ -d $coredir ]] || { derror "failed to create $coredir" From a859abe3652c1eea75b847e6f6f93033b478a4d3 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:08 +0100 Subject: [PATCH 568/806] kdumpctl: drop SSH_KEY_LOCATION variable The variable is only used for ssh dump targets. Furthermore it is identical to the value stored in ${OPT[sshkey]}. Thus drop SSH_KEY_LOCATION and use ${OPT[sshkey]} instead. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kdumpctl b/kdumpctl index 876561e..c5afedb 100755 --- a/kdumpctl +++ b/kdumpctl @@ -9,7 +9,6 @@ KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" -SSH_KEY_LOCATION=$DEFAULT_SSHKEY INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DUMP_TARGET="" DEFAULT_INITRD="" @@ -238,9 +237,10 @@ parse_config() derror "Invalid kdump config value for option '$config_opt'" return 1 elif [[ -f $config_val ]]; then - SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") + config_val=$(/usr/bin/readlink -m "$config_val") else - dwarn "WARNING: '$config_val' doesn't exist, using default value '$SSH_KEY_LOCATION'" + dwarn "WARNING: '$config_val' doesn't exist, using default value '$DEFAULT_SSHKEY'" + config_val=$DEFAULT_SSHKEY fi ;; path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; @@ -262,6 +262,7 @@ parse_config() done <<< "$(kdump_read_conf)" OPT[path]=${OPT[path]:-$DEFAULT_PATH} + OPT[sshkey]=${OPT[sshkey]:-$DEFAULT_SSHKEY} check_failure_action_config || return 1 check_final_action_config || return 1 @@ -718,7 +719,7 @@ check_and_wait_network_ready() start_time=$(date +%s) while true; do - errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "${OPT[path]}" 2>&1) + errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "${OPT[path]}" 2>&1) retval=$? # ssh exits with the exit status of the remote command or with 255 if an error occurred @@ -766,7 +767,7 @@ propagate_ssh_key() exit 1 fi - local KEYFILE=$SSH_KEY_LOCATION + local KEYFILE=${OPT[sshkey]} #Check to see if we already created key, if not, create it. if [[ -f $KEYFILE ]]; then From 5118daf2ff9f2283782ea38e4b99cf9c307c2324 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:09 +0100 Subject: [PATCH 569/806] kdumpctl: drop DUMP_TARGET variable The variable is only used for ssh dump targets. Furthermore it is identical to the value stored in ${OPT[_target]}. Thus drop DUMP_TARGET and use ${OPT[_target]} instead. In order to be able to distinguish between the different target types introduce the internal ${OPT[_fstype]}. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/kdumpctl b/kdumpctl index c5afedb..bfba442 100755 --- a/kdumpctl +++ b/kdumpctl @@ -10,7 +10,6 @@ MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" -DUMP_TARGET="" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" KDUMP_INITRD="" @@ -196,7 +195,7 @@ _set_config() fi if [[ -n ${OPT[$opt]} ]]; then - if [[ $opt == _target ]]; then + if [[ $opt == _target ]] || [[ $opt == _fstype ]]; then derror "More than one dump targets specified" else derror "Duplicated kdump config value of option $opt" @@ -216,6 +215,7 @@ parse_config() derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi + _set_config _fstype "$(get_dracut_args_fstype "$config_val")" || return 1 _set_config _target "$(get_dracut_args_target "$config_val")" || return 1 fi ;; @@ -223,15 +223,13 @@ parse_config() if [[ -d "/proc/device-tree/ibm,opal/dump" ]]; then dwarn "WARNING: Won't capture opalcore when 'raw' dump target is used." fi + _set_config _fstype "$config_opt" || return 1 config_opt=_target ;; - ext[234] | minix | btrfs | xfs | nfs ) + ext[234] | minix | btrfs | xfs | nfs | ssh) + _set_config _fstype "$config_opt" || return 1 config_opt=_target ;; - ssh) - config_opt=_target - DUMP_TARGET=$config_val - ;; sshkey) if [[ -z $config_val ]]; then derror "Invalid kdump config value for option '$config_opt'" @@ -691,12 +689,12 @@ check_ssh_config() { local target - [[ -n $DUMP_TARGET ]] || return 0 + [[ "${OPT[_fstype]}" == ssh ]] || return 0 - [[ $DUMP_TARGET =~ .*@.* ]] || return 1 - target=$(ssh -G "$DUMP_TARGET" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p") - if [[ ${DUMP_TARGET#*@} != "$target" ]]; then - derror "Invalid ssh destination $DUMP_TARGET provided." + target=$(ssh -G "${OPT[_target]}" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p") + [[ ${OPT[_target]} =~ .*@.* ]] || return 1 + if [[ ${OPT[_target]#*@} != "$target" ]]; then + derror "Invalid ssh destination ${OPT[_target]} provided." return 1 fi @@ -715,25 +713,25 @@ check_and_wait_network_ready() local retval local errmsg - [[ -n $DUMP_TARGET ]] || return 0 + [[ "${OPT[_fstype]}" == ssh ]] || return 0 start_time=$(date +%s) while true; do - errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "${OPT[path]}" 2>&1) + errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "${OPT[_target]}" mkdir -p "${OPT[path]}" 2>&1) retval=$? # ssh exits with the exit status of the remote command or with 255 if an error occurred if [[ $retval -eq 0 ]]; then return 0 elif [[ $retval -ne 255 ]]; then - derror "Could not create $DUMP_TARGET:${OPT[path]}, you should check the privilege on server side" + derror "Could not create ${OPT[_target]}:${OPT[path]}, you should check the privilege on server side" return 1 fi # if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa ddebug "$errmsg" if echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed"; then - derror "Could not create $DUMP_TARGET:${OPT[path]}, you probably need to run \"kdumpctl propagate\"" + derror "Could not create ${OPT[_target]}:${OPT[path]}, you probably need to run \"kdumpctl propagate\"" return 1 fi @@ -751,7 +749,7 @@ check_and_wait_network_ready() sleep 1 done - dinfo "Could not create $DUMP_TARGET:${OPT[path]}, ipaddr is not ready yet. You should check network connection" + dinfo "Could not create ${OPT[_target]}:${OPT[path]}, ipaddr is not ready yet. You should check network connection" return 1 } @@ -761,7 +759,7 @@ propagate_ssh_key() parse_config || return 1 - if [[ -z $DUMP_TARGET ]] ; then + if [[ ${OPT[_fstype]} != ssh ]] ; then derror "No ssh destination defined in $KDUMP_CONFIG_FILE." derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh @' and that it is properly formatted." exit 1 @@ -778,9 +776,9 @@ propagate_ssh_key() dinfo "done." fi - SSH_USER=${DUMP_TARGET%@*} - SSH_SERVER=${DUMP_TARGET#*@} - if ssh-copy-id -i "$KEYFILE" "$DUMP_TARGET"; then + SSH_USER=${OPT[_target]%@*} + SSH_SERVER=${OPT[_target]#*@} + if ssh-copy-id -i "$KEYFILE" "${OPT[_target]}"; then dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER" return 0 else From ac5968218f4d4d86d5ad217c0912a81e985c5893 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:10 +0100 Subject: [PATCH 570/806] kdumpctl: remove kdump_get_conf_val in save_raw With the introduction of ${OPT[fstype]} this call to kdump_get_conf_val can be removed now as well. Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index bfba442..82e8574 100755 --- a/kdumpctl +++ b/kdumpctl @@ -819,8 +819,9 @@ save_raw() { local raw_target - raw_target=$(kdump_get_conf_val raw) - [[ -z $raw_target ]] && return 0 + [[ ${OPT[_fstype]} == raw ]] || return 0 + + raw_target=${OPT[_target]} [[ -b $raw_target ]] || { derror "raw partition $raw_target not found" return 1 From 55b5c4e2b0105ae5b64ab3a5ea1c1879dc818a03 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 25 Mar 2022 15:47:11 +0100 Subject: [PATCH 571/806] kdumpctl: simplify local_fs_dump_target Make use of the new ${OPT[]} array and simplify local_fs_dump_target to remove one more file operations. While at it rename the local_fs_dump_target to is_local_target Signed-off-by: Philipp Rudo Reviewed-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/kdumpctl b/kdumpctl index 82e8574..4d819c2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -850,27 +850,22 @@ save_raw() return 0 } -local_fs_dump_target() +is_local_target() { - local _target - - if _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf); then - echo "$_target" | awk '{print $2}' - fi + [[ ${OPT[_fstype]} =~ ^ext[234]|^xfs|^btrfs|^minix ]] } path_to_be_relabeled() { - local _path _target _mnt="/" _rmnt + local _path _mnt="/" _rmnt if is_user_configured_dump_target; then if is_mount_in_dracut_args; then return fi - _target=$(local_fs_dump_target) - if [[ -n $_target ]]; then - _mnt=$(get_mntpoint_from_target "$_target") + if is_local_target; then + _mnt=$(get_mntpoint_from_target "${OPT[_target]}") if ! is_mounted "$_mnt"; then return fi From 11140c28a25169837333c5bf7d51cbe17c897025 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 11 Apr 2022 10:56:46 +0800 Subject: [PATCH 572/806] Release 2.0.24-1 --- kexec-tools.spec | 28 ++++++++++++++++++++++++---- sources | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6b7ef14..db6374c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.23 -Release: 5%{?dist} +Version: 2.0.24 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -103,7 +103,6 @@ Requires: systemd-udev%{?_isa} # # Patches 401 through 500 are meant for s390 kexec-tools enablement # -Patch401: ./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch # # Patches 501 through 600 are meant for ARM kexec-tools enablement @@ -127,7 +126,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch401 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -407,6 +405,28 @@ fi %endif %changelog +* Mon Apr 11 2022 Coiby - 2.0.24-1 +- Update kexec-tools to 2.0.24 +- kdumpctl: remove kdump_get_conf_val in save_raw +- kdumpctl: drop DUMP_TARGET variable +- kdumpctl: drop SSH_KEY_LOCATION variable +- kdumpctl: drop SAVE_PATH variable +- kdumpctl: reduce file operations on kdump.conf +- kdumpctl: merge check_ssh_config into check_config +- kdumpctl: simplify propagate_ssh_key +- kdumpctl: forbid aliases from ssh config +- kdumpctl: fix comment in check_and_wait_network_ready +- kdump-lib-initramfs: merge definitions for default ssh key +- kdumpctl: remove unnecessary uses of $? +- kdump-lib: fix typo in variable name +- kdump-capture.service: switch to journal for stdout +- kdumpctl/estimate: Fix unnecessary warning +- kdumpctl: sync the $TARGET_INITRD after rebuild +- try to update the crashkernel in GRUB_ETC_DEFAULT after kexec-tools updates the default crashkernel value +- address the case where there are multiple values for the same kernel arg +- update kernel crashkernel in posttrans RPM scriptlet when updating kexec-tools +- kdump-lib.sh: Check the output of blkid with sed instead of eval + * Mon Feb 14 2022 Coiby - 2.0.23-5 - fix incorrect usage of _get_all_kernels_from_grubby - fix the mistake of swapping function parameters of read_proc_environ_var diff --git a/sources b/sources index 5069108..95c0fc6 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 -SHA512 (kexec-tools-2.0.23.tar.xz) = b6e3b967cacc31c434b185d25da4d53c822ae4bbcec26ef9d6cb171f294fdcc80913d381e686a0a41e025187835f4dc088052ff88efe75a021d7624c8b1a1ed8 +SHA512 (kexec-tools-2.0.24.tar.xz) = ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822 SHA512 (makedumpfile-1.7.0.tar.gz) = 579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7 From b97310428f336d58028d34f3f3c7a551e47b5c32 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 4 Jan 2022 14:04:38 +0800 Subject: [PATCH 573/806] unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested Currently there are two issues with unit-testing the functions defined in kdumpctl and other shell scripts after sourcing them, - kdumpctl would call main which requires root permission and would create single instance lock (/var/lock/kdump) - kdumpctl and other shell scripts directly source files under /usr/lib/kdump/ When ShellSpec load a script via "Include", it defines the__SOURCED__ variable. By making use of __SOURCED__, we can 1. let kdumpctl not call main when kdumpctl is "Include"d by ShellSpec 2. instruct kdumpctl and kdump-lib.sh to source the files in the repo when running ShelSpec tests Note coverage/ is added to .gitignore because ShellSpec generates code coverage results in this folder. Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- .gitignore | 1 + kdump-lib.sh | 7 +++++-- kdumpctl | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7a38a39..e9c2dd8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ /kexec-tools-2.0.11.tar.xz /makedumpfile-1.5.9.tar.gz /kexec-tools-2.0.12.tar.xz +coverage/ diff --git a/kdump-lib.sh b/kdump-lib.sh index 5b1656e..557eff6 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -2,8 +2,11 @@ # # Kdump common variables and functions # - -. /usr/lib/kdump/kdump-lib-initramfs.sh +if [[ ${__SOURCED__:+x} ]]; then + . ./kdump-lib-initramfs.sh +else + . /lib/kdump/kdump-lib-initramfs.sh +fi FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" diff --git a/kdumpctl b/kdumpctl index 4d819c2..6188d47 100755 --- a/kdumpctl +++ b/kdumpctl @@ -32,8 +32,14 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh -. /lib/kdump/kdump-lib.sh -. /lib/kdump/kdump-logger.sh + +if [[ ${__SOURCED__:+x} ]]; then + KDUMP_LIB_PATH=. +else + KDUMP_LIB_PATH=/lib/kdump +fi +. $KDUMP_LIB_PATH/kdump-lib.sh +. $KDUMP_LIB_PATH/kdump-logger.sh #initiate the kdump logger if ! dlog_init; then @@ -1676,11 +1682,6 @@ reset_crashkernel_for_installed_kernel() fi } -if [[ ! -f $KDUMP_CONFIG_FILE ]]; then - derror "Error: No kdump config file found!" - exit 1 -fi - main() { # Determine if the dump mode is kdump or fadump @@ -1753,6 +1754,15 @@ main() esac } +if [[ ${__SOURCED__:+x} ]]; then + return +fi + +if [[ ! -f $KDUMP_CONFIG_FILE ]]; then + derror "Error: No kdump config file found!" + exit 1 +fi + # Other kdumpctl instances will block in queue, until this one exits single_instance_lock From 93373c040627f31826d864110413c4e1f72e9b4b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 5 Jan 2022 13:48:58 +0800 Subject: [PATCH 574/806] unit tests: add tests for get_grub_kernel_boot_parameter This test suite makes use of three features provided by ShellSpec - funcion-based mock [2]: mock a function by re-defining and exporting it - parameterized tests [3]: run multiple sets of input against the same test - %text directive [4]: similar to heredoc but free of the indentation issue Note 1. Describe and Context are aliases for ExampleGroup which a block for grouping example groups or examples [5]. Describe and Context are used to improve readability. 2. ShellSpec requires .shellspec file. [1] https://github.com/dodie/testing-in-bash#detailed-comparision [2] https://github.com/shellspec/shellspec#function-based-mock [3] https://github.com/shellspec/shellspec#parameters---parameterized-example [4] https://github.com/shellspec/shellspec#text---embedded-text [5] https://github.com/shellspec/shellspec#dsl-syntax Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- .shellspec | 0 spec/kdumpctl_general_spec.sh | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .shellspec create mode 100644 spec/kdumpctl_general_spec.sh diff --git a/.shellspec b/.shellspec new file mode 100644 index 0000000..e69de29 diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh new file mode 100644 index 0000000..e1d8698 --- /dev/null +++ b/spec/kdumpctl_general_spec.sh @@ -0,0 +1,48 @@ +#!/bin/bash +Describe 'kdumpctl' + Include ./kdumpctl + + Describe 'get_grub_kernel_boot_parameter()' + grubby() { + %text + #|index=1 + #|kernel="/boot/vmlinuz-5.14.14-200.fc34.x86_64" + #|args="crashkernel=11M nvidia-drm.modeset=1 crashkernel=100M ro rhgb quiet crcrashkernel=200M crashkernel=32T-64T:128G,64T-102400T:180G fadump=on" + #|root="UUID=45fdf703-3966-401b-b8f7-cf056affd2b0" + } + DUMMY_PARAM=/boot/vmlinuz + + Context "when given a kernel parameter in different positions" + # Test the following cases: + # - the kernel parameter in the end + # - the kernel parameter in the first + # - the kernel parameter is crashkernel (suffix of crcrashkernel) + # - the kernel parameter that does not exist + # - the kernel parameter doesn't have a value + Parameters + # parameter answer + fadump on + nvidia-drm.modeset 1 + crashkernel 32T-64T:128G,64T-102400T:180G + aaaa "" + ro "" + End + + It 'should retrieve the value succesfully' + When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" "$2" + The output should equal "$3" + End + End + + It 'should retrive the last value if multiple entries exist' + When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" crashkernel + The output should equal '32T-64T:128G,64T-102400T:180G' + End + + It 'should fail when called with kernel_path=ALL' + When call get_grub_kernel_boot_parameter ALL ro + The status should be failure + The error should include "kernel_path=ALL invalid" + End + End +End From 59386d5a8b1d2c2c2f9e8cdeb2a9e17565316033 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 5 Jan 2022 15:24:02 +0800 Subject: [PATCH 575/806] unit tests: add tests for get_dump_mode_by_fadump_val Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index e1d8698..b968f74 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -45,4 +45,30 @@ Describe 'kdumpctl' The error should include "kernel_path=ALL invalid" End End + + Describe 'get_dump_mode_by_fadump_val()' + + Context 'when given valid fadump values' + Parameters + "#1" on fadump + "#2" nocma fadump + "#3" "" kdump + "#4" off kdump + End + It "should return the dump mode correctly" + When call get_dump_mode_by_fadump_val "$2" + The output should equal "$3" + The status should be success + End + End + + It 'should complain given invalid fadump value' + When call get_dump_mode_by_fadump_val /boot/vmlinuz + The status should be failure + The error should include 'invalid fadump' + End + + End + + End From 6506bd9b1bcd4117676aaef513c144c4d81bec21 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 21 Jan 2022 15:46:40 +0800 Subject: [PATCH 576/806] unit tests: add tests for kdumpctl read_proc_environ_var and _is_osbuild AfterAll is an example group hook [1] which would be run after the group tests are executed. Use this hook to clean up the files created by mktemp. [1] https://github.com/shellspec/shellspec#beforeall-afterall---example-group-hook Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index b968f74..9fbc1a0 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -70,5 +70,41 @@ Describe 'kdumpctl' End + Describe "read_proc_environ_var()" + environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX) + cleanup() { + rm -rf "$environ_test_file" + } + AfterAll 'cleanup' + echo -ne "container=bwrap-osbuild\x00SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEbw33A/agent.1794\x00SSH_AGENT_PID=1929\x00env=test_env" >"$environ_test_file" + Parameters + container bwrap-osbuild + SSH_AUTH_SOCK /tmp/ssh-XXXXXXEbw33A/agent.1794 + env test_env + not_exist "" + End + It 'should read the environ variable value as expected' + When call read_proc_environ_var "$1" "$environ_test_file" + The output should equal "$2" + The status should be success + End + End + + Describe "_is_osbuild()" + environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX) + # shellcheck disable=SC2034 + # override the _OSBUILD_ENVIRON_PATH variable + _OSBUILD_ENVIRON_PATH="$environ_test_file" + Parameters + 'container=bwrap-osbuild' success + '' failure + End + It 'should be able to tell if it is the osbuild environment' + echo -ne "$1" >"$environ_test_file" + When call _is_osbuild + The status should be "$2" + The stderr should equal "" + End + End End From ea8b06df8392d71bdb694646a4e24fd29a947977 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 4 Jan 2022 20:57:55 +0800 Subject: [PATCH 577/806] unit tests: add tests for _{update,read}_kernel_arg_in_grub_etc_default in kdumpctl Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index 9fbc1a0..e72bf1d 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -107,4 +107,71 @@ Describe 'kdumpctl' End End + Describe '_update_kernel_arg_in_grub_etc_default()' + GRUB_ETC_DEFAULT=/tmp/default_grub + + cleanup() { + rm -rf "$GRUB_ETC_DEFAULT" + } + AfterAll 'cleanup' + + Context 'when the given parameter is in different positions' + Parameters + "crashkernel=222M fadump=on rhgb quiet" crashkernel 333M + " fadump=on crashkernel=222M rhgb quiet" crashkernel 333M + "fadump=on rhgb quiet crashkernel=222M" crashkernel 333M + "fadump=on rhgb quiet" crashkernel 333M + "fadump=on foo=bar1 rhgb quiet" foo bar2 + End + + It 'should update the kernel parameter correctly' + echo 'GRUB_CMDLINE_LINUX="'"$1"'"' >$GRUB_ETC_DEFAULT + When call _update_kernel_arg_in_grub_etc_default "$2" "$3" + # the updated kernel parameter should appear in the end + The contents of file $GRUB_ETC_DEFAULT should include "$2=$3\"" + End + End + + It 'should only update the given parameter and not update the parameter that has the given parameter as suffix' + echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT + _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M + When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val" + The contents of file $GRUB_ETC_DEFAULT should include "crashkernel=$_ck_val\"" + The contents of file $GRUB_ETC_DEFAULT should include "ckcrashkernel=222M" + End + + It 'should be able to handle the cases of there are multiple crashkernel entries' + echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet crashkernel=101M crashkernel=222M"' >$GRUB_ETC_DEFAULT + _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M + When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val" + The contents of file $GRUB_ETC_DEFAULT should include "crashkernel=$_ck_val\"" + The contents of file $GRUB_ETC_DEFAULT should not include "crashkernel=222M" + End + + Context 'when it removes a kernel parameter' + + It 'should remove all values for given arg' + echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M fadump=on crashkernel=222M"' >$GRUB_ETC_DEFAULT + When call _update_kernel_arg_in_grub_etc_default crashkernel + The contents of file $GRUB_ETC_DEFAULT should equal 'GRUB_CMDLINE_LINUX="fadump=on"' + End + + It 'should not remove args that have the given arg as suffix' + echo 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M crashkernel=11M ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT + When call _update_kernel_arg_in_grub_etc_default crashkernel + The contents of file $GRUB_ETC_DEFAULT should equal 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M ckcrashkernel=222M"' + End + End + + End + + Describe '_read_kernel_arg_in_grub_etc_default()' + GRUB_ETC_DEFAULT=/tmp/default_grub + It 'should read the value for given arg' + echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT + When call _read_kernel_arg_in_grub_etc_default crashkernel + The output should equal '11M' + End + End + End From e00b45d75fa00a1d47b6cab0f609faf089ff563e Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 4 Jan 2022 15:24:34 +0800 Subject: [PATCH 578/806] unit tests: add tests for "kdumpctl reset-crashkernel" This commit adds a relatively thorough test suite for kdumpctl reset-crashkernel [--fadump=[on|off|nocma]] [--kernel=path_to_kernel] [--reboot] as implemented in commit 140da74 ("rewrite reset_crashkernel to support fadump and to used by RPM scriptlet"). grubby have a few options to support its own testing, - --no-etc-grub-update, not update /etc/default/grub - --bad-image-okay, don't check the validity of the image - --env, specify custom grub2 environment block file to avoid modifying the default /boot/grub2/grubenv - --bls-directory, specify custom BootLoaderSpec config files to avoid modifying the default /boot/loader/entries So the grubby called by kdumpctl is mocked as @grubby --grub2 --no-etc-grub-update --bad-image-okay --env=$SPEC_TEST_DIR/env_temp -b $SPEC_TEST_DIR/boot_load_entries "$@" in the tests. To be able to call the actual grubby in the mock function [1], ShellSpec provides the following command $ shellspec --gen-bin @grubby to generate spec/support/bins/@grubby which is used to call the actual grubby. kdumpctl has implemented its own version of updating /etc/default/grub in _update_kernel_cmdline_in_grub_etc_default. To avoiding writing to /etc/default/grub, this function is mocked as outputting its name and received arguments similar to python unitest's assert_called_with. [1] https://github.com/shellspec/shellspec#execute-the-actual-command-within-a-mock-function Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_reset_crashkernel_spec.sh | 224 ++++++++++++++++++ spec/support/bin/@grubby | 3 + ...846f63134c7295458cf36300ba5b-0-rescue.conf | 8 + ...58cf36300ba5b-5.14.14-200.fc34.x86_64.conf | 8 + ...458cf36300ba5b-5.15.6-100.fc34.x86_64.conf | 8 + spec/support/grub_env | 3 + 6 files changed, 254 insertions(+) create mode 100644 spec/kdumpctl_reset_crashkernel_spec.sh create mode 100755 spec/support/bin/@grubby create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf create mode 100644 spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf create mode 100644 spec/support/grub_env diff --git a/spec/kdumpctl_reset_crashkernel_spec.sh b/spec/kdumpctl_reset_crashkernel_spec.sh new file mode 100644 index 0000000..28d9277 --- /dev/null +++ b/spec/kdumpctl_reset_crashkernel_spec.sh @@ -0,0 +1,224 @@ +#!/bin/bash +Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' + Include ./kdumpctl + kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64 + kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64 + ck=222M + KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -d /tmp/spec_test.XXXXXXXXXX) + current_kernel=5.15.6-100.fc34.x86_64 + + setup() { + cp -r spec/support/boot_load_entries "$KDUMP_SPEC_TEST_RUN_DIR" + cp spec/support/grub_env "$KDUMP_SPEC_TEST_RUN_DIR"/env_temp + } + + cleanup() { + rm -rf "$KDUMP_SPEC_TEST_RUN_DIR" + } + + BeforeAll 'setup' + AfterAll 'cleanup' + + grubby() { + # - --no-etc-grub-update, not update /etc/default/grub + # - --bad-image-okay, don't check the validity of the image + # - --env, specify custom grub2 environment block file to avoid modifying + # the default /boot/grub2/grubenv + # - --bls-directory, specify custom BootLoaderSpec config files to avoid + # modifying the default /boot/loader/entries + @grubby --no-etc-grub-update --grub2 --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" + } + + Describe "Test the kdump dump mode " + uname() { + if [[ $1 == '-m' ]]; then + echo -n x86_64 + elif [[ $1 == '-r' ]]; then + echo -n $current_kernel + fi + } + kdump_crashkernel=$(get_default_crashkernel kdump) + Context "when --kernel not specified" + grubby --args crashkernel=$ck --update-kernel ALL + Specify 'kdumpctl should warn the user that crashkernel has been udpated' + When call reset_crashkernel + The error should include "Updated crashkernel=$kdump_crashkernel" + End + + Specify 'Current running kernel should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$kdump_crashkernel" + The line 3 of output should not include crashkernel=$ck + End + + Specify 'Other kernel still use the old crashkernel value' + When call grubby --info $kernel2 + The line 3 of output should include crashkernel=$ck + End + End + + Context "--kernel=ALL" + grubby --args crashkernel=$ck --update-kernel ALL + Specify 'kdumpctl should warn the user that crashkernel has been udpated' + When call reset_crashkernel --kernel=ALL + The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel1" + The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel2" + End + + Specify 'kernel1 should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$kdump_crashkernel" + End + + Specify 'kernel2 should have crashkernel updated' + When call grubby --info $kernel2 + The line 3 of output should include crashkernel="$kdump_crashkernel" + End + End + + Context "--kernel=/boot/one-kernel to update one specified kernel" + grubby --args crashkernel=$ck --update-kernel ALL + Specify 'kdumpctl should warn the user that crashkernel has been updated' + When call reset_crashkernel --kernel=$kernel1 + The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel1" + End + + Specify 'kernel1 should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$kdump_crashkernel" + End + + Specify 'kernel2 should have the old crashkernel' + When call grubby --info $kernel2 + The line 3 of output should include crashkernel=$ck + End + + End + + End + + Describe "FADump" fadump + uname() { + if [[ $1 == '-m' ]]; then + echo -n ppc64le + elif [[ $1 == '-r' ]]; then + echo -n $current_kernel + fi + } + + _update_kernel_arg_in_grub_etc_default() { + # don't modify /etc/default/grub during the test + echo _update_kernel_arg_in_grub_etc_default "$@" + } + + kdump_crashkernel=$(get_default_crashkernel kdump) + fadump_crashkernel=$(get_default_crashkernel fadump) + Context "when no --kernel specified" + grubby --args crashkernel=$ck --update-kernel ALL + grubby --remove-args=fadump --update-kernel ALL + Specify 'kdumpctl should warn the user that crashkernel has been udpated' + When call reset_crashkernel + The error should include "Updated crashkernel=$kdump_crashkernel" + End + + Specify 'Current running kernel should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$kdump_crashkernel" + End + + Specify 'Other kernel still use the old crashkernel value' + When call grubby --info $kernel2 + The line 3 of output should include crashkernel=$ck + End + End + + Context "--kernel=ALL --fadump=on" + grubby --args crashkernel=$ck --update-kernel ALL + Specify 'kdumpctl should warn the user that crashkernel has been udpated' + When call reset_crashkernel --kernel=ALL --fadump=on + The line 1 of output should include "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2" + End + + Specify 'kernel1 should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$fadump_crashkernel" + End + + Specify 'kernel2 should have crashkernel updated' + When call get_grub_kernel_boot_parameter $kernel2 crashkernel + The output should equal "$fadump_crashkernel" + End + End + + Context "--kernel=/boot/one-kernel to update one specified kernel" + grubby --args crashkernel=$ck --update-kernel ALL + grubby --args fadump=on --update-kernel $kernel1 + Specify 'kdumpctl should warn the user that crashkernel has been updated' + When call reset_crashkernel --kernel=$kernel1 + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" + End + + Specify 'kernel1 should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$fadump_crashkernel" + End + + Specify 'kernel2 should have the old crashkernel' + When call get_grub_kernel_boot_parameter $kernel2 crashkernel + The output should equal $ck + End + End + + Context "Update all kernels but without --fadump specified" + grubby --args crashkernel=$ck --update-kernel ALL + grubby --args fadump=on --update-kernel $kernel1 + Specify 'kdumpctl should warn the user that crashkernel has been updated' + When call reset_crashkernel --kernel=$kernel1 + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" + End + + Specify 'kernel1 should have crashkernel updated' + When call get_grub_kernel_boot_parameter $kernel1 crashkernel + The output should equal "$fadump_crashkernel" + End + + Specify 'kernel2 should have the old crashkernel' + When call get_grub_kernel_boot_parameter $kernel2 crashkernel + The output should equal $ck + End + End + + Context 'Switch between fadump=on and fadump=nocma' + grubby --args crashkernel=$ck --update-kernel ALL + grubby --args fadump=on --update-kernel ALL + Specify 'fadump=on to fadump=nocma' + When call reset_crashkernel --kernel=ALL --fadump=nocma + The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" + The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump nocma" + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" + The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2" + End + + Specify 'kernel1 should have fadump=nocma in cmdline' + When call get_grub_kernel_boot_parameter $kernel1 fadump + The output should equal nocma + End + + Specify 'fadump=nocma to fadump=on' + When call reset_crashkernel --kernel=ALL --fadump=on + The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" + The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump on" + The error should include "Updated fadump=on for kernel=$kernel1" + End + + Specify 'kernel2 should have fadump=on in cmdline' + When call get_grub_kernel_boot_parameter $kernel1 fadump + The output should equal on + End + + End + + End +End diff --git a/spec/support/bin/@grubby b/spec/support/bin/@grubby new file mode 100755 index 0000000..2a9b33f --- /dev/null +++ b/spec/support/bin/@grubby @@ -0,0 +1,3 @@ +#!/bin/sh -e +. "$SHELLSPEC_SUPPORT_BIN" +invoke grubby "$@" diff --git a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf new file mode 100644 index 0000000..b821952 --- /dev/null +++ b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf @@ -0,0 +1,8 @@ +title Fedora (0-rescue-e986846f63134c7295458cf36300ba5b) 33 (Workstation Edition) +version 0-rescue-e986846f63134c7295458cf36300ba5b +linux /boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b +initrd /boot/initramfs-0-rescue-e986846f63134c7295458cf36300ba5b.img +options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on +grub_users $grub_users +grub_arg --unrestricted +grub_class kernel diff --git a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf new file mode 100644 index 0000000..08bd411 --- /dev/null +++ b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf @@ -0,0 +1,8 @@ +title Fedora (5.14.14-200.fc34.x86_64) 34 (Workstation Edition) +version 5.14.14-200.fc34.x86_64 +linux /boot/vmlinuz-5.14.14-200.fc34.x86_64 +initrd /boot/initramfs-5.14.14-200.fc34.x86_64.img +options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on +grub_users $grub_users +grub_arg --unrestricted +grub_class kernel diff --git a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf new file mode 100644 index 0000000..9259b99 --- /dev/null +++ b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf @@ -0,0 +1,8 @@ +title Fedora (5.15.6-100.fc34.x86_64) 34 (Workstation Edition) +version 5.15.6-100.fc34.x86_64 +linux /boot/vmlinuz-5.15.6-100.fc34.x86_64 +initrd /boot/initramfs-5.15.6-100.fc34.x86_64.img +options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on +grub_users $grub_users +grub_arg --unrestricted +grub_class fedora diff --git a/spec/support/grub_env b/spec/support/grub_env new file mode 100644 index 0000000..a77303c --- /dev/null +++ b/spec/support/grub_env @@ -0,0 +1,3 @@ +# GRUB Environment Block +# WARNING: Do not edit this file by tools other than grub-editenv!!! +################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################## \ No newline at end of file From e28a1399a3c9e60806a64216e6457e928a594dc8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 6 Jan 2022 14:24:22 +0800 Subject: [PATCH 579/806] unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh kdump_get_conf_val allows to retrieves config value defined in kdump.conf and it also supports sed regex like "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh". Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdump-lib-initramfs_spec.sh | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/kdump-lib-initramfs_spec.sh diff --git a/spec/kdump-lib-initramfs_spec.sh b/spec/kdump-lib-initramfs_spec.sh new file mode 100644 index 0000000..dc50793 --- /dev/null +++ b/spec/kdump-lib-initramfs_spec.sh @@ -0,0 +1,41 @@ +#!/bin/bash +Describe 'kdump-lib-initramfs' + Include ./kdump-lib-initramfs.sh + + Describe 'Test kdump_get_conf_val' + KDUMP_CONFIG_FILE=/tmp/kdump_shellspec_test.conf + kdump_config() { + %text + #|default shell + #|nfs my.server.com:/export/tmp # trailing comment + #| failure_action shell + #|dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" + #|sshkey /root/.ssh/kdump_id_rsa + #|ssh user@my.server.com + } + kdump_config >$KDUMP_CONFIG_FILE + Context 'Given different cases' + # Test the following cases: + # - there is trailing comment + # - there is space before the parameter + # - complicate value for dracut_args + # - Given two parameters, retrive one parameter that has value specified + # - Given two parameters (in reverse order), retrive one parameter that has value specified + Parameters + "#1" nfs my.server.com:/export/tmp + "#2" ssh user@my.server.com + "#3" failure_action shell + "#4" dracut_args '--omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"' + "#5" 'ssh\|aaa' user@my.server.com + "#6" 'aaa\|ssh' user@my.server.com + End + + It 'should handle all cases correctly' + When call kdump_get_conf_val "$2" + The output should equal "$3" + End + End + + End + +End From 3d4cb38d96e45cf5da1460daf3345dd318fdee2f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 7 Jan 2022 16:00:08 +0800 Subject: [PATCH 580/806] unit tests: add check_config with with the default kdump.conf This test prevents the mistake of adding an option to kdump.conf without changing check_config as is the case with commit 73ced7f ("introduce the auto_reset_crashkernel option to kdump.conf"). Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index e72bf1d..5a3ce1c 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -174,4 +174,29 @@ Describe 'kdumpctl' End End + Describe 'parse_config()' + bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) + cleanup() { + rm -f "$bad_kdump_conf" + } + AfterAll 'cleanup' + + It 'should not be happy with unkown option in kdump.conf' + KDUMP_CONFIG_FILE="$bad_kdump_conf" + echo blabla > "$bad_kdump_conf" + When call parse_config + The status should be failure + The stderr should include 'Invalid kdump config option blabla' + End + + It 'should be happy with the default kdump.conf' + # shellcheck disable=SC2034 + # override the KDUMP_CONFIG_FILE variable + KDUMP_CONFIG_FILE=./kdump.conf + When call parse_config + The status should be success + End + + End + End From a1c63fa6449740f771349f931748b0ccc8a67ec7 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 1 Mar 2022 17:35:39 +0800 Subject: [PATCH 581/806] add man documentation for kdumpctl get-default-crashkernel A few typos and grammar issues are fixed as well. Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl.8 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/kdumpctl.8 b/kdumpctl.8 index 067117b..33c1115 100644 --- a/kdumpctl.8 +++ b/kdumpctl.8 @@ -14,7 +14,7 @@ In most cases, you should use .B systemctl to start / stop / enable kdump service instead. However, .B kdumpctl -provides more details for debug and a helper to setup ssh key authentication. +provides more details for debugging and a helper to set up ssh key authentication. .SH COMMANDS .TP @@ -26,14 +26,14 @@ Stop the service. .TP .I status Prints the current status of kdump service. -It returns non-zero value if kdump is not operational. +It returns a non-zero value if kdump is not operational. .TP .I restart Is equal to .I start; stop .TP .I reload -reload crash kernel image and initramfs without triggering a rebuild. +reload the crash kernel image and initramfs without triggering a rebuild. .TP .I rebuild rebuild the crash kernel initramfs. @@ -43,20 +43,23 @@ Helps to setup key authentication for ssh storage since it's impossible to use password authentication during kdump. .TP .I showmem -Prints the size of reserved memory for crash kernel in megabytes. +Prints the size of reserved memory for the crash kernel in megabytes. .TP .I estimate -Estimate a suitable crashkernel value for current machine. This is a -best-effort estimate. It will print a recommanded crashkernel value -based on current kdump setup, and list some details of memory usage. +Estimate a suitable crashkernel value for the current machine. This is a +best-effort estimate. It will print a recommended crashkernel value +based on the current kdump setup, and list some details of memory usage. +.TP +.I get-default-crashkernel +Return the default crashkernel value provided by kexec-tools. .TP .I reset-crashkernel [--kernel=path_to_kernel] [--reboot] Reset crashkernel to default value recommended by kexec-tools. If no kernel is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump -or current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can +or the current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and -supports an additonal [--fadump=[on|off|nocma]] parameter to toggle FADump +supports an additional [--fadump=[on|off|nocma]] parameter to toggle FADump on/off. Note: The memory requirements for kdump varies heavily depending on the From 683ff878213ea2a58971902f90f9dd77d4e64b8f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 18 Apr 2022 15:54:53 +0800 Subject: [PATCH 582/806] update crashkernel-howto 1. clean up left crashkernel.default 2. fix a few typos and grammar mistakes 3. ask the users to refer to `man kdumpctl` for reset-crashkernel Philipp Rudo Signed-off-by: Coiby Xu --- crashkernel-howto.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt index 1ba79ab..94f4e52 100644 --- a/crashkernel-howto.txt +++ b/crashkernel-howto.txt @@ -37,10 +37,10 @@ Users can override the value during Anaconda installation manually. Auto update of crashkernel boot parameter ========================================= -A new release of kexec-tools could update the default crashkernel value. -By default, kexec-tools would reset crashkernel to the new default value if it -detects old default crashkernel value is used by installed kernels. If you don't -want kexec-tools to update the old default crashkernel to the new default +A new release of kexec-tools could update the default crashkernel value. By +default, kexec-tools would reset crashkernel to the new default value if it +detects the old default crashkernel value is used by installed kernels. If you +don't want kexec-tools to update the old default crashkernel to the new default crashkernel, you can change auto_reset_crashkernel to no in kdump.conf. Supported Bootloaders @@ -67,19 +67,18 @@ value properly, `kdumpctl` also provides a sub-command: `kdumpctl reset-crashkernel [--kernel=path_to_kernel] [--reboot]` -This command will read from the `crashkernel.default` file and reset -bootloader's kernel cmdline to the default value. It will also update bootloader -config if the bootloader has a standalone config file. User will have to reboot -the machine after this command to make it take effect if --reboot is not specified. -For ppc64le, an optional "[--fadump=[on|off|nocma]]" can also be specified to toggle -FADump on/off. +This command will reset the bootloader's kernel cmdline to the default value. +It will also update bootloader config if the bootloader has a standalone config +file. User will have to reboot the machine after this command to make it take +effect if --reboot is not specified. For more details, please refer to the +reset-crashkernel command in `man kdumpctl`. Reset manually -------------- To reset the crashkernel value manually, it's recommended to use utils like `grubby`. A one liner script for resetting `crashkernel=` value of all installed -kernels to current boot kernel's crashkernel.default` is: +kernels to the default value is: grubby --update-kernel ALL --args "crashkernel=$(kdumpctl get-default-crashkernel)" @@ -98,7 +97,7 @@ triggering kdump: The output will be like this: ``` - Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement + Encrypted kdump target requires extra memory, assuming using the keyslot with minimum memory requirement Reserved crashkernel: 256M Recommended crashkernel: 655M From 1e7df3e1f355da4fe0eca6422479963f7e772bf8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 1 Mar 2022 17:30:50 +0800 Subject: [PATCH 583/806] update kexec-kdump-howto 1. yum is deprecated so use dnf instead 2. use the "kdumpctl reset-crashkernel" API 3. ask the users to refer to crashkernel-howto.txt for setting custom crashkernel value 4. fix a typo Philipp Rudo Signed-off-by: Coiby Xu --- kexec-kdump-howto.txt | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 1aeffc7..6741faf 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -44,7 +44,7 @@ ia64 and ppc64. If you're reading this document, you should already have kexec-tools installed. If not, you install it via the following command: - # yum install kexec-tools + # dnf install kexec-tools Now load a kernel with kexec: @@ -66,23 +66,31 @@ How to configure kdump Again, we assume if you're reading this document, you should already have kexec-tools installed. If not, you install it via the following command: - # yum install kexec-tools + # dnf install kexec-tools To be able to do much of anything interesting in the way of debug analysis, you'll also need to install the kernel-debuginfo package, of the same arch as your running kernel, and the crash utility: - # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash + # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash -Next up, we need to modify some boot parameters to reserve a chunk of memory for -the capture kernel. With the help of grubby, it's very easy to append -"crashkernel=128M" to the end of your kernel boot parameters. Note that the X -values are such that X = the amount of memory to reserve for the capture kernel. -And based on arch and system configuration, one might require more than 128M to -be reserved for kdump. One need to experiment and test kdump, if 128M is not -sufficient, try reserving more memory. +Next up, we need to reserve a chunk of memory for the capture kernel. To use +the default crashkernel value, you can kdumpctl: - # grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r` + # kdumpctl reset-crashkernel --kernel=/boot/vmlinuz-`uname -r` + +If the default value does not work for your setup you can use + + # grubby --args="crashkernel=256M" --update-kernel=/boot/vmlinuz-`uname -r` + +to specify a larger value, in this case 256M. You need to experiment to +find the best value that works for your setup. To begin with + + # kdumpctl estimate + +gives you an estimation for the crashkernel value based on the currently +running kernel. For more details, please refer to the "Estimate crashkernel" +section in /usr/share/doc/kexec-tools/crashkernel-howto.txt. Note that there is an alternative form in which to specify a crashkernel memory reservation, in the event that more control is needed over the size and @@ -135,7 +143,7 @@ in /var/crash//vmcore), then the system rebooted back into your normal kernel. Once back to your normal kernel, you can use the previously installed crash -kernel in conjunction with the previously installed kernel-debuginfo to +utility in conjunction with the previously installed kernel-debuginfo to perform postmortem analysis: # crash /usr/lib/debug/lib/modules/2.6.17-1.2621.el5/vmlinux From 695e5b8676ecbdf999ed535eae4074db8c3ef7aa Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 1 Mar 2022 17:30:30 +0800 Subject: [PATCH 584/806] update fadump-howto 1. yum is deprecated so use dnf instead 2. use the "kdumpctl reset-crashkernel --fadump=on" API Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- fadump-howto.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fadump-howto.txt b/fadump-howto.txt index bc87644..9773f78 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -39,7 +39,7 @@ kernel are one and the same on ppc64. If you're reading this document, you should already have kexec-tools installed. If not, you install it via the following command: - # yum install kexec-tools + # dnf install kexec-tools Fadump Operational Flow: @@ -82,7 +82,7 @@ How to configure fadump: Again, we assume if you're reading this document, you should already have kexec-tools installed. If not, you install it via the following command: - # yum install kexec-tools + # dnf install kexec-tools Make the kernel to be configured with FADump as the default boot entry, if it isn't already: @@ -94,20 +94,24 @@ anything interesting in the way of debug analysis, you'll also need to install the kernel-debuginfo package, of the same arch as your running kernel, and the crash utility: - # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash + # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash -Next up, we need to modify some boot parameters to enable firmware assisted -dump. With the help of grubby, it's very easy to append "fadump=on" to the end -of your kernel boot parameters. To reserve the appropriate amount of memory -for boot memory preservation, pass 'crashkernel=X' kernel cmdline parameter. -For the recommended value of X, see 'FADump Memory Requirements' section. +Next up, we can enable firmware assisted dump and reserve the memory for boot +memory preservation as specified in in the table of 'FADump Memory Requirements' +section: + + # kdumpctl reset-crashkernel --fadump=on + +Alternatively, you can use grubby to reserve custom amount of memory: # grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r` By default, FADump reserved memory will be initialized as CMA area to make the memory available through CMA allocator on the production kernel. We can opt out of this, making reserved memory unavailable to production kernel, by booting the -linux kernel with 'fadump=nocma' instead of 'fadump=on'. +linux kernel with 'fadump=nocma' instead of 'fadump=on': + + # kdumpctl reset-crashkernel --fadump=nocma The term 'boot memory' means size of the low memory chunk that is required for a kernel to boot successfully when booted with restricted memory. By default, @@ -350,6 +354,6 @@ Remove "crashkernel=" from kernel cmdline parameters: If KDump is to be used as the dump capturing mechanism, reset the crashkernel parameter: - # kdumpctl reset-crashkernel `uname -r` + # kdumpctl reset-crashkernel --fadump=off Reboot the system for the settings to take effect. From be20580b06dc3fe92556933046ec8d2fd3a9b4b5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 1 Mar 2022 17:33:24 +0800 Subject: [PATCH 585/806] remove the upper bound of default crashkernel value example Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- crashkernel-howto.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt index 94f4e52..6573847 100644 --- a/crashkernel-howto.txt +++ b/crashkernel-howto.txt @@ -17,7 +17,7 @@ Latest kexec-tools provides "kdumpctl get-default-crashkernel" to retrieve the default crashkernel value, $ echo $(kdumpctl get-default-crashkernel) - 1G-4G:192M,4G-64G:256M,64G-102400T:512M + 1G-4G:192M,4G-64G:256M,64G-:512M It will be taken as the default value of 'crashkernel=', you can use this value as a reference for setting crashkernel value manually. From d5b01d7ef0f05c5ecb028aa1e8942ec099cbd9dd Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 24 Apr 2022 09:39:22 +0800 Subject: [PATCH 586/806] Release 2.0.24-2 A issue of bogus date in %changelog is fixed as well. Signed-off-by: Coiby Xu --- kexec-tools.spec | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index db6374c..8b1acf5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.24 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -405,6 +405,21 @@ fi %endif %changelog +* Apr 24 2022 Coiby - 2.0.24-2 +- remove the upper bound of default crashkernel value example +- update fadump-howto +- update kexec-kdump-howto +- update crashkernel-howto +- add man documentation for kdumpctl get-default-crashkernel +- unit tests: add check_config with with the default kdump.conf +- unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh +- unit tests: add tests for "kdumpctl reset-crashkernel" +- unit tests: add tests for _{update,read}_kernel_arg_in_grub_etc_default in kdumpctl +- unit tests: add tests for kdumpctl read_proc_environ_var and _is_osbuild +- unit tests: add tests for get_dump_mode_by_fadump_val +- unit tests: add tests for get_grub_kernel_boot_parameter +- unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested + * Mon Apr 11 2022 Coiby - 2.0.24-1 - Update kexec-tools to 2.0.24 - kdumpctl: remove kdump_get_conf_val in save_raw @@ -472,7 +487,7 @@ fi - sysconfig: make kexec_file_load as default option on aarch64 - Enable zstd compression for makedumpfile in kexec-tools.spec -* Mon Nov 18 2021 Coiby - 2.0.23-1 +* Thu Nov 18 2021 Coiby - 2.0.23-1 - Update kexec-tools to 2.0.23 - Rebase makedumpfile to 1.7.0 - fix broken extra_bins when installing multiple binaries From 1facd0c11876bcbe83a9c52c67c1ce7a59f681dd Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 24 Apr 2022 11:38:04 +0800 Subject: [PATCH 587/806] fix incorrect date format in changelog Signed-off-by: Coiby Xu --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8b1acf5..6673000 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -405,7 +405,7 @@ fi %endif %changelog -* Apr 24 2022 Coiby - 2.0.24-2 +* Sun Apr 24 2022 Coiby - 2.0.24-2 - remove the upper bound of default crashkernel value example - update fadump-howto - update kexec-kdump-howto From 3d70f8b04958c6f7a4a6b937fb828f9970d0c525 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sat, 23 Apr 2022 21:07:31 +0800 Subject: [PATCH 588/806] logger: save log after all kdump progress finished Make log saving the last step of kdump.sh, so it can catch more info, for example, the output of post.d hooks will be covered by the log now. Signed-off-by: Kairui Song Reviewed-by: Philipp Rudo --- dracut-kdump.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index b17455a..f4456a1 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -15,6 +15,8 @@ fi KDUMP_PATH="/var/crash" KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log" +KDUMP_LOG_DEST="" +KDUMP_LOG_OP="" CORE_COLLECTOR="" DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31" DMESG_COLLECTOR="/sbin/vmcore-dmesg" @@ -113,12 +115,19 @@ get_kdump_confs() # store the kexec kernel log to a file. save_log() { + # LOG_OP is empty when log can't be saved, eg. raw target + [ -n "$KDUMP_LOG_OP" ] || return + dmesg -T > $KDUMP_LOG_FILE if command -v journalctl > /dev/null; then journalctl -ab >> $KDUMP_LOG_FILE fi chmod 600 $KDUMP_LOG_FILE + + dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/" + + eval "$KDUMP_LOG_OP" } # $1: dump path, must be a mount point @@ -159,6 +168,9 @@ dump_fs() save_opalcore_fs "$_dump_fs_path" dinfo "saving vmcore" + KDUMP_LOG_DEST=$_dump_fs_path/ + KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'" + $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" _dump_exitcode=$? if [ $_dump_exitcode -eq 0 ]; then @@ -167,12 +179,6 @@ dump_fs() dinfo "saving vmcore complete" else derror "saving vmcore failed, exitcode:$_dump_exitcode" - fi - - dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/" - save_log - mv "$KDUMP_LOG_FILE" "$_dump_fs_path/" - if [ $_dump_exitcode -ne 0 ]; then return 1 fi @@ -395,8 +401,12 @@ dump_ssh() ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" + dinfo "saving vmcore" + KDUMP_LOG_DEST=$2:$_ssh_dir/ + KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE' '$_scp_address:$_ssh_dir/'" + save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then @@ -421,12 +431,6 @@ dump_ssh() derror "saving vmcore failed, exitcode:$_ret" fi - dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/" - save_log - if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then - derror "saving log file failed, _exitcode:$_ret" - fi - return $_ret } @@ -576,6 +580,8 @@ if ! do_kdump_post $DUMP_RETVAL; then derror "kdump_post script exited with non-zero status!" fi +save_log + if [ $DUMP_RETVAL -ne 0 ]; then exit 1 fi From 5c23b6ebb79c5e06ff713d437cb54fb2843aa12d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 7 May 2022 16:30:39 +0800 Subject: [PATCH 589/806] fix a calculation error in get_system_size Recently, it's found 'kdumpctl estimate' returns 512M while the system reserves 1024M kdump memory in a case. This happens because the ranges in /proc/iomem are inclusively. For example, "0-1: System RAM" means 2 bytes of system memory other than 1 byte. Fix this error by adding one more byte. Note 1. the function has been simplified as well. 2. define PROC_IOMEM as /proc/iomem for the sake of unit tests Reported-by: Ruowen Qin Fixes: 1813189 ("kdump-lib.sh: introduce functions to return recommened mem size") Suggested-by: Philipp Rudo Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 557eff6..ed28df3 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -788,17 +788,12 @@ prepare_cmdline() echo "$cmdline" } -#get system memory size in the unit of GB +PROC_IOMEM=/proc/iomem +#get system memory size i.e. memblock.memory.total_size in the unit of GB get_system_size() { - result=$(grep "System RAM" /proc/iomem | awk -F ":" '{ print $1 }' | tr "[:lower:]" "[:upper:]" | paste -sd+) - result="+$result" - # replace '-' with '+0x' and '+' with '-0x' - sum=$(echo "$result" | sed -e 's/-/K0x/g' -e 's/+/-0x/g' -e 's/K/+/g') - size=$(printf "%d\n" $((sum))) - size=$((size / 1024 / 1024 / 1024)) - - echo "$size" + sum=$(sed -n "s/\s*\([0-9a-fA-F]\+\)-\([0-9a-fA-F]\+\) : System RAM$/+ 0x\2 - 0x\1 + 1/p" $PROC_IOMEM) + echo $(( (sum) / 1024 / 1024 / 1024)) } get_recommend_size() From 4f702c81e9d14a90d22d6b587de37733d0126960 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 12 May 2022 10:48:31 +0800 Subject: [PATCH 590/806] improve get_recommend_size This patch rewrites get_recommend_size to get rid of the following limitations, 1. only supports ranges in crashkernel sorted in increasing order 2. the first entry of crashkernel should have only a single digit and it's in gigabytes Suggested-by: Philipp Rudo Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index ed28df3..b137c89 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -796,33 +796,40 @@ get_system_size() echo $(( (sum) / 1024 / 1024 / 1024)) } +# Return the recommended size for the reserved crashkernel memory +# depending on the system memory size. +# +# This functions is expected to be consistent with the parse_crashkernel_mem() +# in kernel i.e. how kernel allocates the kdump memory given the crashkernel +# parameter crashkernel=range1:size1[,range2:size2,…] and the system memory +# size. get_recommend_size() { local mem_size=$1 local _ck_cmdline=$2 - local OLDIFS="$IFS" + local range start start_unit end end_unit size - start=${_ck_cmdline::1} - if [[ $mem_size -lt $start ]]; then - echo "0M" - return - fi - IFS=',' - for i in $_ck_cmdline; do - end=$(echo "$i" | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $1 }') - recommend=$(echo "$i" | awk -F "-" '{ print $2 }' | awk -F ":" '{ print $2 }') - size=${end::-1} - unit=${end: -1} - if [[ $unit == 'T' ]]; then - size=$((size * 1024)) - fi - if [[ $mem_size -lt $size ]]; then - echo "$recommend" - IFS="$OLDIFS" + while read -r -d , range; do + # need to use non-default IFS as double spaces are used as a + # single delimiter while commas aren't... + IFS=, read start start_unit end end_unit size <<< \ + "$(echo "$range" | sed -n "s/\([0-9]\+\)\([GT]\?\)-\([0-9]*\)\([GT]\?\):\([0-9]\+[MG]\)/\1,\2,\3,\4,\5/p")" + + # aka. 102400T + end=${end:-104857600} + [[ "$end_unit" == T ]] && end=$((end * 1024)) + [[ "$start_unit" == T ]] && start=$((start * 1024)) + + if [[ $mem_size -ge $start ]] && [[ $mem_size -lt $end ]]; then + echo "$size" return fi - done - IFS="$OLDIFS" + + # append a ',' as read expects the 'file' to end with a delimiter + done <<< "$_ck_cmdline," + + # no matching range found + echo "0M" } # get default crashkernel From 1101190e1cc11c25c50f26af61120154eeed1133 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 27 Apr 2022 19:17:32 +0800 Subject: [PATCH 591/806] unit tests: add tests for get_system_size and get_recommend_size Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- spec/kdump-lib_spec.sh | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 spec/kdump-lib_spec.sh diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh new file mode 100644 index 0000000..8c91480 --- /dev/null +++ b/spec/kdump-lib_spec.sh @@ -0,0 +1,51 @@ +#!/bin/bash +Describe 'kdump-lib' + Include ./kdump-lib.sh + + Describe 'get_system_size()' + + PROC_IOMEM=$(mktemp -t spec_test_proc_iomem_file.XXXXXXXXXX) + + cleanup() { + rm -rf "$PROC_IOMEM" + } + + AfterAll 'cleanup' + + ONE_GIGABYTE='000000-3fffffff : System RAM' + Parameters + 1 + 3 + End + + It 'should return correct system RAM size' + echo -n >"$PROC_IOMEM" + for _ in $(seq 1 "$1"); do echo "$ONE_GIGABYTE" >>"$PROC_IOMEM"; done + When call get_system_size + The output should equal "$1" + End + + End + + Describe 'get_recommend_size()' + # Testing stragety: + # 1. inclusive for the lower bound of the range of crashkernel + # 2. exclusive for the upper bound of the range of crashkernel + # 3. supports ranges not sorted in increasing order + + ck="4G-64G:256M,2G-4G:192M,64G-1T:512M,1T-:12345M" + Parameters + 1 0M + 2 192M + 64 512M + 1024 12345M + "$((64 * 1024))" 12345M + End + + It 'should handle all cases correctly' + When call get_recommend_size "$1" $ck + The output should equal "$2" + End + End + +End From 218d9917c03f25bc9872f076491c587815d16efb Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Mon, 16 May 2022 14:04:12 -0400 Subject: [PATCH 592/806] kdump.sysconfig*: add ignition.firstboot to KDUMP_COMMANDLINE_REMOVE For CoreOS based systems we use Ignition for provisioning machines in the initramfs on first boot. We trigger Ignition right now by the presence of `ignition.firstboot` in the kernel command line. The kernel argument is only present on first boot so after a reboot it no longer is in the kernel command line. If a kernel crash happens before the first reboot of a machine we want the `ignition.firstboot` kernel argument to be removed and not passed on to the crash kernel. --- kdump.sysconfig | 2 +- kdump.sysconfig.aarch64 | 2 +- kdump.sysconfig.i386 | 2 +- kdump.sysconfig.ppc64 | 2 +- kdump.sysconfig.ppc64le | 2 +- kdump.sysconfig.s390x | 2 +- kdump.sysconfig.x86_64 | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kdump.sysconfig b/kdump.sysconfig index 70ebf04..c1143f3 100644 --- a/kdump.sysconfig +++ b/kdump.sysconfig @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 index 67a2af7..df75f94 100644 --- a/kdump.sysconfig.aarch64 +++ b/kdump.sysconfig.aarch64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 index 7e18c1c..d8bf5f6 100644 --- a/kdump.sysconfig.i386 +++ b/kdump.sysconfig.i386 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 index ebb22f6..1b0cdc7 100644 --- a/kdump.sysconfig.ppc64 +++ b/kdump.sysconfig.ppc64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le index 270a2cf..d951def 100644 --- a/kdump.sysconfig.ppc64le +++ b/kdump.sysconfig.ppc64le @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x index 234cfe9..2971ae7 100644 --- a/kdump.sysconfig.s390x +++ b/kdump.sysconfig.s390x @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index 188ba3c..6a3ba6e 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -17,7 +17,7 @@ KDUMP_COMMANDLINE="" # This variable lets us remove arguments from the current kdump commandline # as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline # NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma" +KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE From 8f7ffb1a0054e48f833590d908a7d051008986f7 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 24 Apr 2022 09:47:26 +0800 Subject: [PATCH 593/806] Update makedumpfile to 1.7.1 Signed-off-by: Coiby Xu --- kexec-tools.spec | 6 +++--- sources | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6673000..9b8218d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.7.0 +%global mkdf_ver 1.7.1 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools @@ -220,8 +220,8 @@ install -m 755 -D %{SOURCE33} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/92- %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8 +install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5 install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ diff --git a/sources b/sources index 95c0fc6..d0190bb 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 SHA512 (kexec-tools-2.0.24.tar.xz) = ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822 -SHA512 (makedumpfile-1.7.0.tar.gz) = 579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7 +SHA512 (makedumpfile-1.7.1.tar.gz) = 93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632 From 6f9653b9183b710008b8271e6cc51ea47c2585bd Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 24 Apr 2022 09:48:05 +0800 Subject: [PATCH 594/806] Release 2.0.24-3 Signed-off-by: Coiby Xu --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9b8218d..9c6ea8d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.24 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -405,6 +405,13 @@ fi %endif %changelog +* Mon May 23 2022 Coiby - 2.0.24-3 +- Update makedumpfile to 1.7.1 +- unit tests: add tests for get_system_size and get_recommend_size +- improve get_recommend_size +- fix a calculation error in get_system_size +- logger: save log after all kdump progress finished + * Sun Apr 24 2022 Coiby - 2.0.24-2 - remove the upper bound of default crashkernel value example - update fadump-howto From c5bdd2d8f195103d6651f7fa3b429f4edf204956 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 13 Jun 2022 12:08:08 +0800 Subject: [PATCH 595/806] kdump-lib: use non-debug kernels first Kdump uses currently running kernel as default, but when currently running kernel is a debug kernel, it will consume more memory, which may cause out-of-memory and fail to collect vmcore. Now we will try to use non-debug kernels first if possible. Also extract the logic of determine KDUMP_KERNEL from prepare_kdump_bootinfo into a function. This function will return KDUMP_KERNEL given a kernel version. Signed-off-by: Lichen Liu Acked-by: Coiby Xu --- kdump-lib.sh | 71 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index b137c89..944d823 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -633,8 +633,36 @@ prepare_kexec_args() echo "$kexec_args" } +# prepare_kdump_kernel +# This function return kdump_kernel given a kernel version. +prepare_kdump_kernel() +{ + local kdump_kernelver=$1 + local dir img boot_dirlist boot_imglist kdump_kernel machine_id + read -r machine_id < /etc/machine-id + + boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} + boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT $machine_id/$kdump_kernelver/$KDUMP_IMG" + + # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format + boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)" + if [[ "$boot_img" == *"$kdump_kernelver" ]]; then + boot_imglist="$boot_img $boot_imglist" + fi + + for dir in $boot_dirlist; do + for img in $boot_imglist; do + if [[ -f "$dir/$img" ]]; then + kdump_kernel=$(echo "$dir/$img" | tr -s '/') + break 2 + fi + done + done + echo "$kdump_kernel" +} + # -# Detect initrd and kernel location, results are stored in global enviromental variables: +# Detect initrd and kernel location, results are stored in global environmental variables: # KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD # # Expectes KDUMP_BOOTDIR, KDUMP_IMG, KDUMP_IMG_EXT, KDUMP_KERNELVER to be loaded from config already @@ -642,37 +670,40 @@ prepare_kexec_args() # prepare_kdump_bootinfo() { - local boot_img boot_imglist boot_dirlist boot_initrdlist - local machine_id dir img default_initrd_base var_target_initrd_dir + local boot_initrdlist nondebug_kernelver debug_kernelver + local default_initrd_base var_target_initrd_dir if [[ -z $KDUMP_KERNELVER ]]; then - KDUMP_KERNELVER="$(uname -r)" + KDUMP_KERNELVER=$(uname -r) + nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER") fi - read -r machine_id < /etc/machine-id - boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} - boot_imglist="$KDUMP_IMG-$KDUMP_KERNELVER$KDUMP_IMG_EXT $machine_id/$KDUMP_KERNELVER/$KDUMP_IMG" - - # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format - boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)" - if [[ -n $boot_img ]]; then - boot_imglist="$boot_img $boot_imglist" + # Use nondebug kernel if possible, because debug kernel will consume more memory and may oom. + if [[ -n $nondebug_kernelver ]]; then + dinfo "Trying to use $nondebug_kernelver." + debug_kernelver=$KDUMP_KERNELVER + KDUMP_KERNELVER=$nondebug_kernelver fi - for dir in $boot_dirlist; do - for img in $boot_imglist; do - if [[ -f "$dir/$img" ]]; then - KDUMP_KERNEL=$(echo "$dir/$img" | tr -s '/') - break 2 - fi - done - done + KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER") + + if ! [[ -e $KDUMP_KERNEL ]]; then + if [[ -n $debug_kernelver ]]; then + dinfo "Fallback to using debug kernel" + KDUMP_KERNELVER=$debug_kernelver + KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER") + fi + fi if ! [[ -e $KDUMP_KERNEL ]]; then derror "Failed to detect kdump kernel location" return 1 fi + if [[ "$KDUMP_KERNEL" == *"+debug" ]]; then + dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value." + fi + # Set KDUMP_BOOTDIR to where kernel image is stored KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL") From b92bc6e0a775255e545506cedfa6946a1a104eff Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 13 Jun 2022 10:25:26 +0800 Subject: [PATCH 596/806] crashkernel: optimize arm64 reserved size if PAGE_SIZE=4k On RHEL9 and Fedora, the arm64 platform only supports 4KB page size. the reserved memory size can be aligned to that on x86_64. Introducing a new formula for 4KB on arm64, which bases on x86_64 plus extra 64MB. Signed-off-by: Pingfan Liu Acked-by: Baoquan He --- kdump-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 944d823..36437ab 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -884,7 +884,8 @@ kdump_get_arch_recommend_crashkernel() if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" elif [[ $_arch == "aarch64" ]]; then - _ck_cmdline="2G-:448M" + # For 4KB page size, the formula is based on x86 plus extra = 64M + _ck_cmdline="1G-4G:256M,4G-64G:320M,64G-:576M" elif [[ $_arch == "ppc64le" ]]; then if [[ $_dump_mode == "fadump" ]]; then _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" From 980f10aa40852da41907dc0aeb59ad7d3e8f4c30 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Wed, 22 Jun 2022 11:58:31 -0400 Subject: [PATCH 597/806] kdump-lib: clear up references to Atomic/CoreOS There are many variants on OSTree based systems these days so we should probably refer to the class of systems as "OSTree based systems". Also, Atomic Host is dead. Signed-off-by: Dusty Mabe Acked-by: Coiby Xu --- kdump-lib.sh | 2 +- kdumpctl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 36437ab..91b3226 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -248,7 +248,7 @@ kdump_get_persistent_dev() echo $(get_persistent_dev "$dev") } -is_atomic() +is_ostree() { grep -q "ostree" /proc/cmdline } diff --git a/kdumpctl b/kdumpctl index 6188d47..2157371 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1342,7 +1342,7 @@ _update_grub() { local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4 - if is_atomic; then + if is_ostree; then if rpm-ostree kargs | grep -q "crashkernel="; then rpm-ostree kargs --replace="crashkernel=$_crashkernel" else @@ -1472,13 +1472,13 @@ reset_crashkernel() esac done - # 1. CoreOS uses "rpm-ostree kargs" instead of grubby to manage kernel command - # line. --kernel=ALL doesn't make sense for CoreOS. - # 2. CoreOS doesn't support POWER so the dump mode is always kdump. + # 1. OSTree systems use "rpm-ostree kargs" instead of grubby to manage kernel command + # line. --kernel=ALL doesn't make sense for OStree. + # 2. We don't have any OSTree POWER systems so the dump mode is always kdump. # 3. "rpm-ostree kargs" would prompt the user to reboot the system after # modifying the kernel command line so there is no need for kexec-tools # to repeat it. - if is_atomic; then + if is_ostree; then _old_crashkernel=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') _new_dump_mode=kdump _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") From a1ebf0b5654625cd7a80a3b368080d4f56088537 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Fri, 24 Jun 2022 09:57:03 -0400 Subject: [PATCH 598/806] kdump-lib: change how ostree based systems are detected The current recommendation is to check for /run/ostree-booted. See https://bugzilla.redhat.com/show_bug.cgi?id=2092012#c0 Signed-off-by: Dusty Mabe Acked-by: Coiby Xu --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 91b3226..a48ff8a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -250,7 +250,7 @@ kdump_get_persistent_dev() is_ostree() { - grep -q "ostree" /proc/cmdline + test -f /run/ostree-booted } # get ip address or hostname from nfs/ssh config value From f9c32372d2c8d5e58024d2ddc0b70498c696b5d8 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Wed, 22 Jun 2022 12:34:12 -0400 Subject: [PATCH 599/806] kdump-lib: attempt to fix BOOT_IMAGE detection Currently $boot_img can get bad data if running on a platform that doesn't set BOOT_IMAGE in the kernel command line. For example, currently: - s390x Fedora CoreOS machine: ``` [root@cosa-devsh ~]# sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline mitigations=auto,nosmt ignition.platform.id=qemu ostree=/ostree/boot.0/fedora-coreos/2a72567ac8f7ed678c3ac89408f795e6ccd4e97b41e14af5f471b6a807e858b9/0 root=UUID=2a88436a-3b6b-4706-b33a-b8270bd87cde rw rootflags=prjquota boot=UUID=f4b2eaa5-9317-4798-85cf-308c477fee4c crashkernel=600M ``` where on a platform that uses GRUB we get: - x86_64 Fedora CoreOS machine: ``` [root@cosa-devsh ~]# sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline /ostree/fedora-coreos-af4f6cc7b9ff486cfa647680b180e989c72c8eed03a34a42e7328e49332bd20e/vmlinuz-5.18.5-200.fc36.x86_64 ``` We should change the setting of the boot_img variable such that it will be empty if BOOT_IMAGE doesn't exist. With this change on the s390x machine: ``` [root@cosa-devsh ~]# grep -P -o '^BOOT_IMAGE=(\S+)' /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\)/\2/" [root@cosa-devsh ~]# ``` This change mattered much more before the change in c5bdd2d which changed the following line from [[ -n $boot_img ]] to [[ "$boot_img" == *"$kdump_kernelver" ]]. Still I think this change has merit. Signed-off-by: Dusty Mabe Acked-by: Coiby Xu --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index a48ff8a..1c1dcea 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -645,7 +645,7 @@ prepare_kdump_kernel() boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT $machine_id/$kdump_kernelver/$KDUMP_IMG" # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format - boot_img="$(sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\) .*/\2/" /proc/cmdline)" + boot_img="$(grep -P -o '^BOOT_IMAGE=(\S+)' /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\)/\2/")" if [[ "$boot_img" == *"$kdump_kernelver" ]]; then boot_imglist="$boot_img $boot_imglist" fi From ed9cbec2ee263b181ea0023c60b392c37c20071b Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 21 Jun 2022 16:55:09 +0800 Subject: [PATCH 600/806] kdump-lib: Add the CoreOS kernel dir to the boot_dirlist The kernel of CoreOS is not in the standard locations, add /boot/ostree/* to the boot_dirlist to find the vmlinuz. Signed-off-by: Lichen Liu Acked-by: Coiby Xu --- kdump-lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 1c1dcea..f7b659e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -644,6 +644,11 @@ prepare_kdump_kernel() boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT $machine_id/$kdump_kernelver/$KDUMP_IMG" + # The kernel of OSTree based systems is not in the standard locations. + if is_ostree; then + boot_dirlist="$(echo /boot/ostree/*) $boot_dirlist" + fi + # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format boot_img="$(grep -P -o '^BOOT_IMAGE=(\S+)' /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\)/\2/")" if [[ "$boot_img" == *"$kdump_kernelver" ]]; then From 1913ea9118f855f27b89907977f9eb5fdb7ce61b Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Thu, 14 Jul 2022 18:55:31 +0800 Subject: [PATCH 601/806] Checking the existence of 40-redhat.rules before modifying Resolves: bz2106645 The code of commit 163c02970e4ddc takes effect in rhel firstly, later pulled to Fedora. However, Fedora OS doesn't have 40-redhat.rules in systemd-udev package. With this commit applied, a false positive warning message can always been seen as below. So fixing it by checking if 40-redhat.rules exists before handling. With this change, the false warning is gone. [root@ ~]# kdumpctl restart kdump: kexec: unloaded kdump kernel kdump: Stopping kdump: [OK] kdump: No kdump initial ramdisk found. kdump: Rebuilding /boot/initramfs-5.19.0-rc6+kdump.img sed: can't read /var/tmp/dracut.NnAV2g/initramfs/usr/lib/udev/rules.d/40-redhat.rules: No such file or directory kdump: kexec: loaded kdump kernel kdump: Starting kdump: [OK] Signed-off-by: Baoquan He Acked-by: Pingfan Liu --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index c319fc2..4c6096a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1013,7 +1013,9 @@ kdump_install_systemd_conf() { remove_cpu_online_rule() { local file=${initdir}/usr/lib/udev/rules.d/40-redhat.rules - sed -i '/SUBSYSTEM=="cpu"/d' "$file" + if [[ -f $file ]]; then + sed -i '/SUBSYSTEM=="cpu"/d' "$file" + fi } install() { From c735539b3549ca29ca72d824de5a3226ee8fc17f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 21 Jul 2022 16:42:34 +0800 Subject: [PATCH 602/806] Release 2.0.24-4 Signed-off-by: Coiby Xu --- kexec-tools.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9c6ea8d..c6e42b2 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.24 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -405,6 +405,15 @@ fi %endif %changelog +* Thu Jul 21 2022 Coiby - 2.0.24-4 +- Checking the existence of 40-redhat.rules before modifying +- kdump-lib: Add the CoreOS kernel dir to the boot_dirlist +- kdump-lib: attempt to fix BOOT_IMAGE detection +- kdump-lib: change how ostree based systems are detected +- kdump-lib: clear up references to Atomic/CoreOS +- crashkernel: optimize arm64 reserved size if PAGE_SIZE=4k +- kdump-lib: use non-debug kernels first + * Mon May 23 2022 Coiby - 2.0.24-3 - Update makedumpfile to 1.7.1 - unit tests: add tests for get_system_size and get_recommend_size From d593bfa6fc5e2e894798e22fa9c4c433517de4b3 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 21 Jul 2022 19:00:19 +0800 Subject: [PATCH 603/806] KDUMP_COMMANDLINE: remove irqpoll parameter on aws aarch64 platform Currently, kdump may experience failure on some aws aarch64 platform. The final scenario is: [ 79.145089] printk: console [ttyS0] disabled Then the system has no response any more. And after reboot, there is no vmcore generated under /var/crash/. More detail [1]. In a short word, it is caused by the irqpoll policy and some unknown acpi issue. The serial device is hot-removed as a pci device. More detailed, the irqpoll policy demands to iterate over all interrupt handler, if the interrupt line is shared, then the handler is dispatched. And acpi handler acpi_irq() is on a shared interrupt line, so it is called. But for some unknown reason, the acpi hardware regs hold wrong state, and the acpi driver decides that a hot-removed event happens on a pci slot, which finally removes the pci serial device. To tackle this issue by removing the irqpoll parameter on aws aarch64 platform, until the real root cause in acpi is found and resolved. [1]: https://bugzilla.redhat.com/show_bug.cgi?id=2080468#c0 Signed-off-by: Pingfan Liu Acked-by: Coiby Xu --- kdumpctl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kdumpctl b/kdumpctl index 2157371..7ff635c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -641,6 +641,18 @@ function remove_kdump_kernel_key() keyctl unlink "$KDUMP_KEY_ID" %:.ima } +function is_aws_aarch64() +{ + local _bios_model + + _bios_model=$(lscpu | grep "BIOS Model name") + if [[ "${_bios_model}" =~ "AWS Graviton" ]]; then + return 0 + fi + + return 1 +} + # Load the kdump kernel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. @@ -650,6 +662,10 @@ load_kdump() KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") + # This is a workaround on AWS platform, since irqpoll may cause the hot-remove of some pci hotplug device + if is_aws_aarch64; then + KDUMP_COMMANDLINE=$(remove_cmdline_param "${KDUMP_COMMANDLINE}" irqpoll) + fi # For secureboot enabled machines, use new kexec file based syscall. # Old syscall will always fail as it does not have capability to From da0ca0d205e7ac64426ad43540dae3d03cd4447a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 28 Jun 2022 14:38:28 +0800 Subject: [PATCH 604/806] Allow to update kexec-tools using virt-customize for cloud base image Resolves: bz2089871 Currently, kexec-tools can't be updated using virt-customize because older version of kdumpctl can't acquire instance lock for the get-default-crashkernel subcommand. The reason is /var/lock is linked to /run/lock which however doesn't exist in the case of virt-customize. This patch fixes this problem by using /tmp/kdump.lock as the lock file if /run/lock doesn't exist. Note 1. The lock file is now created in /run/lock instead of /var/run/lock since Fedora has adopted adopted /run [2] since F15. 2. %pre scriptlet now always return success since package update won't be blocked [1] https://fedoraproject.org/wiki/Features/var-run-tmpfs Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Reported-by: Nicolas Hicher Suggested-by: Laszlo Ersek Suggested-by: Philipp Rudo Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 11 +++++++++-- kexec-tools.spec | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7ff635c..fed55bd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -49,9 +49,16 @@ fi single_instance_lock() { - local rc timeout=5 + local rc timeout=5 lockfile - if ! exec 9> /var/lock/kdump; then + if [[ -d /run/lock ]]; then + lockfile=/run/lock/kdump + else + # when updating package using virt-customize, /run/lock doesn't exist + lockfile=/tmp/kdump.lock + fi + + if ! exec 9> $lockfile; then derror "Create file lock failed" exit 1 fi diff --git a/kexec-tools.spec b/kexec-tools.spec index c6e42b2..bdc3b95 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -269,6 +269,8 @@ if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crash kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null %endif fi +# don't block package update +: %post # Initial installation From f6bcd819fc2645f762946a802c15684e7627f379 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 15 Jul 2022 15:11:44 +0800 Subject: [PATCH 605/806] use /run/ostree-booted to tell if scriptlet is running on OSTree system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: bz2092012 According to the ostree team [1], the existence of /run/ostree-booted > is the most stable way to signal/check that a system has been > booted in ostree-style. It is also used by rpm-ostree at > compose/install time in the sandboxed environment where scriptlets run, > in order to signal that the package is being installed/composed into > an ostree commit (i.e. not directly on a live system). See > https://github.com/coreos/rpm-ostree/blob/8ddf5f40d9cbbd9d3668cc75b703316e0a89ab11/src/libpriv/rpmostree-scripts.cxx#L350-L353 > for reference. By checking the existence of /run/ostree-booted, we could skip trying to update kernel cmdline during OSTree compose time. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2092012#c3 Reported-by: Luca BRUNO Suggested-by: Luca BRUNO Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Acked-by: Timothée Ravier --- kexec-tools.spec | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index bdc3b95..c82bea8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -262,8 +262,12 @@ mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ %pre -# save the old default crashkernel values to /tmp/ when upgrading the package -if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then +# Save the old default crashkernel values to /tmp/ when upgrading the package +# so kdumpctl later can tell if it should update the kernel crashkernel +# parameter in the posttrans scriptlet. Note this feauture of auto-updating +# the kernel crashkernel parameter currently doesn't support ostree, so skip it +# for ostree. +if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null @@ -338,9 +342,14 @@ do done %posttrans -# try to reset kernel crashkernel value to new default value when upgrading -# the package -if ! grep -qs "ostree" /proc/cmdline && [ $1 == 1 ]; then +# Try to reset kernel crashkernel value to new default value based on the old +# default value or set up crasherkernel value for osbuild +# +# Note +# 1. Skip ostree systems as they are not supported. +# 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The +# former case is used to set up crashkernel for osbuild +if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then kdumpctl reset-crashkernel-after-update rm /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le From e8ae8975958d2b2d2a5f3853d82cdd95ef4bb653 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 12 Jul 2022 14:06:25 +0800 Subject: [PATCH 606/806] skip updating /etc/default/grub for s390x Resolves: bz2104534 When running "kdumpctl reset-crashkernel --kernel=ALL" on s390x, sed: can't read /etc/default/grub: No such file or directory sed: can't read /etc/default/grub: No such file or directory This happens because s390x doesn't use the grub bootloader and /etc/default/grub doesn't exist. Reported-by: smitterl@redhat.com Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kdumpctl b/kdumpctl index fed55bd..1b4b261 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1428,6 +1428,10 @@ _update_kernel_arg_in_grub_etc_default() { local _para=$1 _val=$2 _para_val + if [[ $(uname -m) == s390x ]]; then + return + fi + if [[ -n $_val ]]; then _para_val="$_para=$_val" fi From 58eef4582a5ec060a51a699839868d5b86fa2b05 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 12 Jul 2022 16:07:37 +0800 Subject: [PATCH 607/806] remove useless --zipl when calling grubby to update kernel command line "grubby --zipl" only takes effect when setting default kernel. It's useless to add "--zipl" when updating kernel command line. Also rename _update_grub to _update_kernel_cmdline since s390x doesn't use GRUB. Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kdumpctl b/kdumpctl index 1b4b261..126ecb9 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1361,7 +1361,7 @@ _get_current_running_kernel_path() fi } -_update_grub() +_update_kernel_cmdline() { local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4 @@ -1372,15 +1372,14 @@ _update_grub() rpm-ostree kargs --append="crashkernel=$_crashkernel" fi else - [[ -f /etc/zipl.conf ]] && zipl_arg="--zipl" - grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path" $zipl_arg + grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path" if [[ $_dump_mode == kdump ]]; then grubby --remove-args="fadump" --update-kernel "$_kernel_path" else grubby --args="fadump=$_fadump_val" --update-kernel "$_kernel_path" fi fi - [[ $zipl_arg ]] && zipl > /dev/null + [[ -f /etc/zipl.conf ]] && zipl > /dev/null } _valid_grubby_kernel_path() @@ -1510,7 +1509,7 @@ reset_crashkernel() _new_dump_mode=kdump _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then - _update_grub "" "$_new_crashkernel" "$_new_dump_mode" "" + _update_kernel_cmdline "" "$_new_crashkernel" "$_new_dump_mode" "" if [[ $_reboot == yes ]]; then systemctl reboot fi @@ -1578,7 +1577,7 @@ reset_crashkernel() _old_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) _old_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) if [[ $_old_crashkernel != "$_new_crashkernel" || $_old_fadump_val != "$_new_fadump_val" ]]; then - _update_grub "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val" + _update_kernel_cmdline "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val" if [[ $_reboot != yes ]]; then if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then _what_is_updated="Updated crashkernel=$_new_crashkernel" @@ -1647,7 +1646,7 @@ reset_crashkernel_after_update() if [[ $_crashkernel == "$_old_default_crashkernel" ]] && [[ $_new_default_crashkernel != "$_old_default_crashkernel" ]]; then _fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) - if _update_grub "$_kernel" "$_new_default_crashkernel" "$_dump_mode" "$_fadump_val"; then + if _update_kernel_cmdline "$_kernel" "$_new_default_crashkernel" "$_dump_mode" "$_fadump_val"; then echo "For kernel=$_kernel, crashkernel=$_new_default_crashkernel now." fi fi @@ -1703,7 +1702,7 @@ reset_crashkernel_for_installed_kernel() _fadump_val_running=$(get_grub_kernel_boot_parameter "$_kernel" fadump) if [[ $_crashkernel != "$_crashkernel_running" ]]; then - if _update_grub "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then + if _update_kernel_cmdline "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then echo "kexec-tools has reset $_installed_kernel to use the new default crashkernel value $_crashkernel_running" fi fi From 4d1e02d3405c92a6d474042572313181d8753595 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 12 Jul 2022 10:52:10 +0800 Subject: [PATCH 608/806] remind the users to run zipl after calling grubby on s390x s390x doesn't use GRUB. To make sure the boot entries are updated, call zipl after running grubby. Suggested-by: smitterl@redhat.com Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- crashkernel-howto.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt index 6573847..54e1141 100644 --- a/crashkernel-howto.txt +++ b/crashkernel-howto.txt @@ -82,6 +82,8 @@ kernels to the default value is: grubby --update-kernel ALL --args "crashkernel=$(kdumpctl get-default-crashkernel)" +NOTE: On s390x you also need to run zipl for the change to take effect. + Estimate crashkernel ==================== From d347ad591fea5296403cdcab6c5377b22d6acaee Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 14 Oct 2021 13:12:56 +0800 Subject: [PATCH 609/806] tests: correctly mount the root and also the boot partitions for Fedora 35, 36 and rawhide Cloud Base Image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fedora 33 and 34 Cloud Base Images have only one partition with the following directory structure, . ├── bin -> usr/bin ├── boot ├── dev ├── etc ├── home ├── root By comparison, Fedora 35, 36 and 37 Cloud Base Images have multiple partitions. The root partition which is the last partition has the following directory, . ├── home └── root ├── bin -> usr/bin ├── boot ├── dev ├── etc ├── home ├── root and the 2nd partition is the boot partition. This patch address the above changes by mounting {LAST_PARTITION}/root as to TEMP_ROOT and mount SECOND_PARTITION to TEMP_ROOT/boot. So the test image can be built successfully. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/scripts/image-init-lib.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 0a1524b..822d740 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -23,7 +23,7 @@ is_mounted() clean_up() { for _mnt in ${MNTS[@]}; do - is_mounted $_mnt && $SUDO umount -f $_mnt + is_mounted $_mnt && $SUDO umount -f -R $_mnt done for _dev in ${DEVS[@]}; do @@ -81,6 +81,17 @@ get_mountable_dev() { fi } +# get the separate boot partition +# return the 2nd partition as boot partition +get_mount_boot() { + local dev=$1 _second_part=${dev}p2 + + if [[ $(lsblk -f $_second_part -n -o LABEL 2> /dev/null) == boot ]]; then + echo $_second_part + fi +} + + prepare_loop() { [ -n "$(lsmod | grep "^loop")" ] && return @@ -133,7 +144,7 @@ image_lock() # Mount a device, will umount it automatially when shell exits mount_image() { local image=$1 fmt - local dev mnt mnt_dev + local dev mnt mnt_dev boot root # Lock the image just in case user run this script in parrel image_lock $image @@ -166,12 +177,20 @@ mount_image() { $SUDO mount $mnt_dev $mnt [ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'" + boot=$(get_mount_boot "$dev") + if [[ -n "$boot" ]]; then + root=$(get_image_mount_root $image) + $SUDO mount $boot $root/boot + [ $? -ne 0 ] && perror_exit "failed to mount the bootable partition for device '$mnt_dev'" + fi } get_image_mount_root() { local image=$1 local root=${MNTS[$image]} + # Starting from Fedora 36, the root node is /root/root of the last partition + [ -d "$root/root/root" ] && root=$root/root echo $root if [ -z "$root" ]; then @@ -213,7 +232,7 @@ run_in_image() { inst_in_image() { local image=$1 src=$2 dst=$3 - local root=${MNTS[$image]} + local root=$(get_image_mount_root $1) $SUDO cp $src $root/$dst } From f91711ba8e7eb24882c7bd78e7aec85f51727f63 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 29 Apr 2022 14:21:38 +0800 Subject: [PATCH 610/806] tests: specify the backing format for the backing file when using qemu-img create New version of qemu-img requires specifying the backing format for the backing file otherwise it will abort. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/scripts/image-init-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 822d740..467f32f 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -259,7 +259,7 @@ create_image_from_base_image() { if [ "$image_fmt" != "raw" ]; then if fmt_is_qcow2 "$image_fmt"; then echo "Source image is qcow2, using snapshot..." - qemu-img create -f qcow2 -b $image $output + qemu-img create -f qcow2 -b $image -F qcow2 $output else perror_exit "Unrecognized base image format '$image_mnt'" fi From 2d5df7a512ff0ce2925d08659005a8f7b4deb08f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 29 Apr 2022 14:24:52 +0800 Subject: [PATCH 611/806] tests: specify the Fedora version when running fedpkg sources So fedpkg will fetch the sources that matches given Fedora version. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 8fb38c7..05fda1d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -42,7 +42,7 @@ all: $(TEST_ROOT)/output/test-base-image # to rebuild the rpm, currently use rpmbuild to have better control over the rpm building process # $(KEXEC_TOOLS_RPM): $(KEXEC_TOOLS_SRC) - sh -c "cd .. && fedpkg sources" + sh -c "cd .. && fedpkg --release f$(RELEASE) sources" @echo Rebuilding RPM due to modification of sources: $? rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC) From aa842443462d588b825c8cbfd5c2112695ddf549 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 3 Aug 2022 19:54:42 +0800 Subject: [PATCH 612/806] Release 2.0.25-1 Signed-off-by: Coiby Xu --- kexec-tools.spec | 13 +++++++++++-- sources | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c82bea8..24c616d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.24 -Release: 4%{?dist} +Version: 2.0.25 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -416,6 +416,15 @@ fi %endif %changelog +* Wed Aug 03 2022 Coiby - 2.0.25-1 +- Update kexec-tools to 2.0.25 +- remind the users to run zipl after calling grubby on s390x +- remove useless --zipl when calling grubby to update kernel command line +- skip updating /etc/default/grub for s390x +- use /run/ostree-booted to tell if scriptlet is running on OSTree system +- Allow to update kexec-tools using virt-customize for cloud base image +- KDUMP_COMMANDLINE: remove irqpoll parameter on aws aarch64 platform + * Thu Jul 21 2022 Coiby - 2.0.24-4 - Checking the existence of 40-redhat.rules before modifying - kdump-lib: Add the CoreOS kernel dir to the boot_dirlist diff --git a/sources b/sources index d0190bb..15c98ee 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 -SHA512 (kexec-tools-2.0.24.tar.xz) = ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822 +SHA512 (kexec-tools-2.0.25.tar.xz) = 6fd3fe11d428c5bb2ce318744146e03ddf752cc77632064bdd7418ef3ad355ad2e2db212d68a5bc73554d78f786901beb42d72bd62e2a4dae34fb224b667ec6b SHA512 (makedumpfile-1.7.1.tar.gz) = 93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632 From 677da8a59bdf00c661bc6e05c96f2b59a99cfb63 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 1 Aug 2022 23:25:48 +0800 Subject: [PATCH 613/806] sysconfig: use a simple generator script to maintain These kdump.sysconfig.* files are almost identical with a bit difference in several parameters, just use a simple script to generate them upon packaging. This should make it easier to maintain, updating a comment or param for a certain arch can be done in one place. There are only some comment or empty option differences with the generated version because some arch's sysconfig is not up-to-dated, this actually fixes the issue, I used the following script to check these differences: # for arch in aarch64 i386 ppc64 ppc64le s390x x86_64; do ./gen-kdump-sysconfig.sh $arch > kdump.sysconfig.$arch.new git checkout HEAD^ kdump.sysconfig.$arch &>/dev/null echo "$arch:" diff kdump.sysconfig.$arch kdump.sysconfig.$arch.new; echo "" done; git reset; Signed-off-by: Kairui Song Reviewed-by: Philipp Rudo --- kdump.sysconfig => gen-kdump-sysconfig.sh | 61 +++++++++++++++++++++++ kdump.sysconfig.aarch64 | 53 -------------------- kdump.sysconfig.i386 | 56 --------------------- kdump.sysconfig.ppc64 | 58 --------------------- kdump.sysconfig.ppc64le | 58 --------------------- kdump.sysconfig.s390x | 59 ---------------------- kdump.sysconfig.x86_64 | 56 --------------------- kexec-tools.spec | 17 ++----- 8 files changed, 66 insertions(+), 352 deletions(-) rename kdump.sysconfig => gen-kdump-sysconfig.sh (50%) mode change 100644 => 100755 delete mode 100644 kdump.sysconfig.aarch64 delete mode 100644 kdump.sysconfig.i386 delete mode 100644 kdump.sysconfig.ppc64 delete mode 100644 kdump.sysconfig.ppc64le delete mode 100644 kdump.sysconfig.s390x delete mode 100644 kdump.sysconfig.x86_64 diff --git a/kdump.sysconfig b/gen-kdump-sysconfig.sh old mode 100644 new mode 100755 similarity index 50% rename from kdump.sysconfig rename to gen-kdump-sysconfig.sh index c1143f3..bc37dee --- a/kdump.sysconfig +++ b/gen-kdump-sysconfig.sh @@ -1,3 +1,11 @@ +#!/bin/bash +# $1: target arch + +SED_EXP="" + +generate() +{ + sed "$SED_EXP" << EOF # Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump # If no version is specified, then the init script will try to find a # kdump kernel with the same version number as the running kernel. @@ -36,6 +44,9 @@ KEXEC_ARGS="" #What is the image type used for kdump KDUMP_IMG="vmlinuz" +#What is the images extension. Relocatable kernels don't have one +KDUMP_IMG_EXT="" + # Logging is controlled by following variables in the first kernel: # - @var KDUMP_STDLOGLVL - logging level to standard error (console output) # - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) @@ -51,3 +62,53 @@ KDUMP_IMG="vmlinuz" # KDUMP_STDLOGLVL=3 # KDUMP_SYSLOGLVL=0 # KDUMP_KMSGLOGLVL=0 +EOF +} + +update_param() +{ + SED_EXP="${SED_EXP}s/^$1=.*$/$1=\"$2\"/;" +} + +case "$1" in +aarch64) + update_param KEXEC_ARGS "-s" + update_param KDUMP_COMMANDLINE_APPEND \ + "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0" + ;; +i386) + update_param KDUMP_COMMANDLINE_APPEND \ + "irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0" + ;; +ppc64) + update_param KEXEC_ARGS "--dt-no-old-root" + update_param KDUMP_COMMANDLINE_REMOVE \ + "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" + update_param KDUMP_COMMANDLINE_APPEND \ + "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" + ;; +ppc64le) + update_param KEXEC_ARGS "--dt-no-old-root -s" + update_param KDUMP_COMMANDLINE_REMOVE \ + "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" + update_param KDUMP_COMMANDLINE_APPEND \ + "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" + ;; +s390x) + update_param KEXEC_ARGS "-s" + update_param KDUMP_COMMANDLINE_REMOVE \ + "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot" + update_param KDUMP_COMMANDLINE_APPEND \ + "nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0" + ;; +x86_64) + update_param KEXEC_ARGS "-s" + update_param KDUMP_COMMANDLINE_APPEND \ + "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0" + ;; +*) + echo "Warning: Unknown architecture '$1', using default sysconfig template." + ;; +esac + +generate diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64 deleted file mode 100644 index df75f94..0000000 --- a/kdump.sysconfig.aarch64 +++ /dev/null @@ -1,53 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="-s" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386 deleted file mode 100644 index d8bf5f6..0000000 --- a/kdump.sysconfig.i386 +++ /dev/null @@ -1,56 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64 deleted file mode 100644 index 1b0cdc7..0000000 --- a/kdump.sysconfig.ppc64 +++ /dev/null @@ -1,58 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="--dt-no-old-root" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -#Specify the action after failure - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le deleted file mode 100644 index d951def..0000000 --- a/kdump.sysconfig.ppc64le +++ /dev/null @@ -1,58 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="--dt-no-old-root -s" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -#Specify the action after failure - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x deleted file mode 100644 index 2971ae7..0000000 --- a/kdump.sysconfig.s390x +++ /dev/null @@ -1,59 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0" - -# Any additional /sbin/mkdumprd arguments required. -MKDUMPRD_ARGS="" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="-s" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 deleted file mode 100644 index 6a3ba6e..0000000 --- a/kdump.sysconfig.x86_64 +++ /dev/null @@ -1,56 +0,0 @@ -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="-s" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 diff --git a/kexec-tools.spec b/kexec-tools.spec index 24c616d..ee43b13 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -11,10 +11,7 @@ Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Source1: kdumpctl -Source2: kdump.sysconfig -Source3: kdump.sysconfig.x86_64 -Source4: kdump.sysconfig.i386 -Source5: kdump.sysconfig.ppc64 +Source3: gen-kdump-sysconfig.sh Source7: mkdumprd Source8: kdump.conf Source9: https://github.com/makedumpfile/makedumpfile/archive/%{mkdf_ver}/makedumpfile-%{mkdf_shortver}.tar.gz @@ -25,18 +22,15 @@ Source13: 98-kexec.rules Source14: 98-kexec.rules.ppc64 Source15: kdump.conf.5 Source16: kdump.service -Source18: kdump.sysconfig.s390x Source19: https://github.com/lucchouina/eppic/archive/%{eppic_ver}/eppic-%{eppic_shortver}.tar.gz Source20: kdump-lib.sh Source21: kdump-in-cluster-environment.txt Source22: kdump-dep-generator.sh Source23: kdump-lib-initramfs.sh -Source24: kdump.sysconfig.ppc64le Source25: kdumpctl.8 Source26: live-image-kdump-howto.txt Source27: early-kdump-howto.txt Source28: kdump-udev-throttler -Source29: kdump.sysconfig.aarch64 Source30: 60-kdump.install Source31: kdump-logger.sh Source32: mkfadumprd @@ -152,6 +146,9 @@ cp %{SOURCE26} . cp %{SOURCE27} . cp %{SOURCE34} . +# Generate sysconfig file +%{SOURCE3} %{_target_cpu} > kdump.sysconfig + make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic-%{eppic_ver}/libeppic @@ -183,13 +180,9 @@ install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ -SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} -[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_arch} -[ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig -install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump - install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf +install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 From 4edcd9a4001f684d6c5b66afc2e164bdd6a296eb Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Wed, 24 Aug 2022 16:16:14 +0800 Subject: [PATCH 614/806] kdumpctl: make the kdump.log root-readable-only Decrease the risk that of leaking information that could potentially be used to exploit the crash further (think location of keys). Signed-off-by: Lichen Liu Acked-by: Coiby Xu --- kdumpctl | 1 + 1 file changed, 1 insertion(+) diff --git a/kdumpctl b/kdumpctl index 126ecb9..0e37d36 100755 --- a/kdumpctl +++ b/kdumpctl @@ -691,6 +691,7 @@ load_kdump() # and release it. exec 12>&2 exec 2>> $KDUMP_LOG_PATH/kdump.log + chmod 600 $KDUMP_LOG_PATH/kdump.log PS4='+ $(date "+%Y-%m-%d %H:%M:%S") ${BASH_SOURCE}@${LINENO}: ' set -x From 4d52b7d5480ae27bfe70a55030b3be1282843662 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 6 Sep 2022 11:15:15 +0800 Subject: [PATCH 615/806] mkdumprd: Improve error messages on non-existing NFS target directories When kdump is configured with a NFS location, and the remote directory does not exist, kdump.service fails with a confusing error message. kdumpctl[2172]: kdump: Dump path "/tmp/mkdumprd.ftWhOF/target/dumps" does not exist in dump target "10.111.113.2:/srv/kdump" We just need to print the remote directory "dumps" in such case, because "/tmp/mkdumprd.ftWhOF/target" is the local temporary mount point. Signed-off-by: Lichen Liu Reviewed-by: Coiby Xu --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 3e250e0..c0f131d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -242,7 +242,7 @@ check_user_configured_target() # For user configured target, use $SAVE_PATH as the dump path within the target if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then - perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\"" + perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\"" fi check_size fs "$_target" From d905d49c08deab9a404220e8dc0c127df51455d2 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Fri, 16 Sep 2022 19:07:24 +0530 Subject: [PATCH 616/806] fadump: avoid non-debug kernel use for fadump case Since commit c5bdd2d8f195 ("kdump-lib: use non-debug kernels first"), non-debug kernel is preferred, over the debug variant, as dump capture kernel to reduce memory consumption. This works alright for kdump as the capture kernel is loaded using kexec. In case of fadump, regular boot loader is used to load the capture kernel. So, the default kernel needs to be used as capture kernel as well. But with commit c5bdd2d8f195, initrd of a different kernel is made dump capture capable, breaking fadump's ability to capture dump properly. Fix this by sticking with the debug variant in case of fadump. Fixes: c5bdd2d8f195 ("kdump-lib: use non-debug kernels first") Signed-off-by: Hari Bathini Acked-by: Lichen Liu Acked-by: Coiby Xu --- kdump-lib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index f7b659e..6d081a8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -680,7 +680,13 @@ prepare_kdump_bootinfo() if [[ -z $KDUMP_KERNELVER ]]; then KDUMP_KERNELVER=$(uname -r) - nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER") + + # Fadump uses the regular bootloader, unlike kdump. So, use the same version + # for default kernel and capture kernel unless specified explicitly with + # KDUMP_KERNELVER option. + if ! is_fadump_capable; then + nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER") + fi fi # Use nondebug kernel if possible, because debug kernel will consume more memory and may oom. From c743881ae691c4e2bcf049cbf28abd2850b816e8 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Fri, 23 Sep 2022 18:13:11 +0800 Subject: [PATCH 617/806] virtiofs support for kexec-tools This patch add virtiofs support for kexec-tools by introducing a new option for /etc/kdump.conf: virtiofs myfs Where myfs is a variable tag name specified in qemu cmdline "-device vhost-user-fs-pci,tag=myfs". The patch covers the following cases: 1) Dumping VM's vmcore to a virtiofs shared directory; 2) When the VM's rootfs is a virtiofs shared directory and dumping the VM's vmcore to its subdirectory, such as /var/crash; 3) The combination of case 1 & 2: The VM's rootfs is a virtiofs shared directory and dumping the VM's vmcore to another virtiofs shared directory. Case 2 & 3 need dracut >= 057, otherwise VM cannot boot from virtiofs shared rootfs. But it is not the issue of kexec-tools. Reviewed-by: Philipp Rudo Signed-off-by: Tao Liu --- dracut-kdump.sh | 2 +- dracut-module-setup.sh | 2 +- kdump-lib-initramfs.sh | 24 +++++++++++++++++++++++- kdump-lib.sh | 33 +++++++++++++++------------------ kdump.conf | 2 ++ kdumpctl | 6 +++--- mkdumprd | 2 +- 7 files changed, 46 insertions(+), 25 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index f4456a1..5c980a8 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -519,7 +519,7 @@ read_kdump_confs() DUMP_INSTRUCTION="dump_fs $config_val" fi ;; - ext[234] | xfs | btrfs | minix | nfs) + ext[234] | xfs | btrfs | minix | nfs | virtiofs) config_val=$(get_mntpoint_from_target "$config_val") DUMP_INSTRUCTION="dump_fs $config_val" ;; diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4c6096a..a790a93 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -673,7 +673,7 @@ kdump_install_conf() { _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val") sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" ;; - ext[234] | xfs | btrfs | minix) + ext[234] | xfs | btrfs | minix | virtiofs) _pdev=$(kdump_get_persistent_dev "$_val") sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" ;; diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 84e6bf7..e982b14 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -55,6 +55,11 @@ is_fs_type_nfs() [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] } +is_fs_type_virtiofs() +{ + [ "$1" = "virtiofs" ] +} + # If $1 contains dracut_args "--mount", return get_dracut_args_fstype() { @@ -110,6 +115,23 @@ is_raw_dump_target() [ -n "$(kdump_get_conf_val raw)" ] } +is_virtiofs_dump_target() +{ + if [ -n "$(kdump_get_conf_val virtiofs)" ]; then + return 0 + fi + + if is_fs_type_virtiofs "$(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)")"; then + return 0 + fi + + if is_fs_type_virtiofs "$(get_fs_type_from_target "$(get_target_from_path "$(get_save_path)")")"; then + return 0 + fi + + return 1 +} + is_nfs_dump_target() { if [ -n "$(kdump_get_conf_val nfs)" ]; then @@ -129,5 +151,5 @@ is_nfs_dump_target() is_fs_dump_target() { - [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix")" ] + [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|virtiofs")" ] } diff --git a/kdump-lib.sh b/kdump-lib.sh index 6d081a8..817652d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -81,35 +81,31 @@ to_dev_name() is_user_configured_dump_target() { - [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh") ]] || is_mount_in_dracut_args -} - -get_user_configured_dump_disk() -{ - local _target - - _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw") - [[ -n $_target ]] && echo "$_target" && return - - _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") - [[ -b $_target ]] && echo "$_target" + [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh\|virtiofs") ]] || is_mount_in_dracut_args } get_block_dump_target() { - local _target _path + local _target _fstype if is_ssh_dump_target || is_nfs_dump_target; then return fi - _target=$(get_user_configured_dump_disk) + _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|virtiofs") [[ -n $_target ]] && to_dev_name "$_target" && return - # Get block device name from local save path - _path=$(get_save_path) - _target=$(get_target_from_path "$_path") - [[ -b $_target ]] && to_dev_name "$_target" + _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") + [[ -b $_target ]] && to_dev_name "$_target" && return + + _fstype=$(get_dracut_args_fstype "$(kdump_get_conf_val "dracut_args")") + is_fs_type_virtiofs "$_fstype" && echo "$_target" && return + + _target=$(get_target_from_path "$(get_save_path)") + [[ -b $_target ]] && to_dev_name "$_target" && return + + _fstype=$(get_fs_type_from_target "$_target") + is_fs_type_virtiofs "$_fstype" && echo "$_target" && return } is_dump_to_rootfs() @@ -125,6 +121,7 @@ get_failure_action_target() # Get rootfs device name _target=$(get_root_fs_device) [[ -b $_target ]] && to_dev_name "$_target" && return + is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return # Then, must be nfs root echo "nfs" fi diff --git a/kdump.conf b/kdump.conf index d4fc78b..e598a49 100644 --- a/kdump.conf +++ b/kdump.conf @@ -43,6 +43,7 @@ # It's recommended to use persistent device names # such as /dev/vg/. # Otherwise it's suggested to use label or uuid. +# Supported fs types: ext[234], xfs, btrfs, minix, virtiofs # # path # - "path" represents the file system path in which vmcore @@ -171,6 +172,7 @@ #ext4 /dev/vg/lv_kdump #ext4 LABEL=/boot #ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 +#virtiofs myfs #nfs my.server.com:/export/tmp #nfs [2001:db8::1:2:3:4]:/export/tmp #ssh user@my.server.com diff --git a/kdumpctl b/kdumpctl index 0e37d36..c7efa2c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -239,7 +239,7 @@ parse_config() _set_config _fstype "$config_opt" || return 1 config_opt=_target ;; - ext[234] | minix | btrfs | xfs | nfs | ssh) + ext[234] | minix | btrfs | xfs | nfs | ssh | virtiofs) _set_config _fstype "$config_opt" || return 1 config_opt=_target ;; @@ -478,8 +478,8 @@ check_fs_modified() fi # No need to check in case of raw target. - # Currently we do not check also if ssh/nfs target is specified - if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target; then + # Currently we do not check also if ssh/nfs/virtiofs target is specified + if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || is_virtiofs_dump_target; then return 0 fi diff --git a/mkdumprd b/mkdumprd index c0f131d..2e5659d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -391,7 +391,7 @@ while read -r config_opt config_val; do extra_modules) extra_modules="$extra_modules $config_val" ;; - ext[234] | xfs | btrfs | minix | nfs) + ext[234] | xfs | btrfs | minix | nfs | virtiofs) check_user_configured_target "$config_val" "$config_opt" add_mount "$config_val" "$config_opt" ;; From bea61431785def6a10aaf55b4c15657d9ad0ca32 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 14:53:21 +0800 Subject: [PATCH 618/806] Fix the sync issue for dump_fs Previously the sync for dump_fs is problematic, it always return success according to man 2 sync. So it cannot detect the error of the dump target is full and not all of vmcore data been written back the disk, which will leave the vmcore imcomplete and report misleading log as "saving vmcore complete". In this patch, we will use "sync -f vmcore" instead, which will return error if syncfs on the dump target fails. In this way, vmcore sync related failures, such as autoextend of lvm2 thinpool fails, can be detected and handled properly. Signed-off-by: Tao Liu Reviewed-by: Coiby Xu --- dracut-kdump.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 5c980a8..9734f43 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -174,9 +174,15 @@ dump_fs() $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" _dump_exitcode=$? if [ $_dump_exitcode -eq 0 ]; then - mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" - sync - dinfo "saving vmcore complete" + sync -f "$_dump_fs_path/vmcore-incomplete" + _sync_exitcode=$? + if [ $_sync_exitcode -eq 0 ]; then + mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" + dinfo "saving vmcore complete" + else + derror "sync vmcore failed, exitcode:$_sync_exitcode" + return 1 + fi else derror "saving vmcore failed, exitcode:$_dump_exitcode" return 1 From fc1c79ffd21e7bcb3a710368cd7023c9a634258e Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 12:09:08 +0800 Subject: [PATCH 619/806] Seperate dracut and dracut-squash compressor for zstd Previously kexec-tools will pass "--compress zstd" to dracut. It will make dracut to decide whether: a) call mksquashfs to make a zstd format squash-root.img, b) call cmd zstd to make a initramfs. Since dracut(>= 057) has decoupled the compressor for dracut and dracut-squash, So in this patch, we will pass the compressor seperately. Note: The is_squash_available && !dracut_has_option --squash-compressor && !is_zsdt_command_available case is left unprocessed on purpose. Actually, the situation when we want to call zstd compression is: 1) If squash function OK, we want dracut to invoke mksquashfs to make a zstd format squash-root.img within initramfs. 2) If squash function is not OK, and cmd zstd presents, we want dracut to invoke cmd zstd to make a zstd format initramfs. is_zstd_command_available check can handle case 2 completely. However, for the is_squash_available check, it cannot handle case 1 completely. It only checks if the kernel supports squashfs, it doesn't check whether the squash module has been added by dracut when making initramfs. In fact, in kexec-tools we are unable to do the check, there are multiple ways to forbit dracut to load a module, such as "dracut -o module" and "omit_dracutmodules in dracut.conf". When squash dracut module is omitted, is_squash_available check will still pass, so "--compress zstd" will be appended to dracut cmdline, and it will call cmd zstd to do the compression. However cmd zstd may not exist, so it fails. The previous "--compress zstd" is ambiguous, after the intro of "--squash-compressor", "--squash-compressor" only effect for mksquashfs and "--compress" only effect for specific cmd. So for the is_squash_available && !dracut_has_option --squash-compressor && !is_zsdt_command_available case, we just leave it to be handled the default way. Reviewed-by: Philipp Rudo Signed-off-by: Tao Liu --- kdump-lib.sh | 9 +++++++-- kexec-tools.spec | 1 - mkdumprd | 7 +++---- mkfadumprd | 4 +++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 817652d..b50b4f4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -37,6 +37,12 @@ is_zstd_command_available() [[ -x "$(command -v zstd)" ]] } +dracut_have_option() +{ + local _option=$1 + ! dracut "$_option" 2>&1 | grep -q "unrecognized option" +} + perror_exit() { derror "$@" @@ -448,8 +454,7 @@ is_wdt_active() have_compression_in_dracut_args() { - [[ "$(kdump_get_conf_val dracut_args)" =~ \ - (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress)([[:space:]]|$) ]] + [[ "$(kdump_get_conf_val dracut_args)" =~ (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress|squash-compressor)([[:space:]]|$) ]] } # If "dracut_args" contains "--mount" information, use it diff --git a/kexec-tools.spec b/kexec-tools.spec index ee43b13..c829bbe 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -64,7 +64,6 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool -Recommends: zstd Recommends: grubby Recommends: hostname BuildRequires: make diff --git a/mkdumprd b/mkdumprd index 2e5659d..7b843a8 100644 --- a/mkdumprd +++ b/mkdumprd @@ -432,10 +432,9 @@ done <<< "$(kdump_read_conf)" handle_default_dump_target if ! have_compression_in_dracut_args; then - # Here zstd is set as the default compression method. If squash module - # is available for dracut, libzstd will be used by mksquashfs. If - # squash module is unavailable, command zstd will be used instead. - if is_squash_available || is_zstd_command_available; then + if is_squash_available && dracut_have_option "--squash-compressor"; then + add_dracut_arg "--squash-compressor" "zstd" + elif is_zstd_command_available; then add_dracut_arg "--compress" "zstd" fi fi diff --git a/mkfadumprd b/mkfadumprd index 86dfcee..f353f15 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -64,7 +64,9 @@ fi # Same as setting zstd in mkdumprd if ! have_compression_in_dracut_args; then - if is_squash_available || is_zstd_command_available; then + if is_squash_available && dracut_have_option "--squash-compressor"; then + _dracut_isolate_args+=(--squash-compressor zstd) + elif is_zstd_command_available; then _dracut_isolate_args+=(--compress zstd) fi fi From a7ead187a4694188de2e8ee26f8063fcec310085 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Sep 2022 14:08:42 +0800 Subject: [PATCH 620/806] Prefix reset-crashkernel-{for-installed_kernel,after-update} with underscore Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2048690 To indicate they are for internal use only, underscore them. Reported-by: rcheerla@redhat.com Signed-off-by: Coiby Xu Reviewed-by: Lichen Liu --- 92-crashkernel.install | 2 +- kdumpctl | 4 ++-- kexec-tools.spec | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/92-crashkernel.install b/92-crashkernel.install index 1d67a13..19bd078 100755 --- a/92-crashkernel.install +++ b/92-crashkernel.install @@ -7,7 +7,7 @@ KERNEL_IMAGE="$4" case "$COMMAND" in add) - kdumpctl reset-crashkernel-for-installed_kernel "$KERNEL_VERSION" + kdumpctl _reset-crashkernel-for-installed_kernel "$KERNEL_VERSION" exit 0 ;; esac diff --git a/kdumpctl b/kdumpctl index c7efa2c..690584e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1764,12 +1764,12 @@ main() shift reset_crashkernel "$@" ;; - reset-crashkernel-after-update) + _reset-crashkernel-after-update) if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then reset_crashkernel_after_update fi ;; - reset-crashkernel-for-installed_kernel) + _reset-crashkernel-for-installed_kernel) if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then reset_crashkernel_for_installed_kernel "$2" fi diff --git a/kexec-tools.spec b/kexec-tools.spec index c829bbe..ba9f0ea 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -342,7 +342,7 @@ done # 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The # former case is used to set up crashkernel for osbuild if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then - kdumpctl reset-crashkernel-after-update + kdumpctl _reset-crashkernel-after-update rm /tmp/old_default_crashkernel 2>/dev/null %ifarch ppc64 ppc64le rm /tmp/old_default_crashkernel_fadump 2>/dev/null From e218128e282066440a4a654707309d785066d79a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Sep 2022 14:30:02 +0800 Subject: [PATCH 621/806] Only try to reset crashkernel for osbuild during package install Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2060319 Currently, kexec-tools tries to reset crashkernel when using anaconda to install the system. But grubby isn't ready and complains that, 10:33:17,631 INF packaging: Configuring (running scriptlet for): kernel-core-5.14.0-70.el9.x86_64 1645746534 03dcd32db234b72440ee6764d59b32347c5f0cd98ac3fb55beb47214a76f33b4 10:34:16,696 INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory We only need to try resetting crashkernel for osbuild. Skip it for other cases. To tell if it's package install instead of package upgrade, make use of %pre to write a file /tmp/kexec-tools-install when "$1 == 1" [1]. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax Reported-by: Jan Stodola Signed-off-by: Coiby Xu Reviewed-by: Lichen Liu --- kdumpctl | 16 ++++++++++++++++ kexec-tools.spec | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/kdumpctl b/kdumpctl index 690584e..7f82f4f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1597,6 +1597,12 @@ reset_crashkernel() fi } +# to tell if it's package install other than upgrade +_is_package_install() +{ + [[ -f /tmp/kexec_tools_package_install ]] +} + # update the crashkernel value in GRUB_ETC_DEFAULT if necessary # # called by reset_crashkernel_after_update and inherit its array variable @@ -1606,6 +1612,10 @@ update_crashkernel_in_grub_etc_default_after_update() local _crashkernel _fadump_val local _dump_mode _old_default_crashkernel _new_default_crashkernel + if _is_package_install; then + return + fi + _crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel) if [[ -z $_crashkernel ]]; then @@ -1681,6 +1691,12 @@ reset_crashkernel_for_installed_kernel() local _installed_kernel _running_kernel _crashkernel _crashkernel_running local _dump_mode_running _fadump_val_running + # During package install, only try to reset crashkernel for osbuild + # thus to avoid calling grubby when installing os via anaconda + if _is_package_install && ! _is_osbuild; then + return + fi + if ! _installed_kernel=$(_find_kernel_path_by_release "$1"); then exit 1 fi diff --git a/kexec-tools.spec b/kexec-tools.spec index ba9f0ea..c9c1ce7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -265,6 +265,11 @@ if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null %endif fi +# indicate it's package install so kdumpctl later will only reset crashkernel +# value for osbuild. +if [ $1 == 1 ]; then + touch /tmp/kexec_tools_package_install +fi # don't block package update : From 15122b3f983f3cbb2ea47c2fbe1121681928f988 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 20 Sep 2022 17:09:44 +0800 Subject: [PATCH 622/806] Fix grep warnings "grep: warning: stray \ before -" Latest grep (3.8) warnings about unneeded backslashes when building kdump initrd [1], kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - grep: warning: stray \ before - Some warnings can be avoided by using "sed -n" to remove grep and the others can use the -- argument. [1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/datawarehouse-public/2022/09/17/redhat:643020269/build_aarch64_redhat:643020269_aarch64/tests/4/results_0001/job.01/recipes/12617739/tasks/5/logs/taskout.log Reported-by: Baoquan He Signed-off-by: Coiby Xu Suggested-by: Philipp Rudo Reviewed-by: Philipp Rudo --- kdump-lib-initramfs.sh | 4 ++-- kdumpctl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e982b14..52dfcb4 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -63,13 +63,13 @@ is_fs_type_virtiofs() # If $1 contains dracut_args "--mount", return get_dracut_args_fstype() { - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3 + echo "$1" | sed -n "s/.*--mount .\(.*\)/\1/p" | cut -d' ' -f3 } # If $1 contains dracut_args "--mount", return get_dracut_args_target() { - echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1 + echo "$1" | sed -n "s/.*--mount .\(.*\)/\1/p" | cut -d' ' -f1 } get_save_path() diff --git a/kdumpctl b/kdumpctl index 7f82f4f..8ff4cb0 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ parse_config() case "$config_opt" in dracut_args) if [[ $config_val == *--mount* ]]; then - if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then + if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then derror 'Multiple mount targets specified in one "dracut_args".' return 1 fi @@ -506,7 +506,7 @@ check_fs_modified() # if --mount argument present then match old and new target, mount # point and file system. If any of them mismatches then rebuild - if echo "$_dracut_args" | grep -q "\-\-mount"; then + if echo "$_dracut_args" | grep -q -- "--mount"; then # shellcheck disable=SC2046 set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3) _old_dev=$1 From 50a8461fc7cc70b57387baa58ff4db864ba36632 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 5 Sep 2022 17:49:18 +0800 Subject: [PATCH 623/806] Choosing the most memory-consuming key slot when estimating the memory requirement for LUKS-encrypted target When there are multiple key slots, "kdumpctl estimate" uses the least memory-consuming key slot. For example, when there are two memory slots created with --pbkdf-memory=1048576 (1G) and --pbkdf-memory=524288 (512M), "kdumpctl estimate" thinks the extra memory requirement is only 512M. This will of course lead to OOM if the user uses the more memory-consuming key slot. Fix it by sorting in reverse order. Fixes: e9e6a2c ("kdumpctl: Add kdumpctl estimate") Signed-off-by: Coiby Xu Reviewed-by: Lichen Liu Signed-off-by: Coiby Xu --- kdumpctl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 8ff4cb0..90d84f3 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1242,12 +1242,12 @@ do_estimate() for _dev in $(get_all_kdump_crypt_dev); do _crypt_info=$(cryptsetup luksDump "/dev/block/$_dev") [[ $(echo "$_crypt_info" | sed -n "s/^Version:\s*\(.*\)/\1/p") == "2" ]] || continue - for _mem in $(echo "$_crypt_info" | sed -n "s/\sMemory:\s*\(.*\)/\1/p" | sort -n); do + for _mem in $(echo "$_crypt_info" | sed -n "s/\sMemory:\s*\(.*\)/\1/p" | sort -n -r); do crypt_size=$((crypt_size + _mem * 1024)) break done done - [[ $crypt_size -ne 0 ]] && echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement\n" + [[ $crypt_size -ne 0 ]] && echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with maximum memory requirement\n" estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size + crypt_size)) if [[ $baseline_size -gt $estimated_size ]]; then From 6ce4b85bb3ed6c97beda9ee4774e0924afbbf58a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 5 Sep 2022 18:08:44 +0800 Subject: [PATCH 624/806] Include the memory overhead cost of cryptsetup when estimating the memory requirement for LUKS-encrypted target Currently, "kdumpctl estimate" neglects the memory overhead cost of cryptsetup itself. Unfortunately, there is no golden formula to calculate the overhead cost [1]. So estimate the overhead cost as 50M for aarch64 and 20M for other architectures based on the following empirical data, | Overhead (M) | OS | arch | | ------------ | ----------------------------------------- | ------- | | 14.1 | RHEL-9.2.0-20220829.d.1 | ppc64le | | 14 | Fedora-37-20220830.n.0 Everything ppc64le | ppc64le | | 17 | Fedora 36 | ppc64le | | 8.8 | Fedora 35 | s390x | | 10.1 | Fedora-Rawhide-20220829.n.0, fc38 | s390x | | 42 | Fedora-Rawhide-20220829.n.0, fc38 | arch64 | | 40 | F35 | arch64 | | 42 | F36 | arch64 | | 42 | Fedora-Rawhide-20220901.n.0 | arch64 | | 10 | F35 | x86_64 | | 10 | Fedora-Rawhide-20220901.n.0 | x86_64 | | 11 | Fedora-Rawhide-20220901.n.0 | x86_64 | [1] https://lore.kernel.org/cryptsetup/20220616044339.376qlipk5h2omhx2@Rk/T/#u Fixes: e9e6a2c ("kdumpctl: Add kdumpctl estimate") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 90d84f3..42c839b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1193,7 +1193,7 @@ do_estimate() local kdump_mods local -A large_mods local baseline - local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommended_size + local kernel_size mod_size initrd_size baseline_size runtime_size reserved_size estimated_size recommended_size _cryptsetup_overhead local size_mb=$((1024 * 1024)) setup_initrd @@ -1247,7 +1247,17 @@ do_estimate() break done done - [[ $crypt_size -ne 0 ]] && echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with maximum memory requirement\n" + + if [[ $crypt_size -ne 0 ]]; then + if [[ $(uname -m) == aarch64 ]]; then + _cryptsetup_overhead=50 + else + _cryptsetup_overhead=20 + fi + + crypt_size=$((crypt_size + _cryptsetup_overhead * size_mb)) + echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with maximum memory requirement\n" + fi estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size + crypt_size)) if [[ $baseline_size -gt $estimated_size ]]; then From fdad7d9869a9637e6799cce222d386aed0b8781e Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 29 Sep 2022 12:35:00 +0800 Subject: [PATCH 625/806] Skip reading /etc/defaut/grub for s390x Currently, updating kexec-tools on s390x gives the warning sed: can't read /etc/default/grub: No such file or directory This happens because s390x doesn't use GRUB and /etc/default/grub doesn't exist. We need to skip both reading and writing to /etc/default/grub. Reported-by: Jie Li Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- kdumpctl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kdumpctl b/kdumpctl index 42c839b..d4d196f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1626,6 +1626,10 @@ update_crashkernel_in_grub_etc_default_after_update() return fi + if [[ $(uname -m) == s390x ]]; then + return + fi + _crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel) if [[ -z $_crashkernel ]]; then From 995ee249034e762a29623daece276f27e712e959 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 27 Oct 2022 16:00:11 +0800 Subject: [PATCH 626/806] Release 2.0.25-2 Signed-off-by: Coiby Xu --- kexec-tools.spec | 20 ++++++++++++++++++-- sources | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c9c1ce7..bfa7a5b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,11 +1,11 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.7.1 +%global mkdf_ver 1.7.2 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools Version: 2.0.25 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -413,6 +413,22 @@ fi %endif %changelog +* Thu Oct 27 2022 Coiby - 2.0.25-1 +- Update makedumpfile to 1.7.2 +- Skip reading /etc/defaut/grub for s390x +- Include the memory overhead cost of cryptsetup when estimating the memory requirement for LUKS-encrypted target +- Choosing the most memory-consuming key slot when estimating the memory requirement for LUKS-encrypted target +- Fix grep warnings "grep: warning: stray \ before -" +- Only try to reset crashkernel for osbuild during package install +- Prefix reset-crashkernel-{for-installed_kernel,after-update} with underscore +- Seperate dracut and dracut-squash compressor for zstd +- Fix the sync issue for dump_fs +- virtiofs support for kexec-tools +- fadump: avoid non-debug kernel use for fadump case +- mkdumprd: Improve error messages on non-existing NFS target directories +- kdumpctl: make the kdump.log root-readable-only +- sysconfig: use a simple generator script to maintain + * Wed Aug 03 2022 Coiby - 2.0.25-1 - Update kexec-tools to 2.0.25 - remind the users to run zipl after calling grubby on s390x diff --git a/sources b/sources index 15c98ee..20bacfe 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 SHA512 (kexec-tools-2.0.25.tar.xz) = 6fd3fe11d428c5bb2ce318744146e03ddf752cc77632064bdd7418ef3ad355ad2e2db212d68a5bc73554d78f786901beb42d72bd62e2a4dae34fb224b667ec6b -SHA512 (makedumpfile-1.7.1.tar.gz) = 93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632 +SHA512 (makedumpfile-1.7.2.tar.gz) = 324e303dd5f507703f66e2bd5dc9d24f9f50ba797be70c05702008ba77078f61ffcc884796ddf9ab737de1d124c3a9d881ab5ce4f3f459690ec00055af25ea9e From 0a5b71d123ee41b244732fb04d224d36e9ccff84 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 15:41:39 +0800 Subject: [PATCH 627/806] Add lvm2 thin provision dump target checker We need to check if a directory or a device is lvm2 thinp target. First, we use get_block_dump_target() to convert dump path into block device, then we check if the device is lvm2 thinp target by cmd lvs. is_lvm2_thinp_device is now located in kdump-lib-initramfs.sh, for it will be used in 2nd kernel. is_lvm2_thinp_dump_target is located in kdump-lib.sh, for it is only used in 1st kernel, and it has dependencies which exist in kdump-lib.sh. Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- kdump-lib-initramfs.sh | 9 +++++++++ kdump-lib.sh | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 52dfcb4..38d71df 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -153,3 +153,12 @@ is_fs_dump_target() { [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|virtiofs")" ] } + +is_lvm2_thinp_device() +{ + _device_path=$1 + _lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \ + --nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null) + + [ -n "$_lvm2_thin_device" ] +} diff --git a/kdump-lib.sh b/kdump-lib.sh index b50b4f4..400b05c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -119,6 +119,12 @@ is_dump_to_rootfs() [[ $(kdump_get_conf_val 'failure_action\|default') == dump_to_rootfs ]] } +is_lvm2_thinp_dump_target() +{ + _target=$(get_block_dump_target) + [ -n "$_target" ] && is_lvm2_thinp_device "$_target" +} + get_failure_action_target() { local _target From 10ca970940f0d8f4edc29737eba1968526182f1e Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 15:41:40 +0800 Subject: [PATCH 628/806] lvm.conf should be check modified if lvm2 thinp enabled lvm2 relies on /etc/lvm/lvm.conf to determine its behaviour. The important configs such as thin_pool_autoextend_threshold and thin_pool_autoextend_percent will be used during kdump in 2nd kernel. So if the file is modified, the initramfs should be rebuild to include the latest. Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- kdump-lib-initramfs.sh | 1 + kdumpctl | 1 + 2 files changed, 2 insertions(+) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index 38d71df..a893532 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -8,6 +8,7 @@ DEFAULT_SSHKEY="/root/.ssh/kdump_id_rsa" KDUMP_CONFIG_FILE="/etc/kdump.conf" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" +LVM_CONF="/etc/lvm/lvm.conf" # Read kdump config in well formated style kdump_read_conf() diff --git a/kdumpctl b/kdumpctl index d4d196f..32a5458 100755 --- a/kdumpctl +++ b/kdumpctl @@ -390,6 +390,7 @@ check_files_modified() # HOOKS is mandatory and need to check the modification time files="$files $HOOKS" + is_lvm2_thinp_dump_target && files="$files $LVM_CONF" check_exist "$files" && check_executable "$EXTRA_BINS" || return 2 for file in $files; do From f11721077a5b1ade96d6326c1620d3da0e5eea18 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 15:41:41 +0800 Subject: [PATCH 629/806] Add dependency of dracut lvmthinpool-monitor module The 80lvmthinpool-monitor module is needed for monitor and autoextend the size of thin pool in 2nd kernel. The module was integrated in dracut version 057. If lvmthinpool-monitor module is not found, we will print a warning. Because we don't want to block the kdump process when the thin pool capacity is enough and no monitor-and-autoextend actually needed. Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a790a93..38d2a85 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -40,6 +40,14 @@ depends() { _dep="$_dep ssh-client" fi + if is_lvm2_thinp_dump_target; then + if dracut --list-modules | grep -q lvmthinpool-monitor; then + add_opt_module lvmthinpool-monitor + else + dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057." + fi + fi + if [[ "$(uname -m)" == "s390x" ]]; then _dep="$_dep znet" fi From 68978f924159b5fc10899941b062e3cc034c8124 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 15:41:42 +0800 Subject: [PATCH 630/806] selftest: Only iterate the .sh files for test execution Previously, all files within $TESTCASEDIR/$test_case are regarded as shell script files for testing. However there might be config files under the directory. So let's only iterate the .sh files. Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- tests/scripts/run-test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index 1501db4..0b589f7 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -85,8 +85,7 @@ for test_case in $testcases; do results[$test_case]="" testdir=$TESTCASEDIR/$test_case - script_num=$(ls -1 $testdir | wc -l) - scripts=$(ls -r -1 $testdir | tr '\n' ' ') + scripts=$(ls -r -1 $testdir | egrep "\.sh$" | tr '\n' ' ') test_outputs="" read main_script aux_script <<< "$scripts" From 6d2c22bb81ee618299df36171d8f85677d4d87d5 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 8 Oct 2022 15:41:43 +0800 Subject: [PATCH 631/806] selftest: Add lvm2 thin provision for kdump test Signed-off-by: Tao Liu Reviewed-by: Philipp Rudo --- .../lvm2-thinp-kdump/0-local-lvm2-thinp.sh | 59 +++++++++++++++++++ .../testcases/lvm2-thinp-kdump/lvm.conf | 5 ++ 2 files changed, 64 insertions(+) create mode 100755 tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh create mode 100644 tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf diff --git a/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh b/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh new file mode 100755 index 0000000..5470aa0 --- /dev/null +++ b/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh @@ -0,0 +1,59 @@ +on_build() { + TEST_DIR_PREFIX=/tmp/lvm_test.XXXXXX + # clear TEST_DIRs if any + rm -rf ${TEST_DIR_PREFIX%.*}.* + TEST_IMG="$(mktemp -d $TEST_DIR_PREFIX)/test.img" + + img_inst_pkg "lvm2" + img_inst $TESTDIR/scripts/testcases/lvm2-thinp-kdump/lvm.conf /etc/lvm/ + dd if=/dev/zero of=$TEST_IMG bs=300M count=1 + # The test.img will be /dev/sdb + img_add_qemu_cmd "-hdb $TEST_IMG" +} + +on_test() { + VG=vg00 + LV_THINPOOL=thinpool + LV_VOLUME=thinlv + VMCORE_PATH=var/crash + + local boot_count=$(get_test_boot_count) + + if [ $boot_count -eq 1 ]; then + + vgcreate $VG /dev/sdb + # Create a small thinpool which is definitely not enough for + # vmcore, then create a thin volume which is definitely enough + # for vmcore, so we can make sure thinpool should be autoextend + # during runtime. + lvcreate -L 10M -T $VG/$LV_THINPOOL + lvcreate -V 300M -T $VG/$LV_THINPOOL -n $LV_VOLUME + mkfs.ext4 /dev/$VG/$LV_VOLUME + mount /dev/$VG/$LV_VOLUME /mnt + mkdir -p /mnt/$VMCORE_PATH + + cat << EOF > /etc/kdump.conf +ext4 /dev/$VG/$LV_VOLUME +path /$VMCORE_PATH +core_collector makedumpfile -l --message-level 7 -d 31 +EOF + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + + elif [ $boot_count -eq 2 ]; then + mount /dev/$VG/$LV_VOLUME /mnt + if has_valid_vmcore_dir /mnt/$VMCORE_PATH; then + test_passed + else + test_failed "Vmcore missing" + fi + + shutdown -h 0 + else + test_failed "Unexpected reboot" + fi +} diff --git a/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf b/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf new file mode 100644 index 0000000..4d81fbd --- /dev/null +++ b/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf @@ -0,0 +1,5 @@ +activation { + thin_pool_autoextend_threshold = 70 + thin_pool_autoextend_percent = 20 + monitoring = 1 +} \ No newline at end of file From 55b0dd03b36556b40e1f0d660b76bc5acb99b982 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 31 Oct 2022 15:42:20 +0530 Subject: [PATCH 632/806] fadump: do not use squash to reduce image size With commit fa9201b2 ("fadump: isolate fadump initramfs image within the default one"), initramfs image gets to hold two squash images, one for production kernel boot purpose and the other for capture kernel boot. Having separate images improved reliability for both production kernel and capture kernel boot scenarios, but the size of initramfs image became considerably larger. Instead of having squash images, compressing $initdir without using squash images reduced the size of initramfs image for fadump case by around 30%. So, avoid using squash for fadump case. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo --- mkfadumprd | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mkfadumprd b/mkfadumprd index f353f15..1e09ac2 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -38,7 +38,9 @@ FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img" # this file tells the initrd is fadump enabled touch "$MKFADUMPRD_TMPDIR/fadump.initramfs" ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER" -if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then +# Don't use squash for capture image or default image as it negatively impacts +# compression ratio and increases the size of the initramfs image. +if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash; then perror_exit "mkfadumprd: failed to build image with dump capture support" fi @@ -58,10 +60,6 @@ _dracut_isolate_args=( /usr/lib/dracut/fadump-kernel-modules.txt ) -if is_squash_available; then - _dracut_isolate_args+=(--add squash) -fi - # Same as setting zstd in mkdumprd if ! have_compression_in_dracut_args; then if is_squash_available && dracut_have_option "--squash-compressor"; then From f33c99e34749e976b610ad939f507cc471b33980 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 31 Oct 2022 15:42:21 +0530 Subject: [PATCH 633/806] fadump: preserve file modification time to help with hardlinking With commit fa9201b2 ("fadump: isolate fadump initramfs image within the default one"), initramfs image gets to hold two images, one for production kernel boot purpose and the other for capture kernel boot. Most files are common among the two images. Retain file modification time to replace duplicate files with hardlinks and save space. Also, avoid unnecessarily compressing fadump image that is decompressed immediately anyway. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo --- mkfadumprd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mkfadumprd b/mkfadumprd index 1e09ac2..36ad645 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -40,14 +40,16 @@ touch "$MKFADUMPRD_TMPDIR/fadump.initramfs" ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER" # Don't use squash for capture image or default image as it negatively impacts # compression ratio and increases the size of the initramfs image. -if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash; then +# Don't compress the capture image as uncompressed image is needed immediately. +# Also, early microcode would not be needed here. +if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --no-compress --no-early-microcode; then perror_exit "mkfadumprd: failed to build image with dump capture support" fi -### Unpack the initramfs having dump capture capability +### Unpack the initramfs having dump capture capability retaining previous file modification time. +# This helps in saving space by hardlinking identical files. mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" -if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && - popd > /dev/null); then +if ! cpio -id --preserve-modification-time --quiet -D "$MKFADUMPRD_TMPDIR/fadumproot" < "$FADUMP_INITRD"; then derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" exit 1 fi From cea74a7b3e2e8c8eff65c68354f0b16e8558a888 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 25 Oct 2022 18:02:04 +0800 Subject: [PATCH 634/806] tests: use .nmconnection to set up test network F36 has dropped support on ifcfg and as a result current network tests fails. Use .nmconnection to set up test network instead. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/scripts/testcases/nfs-kdump/0-server.sh | 13 +++++++------ tests/scripts/testcases/ssh-kdump/0-server.sh | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/scripts/testcases/nfs-kdump/0-server.sh b/tests/scripts/testcases/nfs-kdump/0-server.sh index cf54e70..5436d3d 100755 --- a/tests/scripts/testcases/nfs-kdump/0-server.sh +++ b/tests/scripts/testcases/nfs-kdump/0-server.sh @@ -16,12 +16,13 @@ on_build() { img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" img_run_cmd "systemctl enable dnsmasq" - img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo BOOTPROTO="none" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo [connection] > /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo type=ethernet >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo interface-name=eth0 >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo [ipv4] >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo address1=192.168.77.1/24 >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo method=manual >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'chmod 600 /etc/NetworkManager/system-connections/eth0.nmconnection' img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56" } diff --git a/tests/scripts/testcases/ssh-kdump/0-server.sh b/tests/scripts/testcases/ssh-kdump/0-server.sh index 6dfcc91..b4b84c9 100755 --- a/tests/scripts/testcases/ssh-kdump/0-server.sh +++ b/tests/scripts/testcases/ssh-kdump/0-server.sh @@ -17,12 +17,13 @@ on_build() { img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" img_run_cmd "systemctl enable dnsmasq" - img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo BOOTPROTO="none >> /etc/sysconfig/network-scripts/ifcfg-eth0"' - img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' - img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo [connection] > /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo type=ethernet >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo interface-name=eth0 >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo [ipv4] >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo address1=192.168.77.1/24 >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'echo method=manual >> /etc/NetworkManager/system-connections/eth0.nmconnection' + img_run_cmd 'chmod 600 /etc/NetworkManager/system-connections/eth0.nmconnection' } # Executed when VM boots From 3ae8cf8876edd6ca668890f55d4c006e28a41f90 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Thu, 10 Nov 2022 10:25:58 +0800 Subject: [PATCH 635/806] Don't check fs modified when dump target is lvm2 thinp When the dump target is lvm2 thinp, if we didn't mount the dump target first, get_fs_type_from_target will get empty output: Before mount: $ get_fs_type_from_target /dev/vg00/thinlv After mount: $ mount /dev/vg00/thinlv /mnt $ get_fs_type_from_target /dev/vg00/thinlv ext4 As a result, kdumpctl start will fail with: $ kdumpctl start kdump: Dump target is invalid kdump: Starting kdump: [FAILED] This patch fix the issue by bypassing check_fs_modified when the dump target is lvm2 thinp. Signed-off-by: Tao Liu Reviewed-by: Coiby Xu --- kdumpctl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 32a5458..7caaae5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -479,8 +479,9 @@ check_fs_modified() fi # No need to check in case of raw target. - # Currently we do not check also if ssh/nfs/virtiofs target is specified - if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || is_virtiofs_dump_target; then + # Currently we do not check also if ssh/nfs/virtiofs/thinp target is specified + if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || + is_virtiofs_dump_target || is_lvm2_thinp_dump_target; then return 0 fi From a3da46d6c418d694eba6dc44fe91d841751f164d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 18 Nov 2022 17:11:25 +0800 Subject: [PATCH 636/806] Skip reset_crashkernel_after_update during package install Currently, kexec-tools tries to reset crashkernel when using anaconda to install the system. But grubby isn't ready and complains that, 10:34:17,014 INF packaging: Configuring (running scriptlet for): kexec-tools-2.0.23-9.el9.x86_64 1646034766 53ff7158f8808774f4e3c3c87e504aa7a6d677b537754dac86c87925c8f0a397 10:34:17,205 INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory kexec-tools is supposed to update the kernel crashkernel parameter after package upgrade. Unfortunately, the posttrans RPM scriptlet doesn't distinguish between package install and upgrade. This patch skips reset_crashkernel_after_update as similar to e218128e ("Only try to reset crashkernel for osbuild during package install"). Reported-by: Jan Stodola Signed-off-by: Coiby Xu --- kdumpctl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kdumpctl b/kdumpctl index 7caaae5..b82d869 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1657,6 +1657,10 @@ reset_crashkernel_after_update() local _kernel _crashkernel _dump_mode _fadump_val _old_default_crashkernel _new_default_crashkernel declare -A _crashkernel_vals + if _is_package_install; then + return + fi + _crashkernel_vals[old_kdump]=$(cat /tmp/old_default_crashkernel 2> /dev/null) _crashkernel_vals[old_fadump]=$(cat /tmp/old_default_crashkernel_fadump 2> /dev/null) _crashkernel_vals[new_kdump]=$(get_default_crashkernel kdump) From b7e58619d175ccefcd1cfc2e9801ffb4448d0257 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 13 Sep 2021 22:13:44 +0800 Subject: [PATCH 637/806] Fix error for vlan over team network interface 6f9235887f7817085aabfcc67bf4a6d68e474264 ("module-setup.sh: enable vlan on team interface") skips establishing teaming network by mistake. Although it could use one of slave netifs to establish connection to transfer vmcore to remote fs, it breaks the implicit assumption of creating an identical network topology to the 1st kernel. Fixes: 6f92358 ("module-setup.sh: enable vlan on team interface") Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 38d2a85..668768e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -445,6 +445,9 @@ kdump_setup_vlan() { elif kdump_is_bond "$_phydev"; then (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_apath_by_ifname "$_phydev")") || exit 1 echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" + elif kdump_is_team "$_phydev"; then + (kdump_setup_team "$_phydev") || exit 1 + echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" else _kdumpdev="$(kdump_setup_ifname "$_phydev")" echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf" From d25b1ee31c0c7eee43362c96d5e76f6fb0e90a25 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 9 Sep 2021 11:35:52 +0800 Subject: [PATCH 638/806] Add functions to copy NetworkManage connection profiles to the initramfs Each network interface is manged by a NM connection. Given a list of network interface names, copy the NetworkManager (NM) connection profiles i.e. .nmconnection files to the kdump initramfs. Before copying a connection file, clone it to automatically convert a legacy ifcfg-*[1] file to a .nmconnection file and for the convenience of editing the connection profile. [1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 668768e..4a213e0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1,10 +1,21 @@ #!/bin/bash +_DRACUT_KDUMP_NM_TMP_DIR="/tmp/$$-DRACUT_KDUMP_NM" + +cleanup() { + rm -rf "$_DRACUT_KDUMP_NM_TMP_DIR" +} + +# shellcheck disable=SC2154 # known issue of shellcheck https://github.com/koalaman/shellcheck/issues/1299 +trap 'ret=$?; cleanup; exit $ret;' EXIT + kdump_module_init() { if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" fi + mkdir -p "$_DRACUT_KDUMP_NM_TMP_DIR" + . /lib/kdump/kdump-lib.sh } @@ -354,6 +365,71 @@ kdump_setup_ifname() { echo "$_ifname" } +_clone_nmconnection() { + local _clone_output _name _unique_id + + _unique_id=$1 + _name=$(nmcli --get-values connection.id connection show "$_unique_id") + if _clone_output=$(nmcli connection clone --temporary uuid "$_unique_id" "$_name"); then + sed -E -n "s/.* \(.*\) cloned as.*\((.*)\)\.$/\1/p" <<< "$_clone_output" + return 0 + fi + + return 1 +} + +# Clone and modify NM connection profiles +# +# This function makes use of "nmcli clone" to automatically convert ifcfg-* +# files to Networkmanager .nmconnection connection profiles and also modify the +# properties of .nmconnection if necessary. +clone_and_modify_nmconnection() { + local _dev _cloned_nmconnection_file_path _tmp_nmconnection_file_path _old_uuid _uuid + + _dev=$1 + _nmconnection_file_path=$2 + + _old_uuid=$(nmcli --get-values connection.uuid connection show filename "$_nmconnection_file_path") + + if ! _uuid=$(_clone_nmconnection "$_old_uuid"); then + derror "Failed to clone $_old_uuid" + exit 1 + fi + + _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") + _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") + cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" + # change uuid back to old value in case it's refered by other connection + # profile e.g. connection.master could be interface name of the master + # device or UUID of the master connection. + sed -i -E "s/(^uuid=).*$/\1${_old_uuid}/g" "$_tmp_nmconnection_file_path" + nmcli connection del "$_uuid" &> >(ddebug) + echo -n "$_tmp_nmconnection_file_path" +} + +_install_nmconnection() { + local _src _nmconnection_name _dst + + _src=$1 + _nmconnection_name=$(basename "$_src") + _dst="/etc/NetworkManager/system-connections/$_nmconnection_name" + inst "$_src" "$_dst" +} + +kdump_install_nmconnections() { + local _netif _nm_conn_path _cloned_nm_path + + while IFS=: read -r _netif _nm_conn_path; do + [[ -v "unique_netifs[$_netif]" ]] || continue + if _cloned_nm_path=$(clone_and_modify_nmconnection "$_netif" "$_nm_conn_path"); then + _install_nmconnection "$_cloned_nm_path" + else + derror "Failed to install the .nmconnection for $_netif" + exit 1 + fi + done <<< "$(nmcli -t -f device,filename connection show --active)" +} + kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev @@ -1030,6 +1106,7 @@ remove_cpu_online_rule() { } install() { + declare -A unique_netifs local arch kdump_module_init From 9dfcacf72d2cd135bf8b72c4bbc97f15efa21250 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 8 Sep 2022 17:06:19 +0800 Subject: [PATCH 639/806] Determine whether IPv4 or IPv6 is needed According to `man nm-online`, "By default, connections have the ipv4.may-fail and ipv6.may-fail properties set to yes; this means that NetworkManager waits for one of the two address families to complete configuration before considering the connection activated. If you need a specific address family configured before network-online.target is reached, set the corresponding may-fail property to no." If a NIC has an IPv4 or IPv6 address, set the corresponding may-fail property to no. Otherwise, dumping vmcore over IPv6 could fail because only IPv4 network is ready or vice versa. Also disable IPv6 if only IPv4 is used and vice versa. Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4a213e0..e5ca6f7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -365,6 +365,24 @@ kdump_setup_ifname() { echo "$_ifname" } +use_ipv4_or_ipv6() { + local _netif=$1 _uuid=$2 + + if [[ -v "ipv4_usage[$_netif]" ]]; then + nmcli connection modify --temporary "$_uuid" ipv4.may-fail no &> >(ddebug) + fi + + if [[ -v "ipv6_usage[$_netif]" ]]; then + nmcli connection modify --temporary "$_uuid" ipv6.may-fail no &> >(ddebug) + fi + + if [[ -v "ipv4_usage[$_netif]" ]] && [[ ! -v "ipv6_usage[$_netif]" ]]; then + nmcli connection modify --temporary "$_uuid" ipv6.method disabled &> >(ddebug) + elif [[ ! -v "ipv4_usage[$_netif]" ]] && [[ -v "ipv6_usage[$_netif]" ]]; then + nmcli connection modify --temporary "$_uuid" ipv4.method disabled &> >(ddebug) + fi +} + _clone_nmconnection() { local _clone_output _name _unique_id @@ -396,6 +414,8 @@ clone_and_modify_nmconnection() { exit 1 fi + use_ipv4_or_ipv6 "$_dev" "$_uuid" + _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" @@ -1106,7 +1126,7 @@ remove_cpu_online_rule() { } install() { - declare -A unique_netifs + declare -A unique_netifs ipv4_usage ipv6_usage local arch kdump_module_init From 6b586a903632831b05f591048fdb7de4af273088 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 22 Sep 2022 22:08:43 +0800 Subject: [PATCH 640/806] Apply the timeout configuration of nm-initrd-generator nm-wait-online-initrd.service installed by dracut's 35-networkmanager module calls nm-online with "-s" which means it returns immediately when NetworkManager logs "startup complete" after certain timeouts are reached. "startup complete" doesn't necessarily network connectivity has been established. nm-initrd-generator has a set of timeouts that in most of cases when applied, "startup-complete" means network connectivity has been established. So apply it when setting up kdump network. Suggested-by: Thomas Haller Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e5ca6f7..aeff5fc 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -365,6 +365,22 @@ kdump_setup_ifname() { echo "$_ifname" } +apply_nm_initrd_generator_timeouts() { + local _timeout_conf + + _timeout_conf=$_DRACUT_KDUMP_NM_TMP_DIR/timeout_conf + cat << EOF > "$_timeout_conf" +[device-95-kdump] +carrier-wait-timeout=30000 + +[connection-95-kdump] +ipv4.dhcp-timeout=90 +ipv6.dhcp-timeout=90 +EOF + + inst "$_timeout_conf" "/etc/NetworkManager/conf.d/95-kdump-timeouts.conf" +} + use_ipv4_or_ipv6() { local _netif=$1 _uuid=$2 @@ -416,6 +432,7 @@ clone_and_modify_nmconnection() { use_ipv4_or_ipv6 "$_dev" "$_uuid" + nmcli connection modify --temporary uuid "$_uuid" connection.wait-device-timeout 60000 &> >(ddebug) _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" From 62355ebe5abed6fdd3331bbb2f07c64d3434d159 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 23 Sep 2022 22:16:49 +0800 Subject: [PATCH 641/806] Stop dracut 35network-manager from running nm-initrd-generator kexec-tools depends on dracut's 35network-manager module which will call nm-initrd-generator. We don't want nm-initrd-generator to generate connection profiles since we will copy them from 1st kernel to kdump kernel initramfs. NetworkManager >= 1.35.2 won't generate connection profiles if there's a connection dir with rd.neednet. For Fedora/RHEL, this connection dir is /etc/NetworkManager/system-connections. For the details, please refer to the NetworkManager commit 79885656d3 ("initrd: don't add a connection if there's a connection dir with rd.neednet") [1]. Before the release of NetworkManager >= 1.35.2, we need to mask /usr/libexec/nm-initrd-generator. [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1010 Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index aeff5fc..ecfabc7 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -465,6 +465,11 @@ kdump_install_nmconnections() { exit 1 fi done <<< "$(nmcli -t -f device,filename connection show --active)" + + # Stop dracut 35network-manger to calling nm-initrd-generator. + # Note this line of code can be removed after NetworkManager >= 1.35.2 + # gets released. + echo > "${initdir}/usr/libexec/nm-initrd-generator" } kdump_setup_bridge() { From 63c3805c486adf700bafb5ad78cc9b0f55fcb345 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 17 Sep 2021 13:02:07 +0800 Subject: [PATCH 642/806] Set up kdump network by directly copying NM connection profile to initrd This patch setup kdump network by directly copying NM connection profile(s) for different network setup including bond, bridge, vlan, and team. For vlan network, rename phydev to parent_netif to improve code readability. With the new approach, the related code to build up dracut cmdline parameter such rd.route, ip and etc can be cleaned up. And there is no need to setup dns when copying .nmconnection directly to initrd either. Note the bootdev dracut command line parameter is only used by dracut's 35network-legacy and network-manager doesn't use it, remove related code as well. Note 1. kdump_setup_vlan/bond/... are no longer called in subshells in order to modify global variables like unique_netifs 2. The original kdump_install_net is renamed to better reflect its current function Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 287 ++++++++--------------------------------- 1 file changed, 57 insertions(+), 230 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ecfabc7..67468cd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -2,6 +2,14 @@ _DRACUT_KDUMP_NM_TMP_DIR="/tmp/$$-DRACUT_KDUMP_NM" +_save_kdump_netifs() { + unique_netifs[$1]=1 +} + +_get_kdump_netifs() { + echo -n "${!unique_netifs[@]}" +} + cleanup() { rm -rf "$_DRACUT_KDUMP_NM_TMP_DIR" } @@ -103,39 +111,6 @@ source_ifcfg_file() { fi } -kdump_setup_dns() { - local _netdev="$1" - local _conpath="$2" - local _nameserver _dns _tmp array - local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - - _tmp=$(get_nmcli_field_by_conpath "IP4.DNS" "$_conpath") - # shellcheck disable=SC2206 - array=(${_tmp//|/ }) - if [[ ${array[*]} ]]; then - for _dns in "${array[@]}"; do - echo "nameserver=$_dns" >> "$_dnsfile" - done - else - dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" - source_ifcfg_file "$_netdev" - [[ -n $DNS1 ]] && echo "nameserver=$DNS1" > "$_dnsfile" - [[ -n $DNS2 ]] && echo "nameserver=$DNS2" >> "$_dnsfile" - fi - - while read -r content; do - _nameserver=$(echo "$content" | grep ^nameserver) - [[ -z $_nameserver ]] && continue - - _dns=$(echo "$_nameserver" | awk '{print $2}') - [[ -z $_dns ]] && continue - - if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then - echo "nameserver=$_dns" >> "$_dnsfile" - fi - done < "/etc/resolv.conf" -} - # $1: repeat times # $2: string to be repeated # $3: separator @@ -246,89 +221,6 @@ cal_netmask_by_prefix() { fi } -#$1: netdev name -#$2: srcaddr -#if it use static ip echo it, or echo null -kdump_static_ip() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag - local _netmask _gateway _ipaddr _target _nexthop _prefix - - _ipaddr=$(ip addr show dev "$_netdev" permanent | awk "/ $_srcaddr\/.* /{print \$2}") - - if is_ipv6_address "$_srcaddr"; then - _ipv6_flag="-6" - fi - - if [[ -n $_ipaddr ]]; then - _gateway=$(ip $_ipv6_flag route list dev "$_netdev" \ - | awk '/^default /{print $3}' | head -n 1) - - if [[ "x" != "x"$_ipv6_flag ]]; then - # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" - _netmask=${_ipaddr#*\/} - _srcaddr="[$_srcaddr]" - _gateway="[$_gateway]" - else - _prefix=$(cut -d'/' -f2 <<< "$_ipaddr") - if ! _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag"); then - derror "Failed to calculate netmask for $_ipaddr" - exit 1 - fi - fi - echo -n "${_srcaddr}::${_gateway}:${_netmask}::" - fi - - /sbin/ip $_ipv6_flag route show | grep -v default \ - | grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" \ - | while read -r _route; do - _target=$(echo "$_route" | awk '{print $1}') - _nexthop=$(echo "$_route" | awk '{print $3}') - if [[ "x" != "x"$_ipv6_flag ]]; then - _target="[$_target]" - _nexthop="[$_nexthop]" - fi - echo "rd.route=$_target:$_nexthop:$kdumpnic" - done >> "${initdir}/etc/cmdline.d/45route-static.conf" - - kdump_handle_mulitpath_route "$_netdev" "$_srcaddr" "$kdumpnic" -} - -kdump_handle_mulitpath_route() { - local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag - local _target _nexthop _route _weight _max_weight _rule - - if is_ipv6_address "$_srcaddr"; then - _ipv6_flag="-6" - fi - - while IFS="" read -r _route; do - if [[ $_route =~ [[:space:]]+nexthop ]]; then - _route=${_route##[[:space:]]} - # Parse multipath route, using previous _target - [[ $_target == 'default' ]] && continue - [[ $_route =~ .*via.*\ $_netdev ]] || continue - - _weight=$(echo "$_route" | cut -d ' ' -f7) - if [[ $_weight -gt $_max_weight ]]; then - _nexthop=$(echo "$_route" | cut -d ' ' -f3) - _max_weight=$_weight - if [[ "x" != "x"$_ipv6_flag ]]; then - _rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic" - else - _rule="rd.route=$_target:$_nexthop:$kdumpnic" - fi - fi - else - [[ -n $_rule ]] && echo "$_rule" - _target=$(echo "$_route" | cut -d ' ' -f1) - _rule="" _max_weight=0 _weight=0 - fi - done >> "${initdir}/etc/cmdline.d/45route-static.conf" \ - <<< "$(/sbin/ip $_ipv6_flag route show)" - - [[ -n $_rule ]] && echo "$_rule" >> "${initdir}/etc/cmdline.d/45route-static.conf" -} - kdump_get_mac_addr() { cat "/sys/class/net/$1/address" } @@ -474,102 +366,55 @@ kdump_install_nmconnections() { kdump_setup_bridge() { local _netdev=$1 - local _brif _dev _mac _kdumpdev + local _dev for _dev in "/sys/class/net/$_netdev/brif/"*; do [[ -e $_dev ]] || continue _dev=${_dev##*/} - _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - (kdump_setup_bond "$_dev" "$(get_nmcli_connection_apath_by_ifname "$_dev")") || exit 1 + kdump_setup_bond "$_dev" || return 1 elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then kdump_setup_vlan "$_dev" - else - _mac=$(kdump_get_mac_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/41bridge.conf" fi - _brif+="$_kdumpdev," + _save_kdump_netifs "$_dev" done - echo " bridge=$_netdev:${_brif%,}" >> "${initdir}/etc/cmdline.d/41bridge.conf" } -# drauct takes bond=[::[:]] syntax to parse -# bond. For example: -# bond=bond0:eth0,eth1:mode=balance-rr kdump_setup_bond() { local _netdev="$1" - local _conpath="$2" - local _dev _mac _slaves _kdumpdev _bondoptions - for _dev in $(cat "/sys/class/net/$_netdev/bonding/slaves"); do - _mac=$(kdump_get_perm_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/42bond.conf" - _slaves+="$_kdumpdev," + local _dev + + for _dev in $(< "/sys/class/net/$_netdev/bonding/slaves"); do + _save_kdump_netifs "$_dev" done - echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf" - - _bondoptions=$(get_nmcli_field_by_conpath "bond.options" "$_conpath") - - if [[ -z $_bondoptions ]]; then - dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file "$_netdev" - _bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")" - fi - - if [[ -z $_bondoptions ]]; then - derror "Get empty bond options" - exit 1 - fi - - echo ":$_bondoptions" >> "${initdir}/etc/cmdline.d/42bond.conf" } kdump_setup_team() { local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _dev for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do - _mac=$(kdump_get_perm_addr "$_dev") - _kdumpdev=$(kdump_setup_ifname "$_dev") - echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf" - _slaves+="$_kdumpdev," + _save_kdump_netifs "$_dev" done - echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf" - #Buggy version teamdctl outputs to stderr! - #Try to use the latest version of teamd. - if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then - derror "teamdctl failed." - exit 1 - fi - inst_dir /etc/teamd - inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf" - rm -f "${initdir}/tmp/$$-$_netdev.conf" } kdump_setup_vlan() { local _netdev=$1 - local _phydev - local _netmac - local _kdumpdev + local _parent_netif - _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" - _netmac="$(kdump_get_mac_addr "$_phydev")" + _parent_netif="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" #Just support vlan over bond and team - if kdump_is_bridge "$_phydev"; then + if kdump_is_bridge "$_parent_netif"; then derror "Vlan over bridge is not supported!" exit 1 - elif kdump_is_bond "$_phydev"; then - (kdump_setup_bond "$_phydev" "$(get_nmcli_connection_apath_by_ifname "$_phydev")") || exit 1 - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" - elif kdump_is_team "$_phydev"; then - (kdump_setup_team "$_phydev") || exit 1 - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf" - else - _kdumpdev="$(kdump_setup_ifname "$_phydev")" - echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf" + elif kdump_is_bond "$_parent_netif"; then + kdump_setup_bond "$_parent_netif" || return 1 + elif kdump_is_team "$_parent_netif"; then + kdump_setup_team "$_parent_netif" || return 1 fi + + _save_kdump_netifs "$_parent_netif" } # find online znet device @@ -656,20 +501,16 @@ kdump_get_remote_ip() { echo "$_remote" } -# Setup dracut to bring up network interface that enable -# initramfs accessing giving destination +# Collect netifs needed by kdump # $1: destination host -kdump_install_net() { - local _destaddr _srcaddr _route _netdev _conpath kdumpnic - local _static _proto _ip_conf _ip_opts _ifname_opts +kdump_collect_netif_usage() { + local _destaddr _srcaddr _route _netdev kdumpnic local _znet_netdev _znet_conpath _destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") - _conpath=$(get_nmcli_connection_apath_by_ifname "$_netdev") - _netmac=$(kdump_get_mac_addr "$_netdev") kdumpnic=$(kdump_setup_ifname "$_netdev") _znet_netdev=$(find_online_znet_device) @@ -681,58 +522,42 @@ kdump_install_net() { fi fi - _static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic") - if [[ -n $_static ]]; then - _proto=none - elif is_ipv6_address "$_srcaddr"; then - _proto=auto6 - else - _proto=dhcp - fi - - _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" - _ip_opts=" ip=${_static}$kdumpnic:${_proto}" - - # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. - # so we have to avoid adding duplicates - # We should also check /proc/cmdline for existing ip=xx arg. - # For example, iscsi boot will specify ip=xxx arg in cmdline. - if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" \ - && ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then - echo "$_ip_opts" >> "$_ip_conf" - fi - if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - (kdump_setup_bond "$_netdev" "$_conpath") || exit 1 + kdump_setup_bond "$_netdev" || return 1 elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" - else - _ifname_opts=" ifname=$kdumpnic:$_netmac" - echo "$_ifname_opts" >> "$_ip_conf" fi - - kdump_setup_dns "$_netdev" "$_conpath" + _save_kdump_netifs "$_netdev" if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then # network-manager module needs this parameter echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi - # Save netdev used for kdump as cmdline - # Whoever calling kdump_install_net() is setting up the default gateway, - # ie. bootdev/kdumpnic. So don't override the setting if calling - # kdump_install_net() for another time. For example, after setting eth0 as - # the default gate way for network dump, eth1 in the fence kdump path will - # call kdump_install_net again and we don't want eth1 to be the default - # gateway. - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] \ - && [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" - echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf" + fi + + if is_ipv6_address "$_srcaddr"; then + ipv6_usage[$_netdev]=1 + else + ipv4_usage[$_netdev]=1 + fi +} + +# Setup dracut to bring up network interface that enable +# initramfs accessing giving destination +kdump_install_net() { + local _netifs + + _netifs=$(_get_kdump_netifs) + if [[ -n "$_netifs" ]]; then + kdump_install_nmconnections + apply_nm_initrd_generator_timeouts fi } @@ -771,7 +596,7 @@ default_dump_target_install_conf() { _fstype=$(get_fs_type_from_target "$_target") if is_fs_type_nfs "$_fstype"; then - kdump_install_net "$_target" + kdump_collect_netif_usage "$_target" _fstype="nfs" else _target=$(kdump_get_persistent_dev "$_target") @@ -807,11 +632,11 @@ kdump_install_conf() { sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" ;; ssh | nfs) - kdump_install_net "$_val" + kdump_collect_netif_usage "$_val" ;; dracut_args) if [[ $(get_dracut_args_fstype "$_val") == nfs* ]]; then - kdump_install_net "$(get_dracut_args_target "$_val")" + kdump_collect_netif_usage "$(get_dracut_args_target "$_val")" fi ;; kdump_pre | kdump_post | extra_bins) @@ -933,7 +758,7 @@ kdump_setup_iscsi_device() { [[ -n $username_in ]] && userpwd_in_str=":$username_in:$password_in" - kdump_install_net "$tgt_ipaddr" + kdump_collect_netif_usage "$tgt_ipaddr" # prepare netroot= command line # FIXME: Do we need to parse and set other parameters like protocol, port @@ -1097,7 +922,7 @@ kdump_configure_fence_kdump() { # setup network for each node for node in ${nodes}; do - kdump_install_net "$node" + kdump_collect_netif_usage "$node" done dracut_install /etc/hosts @@ -1208,6 +1033,8 @@ install() { inst "ip" fi + kdump_install_net + # For the lvm type target under kdump, in /etc/lvm/lvm.conf we can # safely replace "reserved_memory=XXXX"(default value is 8192) with # "reserved_memory=1024" to lower memory pressure under kdump. We do From 586fe410aa1b0093fb208c869b70ffeb7f085a55 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 9 Sep 2021 11:50:00 +0800 Subject: [PATCH 643/806] Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting 10-kdump-netif_allowlist.conf in the initramfs. Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 67468cd..f4a026a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -364,6 +364,29 @@ kdump_install_nmconnections() { echo > "${initdir}/usr/libexec/nm-initrd-generator" } +kdump_install_nm_netif_allowlist() { + local _netif _except_netif _netif_allowlist _netif_allowlist_nm_conf + + for _netif in $1; do + _per_mac=$(kdump_get_perm_addr "$_netif") + if [[ "$_per_mac" != 'not set' ]]; then + _except_netif="mac:$_per_mac" + else + _except_netif="interface-name:$_netif" + fi + _netif_allowlist="${_netif_allowlist}except:${_except_netif};" + done + + _netif_allowlist_nm_conf=$_DRACUT_KDUMP_NM_TMP_DIR/netif_allowlist_nm_conf + cat << EOF > "$_netif_allowlist_nm_conf" +[device-others] +match-device=${_netif_allowlist} +managed=false +EOF + + inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf" +} + kdump_setup_bridge() { local _netdev=$1 local _dev @@ -558,6 +581,7 @@ kdump_install_net() { if [[ -n "$_netifs" ]]; then kdump_install_nmconnections apply_nm_initrd_generator_timeouts + kdump_install_nm_netif_allowlist "$_netifs" fi } From a65dde2d1083a57824aecd1840dea417c98c553d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 19 May 2022 11:39:25 +0800 Subject: [PATCH 644/806] Reduce kdump memory consumption by only installing needed NIC drivers Even after having asked NM to stop managing a unneeded NIC, a NIC driver may still waste memory. For example, mlx5_core uses a substantial amount of memory during driver initialization, ======== Report format module_summary: ======== Module mlx5_core using 350.2MB (89650 pages), peak allocation 367.4MB (94056 pages) Module squashfs using 13.1MB (3360 pages), peak allocation 13.1MB (3360 pages) Module overlay using 2.1MB (550 pages), peak allocation 2.2MB (555 pages) Module dns_resolver using 0.9MB (219 pages), peak allocation 5.2MB (1338 pages) Module mlxfw using 0.7MB (172 pages), peak allocation 5.3MB (1349 pages) ======== Report format module_summary END ======== ======== Report format module_top: ======== Top stack usage of module mlx5_core: (null) Pages: 89650 (peak: 94056) ret_from_fork (0xffffda088b4165f8) Pages: 60007 (peak: 60007) kthread (0xffffda088b4bd7e4) Pages: 60007 (peak: 60007) worker_thread (0xffffda088b4b48d0) Pages: 60007 (peak: 60007) process_one_work (0xffffda088b4b3f40) Pages: 60007 (peak: 60007) work_for_cpu_fn (0xffffda088b4aef00) Pages: 53906 (peak: 53906) local_pci_probe (0xffffda088b9e1e44) Pages: 53906 (peak: 53906) probe_one mlx5_core (0xffffda084f899cc8) Pages: 53518 (peak: 53518) mlx5_init_one mlx5_core (0xffffda084f8994ac) Pages: 49756 (peak: 49756) mlx5_function_setup.constprop.0 mlx5_core (0xffffda084f899100) Pages: 44434 (eak: 44434) mlx5_satisfy_startup_pages mlx5_core (0xffffda084f8a4f24) Pages: 44434 (peak: 44434) mlx5_function_setup.constprop.0 mlx5_core (0xffffda084f899078) Pages: 5285 (peak: 5285) mlx5_cmd_init mlx5_core (0xffffda084f89e414) Pages: 4818 (peak: 4818) mlx5_alloc_cmd_msg mlx5_core (0xffffda084f89aaa0) Pages: 4403 (peak: 4403) This memory consumption is completely unnecessary when kdump doesn't need this NIC. Only install needed NIC drivers to prevent this kind of waste. Note 1. this patch depends on [1] to ask dracut to not install NIC drivers. 2. "ethtool -i" somehow fails to get the vlan driver 3. team.ko doesn't depend on the team mode drivers so we need to install the team mode drivers manually. [1] https://github.com/dracutdevs/dracut/pull/1789 Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 31 +++++++++++++++++++++++++++++++ mkdumprd | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f4a026a..9ed8487 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -387,6 +387,36 @@ EOF inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf" } +_get_nic_driver() { + ethtool -i "$1" | sed -n -E "s/driver: (.*)/\1/p" +} + +kdump_install_nic_driver() { + local _netif _driver _drivers + + _drivers=() + + for _netif in $1; do + _driver=$(_get_nic_driver "$_netif") + if [[ -z $_driver ]]; then + derror "Failed to get the driver of $_netif" + exit 1 + fi + + if [[ $_driver == "802.1Q VLAN Support" ]]; then + # ethtool somehow doesn't return the driver name for a VLAN NIC + _driver=8021q + elif [[ $_driver == "team" ]]; then + # install the team mode drivers like team_mode_roundrobin.ko as well + _driver='=drivers/net/team' + fi + + _drivers+=("$_driver") + done + + instmods "${_drivers[@]}" +} + kdump_setup_bridge() { local _netdev=$1 local _dev @@ -582,6 +612,7 @@ kdump_install_net() { kdump_install_nmconnections apply_nm_initrd_generator_timeouts kdump_install_nm_netif_allowlist "$_netifs" + kdump_install_nic_driver "$_netifs" fi } diff --git a/mkdumprd b/mkdumprd index 7b843a8..a069f92 100644 --- a/mkdumprd +++ b/mkdumprd @@ -27,7 +27,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth resume ifcfg earlykdump") +dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' -o "plymouth resume ifcfg earlykdump") MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." From 568623e69a32266a3b00225b9de6a93435c44474 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 23 Sep 2021 14:25:01 +0800 Subject: [PATCH 645/806] Address the cases where a NIC has a different name in kdump kernel A NIC may get a different name in the kdump kernel from 1st kernel in cases like, - kernel assigned network interface names are not persistent e.g. [1] - there is an udev rule to rename the NIC in the 1st kernel but the kdump initrd may not have that rule e.g. [2] If NM tries to match a NIC with a connection profile based on NIC name i.e. connection.interface-name, it will fail the above bases. A simple solution is to ask NM to match a connection profile by MAC address. Note we don't need to do this for user-created NICs like vlan, bridge and bond. An remaining issue is passing the name of a NIC via the kdumpnic dracut command line parameter which requires passing ifname=: to have fixed NIC name. But we can simply drop this requirement. kdumpnic is needed because kdump needs to get the IP by NIC name and use the IP to created a dumping folder named "{IP}-{DATE}". We can simply pass the IP to the kdump kernel directly via a new dracut command line parameter kdumpip instead. In addition to the benefit of simplifying the code, there are other three benefits brought by this approach, - make use of whatever network to transfer the vmcore. Because as long as we have the network to we don't care which NIC is active. - if obtained IP in the kdump kernel is different from the one in the 1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore comes from. - without passing ifname=: to kdump initrd, the issue of there are two interfaces with the same MAC address for Azure Hyper-V NIC SR-IOV [3] is resolved automatically. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778 [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107 [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421 Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-kdump.sh | 39 ++++++++++++++++------------- dracut-module-setup.sh | 57 +++++++++++++++--------------------------- kdump-lib-initramfs.sh | 14 +++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 9734f43..357c14c 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -484,25 +484,28 @@ save_vmcore_dmesg_ssh() get_host_ip() { - if is_nfs_dump_target || is_ssh_dump_target; then - kdumpnic=$(getarg kdumpnic=) - if [ -z "$kdumpnic" ]; then - derror "failed to get kdumpnic!" - return 1 - fi - if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}') - kdumphost="${kdumphost%%/*}" - if [ -z "$kdumphost" ]; then - derror "wrong kdumpnic: $kdumpnic" - return 1 - fi - HOST_IP=$kdumphost + + if ! is_nfs_dump_target && ! is_ssh_dump_target; then + return 0 fi - return 0 + + _kdump_remote_ip=$(getarg kdump_remote_ip=) + + if [ -z "$_kdump_remote_ip" ]; then + derror "failed to get remote IP address!" + return 1 + fi + _route=$(kdump_get_ip_route "$_kdump_remote_ip") + _netdev=$(kdump_get_ip_route_field "$_route" "dev") + + if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then + derror "Failed to get IP of $_netdev" + return 1 + fi + + _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') + _kdumpip="${_kdumpip%%/*}" + HOST_IP=$_kdumpip } read_kdump_confs() diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 9ed8487..2ecd99c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -237,26 +237,6 @@ kdump_get_perm_addr() { fi } -# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0 -# Because kernel assigned names are not persistent between 1st and 2nd -# kernel. We could probably end up with eth0 being eth1, eth0 being -# eth1, and naming conflict happens. -kdump_setup_ifname() { - local _ifname - - # If ifname already has 'kdump-' prefix, we must be switching from - # fadump to kdump. Skip prefixing 'kdump-' in this case as adding - # another prefix may truncate the ifname. Since an ifname with - # 'kdump-' is already persistent, this should be fine. - if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then - _ifname="kdump-$1" - else - _ifname="$1" - fi - - echo "$_ifname" -} - apply_nm_initrd_generator_timeouts() { local _timeout_conf @@ -304,6 +284,19 @@ _clone_nmconnection() { return 1 } +_match_nmconnection_by_mac() { + local _unique_id _dev _mac _mac_field + + _unique_id=$1 + _dev=$2 + + _mac=$(kdump_get_perm_addr "$_dev") + [[ $_mac != 'not set' ]] || return + _mac_field=$(nmcli --get-values connection.type connection show "$_unique_id").mac-address + nmcli connection modify --temporary "$_unique_id" "$_mac_field" "$_mac" &> >(ddebug) + nmcli connection modify --temporary "$_unique_id" "connection.interface-name" "" &> >(ddebug) +} + # Clone and modify NM connection profiles # # This function makes use of "nmcli clone" to automatically convert ifcfg-* @@ -325,6 +318,10 @@ clone_and_modify_nmconnection() { use_ipv4_or_ipv6 "$_dev" "$_uuid" nmcli connection modify --temporary uuid "$_uuid" connection.wait-device-timeout 60000 &> >(ddebug) + # For physical NIC i.e. non-user created NIC, ask NM to match a + # connection profile based on MAC address + _match_nmconnection_by_mac "$_uuid" "$_dev" + _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" @@ -528,19 +525,6 @@ kdump_setup_znet() { echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" } -kdump_get_ip_route() { - local _route - if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then - derror "Bad kdump network destination: $1" - exit 1 - fi - echo "$_route" -} - -kdump_get_ip_route_field() { - echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" -} - kdump_get_remote_ip() { local _remote _remote_temp _remote=$(get_remote_host "$1") @@ -557,14 +541,13 @@ kdump_get_remote_ip() { # Collect netifs needed by kdump # $1: destination host kdump_collect_netif_usage() { - local _destaddr _srcaddr _route _netdev kdumpnic + local _destaddr _srcaddr _route _netdev local _znet_netdev _znet_conpath _destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") - kdumpnic=$(kdump_setup_ifname "$_netdev") _znet_netdev=$(find_online_znet_device) if [[ -n $_znet_netdev ]]; then @@ -591,8 +574,8 @@ kdump_collect_netif_usage() { echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" fi - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]]; then - echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" + if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then + echo "kdump_remote_ip=$_destaddr" > "${initdir}/etc/cmdline.d/60kdumpip.conf" fi if is_ipv6_address "$_srcaddr"; then diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index a893532..e45d6de 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -163,3 +163,17 @@ is_lvm2_thinp_device() [ -n "$_lvm2_thin_device" ] } + +kdump_get_ip_route() +{ + if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then + derror "Bad kdump network destination: $1" + exit 1 + fi + echo "$_route" +} + +kdump_get_ip_route_field() +{ + echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" +} From 9792994f2f13dd7d6561140fe4b590114a8571c1 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 22 Sep 2022 22:31:47 +0800 Subject: [PATCH 646/806] Wait for the network to be truly ready before dumping vmcore nm-wait-online-initrd.service installed by dracut's 35-networkmanager module calls nm-online with "-s" which means it returns immediately when NetworkManager logs "startup complete". Thus it doesn't truly wait for network connectivity to be established [1]. Wait for the network to be truly ready before dumping vmcore. There are two benefits brought by this approach, - ssh/nfs dumping won't fail because of that the network is not ready e.g. [2][3] - users don't need to use workarounds like rd.net.carrier.timeout to make sure the network is ready [1] https://bugzilla.redhat.com/show_bug.cgi?id=1485712 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1909014 [3] https://bugzilla.redhat.com/show_bug.cgi?id=2035451 Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-kdump.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 357c14c..4eec70b 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -482,6 +482,26 @@ save_vmcore_dmesg_ssh() fi } +wait_online_network() +{ + # In some cases, network may still not be ready because nm-online is called + # with "-s" which means to wait for NetworkManager startup to complete, rather + # than waiting for network connectivity specifically. Wait 10mins more for the + # network to be truely ready in these cases. + _loop=0 + while [ $_loop -lt 600 ]; do + sleep 1 + _loop=$((_loop + 1)) + if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then + printf "%s" "$_route" + return + fi + done + + derror "Oops. The network still isn't ready after waiting 10mins." + exit 1 +} + get_host_ip() { @@ -495,7 +515,11 @@ get_host_ip() derror "failed to get remote IP address!" return 1 fi - _route=$(kdump_get_ip_route "$_kdump_remote_ip") + + if ! _route=$(wait_online_network "$_kdump_remote_ip"); then + return 1 + fi + _netdev=$(kdump_get_ip_route_field "$_route" "dev") if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then From b5577c163aff88c458d638eb7954a000f6513ddb Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 23 Sep 2021 15:26:00 +0800 Subject: [PATCH 647/806] Simplify setup_znet by copying connection profile to initrd /usr/lib/udev/ccw_init [1] shipped by s390utils extracts the values of SUBCHANNELS, NETTYPE and LAYER2 from /etc/sysconfig/network-scripts/ifcfg-* or /etc/NetworkManager/system-connections/*.nmconnection to activate znet network device. If the connection profile is copied to initrd, there is no need to set up the "rd.znet" dracut cmdline parameter. There are two cases addressed by this commit, 1. znet network interface is a slave of bonding/teaming/vlan/bridging network. The connection profile has been copied to initrd by kdump_copy_nmconnection_file and it contains the info needed by ccw_init. 2. znet network interface is a slave of bonding/teaming/vlan/bridging network. The corresponding ifcfg-*/*.nmconnection file may not contain info like SUBCHANNELS [2]. In this case, copy the ifcfg-*/*.nmconnection file that has this info to the kdump initrd. Also to prevent the copied connection profile from being chosen by NM, set connection.autoconnect=false for this connection profile. With this implementation, there is also no need to check if znet is used beforehand. Note 1. ccw_init doesn't care if SUBCHANNELS, NETTYPE and LAYER2 comes from an active NM profile or not. If an inactive NM profile contains this info, it needs to be copied to the kdump initrd as well. 2. "rd.znet_ifname=$_netdev:${SUBCHANNELS}" is no longer needed needed because now there is no renaming of s390x network interfaces when reusing NetworkManager profiles. rd.znet_ifname was introduced in commit ce0305d ("Add a new option 'rd.znet_ifname' in order to use it in udev rules") to address the special case of non-persistent MAC address by renaming a network interface by SUBCHANNELS. [1] https://src.fedoraproject.org/rpms/s390utils/blob/rawhide/f/ccw_init [2] https://bugzilla.redhat.com/show_bug.cgi?id=2064708 Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 93 ++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 58 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 2ecd99c..0cac3bd 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -467,62 +467,48 @@ kdump_setup_vlan() { _save_kdump_netifs "$_parent_netif" } -# find online znet device -# return ifname (_netdev) -# code reaped from the list_configured function of -# https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf -find_online_znet_device() { - local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" - local NETWORK_DEVICES d ifname ONLINE - - [[ ! -d $CCWGROUPBUS_DEVICEDIR ]] && return - NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) - for d in $NETWORK_DEVICES; do - [[ ! -f "$d/online" ]] && continue - read -r ONLINE < "$d/online" - if [[ $ONLINE -ne 1 ]]; then - continue - fi - # determine interface name, if there (only for qeth and if - # device is online) - if [[ -f $d/if_name ]]; then - read -r ifname < "$d/if_name" - elif [[ -d $d/net ]]; then - ifname=$(ls "$d/net/") - fi - [[ -n $ifname ]] && break - done - echo -n "$ifname" +_find_znet_nmconnection() { + LANG=C grep -s -E -i -l \ + "^s390-subchannels=([0-9]\.[0-9]\.[a-f0-9]+;){0,2}" \ + "$1"/*.nmconnection | LC_ALL=C sed -e "$2" } -# setup s390 znet cmdline -# $1: netdev (ifname) -# $2: nmcli connection path +# setup s390 znet +# +# Note part of code is extracted from ccw_init provided by s390utils kdump_setup_znet() { - local _netdev="$1" - local _conpath="$2" - local s390_prefix="802-3-ethernet.s390-" - local _options="" - local NETTYPE - local SUBCHANNELS + local _config_file _unique_name _NM_conf_dir + local __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' - NETTYPE=$(get_nmcli_field_by_conpath "${s390_prefix}nettype" "$_conpath") - SUBCHANNELS=$(get_nmcli_field_by_conpath "${s390_prefix}subchannels" "$_conpath") - _options=$(get_nmcli_field_by_conpath "${s390_prefix}options" "$_conpath") - - if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then - dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." - source_ifcfg_file "$_netdev" - for i in $OPTIONS; do - _options=${_options},$i - done + if [[ "$(uname -m)" != "s390x" ]]; then + return fi - if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then - exit 1 + _NM_conf_dir="/etc/NetworkManager/system-connections" + + _config_file=$(_find_znet_nmconnection "$initdir/$_NM_conf_dir" "$__sed_discard_ignored_files") + if [[ -n "$_config_file" ]]; then + ddebug "$_config_file has already contained the znet config" + return + fi + + _config_file=$(LANG=C grep -s -E -i -l \ + "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){0,2}" \ + /etc/sysconfig/network-scripts/ifcfg-* \ + | LC_ALL=C sed -e "$__sed_discard_ignored_files") + + if [[ -z "$_config_file" ]]; then + _config_file=$(_find_znet_nmconnection "$_NM_conf_dir" "$__sed_discard_ignored_files") + fi + + if [[ -n "$_config_file" ]]; then + _unique_name=$(cat /proc/sys/kernel/random/uuid) + nmcli connection clone --temporary "$_config_file" "$_unique_name" &> >(ddebug) + nmcli connection modify --temporary "$_unique_name" connection.autoconnect false + inst "/run/NetworkManager/system-connections/${_unique_name}.nmconnection" "${_NM_conf_dir}/${_unique_name}.nmconnection" + nmcli connection del "$_unique_name" &> >(ddebug) fi - echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" } kdump_get_remote_ip() { @@ -542,22 +528,12 @@ kdump_get_remote_ip() { # $1: destination host kdump_collect_netif_usage() { local _destaddr _srcaddr _route _netdev - local _znet_netdev _znet_conpath _destaddr=$(kdump_get_remote_ip "$1") _route=$(kdump_get_ip_route "$_destaddr") _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") - _znet_netdev=$(find_online_znet_device) - if [[ -n $_znet_netdev ]]; then - _znet_conpath=$(get_nmcli_connection_apath_by_ifname "$_znet_netdev") - if ! (kdump_setup_znet "$_znet_netdev" "$_znet_conpath"); then - derror "Failed to set up znet" - exit 1 - fi - fi - if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then @@ -594,6 +570,7 @@ kdump_install_net() { if [[ -n "$_netifs" ]]; then kdump_install_nmconnections apply_nm_initrd_generator_timeouts + kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" fi From 523cda8f343b1a48799a5c25e1d76a2a475a6b1d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 25 Nov 2022 12:07:25 +0800 Subject: [PATCH 648/806] Don't run kdump_check_setup_iscsi in a subshell in order to collect needed network interfaces Currently, dumping to iSCSI target fails because the global array (unique_netifs) that stores the network interfaces needed by kdump is empty. The root cause is change of the array made in a subshell (a child process) is inaccessible to the parent process. So don't run kdump_check_setup_iscsi in a subshell. Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Signed-off-by: Coiby Xu Reviewed-by: Pingfan Liu --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 0cac3bd..1fa2a78 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -809,7 +809,7 @@ kdump_check_iscsi_targets() { # If our prerequisites are not met, fail anyways. type -P iscsistart > /dev/null || return 1 - kdump_check_setup_iscsi() ( + kdump_check_setup_iscsi() { local _dev _dev=$1 @@ -819,7 +819,7 @@ kdump_check_iscsi_targets() { cd .. done [[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD" - ) + } [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves_all kdump_check_setup_iscsi From 787b041aabd90ff2bf8fe6cc4d225032efde24d0 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 15 Nov 2022 12:00:09 +0800 Subject: [PATCH 649/806] kdump.conf: use a simple generator script to maintain This commit has the same motivation as the commit 677da8a "sysconfig: use a simple generator script to maintain". At present, only the kdump.conf generated for s390x has a slight difference from the other arches, where the core_collector asks the makedumpfile to use "-c" option to compress dump data by each page using zlib, which is more efficient than lzo on s390x. Signed-off-by: Pingfan Liu Reviewed-by: Philipp Rudo --- kdump.conf => gen-kdump-conf.sh | 37 +++++++++++++++++++++++++++++++++ kexec-tools.spec | 5 +++-- 2 files changed, 40 insertions(+), 2 deletions(-) rename kdump.conf => gen-kdump-conf.sh (95%) mode change 100644 => 100755 diff --git a/kdump.conf b/gen-kdump-conf.sh old mode 100644 new mode 100755 similarity index 95% rename from kdump.conf rename to gen-kdump-conf.sh index e598a49..a9f124f --- a/kdump.conf +++ b/gen-kdump-conf.sh @@ -1,3 +1,11 @@ +#!/bin/bash +# $1: target arch + +SED_EXP="" + +generate() +{ + sed "$SED_EXP" << EOF # This file contains a series of commands to perform (in order) in the kdump # kernel after a kernel crash in the crash kernel(1st kernel) has happened. # @@ -192,3 +200,32 @@ core_collector makedumpfile -l --message-level 7 -d 31 #dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" #fence_kdump_args -p 7410 -f auto -c 0 -i 10 #fence_kdump_nodes node1 node2 +EOF +} + +update_param() +{ + SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;" +} + +case "$1" in +aarch64) ;; + +i386) ;; + +ppc64) ;; + +ppc64le) ;; + +s390x) + update_param core_collector \ + "makedumpfile -c --message-level 7 -d 31" + ;; +x86_64) ;; + +*) + echo "Warning: Unknown architecture '$1', using default kdump.conf template." + ;; +esac + +generate diff --git a/kexec-tools.spec b/kexec-tools.spec index bfa7a5b..cc62984 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -12,8 +12,8 @@ Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Source1: kdumpctl Source3: gen-kdump-sysconfig.sh +Source4: gen-kdump-conf.sh Source7: mkdumprd -Source8: kdump.conf Source9: https://github.com/makedumpfile/makedumpfile/archive/%{mkdf_ver}/makedumpfile-%{mkdf_shortver}.tar.gz Source10: kexec-kdump-howto.txt Source11: fadump-howto.txt @@ -147,6 +147,7 @@ cp %{SOURCE34} . # Generate sysconfig file %{SOURCE3} %{_target_cpu} > kdump.sysconfig +%{SOURCE4} %{_target_cpu} > kdump.conf make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -180,7 +181,7 @@ install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd -install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf +install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 From 0414386cb827652082326e3b8a654bdc0f3d8571 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 25 Nov 2022 16:40:49 +0800 Subject: [PATCH 650/806] unit tests: adapt check_config to gen-kdump-conf.sh Now, kdump.conf is generated by gen-kdump-conf.sh, hence adapting check_config to run that script firstly then check the generated file. Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index 5a3ce1c..41fbc29 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -178,6 +178,7 @@ Describe 'kdumpctl' bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) cleanup() { rm -f "$bad_kdump_conf" + rm -f kdump.conf } AfterAll 'cleanup' @@ -189,8 +190,11 @@ Describe 'kdumpctl' The stderr should include 'Invalid kdump config option blabla' End + Parameters:value aarch64 ppc64le s390x x86_64 + It 'should be happy with the default kdump.conf' - # shellcheck disable=SC2034 + ./gen-kdump-conf.sh "$1" > kdump.conf + # shellcheck disable=SC2034 # override the KDUMP_CONFIG_FILE variable KDUMP_CONFIG_FILE=./kdump.conf When call parse_config From 5eb77ee3fa986f39bb74a5956910aed6f60b8008 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Thu, 24 Nov 2022 09:15:25 +0800 Subject: [PATCH 651/806] kdumpctl: Optimize _find_kernel_path_by_release regex string Currently _find_kernel_path_by_release uses grubby and grep to find the kernel path, if both the normal kernel and it's debug varient exist, the grep will give more than one kernel strings. ``` kernel="/boot/vmlinuz-5.14.0-139.kpq0.el9.s390x+debug" kernel="/boot/vmlinuz-5.14.0-139.kpq0.el9.s390x" ``` This will cause an error when installing debug kernel. ``` The param "/boot/vmlinuz-5.14.0-139.kpq0.el9.s390x+debug /boot/vmlinuz-5.14.0-139.kpq0.el9.s390x" is incorrect ``` Fixes: 945cbbd ("add helper functions to get kernel path by kernel release and the path of current running kernel") Signed-off-by: Lichen Liu Reviewed-by: Philipp Rudo --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index b82d869..abfb352 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1353,7 +1353,7 @@ _filter_grubby_kernel_str() _find_kernel_path_by_release() { local _release="$1" _grubby_kernel_str _kernel_path - _grubby_kernel_str=$(grubby --info ALL | grep "^kernel=.*$_release") + _grubby_kernel_str=$(grubby --info ALL | grep "^kernel=.*$_release\"$") _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") if [[ -z $_kernel_path ]]; then derror "kernel $_release doesn't exist" From e96e441b36d1197c11832114d5e8c22d7c72d513 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 25 Nov 2022 17:47:20 +0800 Subject: [PATCH 652/806] Release 2.0.25-3 Signed-off-by: Coiby Xu --- kexec-tools.spec | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index cc62984..ec8cc68 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.25 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -414,7 +414,34 @@ fi %endif %changelog -* Thu Oct 27 2022 Coiby - 2.0.25-1 +* Fri Nov 25 2022 Coiby - 2.0.25-3 +- kdumpctl: Optimize _find_kernel_path_by_release regex string +- unit tests: adapt check_config to gen-kdump-conf.sh +- kdump.conf: use a simple generator script to maintain +- Don't run kdump_check_setup_iscsi in a subshell in order to collect needed network interfaces +- Simplify setup_znet by copying connection profile to initrd +- Wait for the network to be truly ready before dumping vmcore +- Address the cases where a NIC has a different name in kdump kernel +- Reduce kdump memory consumption by only installing needed NIC drivers +- Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces +- Set up kdump network by directly copying NM connection profile to initrd +- Stop dracut 35network-manager from running nm-initrd-generator +- Apply the timeout configuration of nm-initrd-generator +- Determine whether IPv4 or IPv6 is needed +- Add functions to copy NetworkManage connection profiles to the initramfs +- Fix error for vlan over team network interface +- Skip reset_crashkernel_after_update during package install +- Don't check fs modified when dump target is lvm2 thinp +- tests: use .nmconnection to set up test network +- fadump: preserve file modification time to help with hardlinking +- fadump: do not use squash to reduce image size +- selftest: Add lvm2 thin provision for kdump test +- selftest: Only iterate the .sh files for test execution +- Add dependency of dracut lvmthinpool-monitor module +- lvm.conf should be check modified if lvm2 thinp enabled +- Add lvm2 thin provision dump target checker + +* Thu Oct 27 2022 Coiby - 2.0.25-2 - Update makedumpfile to 1.7.2 - Skip reading /etc/defaut/grub for s390x - Include the memory overhead cost of cryptsetup when estimating the memory requirement for LUKS-encrypted target From f98bd5895e74043430b927828b0bd6944073e0cd Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Fri, 2 Dec 2022 18:46:49 +0530 Subject: [PATCH 653/806] fadump: use 'zstd' as the default compression method If available, use 'zstd' compression method to optimize the size of the initrd built with fadump support. Also, 'squash+zstd' is not preferred because more disk space is consumed with 'squash+zstd' due to the additional binaries needed for fadump with squash case. Signed-off-by: Hari Bathini Acked-by: Tao Liu Reviewed-by: Philipp Rudo --- mkfadumprd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mkfadumprd b/mkfadumprd index 36ad645..2fc396c 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -62,11 +62,9 @@ _dracut_isolate_args=( /usr/lib/dracut/fadump-kernel-modules.txt ) -# Same as setting zstd in mkdumprd +# Use zstd compression method, if available if ! have_compression_in_dracut_args; then - if is_squash_available && dracut_have_option "--squash-compressor"; then - _dracut_isolate_args+=(--squash-compressor zstd) - elif is_zstd_command_available; then + if is_zstd_command_available; then _dracut_isolate_args+=(--compress zstd) fi fi From 25411da9660e732a53e675936813aad924ba65df Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Fri, 2 Dec 2022 18:46:50 +0530 Subject: [PATCH 654/806] fadump: fix default initrd backup and restore logic In case of fadump, default initrd is rebuilt with dump capturing capability, as the same initrd is used for booting production kernel as well as capture kernel. The original initrd file is backed up with a checksum, to restore it as the default initrd when fadump is disabled. As the checksum file is not kernel version specific, switching between different kernel versions and kdump/fadump dump mode breaks the default initrd backup/restore logic. Fix this by having a kernel version specific checksum file. Also, if backing up initrd fails, retaining the checksum file isn't useful. Remove it. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo --- kdumpctl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index abfb352..af93202 100755 --- a/kdumpctl +++ b/kdumpctl @@ -9,9 +9,9 @@ KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" -INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" +INITRD_CHECKSUM_LOCATION="" KDUMP_INITRD="" TARGET_INITRD="" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" @@ -166,7 +166,8 @@ backup_default_initrd() sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION" if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." - rm -f "$DEFAULT_INITRD_BAK" + rm -f -- "$INITRD_CHECKSUM_LOCATION" + rm -f -- "$DEFAULT_INITRD_BAK" fi fi } @@ -317,6 +318,7 @@ setup_initrd() fi DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename "$DEFAULT_INITRD").default" + INITRD_CHECKSUM_LOCATION="$DEFAULT_INITRD_BAK.checksum" if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then TARGET_INITRD="$DEFAULT_INITRD" From 4a2dcab26ac5ede266449515fc906687728f9ace Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Fri, 2 Dec 2022 18:46:51 +0530 Subject: [PATCH 655/806] fadump: add a kernel install hook to clean up fadump initramfs Kdump service will create fadump initramfs when needed, but it won't clean up the fadump initramfs on kernel uninstall. So create a kernel install hook to do the clean up job. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo --- 60-fadump.install | 31 +++++++++++++++++++++++++++++++ kexec-tools.spec | 3 +++ 2 files changed, 34 insertions(+) create mode 100755 60-fadump.install diff --git a/60-fadump.install b/60-fadump.install new file mode 100755 index 0000000..75318ff --- /dev/null +++ b/60-fadump.install @@ -0,0 +1,31 @@ +#!/usr/bin/bash + +COMMAND="$1" +KERNEL_VERSION="$2" + +if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then + exit 0 +fi + +# Currently, fadump is supported only in environments with +# writable /boot directory. +if [[ ! -w "/boot" ]]; then + exit 0 +fi + +FADUMP_INITRD="/boot/.initramfs-${KERNEL_VERSION}.img.default" +FADUMP_INITRD_CHECKSUM="$FADUMP_INITRD.checksum" + +ret=0 +case "$COMMAND" in + add) + # Do nothing, fadump initramfs is strictly host only + # and managed by kdump service + ;; + remove) + rm -f -- "$FADUMP_INITRD" + rm -f -- "$FADUMP_INITRD_CHECKSUM" + ret=$? + ;; +esac +exit $ret diff --git a/kexec-tools.spec b/kexec-tools.spec index ec8cc68..e863e7c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -38,6 +38,7 @@ Source33: 92-crashkernel.install Source34: crashkernel-howto.txt Source35: kdump-migrate-action.sh Source36: kdump-restart.sh +Source37: 60-fadump.install ####################################### # These are sources for mkdumpramfs @@ -204,6 +205,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules %endif %ifarch ppc64 ppc64le install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules +install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install %endif install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service @@ -366,6 +368,7 @@ fi %endif %ifarch ppc64 ppc64le /usr/sbin/mkfadumprd +%{_prefix}/lib/kernel/install.d/60-fadump.install %endif /usr/sbin/mkdumprd /usr/sbin/vmcore-dmesg From a833624fe57a28a4ccb44f7f27f06a7e867e8755 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 21 Nov 2022 18:56:08 +0530 Subject: [PATCH 656/806] fadump: avoid status check while starting in fadump mode With kernel commit 607451ce0aa9b ("powerpc/fadump: register for fadump as early as possible"), 'kdumpctl start' prematurely returns with the below message: "Kdump already running: [WARNING]" instead of setting default initrd with dump capture capability as required for fadump. Skip status check in fadump mode to avoid this problem. Signed-off-by: Hari Bathini Reviewed-by: Philipp Rudo --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index af93202..3cad3dd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1061,7 +1061,7 @@ start() return 1 fi - if check_current_status; then + if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && check_current_kdump_status; then dwarn "Kdump already running: [WARNING]" return 0 fi From b45896c62096f7fcfd65afffb4cd93a3ae5f8b1a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 6 Dec 2022 18:18:32 +0800 Subject: [PATCH 657/806] dracut-module-setup.sh: stop overwriting dracut's trap handler Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2149246 Latest Workstation live x86_64 image has an excess increase of ~300 MB in size. This is because kdumpbase module's trap handler overwrites dracut's handler and DRACUT_TMPDIR which has three unpacked initramfs files fails to be cleaned up. This patch moves kdumpbase module's temporary folder under DRACUT_TMPDIR and lets dracut's trap handler do the cleanup instead. Fixes: d25b1ee3 ("Add functions to copy NetworkManage connection profiles to the initramfs") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1fa2a78..13e9901 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1,6 +1,6 @@ #!/bin/bash -_DRACUT_KDUMP_NM_TMP_DIR="/tmp/$$-DRACUT_KDUMP_NM" +_DRACUT_KDUMP_NM_TMP_DIR="$DRACUT_TMPDIR/$$-DRACUT_KDUMP_NM" _save_kdump_netifs() { unique_netifs[$1]=1 @@ -10,13 +10,6 @@ _get_kdump_netifs() { echo -n "${!unique_netifs[@]}" } -cleanup() { - rm -rf "$_DRACUT_KDUMP_NM_TMP_DIR" -} - -# shellcheck disable=SC2154 # known issue of shellcheck https://github.com/koalaman/shellcheck/issues/1299 -trap 'ret=$?; cleanup; exit $ret;' EXIT - kdump_module_init() { if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" From bc4196afc1a56babefb21dfa03c77f80f0dc369f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 7 Dec 2022 17:47:58 +0800 Subject: [PATCH 658/806] Release 2.0.25-4 Signed-off-by: Coiby Xu --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index e863e7c..24fad76 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.25 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -417,6 +417,13 @@ fi %endif %changelog +* Wed Dec 07 2022 Coiby - 2.0.25-4 +- dracut-module-setup.sh: stop overwriting dracut's trap handler +- fadump: avoid status check while starting in fadump mode +- fadump: add a kernel install hook to clean up fadump initramfs +- fadump: fix default initrd backup and restore logic +- fadump: use 'zstd' as the default compression method + * Fri Nov 25 2022 Coiby - 2.0.25-3 - kdumpctl: Optimize _find_kernel_path_by_release regex string - unit tests: adapt check_config to gen-kdump-conf.sh From 3b22cce1cb7dd12be07822018d08c9bb8f03add9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 14 Dec 2022 10:12:17 +0800 Subject: [PATCH 659/806] dracut-module-setup.sh: skip installing driver for the loopback interface Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2151500 Currently, kdump initrd fails to be built when dumping vmcore to localhost via ssh or nfs, kdumpctl[3331]: Cannot get driver information: Operation not supported kdumpctl[1991]: dracut: Failed to get the driver of lo dracut[2020]: Failed to get the driver of lo kdumpctl[1775]: kdump: mkdumprd: failed to make kdump initrd kdumpctl[1775]: kdump: Starting kdump: [FAILED] systemd[1]: kdump.service: Main process exited, code=exited, status=1/FAILURE systemd[1]: kdump.service: Failed with result 'exit-code'. systemd[1]: Failed to start Crash recovery kernel arming. systemd[1]: kdump.service: Consumed 1.710s CPU time. This is because the loopback interface is used for transferring vmcore and ethtool can't get the driver of the loopback interface. In fact, once COFNIG_NET is enabled, the loopback device is enabled and there is no driver for the loopback device. So skip installing driver for the loopback device. The loopback interface is implemented in linux/drivers/net/loopback.c and always has the name "lo". So we can safely tell if a network interface is the loopback interface by its name. Fixes: a65dde2d ("Reduce kdump memory consumption by only installing needed NIC drivers") Reported-by: Martin Pitt Reported-by: Rich Megginson Reviewed-by: Lichen Liu Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- dracut-module-setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 13e9901..fafaea0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -387,6 +387,7 @@ kdump_install_nic_driver() { _drivers=() for _netif in $1; do + [[ $_netif == lo ]] && continue _driver=$(_get_nic_driver "$_netif") if [[ -z $_driver ]]; then derror "Failed to get the driver of $_netif" @@ -404,6 +405,7 @@ kdump_install_nic_driver() { _drivers+=("$_driver") done + [[ -n ${_drivers[*]} ]] || return instmods "${_drivers[@]}" } From bc101086e2c32594c8e01b50f0353f50d71f87f5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 12 Dec 2022 18:37:25 +0800 Subject: [PATCH 660/806] dracut-module-setup.sh: also install the driver of physical NIC for Hyper-V VM with accelerated networking Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2151842 Currently, vmcore dumping to remote fs fails on Azure Hyper-V VM with accelerated networking because it uses a physical NIC for accrelarated networking [1]. In this case, the driver for this physical NIC should be installed as well. [1] https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview Fixes: a65dde2d ("Reduce kdump memory consumption by only installing needed NIC drivers") Reported-by: Xiaoqiang Xiong Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index fafaea0..a8ac16c 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -381,6 +381,14 @@ _get_nic_driver() { ethtool -i "$1" | sed -n -E "s/driver: (.*)/\1/p" } +_get_hpyerv_physical_driver() { + local _physical_nic + + _physical_nic=$(find /sys/class/net/"$1"/ -name 'lower_*' | sed -En "s/\/.*lower_(.*)/\1/p") + [[ -n $_physical_nic ]] || return + _get_nic_driver "$_physical_nic" +} + kdump_install_nic_driver() { local _netif _driver _drivers @@ -400,6 +408,11 @@ kdump_install_nic_driver() { elif [[ $_driver == "team" ]]; then # install the team mode drivers like team_mode_roundrobin.ko as well _driver='=drivers/net/team' + elif [[ $_driver == "hv_netvsc" ]]; then + # A Hyper-V VM may have accelerated networking + # https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview + # Install the driver of physical NIC as well + _drivers+=("$(_get_hpyerv_physical_driver "$_netif")") fi _drivers+=("$_driver") From 5951b5e26823b6bedf3237bd169a781b03f25031 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 20 Dec 2022 13:59:18 +0800 Subject: [PATCH 661/806] Don't try to update crashkernel when bootloader is not installed Currently when using anaconda to install the OS, the following errors occur, INF packaging: Configuring (running scriptlet for): kernel-core-5.14.0-70.el9.x86_64 ... INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory ... INF packaging: Configuring (running scriptlet for): kexec-tools-2.0.23-9.el9.x86_64 ... INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory grep: /boot/grub2/grubenv: No such file or directory Or for s390, the following errors occur, INF packaging: Configuring (running scriptlet for): kernel-core-5.14.0-71.el9.s390x ... 03:37:51,232 INF dnf.rpm: grep: /etc/zipl.conf: No such file or directory grep: /etc/zipl.conf: No such file or directory grep: /etc/zipl.conf: No such file or directory INF packaging: Configuring (running scriptlet for): kexec-tools-2.0.23-9_1.el9_0.s390x ... INF dnf.rpm: grep: /etc/zipl.conf: No such file or directory This is because when anaconda installs the packages, bootloader hasn't been installed and /boot/grub2/grubenv or /etc/zipl.conf doesn't exist. So don't try to update crashkernel when bootloader isn't ready to avoid the above errors. Note this is the second attempt to fix this issue. Previously a file /tmp/kexec_tools_package_install was created to avoid running the related code thus to avoid the above errors but unfortunately that approach has two issues a) somehow osbuild doesn't delete it for RHEL b) this file could still exist if users manually remove kexec-tools. Fixes: e218128 ("Only try to reset crashkernel for osbuild during package install") Reported-by: Jan Stodola Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 17 ++++++++--------- kexec-tools.spec | 5 ----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/kdumpctl b/kdumpctl index 3cad3dd..361bf51 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1611,10 +1611,13 @@ reset_crashkernel() fi } -# to tell if it's package install other than upgrade -_is_package_install() +_is_bootloader_installed() { - [[ -f /tmp/kexec_tools_package_install ]] + if [[ $(uname -r) == s390x ]]; then + test -f /etc/zipl.conf + else + test -f /boot/grub2/grub.cfg + fi } # update the crashkernel value in GRUB_ETC_DEFAULT if necessary @@ -1626,10 +1629,6 @@ update_crashkernel_in_grub_etc_default_after_update() local _crashkernel _fadump_val local _dump_mode _old_default_crashkernel _new_default_crashkernel - if _is_package_install; then - return - fi - if [[ $(uname -m) == s390x ]]; then return fi @@ -1659,7 +1658,7 @@ reset_crashkernel_after_update() local _kernel _crashkernel _dump_mode _fadump_val _old_default_crashkernel _new_default_crashkernel declare -A _crashkernel_vals - if _is_package_install; then + if ! _is_bootloader_installed; then return fi @@ -1715,7 +1714,7 @@ reset_crashkernel_for_installed_kernel() # During package install, only try to reset crashkernel for osbuild # thus to avoid calling grubby when installing os via anaconda - if _is_package_install && ! _is_osbuild; then + if ! _is_bootloader_installed && ! _is_osbuild; then return fi diff --git a/kexec-tools.spec b/kexec-tools.spec index 24fad76..1ee1770 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -268,11 +268,6 @@ if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null %endif fi -# indicate it's package install so kdumpctl later will only reset crashkernel -# value for osbuild. -if [ $1 == 1 ]; then - touch /tmp/kexec_tools_package_install -fi # don't block package update : From 4895f2a2e9bc2c6c3d274c5214990bb33f142574 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 22 Dec 2022 12:55:14 +0800 Subject: [PATCH 662/806] Release 2.0.26-1 Signed-off-by: Coiby Xu --- kexec-tools.spec | 10 ++++++++-- sources | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 1ee1770..ea49eb2 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.25 -Release: 4%{?dist} +Version: 2.0.26 +Release: 1%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -412,6 +412,12 @@ fi %endif %changelog +* Thu Dec 22 2022 Coiby - 2.0.26-1 +- Update kexec-tools to 2.0.25 +- Don't try to update crashkernel when bootloader is not installed +- dracut-module-setup.sh: also install the driver of physical NIC for Hyper-V VM with accelerated networking +- dracut-module-setup.sh: skip installing driver for the loopback interface + * Wed Dec 07 2022 Coiby - 2.0.25-4 - dracut-module-setup.sh: stop overwriting dracut's trap handler - fadump: avoid status check while starting in fadump mode diff --git a/sources b/sources index 20bacfe..d684233 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 -SHA512 (kexec-tools-2.0.25.tar.xz) = 6fd3fe11d428c5bb2ce318744146e03ddf752cc77632064bdd7418ef3ad355ad2e2db212d68a5bc73554d78f786901beb42d72bd62e2a4dae34fb224b667ec6b +SHA512 (kexec-tools-2.0.26.tar.xz) = afecb64f50a0a2e553712d7e6e4d48e0dc745e4140983a33a10cce931e6aeddaff9c4a3385fbaf7ab9ff7b3b905d932fbce1e0e37aa2c35d5c1e61277140dee9 SHA512 (makedumpfile-1.7.2.tar.gz) = 324e303dd5f507703f66e2bd5dc9d24f9f50ba797be70c05702008ba77078f61ffcc884796ddf9ab737de1d124c3a9d881ab5ce4f3f459690ec00055af25ea9e From 4ffc0113a6d1671e80884671eaf6f3a8ba2fed30 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 19 Jan 2023 14:23:04 +0000 Subject: [PATCH 663/806] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index ea49eb2..bee8721 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -412,6 +412,9 @@ fi %endif %changelog +* Thu Jan 19 2023 Fedora Release Engineering - 2.0.26-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + * Thu Dec 22 2022 Coiby - 2.0.26-1 - Update kexec-tools to 2.0.25 - Don't try to update crashkernel when bootloader is not installed From f4c04c3d6358ef7691fbf6a399d22739f1ebdb88 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 12 Jan 2023 15:02:55 +0800 Subject: [PATCH 664/806] makedumpfile: Fix wrong exclusion of slab pages on Linux 6.2-rc1 Resolves: bz2155754 Upstream: https://github.com/makedumpfile/makedumpfile Conflict: None commit 5f17bdd2128998a3eeeb4521d136a192222fadb6 Author: Kazuhito Hagio Date: Wed Dec 21 11:06:39 2022 +0900 [PATCH] Fix wrong exclusion of slab pages on Linux 6.2-rc1 * Required for kernel 6.2 Kernel commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to allow larger rcu_head"), which is contained in Linux 6.2-rc1 and later, made the offset of slab.slabs equal to page.mapping's one. As a result, "makedumpfile -d 8", which should exclude user data, excludes some slab pages wrongly because isAnon() returns true when slab.slabs is an odd number. With such dumpfiles, crash can fail to start session with an error like this: # crash vmlinux dumpfile ... crash: page excluded: kernel virtual address: ffff8fa047ac2fe8 type: "xa_node shift" Make isAnon() check that the page is not slab to fix this. Signed-off-by: Kazuhito Hagio Reported-by: Baoquan He Acked-by: Baoquan He Signed-off-by: Coiby Xu --- ...exclusion-of-slab-pages-on-Linux-6.2.patch | 81 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 83 insertions(+) create mode 100644 kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch diff --git a/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch b/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch new file mode 100644 index 0000000..5d91bc2 --- /dev/null +++ b/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch @@ -0,0 +1,81 @@ +From 5f17bdd2128998a3eeeb4521d136a192222fadb6 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Wed, 21 Dec 2022 11:06:39 +0900 +Subject: [PATCH] [PATCH] Fix wrong exclusion of slab pages on Linux 6.2-rc1 + +* Required for kernel 6.2 + +Kernel commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to +allow larger rcu_head"), which is contained in Linux 6.2-rc1 and later, +made the offset of slab.slabs equal to page.mapping's one. As a result, +"makedumpfile -d 8", which should exclude user data, excludes some slab +pages wrongly because isAnon() returns true when slab.slabs is an odd +number. With such dumpfiles, crash can fail to start session with an +error like this: + + # crash vmlinux dumpfile + ... + crash: page excluded: kernel virtual address: ffff8fa047ac2fe8 type: "xa_node shift" + +Make isAnon() check that the page is not slab to fix this. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 6 +++--- + makedumpfile.h | 9 +++------ + 2 files changed, 6 insertions(+), 9 deletions(-) + +diff --git a/makedumpfile-1.7.2/makedumpfile.c b/makedumpfile-1.7.2/makedumpfile.c +index ff821eb..f403683 100644 +--- a/makedumpfile-1.7.2/makedumpfile.c ++++ b/makedumpfile-1.7.2/makedumpfile.c +@@ -6502,7 +6502,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, + */ + else if ((info->dump_level & DL_EXCLUDE_CACHE) + && is_cache_page(flags) +- && !isPrivate(flags) && !isAnon(mapping)) { ++ && !isPrivate(flags) && !isAnon(mapping, flags)) { + pfn_counter = &pfn_cache; + } + /* +@@ -6510,7 +6510,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, + */ + else if ((info->dump_level & DL_EXCLUDE_CACHE_PRI) + && is_cache_page(flags) +- && !isAnon(mapping)) { ++ && !isAnon(mapping, flags)) { + if (isPrivate(flags)) + pfn_counter = &pfn_cache_private; + else +@@ -6522,7 +6522,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, + * - hugetlbfs pages + */ + else if ((info->dump_level & DL_EXCLUDE_USER_DATA) +- && (isAnon(mapping) || isHugetlb(compound_dtor))) { ++ && (isAnon(mapping, flags) || isHugetlb(compound_dtor))) { + pfn_counter = &pfn_user; + } + /* +diff --git a/makedumpfile-1.7.2/makedumpfile.h b/makedumpfile-1.7.2/makedumpfile.h +index 70a1a91..21dec7d 100644 +--- a/makedumpfile-1.7.2/makedumpfile.h ++++ b/makedumpfile-1.7.2/makedumpfile.h +@@ -161,12 +161,9 @@ test_bit(int nr, unsigned long addr) + #define isSwapBacked(flags) test_bit(NUMBER(PG_swapbacked), flags) + #define isHWPOISON(flags) (test_bit(NUMBER(PG_hwpoison), flags) \ + && (NUMBER(PG_hwpoison) != NOT_FOUND_NUMBER)) +- +-static inline int +-isAnon(unsigned long mapping) +-{ +- return ((unsigned long)mapping & PAGE_MAPPING_ANON) != 0; +-} ++#define isSlab(flags) test_bit(NUMBER(PG_slab), flags) ++#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \ ++ && !isSlab(flags)) + + #define PTOB(X) (((unsigned long long)(X)) << PAGESHIFT()) + #define BTOP(X) (((unsigned long long)(X)) >> PAGESHIFT()) +-- +2.39.0 + diff --git a/kexec-tools.spec b/kexec-tools.spec index bee8721..a413139 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -105,6 +105,7 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # +Patch601: kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -120,6 +121,7 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch601 -p1 %ifarch ppc %define archdef ARCH=ppc From d5faaee62b13857fc20a47dd2f1bd2642faa4658 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:30:59 +0100 Subject: [PATCH 665/806] kdumpctl: simplify check_failure_action_config With the deprecation of the 'default' option in kdump.conf check_failure_action_config needed to track which option was used (default or failure_action). This made the function quite complex.Thus make option 'default' a true alias of 'failure_action' when parsing kdump.conf and simplify check_failure_action_config. Do the same simplifications for check_final_action_config as both functions are basically identical. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 55 +++++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/kdumpctl b/kdumpctl index 361bf51..7e47091 100755 --- a/kdumpctl +++ b/kdumpctl @@ -255,7 +255,12 @@ parse_config() config_val=$DEFAULT_SSHKEY fi ;; - path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; + default) + dwarn "WARNING: Option 'default' was renamed 'failure_action' and will be removed in the future." + dwarn "Please update $KDUMP_CONFIG_FILE to use option 'failure_action' instead." + _set_config failure_action "$config_val" || return 1 + ;; + path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;; net | options | link_delay | disk_timeout | debug_mem_level | blacklist) derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." @@ -990,31 +995,12 @@ start_dump() check_failure_action_config() { - local default_option - local failure_action - local option="failure_action" - - default_option=${OPT[default]} - failure_action=${OPT[failure_action]} - - if [[ -z $failure_action ]] && [[ -z $default_option ]]; then - return 0 - elif [[ -n $failure_action ]] && [[ -n $default_option ]]; then - derror "Cannot specify 'failure_action' and 'default' option together" - return 1 - fi - - if [[ -n $default_option ]]; then - option="default" - failure_action="$default_option" - fi - - case "$failure_action" in - reboot | halt | poweroff | shell | dump_to_rootfs) + case "${OPT[failure_action]}" in + "" | reboot | halt | poweroff | shell | dump_to_rootfs) return 0 ;; *) - dinfo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" + dinfo $"Usage kdump.conf: failure_action {reboot|halt|poweroff|shell|dump_to_rootfs}" return 1 ;; esac @@ -1022,22 +1008,15 @@ check_failure_action_config() check_final_action_config() { - local final_action - - final_action=${OPT[final_action]} - if [[ -z $final_action ]]; then + case "${OPT[final_action]}" in + "" | reboot | halt | poweroff) return 0 - else - case "$final_action" in - reboot | halt | poweroff) - return 0 - ;; - *) - dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" - return 1 - ;; - esac - fi + ;; + *) + dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" + return 1 + ;; + esac } start() From 0578245746a4324d8e6ff5d22824975f8998154e Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:00 +0100 Subject: [PATCH 666/806] dracut-early-kdump: fix shellcheck findings Fix the following issues found by shellcheck. For the second one disable shellcheck as EARLY_KEXEC_ARGS can contain multiple arguments. In dracut-early-kdump.sh line 9: EARLY_KDUMP_KERNELVER="" ^-------------------^ SC2034: EARLY_KDUMP_KERNELVER appears unused. Verify use (or export if used externally). In dracut-early-kdump.sh line 61: if $KEXEC $EARLY_KEXEC_ARGS $standard_kexec_args \ ^---------------^ SC2086: Double quote to prevent globbing and word splitting. For more information: https://www.shellcheck.net/wiki/SC2034 https://www.shellcheck.net/wiki/SC2086 Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-early-kdump.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 45ee6dc..3b84b48 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -6,7 +6,6 @@ standard_kexec_args="-p" EARLY_KDUMP_INITRD="" EARLY_KDUMP_KERNEL="" EARLY_KDUMP_CMDLINE="" -EARLY_KDUMP_KERNELVER="" EARLY_KEXEC_ARGS="" . /etc/sysconfig/kdump @@ -58,6 +57,7 @@ early_kdump_load() --command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \ $EARLY_KDUMP_KERNEL" + # shellcheck disable=SC2086 if $KEXEC $EARLY_KEXEC_ARGS $standard_kexec_args \ --command-line="$EARLY_KDUMP_CMDLINE" \ --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL; then From ed6936f9fc9f56ee6a3e95acdea7ce1767b511dc Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:01 +0100 Subject: [PATCH 667/806] dracut-early-kdump: explicitly use bash Currently dracut-early-kdump.sh claims to be POSIX compliant but it sources kdump-lib.sh which uses bash-only syntax. Thus require bash for dracut-early-kdump.sh as well. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- .editorconfig | 2 +- dracut-early-kdump.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 87c4f98..b343f27 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,7 +22,7 @@ space_redirects = true shell_variant = bash # Use dracut code style for *-module-setup.sh -[*-module-setup.sh] +[*-module-setup.sh,dracut-early-kdump.sh] shell_variant = bash indent_style = space indent_size = 4 diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 3b84b48..f8d4e0f 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash KEXEC=/sbin/kexec standard_kexec_args="-p" From b9fd7a4076a2b355f57c7c2529a093f3aa9f6863 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:02 +0100 Subject: [PATCH 668/806] kdumpctl: merge check_current_{kdump,fadump}_status Both functions are almost identical. The only differences are (1) the sysfs node the status is read from and (2) the fact the fadump version doesn't verify if the file it's trying to read actually exists. Thus merge the two functions and get rid of the check_current_status wrapper. While at it rename the function to is_kernel_loaded which explains better what the function does. Finally, after moving FADUMP_REGISTER_SYS_NODE shellcheck can no longer access the definition and starts complaining about it not being quoted. Thus quote all uses of FADUMP_REGISTER_SYS_NODE. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-early-kdump.sh | 2 +- kdump-lib.sh | 31 ++++++++++++++++++++++--------- kdumpctl | 34 ++++++++-------------------------- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index f8d4e0f..044f741 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -37,7 +37,7 @@ early_kdump_load() return 1 fi - if check_current_kdump_status; then + if is_kernel_loaded "kdump"; then return 1 fi diff --git a/kdump-lib.sh b/kdump-lib.sh index 400b05c..c3091c8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -9,6 +9,7 @@ else fi FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" +FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" is_fadump_capable() { @@ -494,19 +495,31 @@ check_kdump_feasibility() return $? } -check_current_kdump_status() +is_kernel_loaded() { - if [[ ! -f /sys/kernel/kexec_crash_loaded ]]; then - derror "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" + local _sysfs _mode + + _mode=$1 + + case "$_mode" in + kdump) + _sysfs="/sys/kernel/kexec_crash_loaded" + ;; + fadump) + _sysfs="$FADUMP_REGISTER_SYS_NODE" + ;; + *) + derror "Unknown dump mode '$_mode' provided" + return 1 + ;; + esac + + if [[ ! -f $_sysfs ]]; then + derror "$_mode is not supported on this kernel" return 1 fi - rc=$(< /sys/kernel/kexec_crash_loaded) - if [[ $rc == 1 ]]; then - return 0 - else - return 1 - fi + [[ $(< $_sysfs) -eq 1 ]] } # remove_cmdline_param [] ... [] diff --git a/kdumpctl b/kdumpctl index 7e47091..dd4bae6 100755 --- a/kdumpctl +++ b/kdumpctl @@ -14,7 +14,6 @@ DEFAULT_INITRD_BAK="" INITRD_CHECKSUM_LOCATION="" KDUMP_INITRD="" TARGET_INITRD="" -FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" image_time=0 @@ -837,23 +836,6 @@ show_reserved_mem() dinfo "Reserved ${mem_mb}MB memory for crash kernel" } -check_current_fadump_status() -{ - # Check if firmware-assisted dump has been registered. - rc=$(< $FADUMP_REGISTER_SYS_NODE) - [[ $rc -eq 1 ]] && return 0 - return 1 -} - -check_current_status() -{ - if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then - check_current_fadump_status - else - check_current_kdump_status - fi -} - save_raw() { local raw_target @@ -974,8 +956,8 @@ check_dump_feasibility() start_fadump() { - echo 1 > $FADUMP_REGISTER_SYS_NODE - if ! check_current_fadump_status; then + echo 1 > "$FADUMP_REGISTER_SYS_NODE" + if ! is_kernel_loaded "fadump"; then derror "fadump: failed to register" return 1 fi @@ -1040,7 +1022,7 @@ start() return 1 fi - if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && check_current_kdump_status; then + if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && is_kernel_loaded "kdump"; then dwarn "Kdump already running: [WARNING]" return 0 fi @@ -1065,7 +1047,7 @@ start() reload() { - if ! check_current_status; then + if ! is_kernel_loaded "$DEFAULT_DUMP_MODE"; then dwarn "Kdump was not running: [WARNING]" fi @@ -1096,8 +1078,8 @@ reload() stop_fadump() { - echo 0 > $FADUMP_REGISTER_SYS_NODE - if check_current_fadump_status; then + echo 0 > "$FADUMP_REGISTER_SYS_NODE" + if is_kernel_loaded "fadump"; then derror "fadump: failed to unregister" return 1 fi @@ -1126,7 +1108,7 @@ stop_kdump() reload_fadump() { - if echo 1 > $FADUMP_REGISTER_SYS_NODE; then + if echo 1 > "$FADUMP_REGISTER_SYS_NODE"; then dinfo "fadump: re-registered successfully" return 0 else @@ -1739,7 +1721,7 @@ main() ;; status) EXIT_CODE=0 - check_current_status + is_kernel_loaded "$DEFAULT_DUMP_MODE" case "$?" in 0) dinfo "Kdump is operational" From 383cb622029a52dd1cb460144aa8e62ed0907d73 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:03 +0100 Subject: [PATCH 669/806] mkfadumprd: drop unset globals from debug output mkfadumprd doesn't call prepare_kdump_bootinfo from kdump-lib.sh. Thus both KDUMP_KERNELVER and DEFAULT_INITRD are always empty. Simply remove them from the debug print. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- mkfadumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 mkfadumprd diff --git a/mkfadumprd b/mkfadumprd old mode 100644 new mode 100755 index 2fc396c..719e150 --- a/mkfadumprd +++ b/mkfadumprd @@ -37,7 +37,7 @@ FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img" ### First build an initramfs with dump capture capability # this file tells the initrd is fadump enabled touch "$MKFADUMPRD_TMPDIR/fadump.initramfs" -ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER" +ddebug "rebuild fadump initrd: $FADUMP_INITRD" # Don't use squash for capture image or default image as it negatively impacts # compression ratio and increases the size of the initramfs image. # Don't compress the capture image as uncompressed image is needed immediately. From 88919b73f01ed630843893b0fcf4fec57b91ac22 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:04 +0100 Subject: [PATCH 670/806] kdump-lib: always specify version in is_squash_available is_squash_available is only used in dracut-module-setup.sh and mkdumprd. Neither of the two scripts calls prepare_kdump_bootinfo which determines and sets KDUMP_KERNELVER. Thus KDUMP_KERNELVER is only non-zero if it explicitly specified by the user in /etc/sysconfig/kdump (and the file gets sourced, which is not the case for drachu-module-setup.sh). In theory this can even lead to bugs. For example consider the case when a debug kernel is running. In that case kdumpctl will try to use the non-debug version of the kernel while is_squash_available will make its decision based on the debug version. So in case the debug kernel has squash available but the non-debug kernel doesn't mkdumprd will try to add it nevertheless. Thus factor out the kernel version detection from prepare_kdump_bootinfo and make use of the new function when checking for the availability of those kernel modules. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 64 +++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index c3091c8..0109b95 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -24,12 +24,11 @@ is_fadump_capable() is_squash_available() { + local _version kmodule + + _version=$(_get_kdump_kernel_version) for kmodule in squashfs overlay loop; do - if [[ -z $KDUMP_KERNELVER ]]; then - modprobe --dry-run $kmodule &> /dev/null || return 1 - else - modprobe -S "$KDUMP_KERNELVER" --dry-run $kmodule &> /dev/null || return 1 - fi + modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1 done } @@ -687,6 +686,31 @@ prepare_kdump_kernel() echo "$kdump_kernel" } +_get_kdump_kernel_version() +{ + local _version _version_nondebug + + if [[ -n "$KDUMP_KERNELVER" ]]; then + echo "$KDUMP_KERNELVER" + return + fi + + _version=$(uname -r) + if [[ ! "$_version" =~ \+debug$ ]]; then + echo "$_version" + return + fi + + _version_nondebug=${_version%+debug} + if [[ -f "$(prepare_kdump_kernel "$_version_nondebug")" ]]; then + dinfo "Use of debug kernel detected. Trying to use $_version_nondebug" + echo "$_version_nondebug" + else + dinfo "Use of debug kernel detected but cannot find $_version_nondebug. Falling back to $_version" + echo "$_version" + fi +} + # # Detect initrd and kernel location, results are stored in global environmental variables: # KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD @@ -696,37 +720,11 @@ prepare_kdump_kernel() # prepare_kdump_bootinfo() { - local boot_initrdlist nondebug_kernelver debug_kernelver - local default_initrd_base var_target_initrd_dir - - if [[ -z $KDUMP_KERNELVER ]]; then - KDUMP_KERNELVER=$(uname -r) - - # Fadump uses the regular bootloader, unlike kdump. So, use the same version - # for default kernel and capture kernel unless specified explicitly with - # KDUMP_KERNELVER option. - if ! is_fadump_capable; then - nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER") - fi - fi - - # Use nondebug kernel if possible, because debug kernel will consume more memory and may oom. - if [[ -n $nondebug_kernelver ]]; then - dinfo "Trying to use $nondebug_kernelver." - debug_kernelver=$KDUMP_KERNELVER - KDUMP_KERNELVER=$nondebug_kernelver - fi + local boot_initrdlist default_initrd_base var_target_initrd_dir + KDUMP_KERNELVER=$(_get_kdump_kernel_version) KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER") - if ! [[ -e $KDUMP_KERNEL ]]; then - if [[ -n $debug_kernelver ]]; then - dinfo "Fallback to using debug kernel" - KDUMP_KERNELVER=$debug_kernelver - KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER") - fi - fi - if ! [[ -e $KDUMP_KERNEL ]]; then derror "Failed to detect kdump kernel location" return 1 From 269c26972d52cda24e2a1b6653a1a964b313cc6a Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:05 +0100 Subject: [PATCH 671/806] unit tests: add tests for prepare_cmdline prepare_cmdline is totally broken. For example if the remove list ($2) is empty it removes all white spaces or if a parameter has a quoted value containing a white space it only removes the first part of the parameter up to the first space. Thus add a test case that shows what the function should do in order to fix it in subsequent patches. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- spec/kdump-lib_spec.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 8c91480..3d10006 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -48,4 +48,36 @@ Describe 'kdump-lib' End End + Describe 'prepare_cmdline()' + get_bootcpu_apicid() { + echo 1 + } + + get_watchdog_drvs() { + echo foo + } + + add="disable_cpu_apicid=1 foo.pretimeout=0" + + Parameters + #test cmdline remove add result + "#1" "a b c" "" "" "a b c" + "#2" "a b c" "b" "" "a c" + "#3" "a b=x c" "b" "" "a c" + "#4" "a b='x y' c" "b" "" "a c" + "#5" "a b='x y' c" "b=x" "" "a c" + "#6" "a b='x y' c" "b='x y'" "" "a c" + "#7" "a b c" "" "x" "a b c x" + "#8" "a b c" "" "x=1" "a b c x=1" + "#9" "a b c" "" "x='1 2'" "a b c x='1 2'" + "#10" "a b c" "a" "x='1 2'" "b c x='1 2'" + "#11" "a b c" "x" "x='1 2'" "a b c x='1 2'" + End + + It "Test $1: should generate the correct kernel command line" + When call prepare_cmdline "$2" "$3" "$4" + The output should equal "$5 $add" + End + End + End From d55a0565585aa22db069cf5f5fa1955373be60b3 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:06 +0100 Subject: [PATCH 672/806] kdumpctl: move aws workaround to kdump-lib Move the workaround for aws graviton cpus from load_kdump to prepare_cmdline. This (1) makes the workaround available also for other callers of prepare_cmdline (although not needed at the moment) and (2) makes it easier to fix the problems found by the unit test included earlier as all changes to the cmdline are done at one place now. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 9 +++++++++ kdumpctl | 17 ----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 0109b95..bea74b2 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -22,6 +22,11 @@ is_fadump_capable() return 1 } +is_aws_aarch64() +{ + [[ "$(lscpu | grep "BIOS Model name")" =~ "AWS Graviton" ]] +} + is_squash_available() { local _version kmodule @@ -846,6 +851,10 @@ prepare_cmdline() fi done + # This is a workaround on AWS platform. Always remove irqpoll since it + # may cause the hot-remove of some pci hotplug device. + is_aws_aarch64 && cmdline=$(remove_cmdline_param "${cmdline}" irqpoll) + echo "$cmdline" } diff --git a/kdumpctl b/kdumpctl index dd4bae6..ce3f23f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -656,18 +656,6 @@ function remove_kdump_kernel_key() keyctl unlink "$KDUMP_KEY_ID" %:.ima } -function is_aws_aarch64() -{ - local _bios_model - - _bios_model=$(lscpu | grep "BIOS Model name") - if [[ "${_bios_model}" =~ "AWS Graviton" ]]; then - return 0 - fi - - return 1 -} - # Load the kdump kernel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. @@ -677,11 +665,6 @@ load_kdump() KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - # This is a workaround on AWS platform, since irqpoll may cause the hot-remove of some pci hotplug device - if is_aws_aarch64; then - KDUMP_COMMANDLINE=$(remove_cmdline_param "${KDUMP_COMMANDLINE}" irqpoll) - fi - # For secureboot enabled machines, use new kexec file based syscall. # Old syscall will always fail as it does not have capability to # to kernel signature verification. From 0f6ad91be85d5aec983a00ca54adb1b130889bc2 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:07 +0100 Subject: [PATCH 673/806] kdump-lib: fix prepare_cmdline A recently added unit test found that prepare_cmdline has several problems. For example an empty remove list will remove all spaces or when the cmdline contains a parameter with quoted values containing spaces will only remove the beginning up to the first space. Furthermore the old design requires lots of subshells and pipes. This patch rewrites prepare_cmdline in a way that makes the unit test happy and tries to use as many bash built-ins as possible. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 126 ++++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index bea74b2..6b0a83d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -526,24 +526,6 @@ is_kernel_loaded() [[ $(< $_sysfs) -eq 1 ]] } -# remove_cmdline_param [] ... [] -# Remove a list of kernel parameters from a given kernel cmdline and print the result. -# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. -remove_cmdline_param() -{ - local cmdline=$1 - shift - - for arg in "$@"; do - cmdline=$(echo "$cmdline" | - sed -e "s/\b$arg=[^ ]*//g" \ - -e "s/^$arg\b//g" \ - -e "s/[[:space:]]$arg\b//g" \ - -e "s/\s\+/ /g") - done - echo "$cmdline" -} - # # This function returns the "apicid" of the boot # cpu (cpu 0) if present. @@ -558,23 +540,6 @@ get_bootcpu_apicid() /proc/cpuinfo } -# -# append_cmdline -# This function appends argument "$2=$3" to string ($1) if not already present. -# -append_cmdline() -{ - local cmdline=$1 - local newstr=${cmdline/$2/""} - - # unchanged str implies argument wasn't there - if [[ $cmdline == "$newstr" ]]; then - cmdline="${cmdline} ${2}=${3}" - fi - - echo "$cmdline" -} - # This function check iomem and determines if we have more than # 4GB of ram available. Returns 1 if we do, 0 if we dont need_64bit_headers() @@ -792,26 +757,46 @@ get_watchdog_drvs() echo "$_wdtdrvs" } +_cmdline_parse() +{ + local opt val + + while read -r opt; do + if [[ $opt =~ = ]]; then + val=${opt#*=} + opt=${opt%%=*} + # ignore options like 'foo=' + [[ -z $val ]] && continue + # xargs removes quotes, add them again + [[ $val =~ [[:space:]] ]] && val="\"$val\"" + else + val="" + fi + + echo "$opt $val" + done <<< "$(echo "$1" | xargs -n 1 echo)" +} + # # prepare_cmdline # This function performs a series of edits on the command line. # Store the final result in global $KDUMP_COMMANDLINE. prepare_cmdline() { - local cmdline id arg + local in out append opt val id drv + local -A remove + + in=${1:-$(< /proc/cmdline)} + while read -r opt val; do + [[ -n "$opt" ]] || continue + remove[$opt]=1 + done <<< "$(_cmdline_parse "$2")" + append=$3 - if [[ -z $1 ]]; then - cmdline=$(< /proc/cmdline) - else - cmdline="$1" - fi # These params should always be removed - cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) - # These params can be removed configurably - while read -r arg; do - cmdline=$(remove_cmdline_param "$cmdline" "$arg") - done <<< "$(echo "$2" | xargs -n 1 echo)" + remove[crashkernel]=1 + remove[panic_on_warn]=1 # Always remove "root=X", as we now explicitly generate all kinds # of dump target mount information including root fs. @@ -819,43 +804,62 @@ prepare_cmdline() # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares # about it(e.g. for debug purpose), then can pass "root=X" using # KDUMP_COMMANDLINE_APPEND. - cmdline=$(remove_cmdline_param "$cmdline" root) + remove[root]=1 # With the help of "--hostonly-cmdline", we can avoid some interitage. - cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) + remove[rd.lvm.lv]=1 + remove[rd.luks.uuid]=1 + remove[rd.dm.uuid]=1 + remove[rd.md.uuid]=1 + remove[fcoe]=1 # Remove netroot, rd.iscsi.initiator and iscsi_initiator since # we get duplicate entries for the same in case iscsi code adds # it as well. - cmdline=$(remove_cmdline_param "$cmdline" netroot rd.iscsi.initiator iscsi_initiator) + remove[netroot]=1 + remove[rd.iscsi.initiator]=1 + remove[iscsi_initiator]=1 - cmdline="${cmdline} $3" + while read -r opt val; do + [[ -n "$opt" ]] || continue + [[ -n "${remove[$opt]}" ]] && continue + + if [[ -n "$val" ]]; then + out+="$opt=$val " + else + out+="$opt " + fi + done <<< "$(_cmdline_parse "$in")" + + out+="$append " id=$(get_bootcpu_apicid) - if [[ -n ${id} ]]; then - cmdline=$(append_cmdline "$cmdline" disable_cpu_apicid "$id") + if [[ -n "${id}" ]]; then + out+="disable_cpu_apicid=$id " fi # If any watchdog is used, set it's pretimeout to 0. pretimeout let # watchdog panic the kernel first, and reset the system after the # panic. If the system is already in kdump, panic is not helpful # and only increase the chance of watchdog failure. - for i in $(get_watchdog_drvs); do - cmdline+=" $i.pretimeout=0" + for drv in $(get_watchdog_drvs); do + out+="$drv.pretimeout=0 " - if [[ $i == hpwdt ]]; then - # hpwdt have a special parameter kdumptimeout, is's only suppose - # to be set to non-zero in first kernel. In kdump, non-zero - # value could prevent the watchdog from resetting the system. - cmdline+=" $i.kdumptimeout=0" + if [[ $drv == hpwdt ]]; then + # hpwdt have a special parameter kdumptimeout, it is + # only supposed to be set to non-zero in first kernel. + # In kdump, non-zero value could prevent the watchdog + # from resetting the system. + out+="$drv.kdumptimeout=0 " fi done # This is a workaround on AWS platform. Always remove irqpoll since it # may cause the hot-remove of some pci hotplug device. - is_aws_aarch64 && cmdline=$(remove_cmdline_param "${cmdline}" irqpoll) + is_aws_aarch64 && out=$(echo "$out" | sed -e "/\//") - echo "$cmdline" + # Trim unnecessary whitespaces + echo "$out" | sed -e "s/^ *//g" -e "s/ *$//g" -e "s/ \+/ /g" } PROC_IOMEM=/proc/iomem From 33b307af20c7cd82b4de8bf44dbb3977391b7edd Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:08 +0100 Subject: [PATCH 674/806] kdumpctl: cleanup 'start' The function has many block of the kind if ! cmd; then derror "Starting kdump: [FAILED]" return 1 fi This duplicates code and makes the function hard to read. Thus move the block to the calling function. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/kdumpctl b/kdumpctl index ce3f23f..0dae9b7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -986,46 +986,26 @@ check_final_action_config() start() { - if ! check_dump_feasibility; then - derror "Starting kdump: [FAILED]" - return 1 - fi - - if ! parse_config; then - derror "Starting kdump: [FAILED]" - return 1 - fi + check_dump_feasibility || return + parse_config || return if sestatus 2> /dev/null | grep -q "SELinux status.*enabled"; then selinux_relabel fi - if ! save_raw; then - derror "Starting kdump: [FAILED]" - return 1 - fi + save_raw || return if [[ $DEFAULT_DUMP_MODE == "kdump" ]] && is_kernel_loaded "kdump"; then dwarn "Kdump already running: [WARNING]" return 0 fi - if ! check_and_wait_network_ready; then - derror "Starting kdump: [FAILED]" - return 1 - fi - - if ! check_rebuild; then - derror "Starting kdump: [FAILED]" - return 1 - fi - - if ! start_dump; then - derror "Starting kdump: [FAILED]" - return 1 - fi + check_and_wait_network_ready || return + check_rebuild || return + start_dump || return dinfo "Starting kdump: [OK]" + return 0 } reload() @@ -1697,7 +1677,10 @@ main() case "$1" in start) - start + if ! start; then + derror "Starting kdump: [FAILED]" + exit 1 + fi ;; stop) stop @@ -1722,7 +1705,10 @@ main() ;; restart) stop - start + if ! start; then + derror "Starting kdump: [FAILED]" + exit 1 + fi ;; rebuild) rebuild From 5eefcf2e9434108493b04ddefac6a26909071241 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:09 +0100 Subject: [PATCH 675/806] kdumpctl: cleanup 'stop' Like for 'start' move the printing of the error message to the calling function. This not only makes the code more consistent to 'start' but also prevents 'kdumpctl restart' to call 'start' in case 'stop' has failed. This doesn't impact the case when 'kdumpctl restart' is run without any crash kernel being loaded as kexec will still return success in that case. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kdumpctl b/kdumpctl index 0dae9b7..1534fa5 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1090,15 +1090,9 @@ reload_fadump() stop() { if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then - stop_fadump + stop_fadump || return else - stop_kdump - fi - - # shellcheck disable=SC2181 - if [[ $? != 0 ]]; then - derror "Stopping kdump: [FAILED]" - return 1 + stop_kdump || return fi dinfo "Stopping kdump: [OK]" @@ -1683,7 +1677,10 @@ main() fi ;; stop) - stop + if ! stop; then + derror "Stopping kdump: [FAILED]" + exit 1 + fi ;; status) EXIT_CODE=0 @@ -1704,7 +1701,10 @@ main() reload ;; restart) - stop + if ! stop; then + derror "Stopping kdump: [FAILED]" + exit 1 + fi if ! start; then derror "Starting kdump: [FAILED]" exit 1 From 37577b93ed3519414233be95974917d5c451f5dd Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:10 +0100 Subject: [PATCH 676/806] kdumpctl: refractor check_rebuild check_rebuild uses a bunch of local variables to store the result of the different checks performed. At the end of the function it then evaluates which check failed to print an appropriate info and trigger a rebuild if needed. This not only makes the function hard to read but also requires all checks to be executed even if an earlier one already determined that the initrd needs to be rebuild. Thus refractor check_rebuild such that it only checks whether the initrd needs to rebuild and trigger the rebuild by the caller (if needed). While at it rename the function to need_initrd_rebuild. Furthermore also move setup_initrd to the caller so it is more consisted with the other users of the function. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 83 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/kdumpctl b/kdumpctl index 1534fa5..1952a10 100755 --- a/kdumpctl +++ b/kdumpctl @@ -560,72 +560,58 @@ check_system_modified() return 0 } -check_rebuild() +# need_initrd_rebuild - check whether the initrd needs to be rebuild +# Returns: +# 0 if does not need to be rebuild +# 1 if it needs to be rebuild +# 2 if an error occurred +need_initrd_rebuild() { - local capture_capable_initrd="1" local force_rebuild force_no_rebuild - local ret system_modified="0" - setup_initrd || return 1 - - force_no_rebuild=${OPT[force_no_rebuild]} - force_no_rebuild=${force_no_rebuild:-0} + force_no_rebuild=${OPT[force_no_rebuild]:-0} if [[ $force_no_rebuild != "0" ]] && [[ $force_no_rebuild != "1" ]]; then derror "Error: force_no_rebuild value is invalid" - return 1 + return 2 fi - force_rebuild=${OPT[force_rebuild]} - force_rebuild=${force_rebuild:-0} + force_rebuild=${OPT[force_rebuild]:-0} if [[ $force_rebuild != "0" ]] && [[ $force_rebuild != "1" ]]; then derror "Error: force_rebuild value is invalid" - return 1 + return 2 fi if [[ $force_no_rebuild == "1" && $force_rebuild == "1" ]]; then derror "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf" - return 1 + return 2 fi - # Will not rebuild kdump initrd if [[ $force_no_rebuild == "1" ]]; then return 0 fi - #check to see if dependent files has been modified - #since last build of the image file - if [[ -f $TARGET_INITRD ]]; then - image_time=$(stat -c "%Y" "$TARGET_INITRD" 2> /dev/null) + if [[ $force_rebuild == "1" ]]; then + dinfo "Force rebuild $TARGET_INITRD" + return 1 + fi - #in case of fadump mode, check whether the default/target - #initrd is already built with dump capture capability - if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then - capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$) + if [[ ! -f $TARGET_INITRD ]]; then + dinfo "No kdump initial ramdisk found." + return 1 + fi + + # in case of fadump mode, check whether the default/target initrd is + # already built with dump capture capability + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then + if ! lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -q -e ^kdumpbase$ -e ^zz-fadumpinit$; then + dinfo "Rebuild $TARGET_INITRD with dump capture support" + return 1 fi fi + image_time=$(stat -c "%Y" "$TARGET_INITRD" 2> /dev/null) check_system_modified - ret=$? - if [[ $ret -eq 2 ]]; then - return 1 - elif [[ $ret -eq 1 ]]; then - system_modified="1" - fi - if [[ $image_time -eq 0 ]]; then - dinfo "No kdump initial ramdisk found." - elif [[ $capture_capable_initrd == "0" ]]; then - dinfo "Rebuild $TARGET_INITRD with dump capture support" - elif [[ $force_rebuild != "0" ]]; then - dinfo "Force rebuild $TARGET_INITRD" - elif [[ $system_modified != "0" ]]; then - : - else - return 0 - fi - - dinfo "Rebuilding $TARGET_INITRD" - rebuild_initrd } # On ppc64le LPARs, the keys trusted by firmware do not end up in @@ -1001,7 +987,20 @@ start() fi check_and_wait_network_ready || return - check_rebuild || return + setup_initrd || return + need_initrd_rebuild + case "$?" in + 0) + # Nothing to do + ;; + 1) + dinfo "Rebuilding $TARGET_INITRD" + rebuild_initrd || return + ;; + *) + return + ;; + esac start_dump || return dinfo "Starting kdump: [OK]" From d4e877214c9e6b370d4ee67d26386cfb0c9a7cf5 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 12 Jan 2023 16:31:11 +0100 Subject: [PATCH 677/806] kdumpctl: make do_estimate more robust At the beginning of do_estimate it currently checks whether the TARGET_INITRD exists and if not fails with an error message. This not only requires the user to manually trigger the build of the initrd but also ignores all cases where the TARGET_INITRD exists but need to be rebuild. For example when there were changes to kdump.conf or when the system switches from kdump to fadump. All these changes will impact the outcome of do_estimate. Thus properly check whether the initrd needs to be rebuild and if it does trigger the rebuild automatically. To do so move the check whether the TARGET_INITRD has fadump enabled to is_system_modified and call this function. With this force_(no_)rebuild options in kdump.conf are ignored to avoid unnecessary rebuilds. While at it cleanup check_system_modified and rename it to is_system_modified. Furthermore move printing the info that the initrd gets rebuild to rebuild_initrd to avoid every caller has the same line. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 71 ++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/kdumpctl b/kdumpctl index 1952a10..553c392 100755 --- a/kdumpctl +++ b/kdumpctl @@ -16,7 +16,6 @@ KDUMP_INITRD="" TARGET_INITRD="" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" -image_time=0 standard_kexec_args="-d -p" @@ -117,6 +116,8 @@ rebuild_kdump_initrd() rebuild_initrd() { + dinfo "Rebuilding $TARGET_INITRD" + if [[ ! -w $(dirname "$TARGET_INITRD") ]]; then derror "$(dirname "$TARGET_INITRD") does not have write permission. Cannot rebuild $TARGET_INITRD" return 1 @@ -294,10 +295,12 @@ get_pcs_cluster_modified_files() { local time_stamp local modified_files + local image_time is_generic_fence_kdump && return 1 is_pcs_fence_kdump || return 1 + image_time=$1 time_stamp=$(pcs cluster cib | xmllint --xpath 'string(/cib/@cib-last-written)' - | xargs -0 date +%s --date) if [[ -n $time_stamp ]] && [[ $time_stamp -gt $image_time ]]; then @@ -341,10 +344,14 @@ setup_initrd() check_files_modified() { + local modified_files="" + local image_time + + image_time=$(stat -c "%Y" "$TARGET_INITRD" 2> /dev/null) #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. - modified_files=$(get_pcs_cluster_modified_files) + modified_files=$(get_pcs_cluster_modified_files "$image_time") EXTRA_BINS=${OPT[kdump_post]} CHECK_FILES=${OPT[kdump_pre]} @@ -532,32 +539,25 @@ check_fs_modified() # returns 0 if system is not modified # returns 1 if system is modified -# returns 2 if system modification is invalid -check_system_modified() +# returns 2 if an error occurred +is_system_modified() { local ret [[ -f $TARGET_INITRD ]] || return 1 - check_files_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret - fi - - check_fs_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret + # in case of fadump mode, check whether the default/target initrd is + # already built with dump capture capability + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then + if ! lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -q -e ^kdumpbase$ -e ^zz-fadumpinit$; then + dinfo "Rebuild $TARGET_INITRD with dump capture support" + return 1 + fi fi + check_files_modified || return + check_fs_modified || return check_drivers_modified - ret=$? - if [[ $ret -ne 0 ]]; then - return $ret - fi - - return 0 } # need_initrd_rebuild - check whether the initrd needs to be rebuild @@ -600,18 +600,7 @@ need_initrd_rebuild() return 1 fi - # in case of fadump mode, check whether the default/target initrd is - # already built with dump capture capability - if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then - if ! lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -q -e ^kdumpbase$ -e ^zz-fadumpinit$; then - dinfo "Rebuild $TARGET_INITRD with dump capture support" - return 1 - fi - fi - - image_time=$(stat -c "%Y" "$TARGET_INITRD" 2> /dev/null) - check_system_modified - + is_system_modified } # On ppc64le LPARs, the keys trusted by firmware do not end up in @@ -994,7 +983,6 @@ start() # Nothing to do ;; 1) - dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd || return ;; *) @@ -1105,7 +1093,6 @@ rebuild() setup_initrd || return 1 - dinfo "Rebuilding $TARGET_INITRD" rebuild_initrd } @@ -1118,10 +1105,18 @@ do_estimate() local size_mb=$((1024 * 1024)) setup_initrd - if [[ ! -f $TARGET_INITRD ]]; then - derror "kdumpctl estimate: kdump initramfs is not built yet." - exit 1 - fi + is_system_modified + case "$?" in + 0) + # Nothing to do + ;; + 1) + rebuild_initrd || return + ;; + *) + return + ;; + esac kdump_mods="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" baseline=$(kdump_get_arch_recommend_size) From b41cab7099189abacdfa9e198fb54a7526cca2ae Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 30 Jan 2023 16:18:51 +0800 Subject: [PATCH 678/806] Release 2.0.26-3 Signed-off-by: Coiby Xu --- kexec-tools.spec | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a413139..5c42af6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -414,6 +414,22 @@ fi %endif %changelog +* Jan 30 2023 Coiby - 2.0.26-3 +- kdumpctl: make do_estimate more robust +- kdumpctl: refractor check_rebuild +- kdumpctl: cleanup 'stop' +- kdumpctl: cleanup 'start' +- kdump-lib: fix prepare_cmdline +- kdumpctl: move aws workaround to kdump-lib +- unit tests: add tests for prepare_cmdline +- kdump-lib: always specify version in is_squash_available +- mkfadumprd: drop unset globals from debug output +- kdumpctl: merge check_current_{kdump,fadump}_status +- dracut-early-kdump: explicitly use bash +- dracut-early-kdump: fix shellcheck findings +- kdumpctl: simplify check_failure_action_config +- makedumpfile: Fix wrong exclusion of slab pages on Linux 6.2-rc1 + * Thu Jan 19 2023 Fedora Release Engineering - 2.0.26-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild From 12e6cd2b76a10bb6b52c0cc28ad0e8c8f57a319a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 20 Feb 2023 17:33:08 +0800 Subject: [PATCH 679/806] Use the correct command to get architecture `uname -m` was used by mistake. As a result, kexec-tools failed to update crashkernel=auto during in-place upgrade from RHEL8 to RHEL9. `uname -m` should be used to get architecture instead. Fixes: 5951b5e2 ("Don't try to update crashkernel when bootloader is not installed") Signed-off-by: Coiby Xu Reviewed-by: Lichen Liu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 553c392..2bec428 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1525,7 +1525,7 @@ reset_crashkernel() _is_bootloader_installed() { - if [[ $(uname -r) == s390x ]]; then + if [[ $(uname -m) == s390x ]]; then test -f /etc/zipl.conf else test -f /boot/grub2/grub.cfg From d9dfea12da33747a92fb97235ef068de1a25e05d Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Tue, 7 Mar 2023 14:45:35 +0100 Subject: [PATCH 680/806] sysconfig: add zfcp.allow_lun_scan to KDUMP_COMMANDLINE_REMOVE on s390 Probing unnecessary I/O devices wastes memory and in extreme cases can cause the crashkernel to run OOM. That's why the s390-tools maintain their own module, 95zdev-kdump [1], that disables auto LUN scanning and only configures zfcp devices that can be used as dump target. So remove zfcp.allow_lun_scan from the kernel command line to prevent that we accidentally overwrite the default set by the module. [1] https://github.com/ibm-s390-linux/s390-tools/blob/master/zdev/dracut/95zdev-kdump/module-setup.sh Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- gen-kdump-sysconfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen-kdump-sysconfig.sh b/gen-kdump-sysconfig.sh index bc37dee..5a16e92 100755 --- a/gen-kdump-sysconfig.sh +++ b/gen-kdump-sysconfig.sh @@ -97,7 +97,7 @@ ppc64le) s390x) update_param KEXEC_ARGS "-s" update_param KDUMP_COMMANDLINE_REMOVE \ - "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot" + "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot zfcp.allow_lun_scan" update_param KDUMP_COMMANDLINE_APPEND \ "nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0" ;; From 70c7598ef03a1f611b3a00d8f2254fae1da5b0eb Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 23 Dec 2022 16:03:38 +0800 Subject: [PATCH 681/806] Install nfsv4-related drivers when users specify nfs dumping via dracut_args Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2140721 Currently, if users specify dumping to nfsv4 target via dracut_args --mount ":/var/crash /mnt nfs defaults" it fails with the following errors, [ 5.159760] mount[446]: mount.nfs: Protocol not supported [ 5.164502] systemd[1]: mnt.mount: Mount process exited, code=exited, status=32/n/a [ 5.167616] systemd[1]: mnt.mount: Failed with result 'exit-code'. [FAILED] Failed to mount /mnt. This is because nfsv4-releted drivers are not installed to kdump initrd. mkdumprd calls dracut with "--hostonly-mode strict". If nfsv4-related drivers aren't loaded before calling dracut, they won't be installed. When users specify nfs dumping via dracut_args, kexec-tools won't mount the nfs fs beforehand hence nfsv4-related drivers won't be installed. Note dracut only installs the nfs driver i.e. nfsv3 driver for "--mount ... nfs". So also install nfsv4-related drivers when users specify nfs dumping via dracut_args. Since nfs_layout_nfsv41_files depends on nfsv4, the nfsv4 driver will be installed automatically. As for the reason why we support nfs dumping via dracut_args instead of asking user to use the nfs directive, please refer to commit 74c6f464 ("Support special mount information via 'dracut_args'"). Fixes: 4eedcae5 ("dracut-module-setup.sh: don't include multipath-hostonly") Reported-by: rcheerla@redhat.com Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- mkdumprd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mkdumprd b/mkdumprd index a069f92..a3e5938 100644 --- a/mkdumprd +++ b/mkdumprd @@ -420,6 +420,15 @@ while read -r config_opt config_val; do verify_core_collector "$config_val" ;; dracut_args) + + # When users specify nfs dumping via dracut_args, kexec-tools won't + # mount nfs fs beforehand thus nfsv4-related drivers won't be installed + # because we call dracut with --hostonly-mode strict. So manually install + # nfsv4-related drivers. + if [[ $(get_dracut_args_fstype "$config_val") == nfs* ]]; then + add_dracut_arg "--add-drivers" nfs_layout_nfsv41_files + fi + while read -r dracut_arg; do add_dracut_arg "$dracut_arg" done <<< "$(echo "$config_val" | xargs -n 1 echo)" From d619b6dabe354100e52b3280c3d36ace88217fd4 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 4 Apr 2023 14:13:14 +0800 Subject: [PATCH 682/806] kdumpctl: lower the log level in reset_crashkernel_for_installed_kernel Although upgrading the kernel with `rpm -Uvh` is not recommended, the kexec-tools plugin prints confusing error logs when a customer upgrades the kernel through it. ``` kdump: kernel 5.14.0-80.el9.x86_64 doesn't exist kdump: Couldn't find current running kernel ``` Not finding the currently running kernel will only make kdump unable to copy the grub entry parameters to the newly installed kernel, so lower the log level. Signed-off-by: Lichen Liu Reviewed-by: Coiby Xu --- kdumpctl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 2bec428..7c32468 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1270,7 +1270,7 @@ _find_kernel_path_by_release() _grubby_kernel_str=$(grubby --info ALL | grep "^kernel=.*$_release\"$") _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") if [[ -z $_kernel_path ]]; then - derror "kernel $_release doesn't exist" + ddebug "kernel $_release doesn't exist" return 1 fi echo -n "$_kernel_path" @@ -1642,7 +1642,7 @@ reset_crashkernel_for_installed_kernel() fi if ! _running_kernel=$(_get_current_running_kernel_path); then - derror "Couldn't find current running kernel" + ddebug "Couldn't find current running kernel" exit fi From df6f25ff20a660ce8c300eba95e21e2fed6ed99f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 27 Mar 2023 13:17:32 +0800 Subject: [PATCH 683/806] Tell nmcli to not escape colon when getting the path of connection profile Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2151504 When a NetworManager connection profile contains a colon in the name, "nmcli --get-values UUID,FILENAME" by default would escape the colon because a colon is also used for separating the values. In this case, 99kdumpbase fails to get the correct connection profile path, kdumpctl[5439]: cp: cannot stat '/run/NetworkManager/system-connections/static-52\\\:54\\\:01.nmconnection': No such file or directory kdumpctl[5440]: sed: can't read /tmp/1977-DRACUT_KDUMP_NM/ifcfg-static-52-54-01: No such file or directory kdumpctl[5449]: dracut-install: ERROR: installing '/tmp/1977-DRACUT_KDUMP_NM/ifcfg-static-52-54-01' to '/etc/NetworkManager/system-connections/ifcfg-static-52-54-01' As a result, dumping vmcore to a remote nfs would fail. In our case of getting connection profile path, there is no need to escape the colon so pass "-escape no" to nmcli, [root@localhost ~]# nmcli --get-values UUID,FILENAME c show 659e09c1-a6bd-3549-9be4-a07a1a9a8ffd:/etc/NetworkManager/system-connections/aa\:bb.nmconnection [root@localhost ~]# nmcli -escape no --get-values UUID,FILENAME c show 659e09c1-a6bd-3549-9be4-a07a1a9a8ffd:/etc/NetworkManager/system-connections/aa:bb.nmconnection Suggested-by: Beniamino Galvani Reported-by: Martin Pitt Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a8ac16c..d8c5574 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -315,7 +315,9 @@ clone_and_modify_nmconnection() { # connection profile based on MAC address _match_nmconnection_by_mac "$_uuid" "$_dev" - _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") + # If a value contain ":", nmcli by default escape it with "\:" because it + # also uses ":" as the delimiter to separate values. In our case, escaping is not needed. + _cloned_nmconnection_file_path=$(nmcli --escape no --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" # change uuid back to old value in case it's refered by other connection From 12d9eff9dcd3bcd5890821c8d8a219b94412aca8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 28 Mar 2023 16:33:34 +0800 Subject: [PATCH 684/806] Show how much time kdump has waited for the network to be ready Relates: https://bugzilla.redhat.com/show_bug.cgi?id=2151504 Currently, when the network isn't ready, kdump would repeatedly print the same info, [ 29.537230] kdump[671]: Bad kdump network destination: 192.123.1.21 [ 30.559418] kdump[679]: Bad kdump network destination: 192.123.1.21 [ 31.580189] kdump[687]: Bad kdump network destination: 192.123.1.21 This is not user-friendly and users may think kdump has got stuck. So also show much time has waited for the network to be ready, [ 29.546258] kdump[673]: Waiting for network to be ready (50s / 10min) ... [ 32.608967] kdump[697]: Waiting for network to be ready (56s / 10min) Note kdump_get_ip_route no longer prints an error message and it's up to the caller to determine the log level and print relevant messages. And kdump_collect_netif_usage aborts when kdump_get_ip_route fails. Reported-by: Martin Pitt Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- dracut-kdump.sh | 2 ++ dracut-module-setup.sh | 7 ++++++- kdump-lib-initramfs.sh | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 4eec70b..1fc2231 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -495,6 +495,8 @@ wait_online_network() if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then printf "%s" "$_route" return + else + dwarn "Waiting for network to be ready (${_loop}s / 10min)" fi done diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d8c5574..e744ba5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -540,7 +540,12 @@ kdump_collect_netif_usage() { local _destaddr _srcaddr _route _netdev _destaddr=$(kdump_get_remote_ip "$1") - _route=$(kdump_get_ip_route "$_destaddr") + + if ! _route=$(kdump_get_ip_route "$_destaddr"); then + derror "Bad kdump network destination: $_destaddr" + exit 1 + fi + _srcaddr=$(kdump_get_ip_route_field "$_route" "src") _netdev=$(kdump_get_ip_route_field "$_route" "dev") diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index e45d6de..a625634 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -167,7 +167,6 @@ is_lvm2_thinp_device() kdump_get_ip_route() { if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then - derror "Bad kdump network destination: $1" exit 1 fi echo "$_route" From ca306cd403bf666a6703a59be4a3ce36406f6659 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:54:57 +0200 Subject: [PATCH 685/806] kdump-lib-initramfs: harden is_mounted If the device/mountpoint for findmnt is omitted findmnt will list all mounted filesystems. In that case it will always return "true". So explicitly check if an argument was passed to prevent false-positives. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib-initramfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index a625634..c6338c6 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -30,7 +30,7 @@ kdump_get_conf_val() is_mounted() { - findmnt -k -n "$1" > /dev/null 2>&1 + [ -n "$1" ] && findmnt -k -n "$1" > /dev/null 2>&1 } # $1: info type From 258d285c63dabb0e29f88cf3d1b36be572b9e7dd Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:54:58 +0200 Subject: [PATCH 686/806] kdump-lib-initramfs: remove is_fs_dump_target The function isn't used anywhere. Thus remove it to keep kdump-lib-initramfs small and simple. Signed-off-by: Philipp Rudo Reviewed-by: Lichen Liu Reviewed-by: Coiby Xu --- kdump-lib-initramfs.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index c6338c6..f7b58a2 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -150,11 +150,6 @@ is_nfs_dump_target() return 1 } -is_fs_dump_target() -{ - [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|virtiofs")" ] -} - is_lvm2_thinp_device() { _device_path=$1 From f9d8cabfd1f06fce1e26d6420976609b9a499381 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:54:59 +0200 Subject: [PATCH 687/806] dracut-module-setup: remove dead source_ifcfg_file With the NetworkManager rewrite this function in no longer used. This also allows to remove a lot of dead code in kdump-lib. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-module-setup.sh | 13 ------ kdump-lib.sh | 104 ----------------------------------------- 2 files changed, 117 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e744ba5..ff53d08 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -91,19 +91,6 @@ kdump_is_vlan() { [[ -f /proc/net/vlan/"$1" ]] } -# $1: netdev name -source_ifcfg_file() { - local ifcfg_file - - dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." - ifcfg_file=$(get_ifcfg_filename "$1") - if [[ -f ${ifcfg_file} ]]; then - . "${ifcfg_file}" - else - dwarning "The ifcfg file of $1 is not found!" - fi -} - # $1: repeat times # $2: string to be repeated # $3: separator diff --git a/kdump-lib.sh b/kdump-lib.sh index 6b0a83d..bfc650c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -292,18 +292,6 @@ is_hostname() echo "$1" | grep -q "[a-zA-Z]" } -# Copied from "/etc/sysconfig/network-scripts/network-functions" -get_hwaddr() -{ - if [[ -f "/sys/class/net/$1/address" ]]; then - awk '{ print toupper($0) }' < "/sys/class/net/$1/address" - elif [[ -d "/sys/class/net/$1" ]]; then - LC_ALL="" LANG="" ip -o link show "$1" 2> /dev/null | - awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, - "\\1", 1)); }' - fi -} - # Get value by a field using "nmcli -g" # Usage: get_nmcli_value_by_field # @@ -339,98 +327,6 @@ get_nmcli_connection_apath_by_ifname() get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" } -get_ifcfg_by_device() -{ - grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_hwaddr() -{ - grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_uuid() -{ - grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_name() -{ - grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -is_nm_running() -{ - [[ "$(LANG=C nmcli -t --fields running general status 2> /dev/null)" == "running" ]] -} - -is_nm_handling() -{ - LANG=C nmcli -t --fields device,state dev status 2> /dev/null | - grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$" -} - -# $1: netdev name -get_ifcfg_nmcli() -{ - local nm_uuid nm_name - local ifcfg_file - - # Get the active nmcli config name of $1 - if is_nm_running && is_nm_handling "${1}"; then - # The configuration "uuid" and "name" generated by nm is wrote to - # the ifcfg file as "UUID=" and "NAME=". - nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2> /dev/null | - grep "${1}" | head -1 | cut -d':' -f1) - nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2> /dev/null | - grep "${1}" | head -1 | cut -d':' -f1) - ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") - [[ -z ${ifcfg_file} ]] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") - fi - - echo -n "${ifcfg_file}" -} - -# $1: netdev name -get_ifcfg_legacy() -{ - local ifcfg_file hwaddr - - ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - - ifcfg_file=$(get_ifcfg_by_name "${1}") - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - - hwaddr=$(get_hwaddr "${1}") - if [[ -n $hwaddr ]]; then - ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - fi - - ifcfg_file=$(get_ifcfg_by_device "${1}") - - echo -n "${ifcfg_file}" -} - -# $1: netdev name -# Return the ifcfg file whole name(including the path) of $1 if any. -get_ifcfg_filename() -{ - local ifcfg_file - - ifcfg_file=$(get_ifcfg_nmcli "${1}") - if [[ -z ${ifcfg_file} ]]; then - ifcfg_file=$(get_ifcfg_legacy "${1}") - fi - - echo -n "${ifcfg_file}" -} - # returns 0 when omission of a module is desired in dracut_args # returns 1 otherwise is_dracut_mod_omitted() From 62c41e5343e12d9463de6eb851762f9953d2eb4d Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:55:00 +0200 Subject: [PATCH 688/806] kdump-lib: remove get_nmcli_field_by_conpath The function isn't used anywhere. Thus remove it to keep kdump-lib small and simple. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index bfc650c..06cdc9e 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,15 +307,6 @@ get_nmcli_value_by_field() LANG=C nmcli --get-values "$@" } -# Get nmcli field value of an connection apath (a D-Bus active connection path) -# Usage: get_nmcli_field_by_apath -get_nmcli_field_by_conpath() -{ - local _field=$1 _apath=$2 - - get_nmcli_value_by_field "$_field" connection show "$_apath" -} - # Get nmcli connection apath (a D-Bus active connection path ) by ifname # # apath is used for nmcli connection operations, e.g. From 9eb39cda3cee7c9eef2b8d97aedbbf8bf657ed8a Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:55:01 +0200 Subject: [PATCH 689/806] kdump-lib: remove get_nmcli_connection_apath_by_ifname The function isn't used anywhere. Thus remove it to keep kdump-lib small and simple. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 06cdc9e..722616c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,17 +307,6 @@ get_nmcli_value_by_field() LANG=C nmcli --get-values "$@" } -# Get nmcli connection apath (a D-Bus active connection path ) by ifname -# -# apath is used for nmcli connection operations, e.g. -# $ nmcli connection show $apath -get_nmcli_connection_apath_by_ifname() -{ - local _ifname=$1 - - get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" -} - # returns 0 when omission of a module is desired in dracut_args # returns 1 otherwise is_dracut_mod_omitted() From f81e6ca8da7288a65d8bdc307058fe615e6b0dd3 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:55:03 +0200 Subject: [PATCH 690/806] kdump-lib: move is_dracut_mod_omitted to kdumpctl The function is only used in kdumpctl. Thus move it there to keep kdump-lib small and simple. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdump-lib.sh | 19 ------------------- kdumpctl | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 722616c..75b31b2 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,25 +307,6 @@ get_nmcli_value_by_field() LANG=C nmcli --get-values "$@" } -# returns 0 when omission of a module is desired in dracut_args -# returns 1 otherwise -is_dracut_mod_omitted() -{ - local dracut_args dracut_mod=$1 - - set -- $(kdump_get_conf_val dracut_args) - while [ $# -gt 0 ]; do - case $1 in - -o | --omit) - [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 - ;; - esac - shift - done - - return 1 -} - is_wdt_active() { local active diff --git a/kdumpctl b/kdumpctl index 7c32468..330767b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -45,6 +45,25 @@ if ! dlog_init; then exit 1 fi +# returns 0 when omission of a module is desired in dracut_args +# returns 1 otherwise +is_dracut_mod_omitted() +{ + local dracut_args dracut_mod=$1 + + set -- $(kdump_get_conf_val dracut_args) + while [ $# -gt 0 ]; do + case $1 in + -o | --omit) + [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 + ;; + esac + shift + done + + return 1 +} + single_instance_lock() { local rc timeout=5 lockfile From 0ff44ca6e8f8f0f744d9c7a0baa6a99b2c524cda Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:55:04 +0200 Subject: [PATCH 691/806] kdumpctl: fix is_dracut_mod_omitted The function is pretty broken right now. To start with the -o/--omit option allows a quoted, space separated list of modules. But using 'set' breaks quotation and thus only considers the first element in the list. Furthermore dracut uses getopt internally. This means that it is also possible to pass the list via --omit=. Fix the function by making use of getopt for parsing the dracut_args. While at it also add a test cases to cover the functions. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 52 ++++++++++++++++++++++++++++------- kexec-tools.spec | 1 + spec/kdumpctl_general_spec.sh | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 10 deletions(-) diff --git a/kdumpctl b/kdumpctl index 330767b..2c647d6 100755 --- a/kdumpctl +++ b/kdumpctl @@ -45,23 +45,55 @@ if ! dlog_init; then exit 1 fi -# returns 0 when omission of a module is desired in dracut_args -# returns 1 otherwise -is_dracut_mod_omitted() +_get_dracut_arg() { - local dracut_args dracut_mod=$1 + local shortopt longopt n tmp + local -a _opt _ret - set -- $(kdump_get_conf_val dracut_args) - while [ $# -gt 0 ]; do + shortopt=$1; shift + longopt=$1; shift + n=0 + + if [[ -n $shortopt ]]; then + _opt+=(-o "${shortopt#-}:") + else + # getopt requires the -o/--option to be set. + _opt+=(-o "") + fi + [[ -n $longopt ]] && _opt+=(--long "${longopt#--}:") + + # make sure bash didn't break quoting + eval set -- "$*" + tmp=$( + unset POSIXLY_CORRECT + getopt -q "${_opt[@]}" -- "$@" + ) + eval set -- "$tmp" + while :; do case $1 in - -o | --omit) - [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0 - ;; + "$shortopt"|"$longopt") + _ret+=("$2"); shift + n=$((n+1)) + ;; + --|*) + break + ;; esac shift done - return 1 + echo "${_ret[@]}" + return $n +} + +is_dracut_mod_omitted() +{ + local mod omitted + + mod=$1 + omitted=$(_get_dracut_arg -o --omit "${OPT[dracut_args]}") + + [[ " $omitted " == *" $mod "* ]] } single_instance_lock() diff --git a/kexec-tools.spec b/kexec-tools.spec index 5c42af6..d2a8aca 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -65,6 +65,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool +Requires: util-linux Recommends: grubby Recommends: hostname BuildRequires: make diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index 41fbc29..bb5755c 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -107,6 +107,54 @@ Describe 'kdumpctl' End End + Describe "_get_dracut_arg" + dracut_args='-o "foo bar baz" -t 1 --test="a b c" --omit bla' + Parameters + -o --omit 2 "foo bar baz bla" + -e --empty 0 "" + -t "" 1 "1" + "" --test 1 "a b c" + "" "" 0 "" + End + It "should parse the dracut_args correctly" + When call _get_dracut_arg "$1" "$2" "$dracut_args" + The status should equal $3 + The output should equal "$4" + End + End + + Describe "is_dracut_mod_omitted()" + KDUMP_CONFIG_FILE=$(mktemp -t kdump_conf.XXXXXXXXXX) + cleanup() { + rm -f "$kdump_conf" + } + AfterAll 'cleanup' + + Parameters:dynamic + for opt in '-o ' '--omit ' '--omit='; do + for val in \ + 'foo' \ + '"foo"' \ + '"foo bar baz"' \ + '"bar foo baz"' \ + '"bar baz foo"'; do + %data success foo "$opt$val" + %data success foo "-a x $opt$val -i y" + %data failure xyz "$opt$val" + %data failure xyz "-a x $opt$val -i y" + done + done + %data success foo "-o xxx -o foo" + %data failure foo "-a x -i y" + End + It "shall return $1 for module $2 and dracut_args '$3'" + echo "dracut_args $3" > $KDUMP_CONFIG_FILE + parse_config + When call is_dracut_mod_omitted $2 + The status should be $1 + End + End + Describe '_update_kernel_arg_in_grub_etc_default()' GRUB_ETC_DEFAULT=/tmp/default_grub From 81d89c885f2c07d30738f2a942c23f7b81e60cd0 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 5 May 2023 17:14:40 +0200 Subject: [PATCH 692/806] kdumpctl: Move get_kernel_size to kdumpctl The function is only used in do_estimate. Move it to kdumpctl to prevent confusion. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu Reviewed-by: Coiby Xu --- kdump-lib.sh | 72 ---------------------------------------------------- kdumpctl | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 75b31b2..3f9b494 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -853,75 +853,3 @@ get_all_kdump_crypt_dev() get_luks_crypt_dev "$(kdump_get_maj_min "$_dev")" done } - -check_vmlinux() -{ - # Use readelf to check if it's a valid ELF - readelf -h "$1" &> /dev/null || return 1 -} - -get_vmlinux_size() -{ - local size=0 _msize - - while read -r _msize; do - size=$((size + _msize)) - done <<< "$(readelf -l -W "$1" | awk '/^ LOAD/{print $6}' 2> /dev/stderr)" - - echo $size -} - -try_decompress() -{ - # The obscure use of the "tr" filter is to work around older versions of - # "grep" that report the byte offset of the line instead of the pattern. - - # Try to find the header ($1) and decompress from here - for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"); do - if ! type -P "$3" > /dev/null; then - ddebug "Signiature detected but '$3' is missing, skip this decompressor" - break - fi - - pos=${pos%%:*} - tail "-c+$pos" "$img" | $3 > "$5" 2> /dev/null - if check_vmlinux "$5"; then - ddebug "Kernel is extracted with '$3'" - return 0 - fi - done - - return 1 -} - -# Borrowed from linux/scripts/extract-vmlinux -get_kernel_size() -{ - # Prepare temp files: - local tmp img=$1 - - tmp=$(mktemp /tmp/vmlinux-XXX) - trap 'rm -f "$tmp"' 0 - - # Try to check if it's a vmlinux already - check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 - - # That didn't work, so retry after decompression. - try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || - try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || - try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || - try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || - try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || - try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || - try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" - - # Finally check for uncompressed images or objects: - [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 - - # Fallback to use iomem - local _size=0 _seg - while read -r _seg; do - _size=$((_size + 0x${_seg#*-} - 0x${_seg%-*})) - done <<< "$(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1)" - echo $_size -} diff --git a/kdumpctl b/kdumpctl index 2c647d6..6341709 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1147,6 +1147,78 @@ rebuild() rebuild_initrd } +check_vmlinux() +{ + # Use readelf to check if it's a valid ELF + readelf -h "$1" &> /dev/null || return 1 +} + +get_vmlinux_size() +{ + local size=0 _msize + + while read -r _msize; do + size=$((size + _msize)) + done <<< "$(readelf -l -W "$1" | awk '/^ LOAD/{print $6}' 2> /dev/stderr)" + + echo $size +} + +try_decompress() +{ + # The obscure use of the "tr" filter is to work around older versions of + # "grep" that report the byte offset of the line instead of the pattern. + + # Try to find the header ($1) and decompress from here + for pos in $(tr "$1\n$2" "\n$2=" < "$4" | grep -abo "^$2"); do + if ! type -P "$3" > /dev/null; then + ddebug "Signiature detected but '$3' is missing, skip this decompressor" + break + fi + + pos=${pos%%:*} + tail "-c+$pos" "$img" | $3 > "$5" 2> /dev/null + if check_vmlinux "$5"; then + ddebug "Kernel is extracted with '$3'" + return 0 + fi + done + + return 1 +} + +# Borrowed from linux/scripts/extract-vmlinux +get_kernel_size() +{ + # Prepare temp files: + local tmp img=$1 + + tmp=$(mktemp /tmp/vmlinux-XXX) + trap 'rm -f "$tmp"' 0 + + # Try to check if it's a vmlinux already + check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 + + # That didn't work, so retry after decompression. + try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || + try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || + try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || + try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || + try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || + try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || + try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" + + # Finally check for uncompressed images or objects: + [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 + + # Fallback to use iomem + local _size=0 _seg + while read -r _seg; do + _size=$((_size + 0x${_seg#*-} - 0x${_seg%-*})) + done <<< "$(grep -E "Kernel (code|rodata|data|bss)" /proc/iomem | cut -d ":" -f 1)" + echo $_size +} + do_estimate() { local kdump_mods From ea00b7db43d12a48676f40614c2c5601a6cd34cc Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 5 May 2023 17:14:41 +0200 Subject: [PATCH 693/806] kdumpctl: Move temp file in get_kernel_size to global temp dir Others will need to use a temporary files, too. In order to avoid potential clashes of multiple trap handlers move the local temp file into a global temp dir. While at it make sure that the trap handler returns the correct exit code. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu Reviewed-by: Coiby Xu --- kdump.service | 1 + kdumpctl | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kdump.service b/kdump.service index 99feed8..15405dc 100644 --- a/kdump.service +++ b/kdump.service @@ -11,6 +11,7 @@ ExecStop=/usr/bin/kdumpctl stop ExecReload=/usr/bin/kdumpctl reload RemainAfterExit=yes StartLimitInterval=0 +PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/kdumpctl b/kdumpctl index 6341709..ecbe0d4 100755 --- a/kdumpctl +++ b/kdumpctl @@ -45,6 +45,13 @@ if ! dlog_init; then exit 1 fi +KDUMP_TMPDIR=$(mktemp -d kdump.XXXX) +trap ' + ret=$?; + rm -rf "$KDUMP_TMPDIR" + exit $ret; + ' EXIT + _get_dracut_arg() { local shortopt longopt n tmp @@ -1193,8 +1200,7 @@ get_kernel_size() # Prepare temp files: local tmp img=$1 - tmp=$(mktemp /tmp/vmlinux-XXX) - trap 'rm -f "$tmp"' 0 + tmp="$KDUMP_TMPDIR/vmlinux" # Try to check if it's a vmlinux already check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 From ea7be0608ed719cc1cb134ecf6ef51a4b7e9f104 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Fri, 5 May 2023 17:14:42 +0200 Subject: [PATCH 694/806] kdumpctl: Add basic UKI support A Unified Kernel Image (UKI) is a single EFI PE executable combining an EFI stub, a kernel image, an initrd image, and the kernel command line. They are defined in the Boot Loader Specification [1] as type #2 entries. UKIs have the advantage that all code as well as meta data that is required to boot the system, not only the kernel image, is combined in a single PE file and can be signed for EFI SecureBoot. This extends the coverage of SecureBoot extensively. For RHEL support for UKI were included into kernel-ark with 16c7e3ee836e ("redhat: Add sub-RPM with a EFI unified kernel image for virtual machines"). There are two problems with UKIs from the kdump point of view at the moment. First, they cannot be directly loaded via kexec_file_load and second, the initrd included isn't suitable for kdump. In order to enable kdump on systems with UKIs build the kdump initrd as usual and extract the kernel image before loading the crash kernel. [1] https://uapi-group.org/specifications/specs/boot_loader_specification/ Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu Reviewed-by: Coiby Xu --- kdump-lib.sh | 26 ++++++++++++++++++++++++-- kdumpctl | 12 +++++++++++- kexec-tools.spec | 1 + 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 3f9b494..3f9e423 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -11,6 +11,17 @@ fi FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" +is_uki() +{ + local img + + img="$1" + + [[ -f "$img" ]] || return + [[ "$(file -b --mime-type "$img")" == application/x-dosexec ]] || return + objdump -h -j .linux "$img" &> /dev/null +} + is_fadump_capable() { # Check if firmware-assisted dump is enabled @@ -489,7 +500,9 @@ prepare_kdump_kernel() read -r machine_id < /etc/machine-id boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} - boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT $machine_id/$kdump_kernelver/$KDUMP_IMG" + boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT \ + $machine_id/$kdump_kernelver/$KDUMP_IMG \ + EFI/Linux/$machine_id-$kdump_kernelver.efi" # The kernel of OSTree based systems is not in the standard locations. if is_ostree; then @@ -562,7 +575,11 @@ prepare_kdump_bootinfo() fi # Set KDUMP_BOOTDIR to where kernel image is stored - KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL") + if is_uki "$KDUMP_KERNEL"; then + KDUMP_BOOTDIR=/boot + else + KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL") + fi # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" @@ -715,6 +732,11 @@ prepare_cmdline() # may cause the hot-remove of some pci hotplug device. is_aws_aarch64 && out=$(echo "$out" | sed -e "/\//") + # Always disable gpt-auto-generator as it hangs during boot of the + # crash kernel. Furthermore we know which disk will be used for dumping + # (if at all) and add it explicitly. + is_uki "$KDUMP_KERNEL" && out+="rd.systemd.gpt_auto=no " + # Trim unnecessary whitespaces echo "$out" | sed -e "s/^ *//g" -e "s/ *$//g" -e "s/ \+/ /g" } diff --git a/kdumpctl b/kdumpctl index ecbe0d4..37f3eb9 100755 --- a/kdumpctl +++ b/kdumpctl @@ -694,7 +694,7 @@ function remove_kdump_kernel_key() # as the currently running kernel. load_kdump() { - local ret + local ret uki KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") @@ -707,6 +707,16 @@ load_kdump() load_kdump_kernel_key fi + if is_uki "$KDUMP_KERNEL"; then + uki=$KDUMP_KERNEL + KDUMP_KERNEL=$KDUMP_TMPDIR/vmlinuz + objcopy -O binary --only-section .linux "$uki" "$KDUMP_KERNEL" + sync -f "$KDUMP_KERNEL" + # Make sure the temp file has the correct SELinux label. + # Otherwise starting the kdump.service will fail. + chcon -t boot_t "$KDUMP_KERNEL" + fi + ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL" # The '12' represents an intermediate temporary file descriptor diff --git a/kexec-tools.spec b/kexec-tools.spec index d2a8aca..f1f0423 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -66,6 +66,7 @@ Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool Requires: util-linux +Requires: binutils Recommends: grubby Recommends: hostname BuildRequires: make From c8643af2707e195533425ce12af56b01509e542e Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 28 Apr 2023 00:04:45 +0800 Subject: [PATCH 695/806] mkdumprd: add --aggressive-strip as default dracut args The new aggressive strip option was added in dracut 058, which tell dracut to build the initramfs stripping more sections of the ELF binaries (basically strip .symtab, .strtab). These section are only useful for debugging runtime failures, but in kdump kernel, neccessary tools for debug any runtime failure are absent, there is no point keeping these sections. Stripping these section can help save some memory with almost no side effect. So let enable --aggressive-strip by default. Comparison of unpacked initramfs before / after enabling aggressive strip: du -hs image image.aggressive-strip 31M image 29M image.aggressive-strip Signed-off-by: Kairui Song Reviewed-by: Philipp Rudo Reviewed-by: Coiby Xu --- kexec-tools.spec | 6 +++--- mkdumprd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index f1f0423..6fb97ea 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -61,9 +61,9 @@ Requires(post): servicelog Recommends: keyutils %endif Requires(pre): coreutils sed zlib -Requires: dracut >= 050 -Requires: dracut-network >= 050 -Requires: dracut-squash >= 050 +Requires: dracut >= 058 +Requires: dracut-network >= 058 +Requires: dracut-squash >= 058 Requires: ethtool Requires: util-linux Requires: binutils diff --git a/mkdumprd b/mkdumprd index a3e5938..63a37a7 100644 --- a/mkdumprd +++ b/mkdumprd @@ -27,7 +27,7 @@ SAVE_PATH=$(get_save_path) OVERRIDE_RESETTABLE=0 extra_modules="" -dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' -o "plymouth resume ifcfg earlykdump") +dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' --aggressive-strip -o "plymouth resume ifcfg earlykdump") MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." From 8af05dc45a5e0ee979c96deb61accb6679925350 Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Mon, 8 May 2023 19:46:38 -0500 Subject: [PATCH 696/806] kdumpctl: Add support for systemd-boot paths The default systemd-boot installed kernels on fedora end up in the form: /boot/efi/36b54597c46383/6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64/linux Where the kernel version is a directory containing the kernel (linux) and the initrd. Thus _find_kernel_path_by release needs to be a bit less strict and allow some futher characters on the grubby (really bootctl) output. Signed-off-by: Jeremy Linton Reviewed-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 37f3eb9..844fdad 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1406,7 +1406,7 @@ _filter_grubby_kernel_str() _find_kernel_path_by_release() { local _release="$1" _grubby_kernel_str _kernel_path - _grubby_kernel_str=$(grubby --info ALL | grep "^kernel=.*$_release\"$") + _grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(\/\w+)?\"$") _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") if [[ -z $_kernel_path ]]; then ddebug "kernel $_release doesn't exist" From 5e3d629da7eac381c1ecd0b42127e572a19567f2 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 16 May 2023 09:44:56 +0800 Subject: [PATCH 697/806] Release 2.0.26-4 Signed-off-by: Coiby Xu --- kexec-tools.spec | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6fb97ea..ee06f87 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -416,7 +416,27 @@ fi %endif %changelog -* Jan 30 2023 Coiby - 2.0.26-3 +* Tue May 16 2023 Coiby - 2.0.26-4 +- kdumpctl: Add support for systemd-boot paths +- mkdumprd: add --aggressive-strip as default dracut args +- kdumpctl: Add basic UKI support +- kdumpctl: Move temp file in get_kernel_size to global temp dir +- kdumpctl: Move get_kernel_size to kdumpctl +- kdumpctl: fix is_dracut_mod_omitted +- kdump-lib: move is_dracut_mod_omitted to kdumpctl +- kdump-lib: remove get_nmcli_connection_apath_by_ifname +- kdump-lib: remove get_nmcli_field_by_conpath +- dracut-module-setup: remove dead source_ifcfg_file +- kdump-lib-initramfs: remove is_fs_dump_target +- kdump-lib-initramfs: harden is_mounted +- Show how much time kdump has waited for the network to be ready +- Tell nmcli to not escape colon when getting the path of connection profile +- kdumpctl: lower the log level in reset_crashkernel_for_installed_kernel +- Install nfsv4-related drivers when users specify nfs dumping via dracut_args +- sysconfig: add zfcp.allow_lun_scan to KDUMP_COMMANDLINE_REMOVE on s390 +- Use the correct command to get architecture + +* Mon Jan 30 2023 Coiby - 2.0.26-3 - kdumpctl: make do_estimate more robust - kdumpctl: refractor check_rebuild - kdumpctl: cleanup 'stop' From 81d3cc344d20cee900396bb02977d1cbe8a11034 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 20 Apr 2023 11:26:34 +0800 Subject: [PATCH 698/806] kdump-lib: fix the matching pattern for debug-kernel On aarch64, a 64k kernel's name looks like: vmlinuz-5.14.0-300.el9.aarch64+64k and the corresponding debug kernel's name looks like: vmlinuz-5.14.0-300.el9.aarch64+64k-debug, which ends with the suffix -debug instead of +debug. Fix the matching pattern by [+|-]debug Signed-off-by: Pingfan Liu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 3f9e423..c6bf378 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -536,12 +536,13 @@ _get_kdump_kernel_version() fi _version=$(uname -r) - if [[ ! "$_version" =~ \+debug$ ]]; then + if [[ ! "$_version" =~ [+|-]debug$ ]]; then echo "$_version" return fi _version_nondebug=${_version%+debug} + _version_nondebug=${_version_nondebug%-debug} if [[ -f "$(prepare_kdump_kernel "$_version_nondebug")" ]]; then dinfo "Use of debug kernel detected. Trying to use $_version_nondebug" echo "$_version_nondebug" From 443a43e0750d14c8e3290ecf76535d1746bfac6a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 24 May 2023 12:01:45 +0800 Subject: [PATCH 699/806] mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS Currently, kdump doesn't work on many FIPS-enabled systems including Azure, ESXI, Hyper, POWER and etc. When FIPS is enabled, it needs to access /boot//.vmlinuz-xxx.hmac to verify the integrity of the kernel. However, on those systems, /boot fails to be mounted due to a lack of fs and block device drivers and the system just halted after failing to verify the integrity of the kernel. For example, on Hyper-V, sd_mod, sg, scsi_transport_fc, hv_storvsc and hv_vmbus need to be installed in order for /boot to be mounted. mkdumprd calls dracut with the --no-hostonly-default-device. Following the documentation (man dracut), --no-hostonly-default-device Do not generate implicit host devices like root, swap, fstab, etc. Use "--mount" or "--add-device" to explicitly add devices as needed this patch uses "--add-device" to explicitly add the device of /boot. Note there is already an attempt to fix it in dracut's 01fips module i.e. via the commit 83651776 ("fips: ensure fs module for /boot is installed"). Unfortunately it only installs the file system driver e.g. xfs. Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- mkdumprd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdumprd b/mkdumprd index 63a37a7..3932a1f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -463,6 +463,10 @@ if ! is_fadump_capable; then is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")" add_dracut_arg "--no-hostonly-default-device" + + if fips-mode-setup --is-enabled 2 > /dev/null; then + add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)" + fi fi dracut "${dracut_args[@]}" "$@" From cdc0253a3cc1ea4522fa5ac89eb109bd96095548 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 21 Apr 2023 19:09:51 +0800 Subject: [PATCH 700/806] Let _update_kernel_cmdline return the correct return code Currently, for non-s390x systems, the return code is 1 even when _update_kernel_cmdline is correctly executed. This makes callers like reset_crashkernel_after_update fail to print a message if a kernel has its crashkernel updated. Fix it by put the code inside if block for s390x. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 844fdad..9c109da 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1445,7 +1445,11 @@ _update_kernel_cmdline() grubby --args="fadump=$_fadump_val" --update-kernel "$_kernel_path" fi fi - [[ -f /etc/zipl.conf ]] && zipl > /dev/null + + # Don't use "[[ CONDITION ]] && COMMAND" which returns 1 under false CONDITION + if [[ -f /etc/zipl.conf ]]; then + zipl > /dev/null + fi } _valid_grubby_kernel_path() From 5b31b099ae9b40a8f832b07e8364d7b08025fdd6 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 26 Apr 2023 04:48:25 +0800 Subject: [PATCH 701/806] Simplify the management of the kernel parameter crashkernel 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. Another change brought by this simplification is kexec-tools will also set up the kernel crashkernel parameter for a fresh install (previously it's limited to osbuild). Note 1. This patch also stop trying to update /etc/default/grub because a) it only affects the static file /boot/grub2/grub.cfg b) grubby is recommended to change the kernel command-line parameters for both Fedora [1] and RHEL9 [2][3] c) For the cases of aarch64 and POWER, different kernels could have different default crashkernel value. 2. Starting with Fedora 37, posttrans rpm scriplet distinguish between package install and upgrade. [1] https://fedoraproject.org/wiki/GRUB_2 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_monitoring_and_updating_the_kernel/configuring-kernel-command-line-parameters_managing-monitoring-and-updating-the-kernel#changing-kernel-command-line-parameters-for-all-boot-entries_configuring-kernel-command-line-parameters [3] https://access.redhat.com/solutions/1136173 Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump.conf.5 | 5 ++- kdumpctl | 86 ++++++++++-------------------------------------- kexec-tools.spec | 31 +++-------------- 3 files changed, 25 insertions(+), 97 deletions(-) diff --git a/kdump.conf.5 b/kdump.conf.5 index e3e9900..ec28552 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 .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 .RS diff --git a/kdumpctl b/kdumpctl index 9c109da..57da1af 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1675,72 +1675,37 @@ _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() +_update_crashkernel() { - local _crashkernel _fadump_val - local _dump_mode _old_default_crashkernel _new_default_crashkernel + local _kernel _dump_mode _old_default_crashkernel _new_default_crashkernel _fadump_val _msg - if [[ $(uname -m) == s390x ]]; then - return - fi - - _crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel) - - 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" + _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 + _msg="For kernel=$_kernel, crashkernel=$_new_default_crashkernel now. Please reboot the system for the change to take effet." + _msg+=" Note if you don't want kexec-tools to manage the crashkernel kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf." + dinfo "$_msg" + fi fi } + # shellcheck disable=SC2154 # false positive when dereferencing an array reset_crashkernel_after_update() { - local _kernel _crashkernel _dump_mode _fadump_val _old_default_crashkernel _new_default_crashkernel - declare -A _crashkernel_vals + local _kernel if ! _is_bootloader_installed; then return fi - _crashkernel_vals[old_kdump]=$(cat /tmp/old_default_crashkernel 2> /dev/null) - _crashkernel_vals[old_fadump]=$(cat /tmp/old_default_crashkernel_fadump 2> /dev/null) - _crashkernel_vals[new_kdump]=$(get_default_crashkernel kdump) - _crashkernel_vals[new_fadump]=$(get_default_crashkernel fadump) - for _kernel in $(_get_all_kernels_from_grubby ALL); do - _crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) - if [[ $_crashkernel == auto ]]; then - reset_crashkernel "--kernel=$_kernel" - elif [[ -n $_crashkernel ]]; then - _dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _old_default_crashkernel=${_crashkernel_vals[old_${_dump_mode}]} - _new_default_crashkernel=${_crashkernel_vals[new_${_dump_mode}]} - if [[ $_crashkernel == "$_old_default_crashkernel" ]] && - [[ $_new_default_crashkernel != "$_old_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 "For kernel=$_kernel, crashkernel=$_new_default_crashkernel now." - fi - fi - fi + _update_crashkernel "$_kernel" done - - update_crashkernel_in_grub_etc_default_after_update } # read the value of an environ variable from given environ file path @@ -1764,8 +1729,7 @@ _is_osbuild() reset_crashkernel_for_installed_kernel() { - local _installed_kernel _running_kernel _crashkernel _crashkernel_running - local _dump_mode_running _fadump_val_running + local _installed_kernel # During package install, only try to reset crashkernel for osbuild # thus to avoid calling grubby when installing os via anaconda @@ -1784,21 +1748,7 @@ reset_crashkernel_for_installed_kernel() return fi - if ! _running_kernel=$(_get_current_running_kernel_path); then - ddebug "Couldn't find current running kernel" - exit - fi - - _crashkernel=$(get_grub_kernel_boot_parameter "$_installed_kernel" crashkernel) - _crashkernel_running=$(get_grub_kernel_boot_parameter "$_running_kernel" crashkernel) - _dump_mode_running=$(get_dump_mode_by_kernel "$_running_kernel") - _fadump_val_running=$(get_grub_kernel_boot_parameter "$_kernel" fadump) - - if [[ $_crashkernel != "$_crashkernel_running" ]]; then - if _update_kernel_cmdline "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then - echo "kexec-tools has reset $_installed_kernel to use the new default crashkernel value $_crashkernel_running" - fi - fi + _update_crashkernel "$_installed_kernel" } main() diff --git a/kexec-tools.spec b/kexec-tools.spec index ee06f87..64db9e2 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -260,21 +260,6 @@ chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpini mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ -%pre -# Save the old default crashkernel values to /tmp/ when upgrading the package -# so kdumpctl later can tell if it should update the kernel crashkernel -# parameter in the posttrans scriptlet. Note this feauture of auto-updating -# the kernel crashkernel parameter currently doesn't support ostree, so skip it -# for ostree. -if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then - kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null -%ifarch ppc64 ppc64le - kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null -%endif -fi -# don't block package update -: - %post # Initial installation %systemd_post kdump.service @@ -341,21 +326,15 @@ do done %posttrans -# Try to reset kernel crashkernel value to new default value based on the old -# default value or set up crasherkernel value for osbuild +# Try to reset kernel crashkernel value to new default value or set up +# crasherkernel value for new install # # Note # 1. Skip ostree systems as they are not supported. -# 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The -# former case is used to set up crashkernel for osbuild -if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then +# 2. For Fedora 36 and RHEL9, "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade; +# For Fedora > 36, "[ $1 == 1 ]" only means install and "[ $1 == 2 ]" means upgrade +if [ ! -f /run/ostree-booted ] && [ $1 == 1 -o $1 == 2 ]; then kdumpctl _reset-crashkernel-after-update - rm /tmp/old_default_crashkernel 2>/dev/null -%ifarch ppc64 ppc64le - rm /tmp/old_default_crashkernel_fadump 2>/dev/null -%endif - # dnf would complain about the exit code not being 0. To keep it happy, - # always return 0 : fi From 07b99ecab71ae9dcf4dd6114a9a09b7fb8301e12 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 9 May 2023 12:28:37 +0800 Subject: [PATCH 702/806] Add ShellSpec tests for managing the crashkernel kernel parameter Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 3 +- spec/kdumpctl_manage_crashkernel_spec.sh | 107 +++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 spec/kdumpctl_manage_crashkernel_spec.sh diff --git a/kdumpctl b/kdumpctl index 57da1af..5043a7b 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1666,12 +1666,13 @@ reset_crashkernel() fi } +GRUB_CFG=/boot/grub2/grub.cfg _is_bootloader_installed() { if [[ $(uname -m) == s390x ]]; then test -f /etc/zipl.conf else - test -f /boot/grub2/grub.cfg + test -f "$GRUB_CFG" fi } diff --git a/spec/kdumpctl_manage_crashkernel_spec.sh b/spec/kdumpctl_manage_crashkernel_spec.sh new file mode 100644 index 0000000..9078347 --- /dev/null +++ b/spec/kdumpctl_manage_crashkernel_spec.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +Describe 'Management of the kernel crashkernel parameter.' + Include ./kdumpctl + kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64 + kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64 + old_ck=1G-4G:162M,4G-64G:256M,64G-:512M + new_ck=1G-4G:196M,4G-64G:256M,64G-:512M + KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -u /tmp/spec_test.XXXXXXXXXX) + GRUB_CFG="$KDUMP_SPEC_TEST_RUN_DIR/grub.cfg" + + uname() { + if [[ $1 == '-m' ]]; then + echo -n x86_64 + elif [[ $1 == '-r' ]]; then + echo -n $current_kernel + fi + } + + # dinfo is a bit complex for unit tets, simply mock it + dinfo() { + echo "$1" + } + + kdump_get_arch_recommend_crashkernel() { + echo -n "$new_ck" + } + + setup() { + mkdir -p "$KDUMP_SPEC_TEST_RUN_DIR" + cp -r spec/support/boot_load_entries "$KDUMP_SPEC_TEST_RUN_DIR" + cp spec/support/grub_env "$KDUMP_SPEC_TEST_RUN_DIR"/env_temp + touch "$GRUB_CFG" + + grubby --args crashkernel=$old_ck --update-kernel=$kernel1 + grubby --args crashkernel=$new_ck --update-kernel=$kernel2 + grubby --remove-args fadump --update-kernel=ALL + + } + + cleanup() { + rm -rf "$KDUMP_SPEC_TEST_RUN_DIR" + } + + grubby() { + # - --no-etc-grub-update, not update /etc/default/grub + # - --bad-image-okay, don't check the validity of the image + # - --env, specify custom grub2 environment block file to avoid modifying + # the default /boot/grub2/grubenv + # - --bls-directory, specify custom BootLoaderSpec config files to avoid + # modifying the default /boot/loader/entries + @grubby --no-etc-grub-update --grub2 --config-file="$GRUB_CFG" --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" + } + + Describe "When kexec-tools have its default crashkernel updated, " + + Context "if kexec-tools is updated alone, " + BeforeAll 'setup' + AfterAll 'cleanup' + Specify 'reset_crashkernel_after_update should report updated kernels and note that auto_reset_crashkernel=yes' + When call reset_crashkernel_after_update + The output should include "For kernel=$kernel1, crashkernel=$new_ck now." + The output should not include "For kernel=$kernel2, crashkernel=$new_ck now." + # A hint on how to turn off auto update of crashkernel + The output should include "auto_reset_crashkernel=no" + End + + Specify 'kernel1 should have crashkernel updated' + When call grubby --info $kernel1 + The line 3 of output should include crashkernel="$new_ck" + End + + Specify 'kernel2 should also have crashkernel updated' + When call grubby --info $kernel2 + The line 3 of output should include crashkernel="$new_ck" + End + + End + + Context "If kernel package is installed alone, " + BeforeAll 'setup' + AfterAll 'cleanup' + # BeforeAll somehow doesn't work as expected, manually call setup to bypass this issue. + setup + new_kernel_ver=new_kernel + new_kernel=/boot/vmlinuz-$new_kernel_ver + grubby --add-kernel=$new_kernel --initrd=/boot/initramfs-$new_kernel_ver.img --title=$new_kernel_ver + + Specify 'reset_crashkernel_for_installed_kernel should report the new kernel has its crashkernel updated' + When call reset_crashkernel_for_installed_kernel $new_kernel_ver + The output should include "crashkernel=$new_ck" + End + + Specify 'the new kernel should have crashkernel updated' + When call grubby --info $new_kernel + The output should include crashkernel="$new_ck" + End + + Specify 'kernel1 keeps its crashkernel value' + When call grubby --info $kernel1 + The output should include crashkernel="$old_ck" + End + + End + + End +End From 4311534c85f4f5fe2f9d4a78ee28abed429fc572 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 29 May 2023 17:42:49 +0800 Subject: [PATCH 703/806] Release 2.0.26-5 Signed-off-by: Coiby Xu --- kexec-tools.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 64db9e2..d7d2947 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -395,6 +395,12 @@ fi %endif %changelog +* Mon May 29 2023 Coiby - 2.0.26-5 +- Simplify the management of the kernel parameter crashkernel +- Let _update_kernel_cmdline return the correct return code +- mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS +- kdump-lib: fix the matching pattern for debug-kernel + * Tue May 16 2023 Coiby - 2.0.26-4 - kdumpctl: Add support for systemd-boot paths - mkdumprd: add --aggressive-strip as default dracut args From e42a823daec946da013b63460cded5bd0ff53e48 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Jun 2023 16:05:05 +0800 Subject: [PATCH 704/806] mkdumprd: Use the correct syntax to redirect the stderr to null A space was added by mistake and unfortunately fips-mode-setup refuses an extra parameter, # fips-mode-setup --is-enabled 2 > /dev/null # echo $? 2 # fips-mode-setup --is-enabled 2 Check, enable, or disable the system FIPS mode. usage: /usr/bin/fips-mode-setup --enable|--disable [--no-bootcfg] usage: /usr/bin/fips-mode-setup --check usage: /usr/bin/fips-mode-setup --is-enabled So in this case mkdumprd can never detect if FIPS is enabled. Fix this mistake. Fixes: 443a43e0 ("mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS") Signed-off-by: Coiby Xu Reviewed-by: Tao Liu --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index 3932a1f..f93874d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -464,7 +464,7 @@ if ! is_fadump_capable; then add_dracut_arg "--no-hostonly-default-device" - if fips-mode-setup --is-enabled 2 > /dev/null; then + if fips-mode-setup --is-enabled 2> /dev/null; then add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)" fi fi From 4da1ffe730d61688f9533d2977764775f1fdd41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Fri, 2 Jun 2023 13:04:27 +0200 Subject: [PATCH 705/806] Make binutils a recommend as it's only needed for UKI support UKI are not supported on rpm-ostree based Fedora variants so let's use recommend for binutils for now to let those not include the package until needed. See: https://github.com/coreos/fedora-coreos-tracker/issues/1496 See: https://github.com/ostreedev/ostree/issues/2753 See: https://src.fedoraproject.org/rpms/kexec-tools/c/ea7be0608ed719cc1cb134ecf6ef51a4b7e9f104?branch=rawhide --- kexec-tools.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d7d2947..8f2bc6e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -66,7 +66,8 @@ Requires: dracut-network >= 058 Requires: dracut-squash >= 058 Requires: ethtool Requires: util-linux -Requires: binutils +# Needed for UKI support +Recommends: binutils Recommends: grubby Recommends: hostname BuildRequires: make @@ -395,6 +396,9 @@ fi %endif %changelog +* Fri Jun 02 2023 Timothée Ravier - 2.0.26-6 +- Make binutils a recommend as it's only needed for UKI support + * Mon May 29 2023 Coiby - 2.0.26-5 - Simplify the management of the kernel parameter crashkernel - Let _update_kernel_cmdline return the correct return code From eabbf9d6a07c00b66f49aebe5eaee864707218b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Fri, 2 Jun 2023 13:07:04 +0200 Subject: [PATCH 706/806] Whitespace fixes --- kexec-tools.spec | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8f2bc6e..e69a258 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -273,8 +273,8 @@ servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match %endif # This portion of the script is temporary. Its only here -# to fix up broken boxes that require special settings -# in /etc/sysconfig/kdump. It will be removed when +# to fix up broken boxes that require special settings +# in /etc/sysconfig/kdump. It will be removed when # These systems are fixed. if [ -d /proc/bus/mckinley ] @@ -287,7 +287,7 @@ then elif [ -d /proc/sgi_sn ] then # This is for SGI SN boxes - # They require the --noio option to kexec + # They require the --noio option to kexec # since they don't support legacy io sed -e's/\(^KEXEC_ARGS.*\)\("$\)/\1 --noio"/' \ /etc/sysconfig/kdump > /etc/sysconfig/kdump.new @@ -1131,7 +1131,7 @@ fi - Revert "dracut-module-setup.sh: pass correct ip= param for ipv6" * Sat Apr 28 2018 Dave Young - 2.0.17-2 -- pull in makedumpfile 1.6.3 +- pull in makedumpfile 1.6.3 * Sat Apr 28 2018 Dave Young - 2.0.17-1 - pull in 2.0.17 @@ -1191,10 +1191,10 @@ fi * Tue Aug 8 2017 Dave Young - 2.0.15-10 - Improve 'cpu add' udev rules - module-setup: suppress the early iscsi error messages -- mkdumprd: use 300s as the default systemd unit timeout for kdump mount +- mkdumprd: use 300s as the default systemd unit timeout for kdump mount * Mon Aug 7 2017 Dave Young - 2.0.15-9 -- fix makedumpfile bug 1474706 +- fix makedumpfile bug 1474706 * Thu Aug 03 2017 Fedora Release Engineering - 2.0.15-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild @@ -1350,9 +1350,9 @@ fi - module-setup: Use get_ifcfg_filename() to get the proper ifcfg file * Mon May 30 2016 Dave Young - 2.0.12-4 -- update kdump anaconda addon to add mem range in tui +- update kdump anaconda addon to add mem range in tui - .gitignore: Update to make it more generic -- kdumpctl: check_rebuild improvement +- kdumpctl: check_rebuild improvement - kdumpctl: Do not rebuild initramfs when $KDUMP_BOOTDIR is read only * Tue Mar 29 2016 Dave Young - 2.0.12-3 @@ -1363,7 +1363,7 @@ fi - ppc64le: fix kexec hang due to ppc64 elf abi breakage * Tue Mar 22 2016 Dave Young - 2.0.12-1 -- Rebase kexec-tools to 2.0.12 +- Rebase kexec-tools to 2.0.12 * Thu Feb 04 2016 Fedora Release Engineering - 2.0.11-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild @@ -1376,7 +1376,7 @@ fi - fix bogus date in changelog * Thu Nov 19 2015 Dave Young - 2.0.11-2 -- Rebase to upstream makedumpfile 1.5.9 +- Rebase to upstream makedumpfile 1.5.9 * Mon Nov 9 2015 Dave Young - 2.0.11-1 - Rebase to upstream kexec-tools 2.0.11 @@ -1386,7 +1386,7 @@ fi - Remove duplicate prefix path ${initdir} * Tue Sep 8 2015 Dave Young - 2.0.10-8 -- update kdump addon to fix a kickstart installationi issue +- update kdump addon to fix a kickstart installationi issue * Wed Aug 19 2015 Dave Young - 2.0.10-7 - add man page for kdumpctl @@ -1728,7 +1728,7 @@ fi * Thu Mar 14 2013 Baoquan He - 2.0.3-69 - Support for eppic language as a subpackage - + * Thu Mar 14 2013 Baoquan He - 2.0.3-68 - tune sysconfig to save memory usage - Remove useless codes related to LOGGER in kdumpctl @@ -1855,7 +1855,7 @@ fi - do not add fstab-sys module in dracut cmdline - omit dash module - network dns config fix -- shell exit value fix +- shell exit value fix * Thu Jul 19 2012 Fedora Release Engineering - 2.0.3-52 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild @@ -2182,7 +2182,7 @@ fi - Make makedumpfile a dynamic binary * Mon Jul 06 2009 Neil Horman 2.0.0-19 -- Fix build issue +- Fix build issue * Mon Jul 06 2009 Neil Horman 2.0.0-18 - Updated initscript to use mkdumprd2 if manifest is present @@ -2394,7 +2394,7 @@ fi - updating mkdumprd to use new kcp syntax * Wed Aug 23 2006 Neil Horman - 1.101-48 -- Bumping revision number +- Bumping revision number * Tue Aug 22 2006 Jarod Wilson - 1.101-47 - ppc64 no-more-platform fix @@ -2414,7 +2414,7 @@ fi * Tue Aug 15 2006 Neil Horman - 1.101-44 - updated init script to implement status function/scrub err messages - + * Wed Aug 09 2006 Jarod Wilson - 1.101-43 - Misc spec cleanups and macro-ifications @@ -2422,13 +2422,13 @@ fi - Add %%dir /var/crash, so default kdump setup works * Thu Aug 03 2006 Neil Horman - 1.101-41 -- fix another silly makefile error for makedumpfile +- fix another silly makefile error for makedumpfile * Thu Aug 03 2006 Neil Horman - 1.101-40 -- exclude makedumpfile from build on non-x86[_64] arches +- exclude makedumpfile from build on non-x86[_64] arches * Thu Aug 03 2006 Neil Horman - 1.101-39 -- exclude makedumpfile from build on non-x86[_64] arches +- exclude makedumpfile from build on non-x86[_64] arches * Thu Aug 03 2006 Neil Horman - 1.101-38 - updating makedumpfile makefile to use pkg-config on glib-2.0 @@ -2525,7 +2525,7 @@ fi * Wed Nov 16 2005 Thomas Graf - 1.101-5 - Report missing kdump kernel image as warning - + * Thu Nov 3 2005 Jeff Moyer - 1.101-4 - Build for x86_64 as well. Kdump support doesn't work there, but users should be able to use kexec. From 29fe563644f5e190067aefb41f99e7b9835fa87b Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 5 Jun 2023 17:35:53 +0800 Subject: [PATCH 707/806] kdump.conf: redirect unknown architecture warning to stderr The warning messages should not be included in the generated files. Redirecting the warning for an unknown architecture to stderr. Signed-off-by: Lichen Liu Reviewed-by: Coiby Xu --- gen-kdump-conf.sh | 2 +- gen-kdump-sysconfig.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gen-kdump-conf.sh b/gen-kdump-conf.sh index a9f124f..4abcd39 100755 --- a/gen-kdump-conf.sh +++ b/gen-kdump-conf.sh @@ -224,7 +224,7 @@ s390x) x86_64) ;; *) - echo "Warning: Unknown architecture '$1', using default kdump.conf template." + echo "Warning: Unknown architecture '$1', using default kdump.conf template." >&2 ;; esac diff --git a/gen-kdump-sysconfig.sh b/gen-kdump-sysconfig.sh index 5a16e92..4a28350 100755 --- a/gen-kdump-sysconfig.sh +++ b/gen-kdump-sysconfig.sh @@ -107,7 +107,7 @@ x86_64) "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0" ;; *) - echo "Warning: Unknown architecture '$1', using default sysconfig template." + echo "Warning: Unknown architecture '$1', using default sysconfig template." >&2 ;; esac From 51efbcf83e26a69fb56466a580b50e5d4867509f Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 13 Jun 2023 17:43:20 +0800 Subject: [PATCH 708/806] kdump-lib: Introduce a help function _crashkernel_add() This help function can manipulate the crashkernel cmdline by adding an number for each item. Also a basic test case for _crashkernel_add() is provided in this patch. Credit to Philipp, who contributes the original code. Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 58 ++++++++++++++++++++++++++++++++++++++++++ spec/kdump-lib_spec.sh | 20 +++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index c6bf378..992e8d9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -786,6 +786,64 @@ get_recommend_size() echo "0M" } +# $1 crashkernel="" +# $2 delta in unit of MB +_crashkernel_add() +{ + local _ck _add _entry _ret + local _range _size _offset + + _ck="$1" + _add="$2" + _ret="" + + if [[ "$_ck" == *@* ]]; then + _offset="@${_ck##*@}" + _ck=${_ck%@*} + elif [[ "$_ck" == *,high ]] || [[ "$_ck" == *,low ]]; then + _offset=",${_ck##*,}" + _ck=${_ck%,*} + else + _offset='' + fi + + while read -d , -r _entry; do + [[ -n "$_entry" ]] || continue + if [[ "$_entry" == *:* ]]; then + _range=${_entry%:*} + _size=${_entry#*:} + else + _range="" + _size=${_entry} + fi + + case "${_size: -1}" in + K) + _size=${_size::-1} + _size="$((_size + (_add * 1024)))K" + ;; + M) + _size=${_size::-1} + _size="$((_size + _add))M" + ;; + G) + _size=${_size::-1} + _size="$((_size * 1024 + _add))M" + ;; + *) + _size="$((_size + (_add * 1024 * 1024)))" + ;; + esac + + [[ -n "$_range" ]] && _ret+="$_range:" + _ret+="$_size," + done <<< "$_ck," + + _ret=${_ret%,} + [[ -n "$_offset" ]] && _ret+=$_offset + echo "$_ret" +} + # get default crashkernel # $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable kdump_get_arch_recommend_crashkernel() diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 3d10006..81f0f86 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -48,6 +48,26 @@ Describe 'kdump-lib' End End + Describe "_crashkernel_add()" + Context "when the input parameter is '1G-4G:256M,4G-64G:320M,64G-:576M'" + delta=100 + Parameters + "1G-4G:256M,4G-64G:320M,64G-:576M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" + "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" + "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" + "300M,high" "400M,high" + "300M,low" "400M,low" + "500M@1G" "600M@1G" + End + It "should add delta to the values after ':'" + + When call _crashkernel_add "$1" "$delta" + The output should equal "$2" + End + End + End + Describe 'prepare_cmdline()' get_bootcpu_apicid() { echo 1 From d8b961be37de09289a2ffff8c9c51cca4d153a92 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 13 Jun 2023 17:43:21 +0800 Subject: [PATCH 709/806] kdump-lib: Introduce parse_kver_from_path() to get kernel version from its path name kdump_get_arch_recommend_crashkernel() expects the kernel version info, while _update_kernel() provides the absolute path, which contains the kernel version info. This patch introduce a dedicated function parse_kver_from_path() to extract the kernel info from the path Credit to Philipp, who contributes the original code. Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 992e8d9..4f31b74 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -526,6 +526,49 @@ prepare_kdump_kernel() echo "$kdump_kernel" } +_is_valid_kver() +{ + [[ -f /usr/lib/modules/$1/modules.dep ]] +} + +# This function is introduced since 64k variant may be installed on 4k or vice versa +# $1 the kernel path name. +parse_kver_from_path() +{ + local _img _kver + + [[ -z "$1" ]] && return + + _img=$1 + BLS_ENTRY_TOKEN=$( + _kver=${_img##*/vmlinuz-} + _kver=${_kver%"$KDUMP_IMG_EXT"} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + # BLS recommended image names, i.e. $BOOT///linux + _kver=${_img##*/"$BLS_ENTRY_TOKEN"/} + _kver=${_kver%%/*} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + # Fedora UKI installation, i.e. $BOOT/efi/EFI/Linux/-.efi + _kver=${_img##*/"$BLS_ENTRY_TOKEN"-} + _kver=${_kver%.efi} + if _is_valid_kver "$_kver"; then + echo "$_kver" + return + fi + + ddebug "Could not parse version from $_img" +} + _get_kdump_kernel_version() { local _version _version_nondebug From 05c48614438611b83033b382de391afd87c6bc5b Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 13 Jun 2023 17:43:22 +0800 Subject: [PATCH 710/806] kdump-lib: add support for 64K aarch64 On aarch64, both 4K and 64K kernel can be installed, while they demand different size reserved memory for kdump kernel. 'get_conf PAGE_SIZE' can not work if installing a 64K kernel when running a 4K kernel. Hence resorting to the kernel release naming rules. At present, the 64K kernel has the keyword '64k' in its suffix. The base line for 64K is decided based on 4K. The diff 100M is picked up since on a high end machine without smmu enabled, the diff of MemFree is 82M. As for the smmu case, a huge difference in the memory consumption lies between 64k and 4k driver. And it should be calculated separatedly. Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 21 ++++++++++++++++++++- kdumpctl | 6 ++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 4f31b74..68431a0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -889,6 +889,7 @@ _crashkernel_add() # get default crashkernel # $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable +# $2 kernel-release, if not specified, got by _get_kdump_kernel_version kdump_get_arch_recommend_crashkernel() { local _arch _ck_cmdline _dump_mode @@ -908,8 +909,26 @@ kdump_get_arch_recommend_crashkernel() if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" elif [[ $_arch == "aarch64" ]]; then - # For 4KB page size, the formula is based on x86 plus extra = 64M + local _running_kernel + local _delta=0 + + # Base line for 4K variant kernel. The formula is based on x86 plus extra = 64M _ck_cmdline="1G-4G:256M,4G-64G:320M,64G-:576M" + if [[ -z "$2" ]]; then + _running_kernel=$(_get_kdump_kernel_version) + else + _running_kernel=$2 + fi + + # the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k" + if echo "$_running_kernel" | grep -q 64k; then + # Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M. + # Picking up 100M to cover this diff. And finally, we have "1G-4G:356M;4G-64G:420M;64G-:676M" + ((_delta += 100)) + else + ((_delta += 0)) + fi + _ck_cmdline=$(_crashkernel_add "$_ck_cmdline" "$_delta") elif [[ $_arch == "ppc64le" ]]; then if [[ $_dump_mode == "fadump" ]]; then _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" diff --git a/kdumpctl b/kdumpctl index 5043a7b..827b595 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1678,12 +1678,14 @@ _is_bootloader_installed() _update_crashkernel() { - local _kernel _dump_mode _old_default_crashkernel _new_default_crashkernel _fadump_val _msg + local _kernel _kver _dump_mode _old_default_crashkernel _new_default_crashkernel _fadump_val _msg _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") + _kver=$(parse_kver_from_path "$_kernel") + # The second argument is for the case of aarch64, where installing a 64k variant on a 4k kernel, or vice versa + _new_default_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_dump_mode" "$_kver") 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 From 7a2c4cbc3b10971c2a465ba2e465761e73390b74 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 13 Jun 2023 17:43:23 +0800 Subject: [PATCH 711/806] kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately On 4k and 64k kernels, the typical consumption values for SMMU are 36MB and 384MB, respectively. Hence for 64k kernel, the consumption by smmu should be taken into account carefully. To do it by adding the extra 384MB value if installing a 64k kernel. The upper limit value 384MB is calculated according to the formula in the kernel smmu driver. As for mlx5 network cards, it is measured by a pratical test, 200M for 64k variant, 150M for 4k variant Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump-lib.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 68431a0..9e818d3 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -829,6 +829,16 @@ get_recommend_size() echo "0M" } +has_mlx5() +{ + [[ -d /sys/bus/pci/drivers/mlx5_core ]] +} + +has_aarch64_smmu() +{ + ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 +} + # $1 crashkernel="" # $2 delta in unit of MB _crashkernel_add() @@ -925,8 +935,14 @@ kdump_get_arch_recommend_crashkernel() # Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M. # Picking up 100M to cover this diff. And finally, we have "1G-4G:356M;4G-64G:420M;64G-:676M" ((_delta += 100)) + # On a 64K system, the extra 384MB is calculated by: cmdq_num * 16 bytes + evtq_num * 32B + priq_num * 16B + # While on a 4K system, it is negligible + has_aarch64_smmu && ((_delta += 384)) + #64k kernel, mlx5 consumes extra 188M memory, and choose 200M + has_mlx5 && ((_delta += 200)) else - ((_delta += 0)) + #4k kernel, mlx5 consumes extra 124M memory, and choose 150M + has_mlx5 && ((_delta += 150)) fi _ck_cmdline=$(_crashkernel_add "$_ck_cmdline" "$_delta") elif [[ $_arch == "ppc64le" ]]; then From 64d93c886f4cd1bc3008e8eb9dea7cdb8e8cc601 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Fri, 9 Jun 2023 16:04:29 +0800 Subject: [PATCH 712/806] kdumpctl: Fix the matching of plus symbol by grep's EREs After introducing 64k variant kernel on aarch64, an example kernel name looks like "vmlinuz-5.14.0-316.el9.aarch64+64k". To match the plus symbol, it demands an escape charater. Signed-off-by: Pingfan Liu Reviewed-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 3 +++ spec/kdumpctl_general_spec.sh | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/kdumpctl b/kdumpctl index 827b595..58c18d2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1406,6 +1406,9 @@ _filter_grubby_kernel_str() _find_kernel_path_by_release() { local _release="$1" _grubby_kernel_str _kernel_path + + # Insert '/' before '+' to cope with grep's EREs + _release=${_release//+/\\+} _grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(\/\w+)?\"$") _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") if [[ -z $_kernel_path ]]; then diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index bb5755c..7304cd4 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -222,6 +222,23 @@ Describe 'kdumpctl' End End + Describe '_find_kernel_path_by_release()' + grubby() { + echo -e 'kernel="/boot/vmlinuz-6.2.11-200.fc37.x86_64"\nkernel="/boot/vmlinuz-5.14.0-322.el9.aarch64"\nkernel="/boot/vmlinuz-5.14.0-316.el9.aarch64+64k"' + } + + Parameters + # parameter answer + vmlinuz-6.2.11-200.fc37.x86_64 /boot/vmlinuz-6.2.11-200.fc37.x86_64 + vmlinuz-5.14.0-322.el9.aarch64 /boot/vmlinuz-5.14.0-322.el9.aarch64 + vmlinuz-5.14.0-316.el9.aarch64+64k /boot/vmlinuz-5.14.0-316.el9.aarch64+64k + End + It 'returns the kernel path for the given release' + When call _find_kernel_path_by_release "$1" + The output should equal "$2" + End + End + Describe 'parse_config()' bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) cleanup() { From 471c136481a7de4c21cef84aab82b97b57b3d0e4 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 14 Jun 2023 17:38:16 +0800 Subject: [PATCH 713/806] Release 2.0.26-7 Signed-off-by: Coiby Xu --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index e69a258..360b6c5 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -396,6 +396,13 @@ fi %endif %changelog +* Wed Jun 14 2023 Coiby - 2.0.26-7 +- kdumpctl: Fix the matching of plus symbol by grep's EREs +- kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately +- kdump-lib: add support for 64K aarch64 +- kdump-lib: Introduce parse_kver_from_path() to get kernel version from its path name +- kdump-lib: Introduce a help function _crashkernel_add() + * Fri Jun 02 2023 Timothée Ravier - 2.0.26-6 - Make binutils a recommend as it's only needed for UKI support From 8f243d2ab13a0d185e9bc7bbd2d1984731e353fd Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 15 Jun 2023 13:17:19 +0800 Subject: [PATCH 714/806] tests: generate correct RPM name Tests failed to run against Fedora 37 or newer cloud images because of the following error, It's a image with multiple partitions, using last partition as main partition 'xxx/tests/build/x86_64/kexec-tools-2.0.26-5.fc37.src.rpm' not found /dev/nbd0 disconnected make: *** [Makefile:73: xxx/tests/output/test-base-image] Error 1 This is because starting with Fedora 37, rpm changes its API, # Fedora >= 37 $ rpm -q --specfile kexec-tools.spec kexec-tools-2.0.26-5.fc37.src # Fedora 36 $ rpm -q --specfile kexec-tools.spec kexec-tools-2.0.26-5.fc36 The tests depends on rpm to generate correct RPM name. Fix this issue by removing the trailing .src from the output of "rpm -q --specfile". Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 05fda1d..45688ca 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -30,7 +30,7 @@ RPMDEFINE = --define '_sourcedir $(REPO)'\ KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*)) KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*) -KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 .) +KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 . | sed -e 's#.src#.$(ARCH)#') KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm all: $(TEST_ROOT)/output/test-base-image From 7cd799462e68393dffe0dc1f3a87c06440a96740 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 15 Jun 2023 13:17:20 +0800 Subject: [PATCH 715/806] tests: skip checking if the second partition has the boot label All the tests failed to run on the Fedora 37 host because the boot partition failed to be mounted and in turn the key kernel cmdline parameters like selinux=0 couldn't be added. The root problem is somehow running lsblk on the second partition returns an empty label unless we wait for enough time. Before figuring out the root cause, simply skip check that the second partition needs to have the boot label. Note the root problem can be produced by building a test image, cd tests ./scripts/build-image.sh Fedora-Cloud-Base-37-1.7.x86_64.qcow2 output_image scripts/build-scripts/base-image_test.sh Source image is qcow2, using snapshot... Formatting 'build/base-image1.building', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=5368709120 backing_file=Fedora-Cloud-Base-37-1.7.x86_64.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 It's a image with multiple partitions, using last partition as main partition grep: /boot/grub2/grubenv: No such file or directory grub2-editenv: error: cannot open `/boot/grub2/grubenv.new': No such file or directory. /dev/nbd0 disconnected Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/scripts/image-init-lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 467f32f..b0af7f8 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -86,9 +86,9 @@ get_mountable_dev() { get_mount_boot() { local dev=$1 _second_part=${dev}p2 - if [[ $(lsblk -f $_second_part -n -o LABEL 2> /dev/null) == boot ]]; then - echo $_second_part - fi + # it's better to check if the 2nd partition has the boot label using lsblk + # but somehow this doesn't work starting with Fedora37 + echo $_second_part } From 17c26558d9b45d31755b9ed7f29a7ad291904740 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 15 Jun 2023 13:17:21 +0800 Subject: [PATCH 716/806] tests: use the default crashkernel value And with commit t5b31b099 ("Simplify the management of the kernel parameter crashkernel"), the default crashkernel value will be used for the kernel. But the test VM has a RAM of 768M thus this is no actual reserved memory for kdump. Even With the old crashkernel=224M, network dumping tests like nfs-kdump will fail out of memory when running against current Fedora Cloud images (>=F37). This patch address the above two issues by 1. increasing the RAM of test VM to 1G 2. installing the kernel-modules which contains the squashfs module in order to use the dracut squash module for kdump initrd. Thanks to the dracut squash module, now even crashkernel=192M (the default crashkernel value for RAM between 1G and 4G) works for network dumping. Another benefit brought by this change is the default crashkernel value can be tested as well. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- tests/scripts/build-scripts/base-image.sh | 3 +-- tests/scripts/test-lib.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/scripts/build-scripts/base-image.sh b/tests/scripts/build-scripts/base-image.sh index 62624e4..1d64cfb 100755 --- a/tests/scripts/build-scripts/base-image.sh +++ b/tests/scripts/build-scripts/base-image.sh @@ -3,8 +3,7 @@ img_inst_pkg grubby\ dnsmasq\ openssh openssh-server\ - dracut-network dracut-squash squashfs-tools ethtool snappy + dracut-network dracut-squash squashfs-tools ethtool snappy kernel-modules img_run_cmd "grubby --args systemd.journald.forward_to_console=1 systemd.log_target=console --update-kernel ALL" img_run_cmd "grubby --args selinux=0 --update-kernel ALL" -img_run_cmd "grubby --args crashkernel=224M --update-kernel ALL" diff --git a/tests/scripts/test-lib.sh b/tests/scripts/test-lib.sh index 8b24b2a..57b05d3 100644 --- a/tests/scripts/test-lib.sh +++ b/tests/scripts/test-lib.sh @@ -8,7 +8,7 @@ DEFAULT_QEMU_CMD="-nodefaults \ -nographic \ -smp 2 \ --m 768M \ +-m 1G \ -monitor none" _YELLOW='\033[1;33m' From dda81d72c2766167d48d3e505b95b2ca9b013039 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 19 Jun 2023 14:31:48 +0200 Subject: [PATCH 717/806] kdumpctl: Fix temporary directory location The temporary directory is currently created under the current working directory. That alone isn't ideal but works most of the time. However, it will fail when the current working directory is not writable. So make sure the directory is created within TMPDIR. Fixes: ea00b7d ("kdumpctl: Move temp file in get_kernel_size to global temp dir") Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kdumpctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 58c18d2..7e561fd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -45,7 +45,7 @@ if ! dlog_init; then exit 1 fi -KDUMP_TMPDIR=$(mktemp -d kdump.XXXX) +KDUMP_TMPDIR=$(mktemp --tmpdir -d kdump.XXXX) trap ' ret=$?; rm -rf "$KDUMP_TMPDIR" From f3139012f290cbc35d262e1d6b24038b12b2c41d Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 20 Jun 2023 08:50:31 +0800 Subject: [PATCH 718/806] kdump-lib: Match 64k debug kernel in prepare_kdump_bootinfo() For kernel 64k variant, it terminates with substring 64k-debug, e.g. vmlinuz-5.14.0-327.el9.aarch64+64k-debug. Providing an extra matching pattern to filter out it. Signed-off-by: Pingfan Liu Reviewed-by: Coiby Xu --- kdump-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 9e818d3..4290be3 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -614,7 +614,8 @@ prepare_kdump_bootinfo() return 1 fi - if [[ "$KDUMP_KERNEL" == *"+debug" ]]; then + # For 64k variant, e.g. vmlinuz-5.14.0-327.el9.aarch64+64k-debug + if [[ "$KDUMP_KERNEL" == *"+debug" || "$KDUMP_KERNEL" == *"64k-debug" ]]; then dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value." fi From daa829f79e308e9d53060331f7721d3ee6b9f549 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 12 Jun 2023 17:17:43 +0800 Subject: [PATCH 719/806] spec: kdump/ppc64: make servicelog_notify silent when there are no errors There is confusing message in /var/log/anaconda/packaging.log when installing kexec-tools during the system installation on ppc64le: Event Notification Registration successful (id: 1) Make servicelog_notify slient when there are no erros. Signed-off-by: Lichen Liu Reviewed-by: Coiby Xu --- kexec-tools.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 360b6c5..d2143ad 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -269,7 +269,7 @@ touch /etc/kdump.conf %ifarch ppc64 ppc64le servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null -servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin +servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null %endif # This portion of the script is temporary. Its only here @@ -300,7 +300,7 @@ fi %preun %ifarch ppc64 ppc64le -servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh +servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/dev/null %endif %systemd_preun kdump.service From 52a034eb10f66f795622ff9c8bcfa474d0d30dee Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 4 Jul 2023 11:56:11 +0800 Subject: [PATCH 720/806] Use SPDX licence Convert to SPDX license by https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_2, # license-fedora2spdx GPLv2 GPL-2.0-only Signed-off-by: Coiby Xu --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d2143ad..5a6648e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -6,7 +6,7 @@ Name: kexec-tools Version: 2.0.26 Release: 7%{?dist} -License: GPLv2 +License: GPL-2.0-only Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz From b725cdb45eb7d3b442204f3459cc3349c9e770ce Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jul 2023 08:42:47 +0000 Subject: [PATCH 721/806] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 5a6648e..ff8b496 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.26 -Release: 7%{?dist} +Release: 8%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -396,6 +396,9 @@ fi %endif %changelog +* Thu Jul 20 2023 Fedora Release Engineering - 2.0.26-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + * Wed Jun 14 2023 Coiby - 2.0.26-7 - kdumpctl: Fix the matching of plus symbol by grep's EREs - kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately From 4b7b7736eef8c682a8af07081d7f06eeb774172f Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Wed, 2 Aug 2023 20:36:48 +0530 Subject: [PATCH 722/806] Introduce a function to get reserved memory size The size of the reserved memory in the functions show_reserved_mem, check_crash_mem_reserved, and do_estimate are fetched from the sysfs node `/sys/kernel/kexec_crash_size`. However, in the case of fadump, the reserved area size is instead present in /sys/kernel/fadump/mem_reserved. For example: $ kdumpctl showmem kdump: Dump mode is fadump kdump: Reserved 0MB memory for crash kernel The above command showed 0MB for Reserved memory which is incorrect, the actual reservation was 2048MB. To resolve this issue a new helper function is introduced to fetch reserved memory size based on the dump mode. For "fadump" mode, it looks in `/sys/kernel/fadump/mem_reserved`, otherwise, it uses `/sys/kernel/kexec_crash_size`. And all functions that previously fetching reserved memory directly from `/sys/kernel/kexec_crash_size` sysfs node are now updated to use this new function to get the reserved memory size. With the fix in place, the `kdumpctl showmem` command will now display correct reserved memory size. $ kdumpctl showmem kdump: Dump mode is fadump kdump: Reserved 2048MB memory for crash kernel Signed-off-by: Sourabh Jain Reported-by: Sachin P Bappalige Reviewed-by: Coiby Xu --- kdump-lib.sh | 15 ++++++++++++++- kdumpctl | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 4290be3..16238c5 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -344,11 +344,24 @@ is_mount_in_dracut_args() [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] } +get_reserved_mem_size() +{ + local reserved_mem_size=0 + + if is_fadump_capable; then + reserved_mem_size=$(< /sys/kernel/fadump/mem_reserved) + else + reserved_mem_size=$(< /sys/kernel/kexec_crash_size) + fi + + echo "$reserved_mem_size" +} + check_crash_mem_reserved() { local mem_reserved - mem_reserved=$(< /sys/kernel/kexec_crash_size) + mem_reserved=$(get_reserved_mem_size) if [[ $mem_reserved -eq 0 ]]; then derror "No memory reserved for crash kernel" return 1 diff --git a/kdumpctl b/kdumpctl index 7e561fd..1f7f4ce 100755 --- a/kdumpctl +++ b/kdumpctl @@ -856,7 +856,7 @@ show_reserved_mem() local mem local mem_mb - mem=$(< /sys/kernel/kexec_crash_size) + mem=$(get_reserved_mem_size) mem_mb=$((mem / 1024 / 1024)) dinfo "Reserved ${mem_mb}MB memory for crash kernel" @@ -1270,7 +1270,7 @@ do_estimate() # The default pre-reserved crashkernel value baseline_size=$((baseline * size_mb)) # Current reserved crashkernel size - reserved_size=$(< /sys/kernel/kexec_crash_size) + reserved_size=$(get_reserved_mem_size) # A pre-estimated value for userspace usage and kernel # runtime allocation, 64M should good for most cases runtime_size=$((64 * size_mb)) From 98c7c6ee6aa6b5c7983f568bb359d7860ed27fd0 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 31 Aug 2023 11:29:43 +0800 Subject: [PATCH 723/806] [packit] 2.0.27 upstream release Upstream tag: v2.0.27 Upstream commit: 17590eed --- .packit.yaml | 16 ++++++++++++++++ README.packit | 3 +++ kexec-tools.spec | 7 +++++-- sources | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .packit.yaml create mode 100644 README.packit diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 0000000..88fcda6 --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,16 @@ +# See the documentation for more information: +# https://packit.dev/docs/configuration/ + +specfile_path: kexec-tools.spec + +# add or remove files that should be synced +files_to_sync: + - kexec-tools.spec + - .packit.yaml + +# name in upstream package repository or registry (e.g. in PyPI) +upstream_package_name: kexec-tools +# downstream (Fedora) RPM package name +downstream_package_name: kexec-tools + +upstream_tag_template: v{version} diff --git a/README.packit b/README.packit new file mode 100644 index 0000000..159f693 --- /dev/null +++ b/README.packit @@ -0,0 +1,3 @@ +This repository is maintained by packit. +https://packit.dev/ +The file was generated using packit 0.79.0. diff --git a/kexec-tools.spec b/kexec-tools.spec index ff8b496..897b6ff 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.26 -Release: 8%{?dist} +Version: 2.0.27 +Release: 1%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -396,6 +396,9 @@ fi %endif %changelog +* Thu Aug 31 2023 Coiby Xu - 2.0.27-1 +- kexec-tools 2.0.27 (Simon Horman) + * Thu Jul 20 2023 Fedora Release Engineering - 2.0.26-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild diff --git a/sources b/sources index d684233..54a591c 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ -SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 -SHA512 (kexec-tools-2.0.26.tar.xz) = afecb64f50a0a2e553712d7e6e4d48e0dc745e4140983a33a10cce931e6aeddaff9c4a3385fbaf7ab9ff7b3b905d932fbce1e0e37aa2c35d5c1e61277140dee9 +SHA512 (kexec-tools-2.0.27.tar.xz) = 30b5ef7c2075dfd11fd1c3c33abe6b60673400257668d60145be08a2472356c7191a0810095da0fa32e327b9806a7578c73129ac0550d26c28ea6571c88c7b3c SHA512 (makedumpfile-1.7.2.tar.gz) = 324e303dd5f507703f66e2bd5dc9d24f9f50ba797be70c05702008ba77078f61ffcc884796ddf9ab737de1d124c3a9d881ab5ce4f3f459690ec00055af25ea9e +SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 From fc7c65312a5bef115ce40818bf43ddd3b01b8958 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 17 Aug 2023 16:38:35 +0530 Subject: [PATCH 724/806] powerpc: update fadump sysfs node path The fadump sysfs nodes /sys/kernel/fadump_[enabled|registered], have been relocated to /sys/kernel/fadump/[enabled|registered] by kernel commits d418b19f34ed ("powerpc/fadump: Reorganize /sys/kernel/fadump_* sysfs files"). To ensure compatibility, symbolic links were added for each relocated sysfs entry. Nonetheless, note that these symbolic links might be removed later, as they have been deprecated by kernel commit 3f5f1f22ef10 ("Documentation/ABI: Mark /sys/kernel/fadump_* sysfs files deprecated") This patch updates the scripts to use the updated fadump sysfs files. Signed-off-by: Sourabh Jain Reviewed-by: Philipp Rudo --- 98-kexec.rules.ppc64 | 2 +- fadump-howto.txt | 2 +- kdump-lib.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/98-kexec.rules.ppc64 b/98-kexec.rules.ppc64 index a1c00a9..e9db276 100644 --- a/98-kexec.rules.ppc64 +++ b/98-kexec.rules.ppc64 @@ -17,6 +17,6 @@ GOTO="kdump_reload_end" LABEL="kdump_reload_cpu" -RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump_enabled || cat /sys/kernel/fadump_enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" +RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump/enabled || cat /sys/kernel/fadump/enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" LABEL="kdump_reload_end" diff --git a/fadump-howto.txt b/fadump-howto.txt index 9773f78..2fe76cf 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -137,7 +137,7 @@ Then, start up kdump as well: # systemctl start kdump.service This should turn on the firmware assisted functionality in kernel by -echo'ing 1 to /sys/kernel/fadump_registered, leaving the system ready +echo'ing 1 to /sys/kernel/fadump/registered, leaving the system ready to capture a vmcore upon crashing. For journaling filesystems like XFS an additional step is required to ensure bootloader does not pick the older initrd (without vmcore capture scripts): diff --git a/kdump-lib.sh b/kdump-lib.sh index 16238c5..99c726b 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -8,8 +8,8 @@ else . /lib/kdump/kdump-lib-initramfs.sh fi -FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" -FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" +FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump/enabled" +FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump/registered" is_uki() { From 026edc2b592c1ce6389acc67520a9e8a3d2d5735 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:36 +0200 Subject: [PATCH 725/806] Fix various shellcheck findings This includes fixes for SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. SC2005 (style): Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. SC2162 (info): read without -r will mangle backslashes. SC2086 (info): Double quote to prevent globbing and word splitting. SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly). In addition add some source hints to prevent false positive findings. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdump-lib.sh | 10 +++++----- kdumpctl | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 99c726b..634bd22 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -197,7 +197,7 @@ get_bind_mount_source() local _fsroot _src_nofsroot _mnt=$(df "$1" | tail -1 | awk '{print $NF}') - _path=${1#$_mnt} + _path=${1#"$_mnt"} _src=$(get_mount_info SOURCE target "$_mnt" -f) _opt=$(get_mount_info OPTIONS target "$_mnt" -f) @@ -214,7 +214,7 @@ get_bind_mount_source() echo "$_mnt$_path" && return fi - _fsroot=${_src#${_src_nofsroot}[} + _fsroot=${_src#"${_src_nofsroot}"[} _fsroot=${_fsroot%]} _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) @@ -223,7 +223,7 @@ get_bind_mount_source() local _subvol _subvol=${_opt#*subvol=} _subvol=${_subvol%,*} - _fsroot=${_fsroot#$_subvol} + _fsroot=${_fsroot#"$_subvol"} fi echo "$_mnt$_fsroot$_path" } @@ -270,7 +270,7 @@ kdump_get_persistent_dev() dev=$(blkid -L "${dev#LABEL=}") ;; esac - echo $(get_persistent_dev "$dev") + get_persistent_dev "$dev" } is_ostree() @@ -823,7 +823,7 @@ get_recommend_size() while read -r -d , range; do # need to use non-default IFS as double spaces are used as a # single delimiter while commas aren't... - IFS=, read start start_unit end end_unit size <<< \ + IFS=, read -r start start_unit end end_unit size <<< \ "$(echo "$range" | sed -n "s/\([0-9]\+\)\([GT]\?\)-\([0-9]*\)\([GT]\?\):\([0-9]\+[MG]\)/\1,\2,\3,\4,\5/p")" # aka. 102400T diff --git a/kdumpctl b/kdumpctl index 1f7f4ce..7844488 100755 --- a/kdumpctl +++ b/kdumpctl @@ -29,14 +29,17 @@ if [[ -f /etc/sysconfig/kdump ]]; then fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut -. $dracutbasedir/dracut-functions.sh +# shellcheck source=/dev/null +. "$dracutbasedir"/dracut-functions.sh if [[ ${__SOURCED__:+x} ]]; then KDUMP_LIB_PATH=. else KDUMP_LIB_PATH=/lib/kdump fi +# shellcheck source=./kdump-lib.sh . $KDUMP_LIB_PATH/kdump-lib.sh +# shellcheck source=./kdump-logger.sh . $KDUMP_LIB_PATH/kdump-logger.sh #initiate the kdump logger @@ -247,7 +250,7 @@ restore_default_initrd() if [[ $default_checksum != "$backup_checksum" ]]; then dwarn "WARNING: checksum mismatch! Can't restore original initrd.." else - rm -f $INITRD_CHECKSUM_LOCATION + rm -f "$INITRD_CHECKSUM_LOCATION" if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then derror "Restoring original initrd as fadump mode is disabled." sync -f "$DEFAULT_INITRD" @@ -497,6 +500,7 @@ check_drivers_modified() # If it's dump target is on block device, detect the block driver _target=$(get_block_dump_target) if [[ -n $_target ]]; then + # shellcheck disable=SC2317 _record_block_drivers() { local _drivers From bbda12a5acbd30a58ad6b3eb4e1313045f402646 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:37 +0200 Subject: [PATCH 726/806] kdump-lib: make is_zstd_command_available more generic There is value to use the function in other places as well. For example it can be used to check whether optional dependencies, like grubby, are installed. Thus make it more generic so it can be reused in later commits. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdump-lib.sh | 4 ++-- mkdumprd | 2 +- mkfadumprd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 634bd22..d314157 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -48,9 +48,9 @@ is_squash_available() done } -is_zstd_command_available() +has_command() { - [[ -x "$(command -v zstd)" ]] + [[ -x $(command -v "$1") ]] } dracut_have_option() diff --git a/mkdumprd b/mkdumprd index f93874d..4feac28 100644 --- a/mkdumprd +++ b/mkdumprd @@ -443,7 +443,7 @@ handle_default_dump_target if ! have_compression_in_dracut_args; then if is_squash_available && dracut_have_option "--squash-compressor"; then add_dracut_arg "--squash-compressor" "zstd" - elif is_zstd_command_available; then + elif has_command zstd; then add_dracut_arg "--compress" "zstd" fi fi diff --git a/mkfadumprd b/mkfadumprd index 719e150..dd6840f 100755 --- a/mkfadumprd +++ b/mkfadumprd @@ -64,7 +64,7 @@ _dracut_isolate_args=( # Use zstd compression method, if available if ! have_compression_in_dracut_args; then - if is_zstd_command_available; then + if has_command zstd; then _dracut_isolate_args+=(--compress zstd) fi fi From f01fef4016734096dc3df0f247cec5f9fe2cd8ed Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:38 +0200 Subject: [PATCH 727/806] kdump-lib: simplify _get_kdump_kernel_version Only check whether modules for a given kernel version are installed instead of searching for a kernel image. It's safer to assume that every kernel uses kernel modules compared to that it follows certain naming conventions. Furthermore it is much more lightweight and thus allows to determine the KDUMP_KERNELVER much earlier for every command in kdumpctl. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdump-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index d314157..55c29bd 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -599,7 +599,7 @@ _get_kdump_kernel_version() _version_nondebug=${_version%+debug} _version_nondebug=${_version_nondebug%-debug} - if [[ -f "$(prepare_kdump_kernel "$_version_nondebug")" ]]; then + if _is_valid_kver "$_version_nondebug"; then dinfo "Use of debug kernel detected. Trying to use $_version_nondebug" echo "$_version_nondebug" else From b9738affc9b9b2a5d32206431811a6c8f9efb773 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:39 +0200 Subject: [PATCH 728/806] kdumpctl: drop _get_current_running_kernel_path _get_current_running_kernel_path is identical to _find_kernel_path_by_release $(uname -r) so simply use this instead of defining a new function. While at it simplify reset_crashkernel slightly. This changes the behavior of the function for the case when KDUMP_KERNELVER is defined but no kernel with this version is installed. Before, the missing kernel is silently ignored and the currently running kernel is used instead. Now, kdumpctl will exit with an error. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdumpctl | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7844488..8cd423c 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1422,18 +1422,6 @@ _find_kernel_path_by_release() echo -n "$_kernel_path" } -_get_current_running_kernel_path() -{ - local _release _path - - _release=$(uname -r) - if _path=$(_find_kernel_path_by_release "$_release"); then - echo -n "$_path" - else - return 1 - fi -} - _update_kernel_cmdline() { local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4 @@ -1628,14 +1616,11 @@ reset_crashkernel() # - use KDUMP_KERNELVER if it's defined # - use current running kernel if [[ -z $_grubby_kernel_path ]]; then - if [[ -z $KDUMP_KERNELVER ]] || - ! _kernel_path=$(_find_kernel_path_by_release "$KDUMP_KERNELVER"); then - if ! _kernel_path=$(_get_current_running_kernel_path); then - derror "no running kernel found" - exit 1 - fi + [[ -n $KDUMP_KERNELVER ]] || KDUMP_KERNELVER=$(uname -r) + if ! _kernels=$(_find_kernel_path_by_release "$KDUMP_KERNELVER"); then + derror "no kernel for version $KDUMP_KERNELVER found" + exit 1 fi - _kernels=$_kernel_path else _kernels=$(_get_all_kernels_from_grubby "$_grubby_kernel_path") fi From 1049e1c79c15865a008f1eb001f8357c03a80e53 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:40 +0200 Subject: [PATCH 729/806] kdumpctl: drop condrestart subcommand condrestart is a left over from the time of SysVinit that is no longer needed since the kexec-tools switched to systemd (10c91a1 ("Removing sysvinit files") plus the one before). What's especially intriguing is that from the beginning (0112f36 ("- Add a kdump sysconfig file and init script - Spec file additions for pre/post install/uninstall")) the sub-command never did any actual work (other than not returning an error). Thus simply remove the condrestart sub-command. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdumpctl | 2 -- 1 file changed, 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 8cd423c..7ef23a8 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1795,8 +1795,6 @@ main() rebuild) rebuild ;; - condrestart) ;; - propagate) propagate_ssh_key ;; From f5785c60aaf349c7264c422f73f287874049f7b4 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:41 +0200 Subject: [PATCH 730/806] kdumpctl: simplify _update_kernel_cmdline _update_kernel_cmdline handles two cmdline parameters at once. This does not only make the function itself but also its callers more complicated than necessary. For example in _update_crashkernel the fadump gets "updated" to the value that has been read from grubby. Thus simplify _update_kernel_cmdline to only update one parameter at once. While at it shorten some variable named in the callers. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdumpctl | 108 ++++++++++++----------- spec/kdumpctl_manage_crashkernel_spec.sh | 5 ++ spec/kdumpctl_reset_crashkernel_spec.sh | 5 ++ 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7ef23a8..5088c32 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1424,21 +1424,33 @@ _find_kernel_path_by_release() _update_kernel_cmdline() { - local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4 + local _kernel _param _old _new + + _kernel="$1" + _param="$2" + _old="$3" + _new="$4" + + # _new = "" removes a _param, so _new = _old = "" is fine + [[ -n "$_new" ]] && [[ "$_old" == "$_new" ]] && return 1 if is_ostree; then - if rpm-ostree kargs | grep -q "crashkernel="; then - rpm-ostree kargs --replace="crashkernel=$_crashkernel" + if [[ -z "$_new" ]]; then + rpm-ostree kargs --delete="$_param=$_old" + elif [[ -n "$_old" ]]; then + rpm-ostree kargs --replace="$_param=$_new" else - rpm-ostree kargs --append="crashkernel=$_crashkernel" + rpm-ostree kargs --append="$_param=$_new" + fi + elif has_command grubby; then + if [[ -n "$_new" ]]; then + grubby --update-kernel "$_kernel" --args "$_param=$_new" + else + grubby --update-kernel "$_kernel" --remove-args "$_param" fi else - grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path" - if [[ $_dump_mode == kdump ]]; then - grubby --remove-args="fadump" --update-kernel "$_kernel_path" - else - grubby --args="fadump=$_fadump_val" --update-kernel "$_kernel_path" - fi + derror "Unable to update kernel command line" + exit 1 fi # Don't use "[[ CONDITION ]] && COMMAND" which returns 1 under false CONDITION @@ -1530,9 +1542,11 @@ _read_kernel_arg_in_grub_etc_default() reset_crashkernel() { - local _opt _val _dump_mode _fadump_val _reboot _grubby_kernel_path _kernel _kernels - local _old_crashkernel _new_crashkernel _new_dump_mode _crashkernel_changed - local _new_fadump_val _old_fadump_val _what_is_updated + local _opt _val _fadump_val _reboot _grubby_kernel_path _kernel _kernels + local _dump_mode _new_dump_mode + local _has_changed _needs_reboot + local _old_ck _new_ck + local _old_fadump _new_fadump for _opt in "$@"; do case "$_opt" in @@ -1570,14 +1584,10 @@ reset_crashkernel() # modifying the kernel command line so there is no need for kexec-tools # to repeat it. if is_ostree; then - _old_crashkernel=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') - _new_dump_mode=kdump - _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") - if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then - _update_kernel_cmdline "" "$_new_crashkernel" "$_new_dump_mode" "" - if [[ $_reboot == yes ]]; then - systemctl reboot - fi + _old_ck=$(rpm-ostree kargs | sed -n -E 's/.*(^|\s)crashkernel=(\S*).*/\2/p') + _new_ck=$(kdump_get_arch_recommend_crashkernel kdump) + if _update_kernel_cmdline "" crashkernel "$_old_ck" "$_new_ck"; then + [[ $_reboot == yes ]] && systemctl reboot fi return fi @@ -1626,35 +1636,33 @@ reset_crashkernel() fi for _kernel in $_kernels; do + _has_changed="" if [[ -z $_dump_mode ]]; then _new_dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") - _new_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") + _new_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) else _new_dump_mode=$_dump_mode - _new_crashkernel=$_crashkernel - _new_fadump_val=$_fadump_val + _new_ck=$_crashkernel + _new_fadump=$_fadump_val fi - _old_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) - _old_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump) - if [[ $_old_crashkernel != "$_new_crashkernel" || $_old_fadump_val != "$_new_fadump_val" ]]; then - _update_kernel_cmdline "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val" - if [[ $_reboot != yes ]]; then - if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then - _what_is_updated="Updated crashkernel=$_new_crashkernel" - else - # This case happens only when switching between fadump=on and fadump=nocma - _what_is_updated="Updated fadump=$_new_fadump_val" - fi - dwarn "$_what_is_updated for kernel=$_kernel. Please reboot the system for the change to take effect." - fi - _crashkernel_changed=yes + _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) + if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then + _has_changed="Updated fadump=$_new_fadump" + fi + if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then + _has_changed="Updated crashkernel=$_new_ck" + fi + if [[ -n "$_has_changed" ]]; then + _needs_reboot=1 + dwarn "$_has_changed for kernel=$_kernel. Please reboot the system for the change to take effect." fi done - if [[ $_reboot == yes && $_crashkernel_changed == yes ]]; then - reboot + if [[ $_reboot == yes && $_needs_reboot == 1 ]]; then + systemctl reboot fi } @@ -1670,21 +1678,19 @@ _is_bootloader_installed() _update_crashkernel() { - local _kernel _kver _dump_mode _old_default_crashkernel _new_default_crashkernel _fadump_val _msg + local _kernel _kver _dump_mode _msg + local _old_ck _new_ck _kernel=$1 _dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _old_default_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) _kver=$(parse_kver_from_path "$_kernel") # The second argument is for the case of aarch64, where installing a 64k variant on a 4k kernel, or vice versa - _new_default_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_dump_mode" "$_kver") - 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 - _msg="For kernel=$_kernel, crashkernel=$_new_default_crashkernel now. Please reboot the system for the change to take effet." - _msg+=" Note if you don't want kexec-tools to manage the crashkernel kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf." - dinfo "$_msg" - fi + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_dump_mode" "$_kver") + if _update_kernel_cmdline "$_kernel" crashkernel "$_old_ck" "$_new_ck"; then + _msg="For kernel=$_kernel, crashkernel=$_new_ck now. Please reboot the system for the change to take effect." + _msg+=" Note if you don't want kexec-tools to manage the crashkernel kernel parameter, please set auto_reset_crashkernel=no in /etc/kdump.conf." + dinfo "$_msg" fi } diff --git a/spec/kdumpctl_manage_crashkernel_spec.sh b/spec/kdumpctl_manage_crashkernel_spec.sh index 9078347..bae3f31 100644 --- a/spec/kdumpctl_manage_crashkernel_spec.sh +++ b/spec/kdumpctl_manage_crashkernel_spec.sh @@ -52,6 +52,11 @@ Describe 'Management of the kernel crashkernel parameter.' @grubby --no-etc-grub-update --grub2 --config-file="$GRUB_CFG" --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" } + # The mocking breaks has_command. Mock it as well to fix the tests. + has_command() { + [[ "$1" == grubby ]] + } + Describe "When kexec-tools have its default crashkernel updated, " Context "if kexec-tools is updated alone, " diff --git a/spec/kdumpctl_reset_crashkernel_spec.sh b/spec/kdumpctl_reset_crashkernel_spec.sh index 28d9277..8fb4385 100644 --- a/spec/kdumpctl_reset_crashkernel_spec.sh +++ b/spec/kdumpctl_reset_crashkernel_spec.sh @@ -29,6 +29,11 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' @grubby --no-etc-grub-update --grub2 --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" } + # The mocking breaks has_command. Mock it as well to fix the tests. + has_command() { + [[ "$1" == grubby ]] + } + Describe "Test the kdump dump mode " uname() { if [[ $1 == '-m' ]]; then From 099434b9932fd8a82a3e021ec8e8c482b3698c01 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:42 +0200 Subject: [PATCH 731/806] kdumpctl: Prevent option --fadump on non-PPC in reset_crashkernel Prevent the --fadump option to be used on non-PPC systems. This not only prevents user errors but also guarantees that _dump_mode and _fadump_val are empty on these systems. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdumpctl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kdumpctl b/kdumpctl index 5088c32..113d8bc 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1551,6 +1551,10 @@ reset_crashkernel() for _opt in "$@"; do case "$_opt" in --fadump=*) + if [[ $(uname -m) != ppc64le ]]; then + derror "Option --fadump only valid on PPC" + exit 1 + fi _val=${_opt#*=} if _dump_mode=$(get_dump_mode_by_fadump_val $_val); then _fadump_val=$_val @@ -1592,12 +1596,7 @@ reset_crashkernel() return fi - # For non-ppc64le systems, the dump mode is always kdump since only ppc64le - # has FADump. - if [[ -z $_dump_mode && $(uname -m) != ppc64le ]]; then - _dump_mode=kdump - _fadump_val=off - fi + [[ $(uname -m) != ppc64le ]] && _dump_mode=kdump # If the dump mode is determined, we can also know the default crashkernel value if [[ -n $_dump_mode ]]; then From 8175924e89aefbc91e5f0b40213e0ed1ea394283 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:43 +0200 Subject: [PATCH 732/806] kdumpctl: Stop updating grub config in reset_crashkernel With multiple kernel variants on the same architecture, e.g. the 4k and 64k kernel on aarch64, we can no longer assume that the crashkernel value for the currently running kernel will work for all installed kernels. This also means that we can no longer update the grub config as we don't know which value to set it to. Thus get the crashkernel value for each kernel and stop updating the grub config. While at it merge the _new_fadump and _fadump_val variables and remove _read_kernel_arg_in_grub_etc_default which has no user. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdumpctl | 96 ++----------------------- spec/kdumpctl_general_spec.sh | 67 ----------------- spec/kdumpctl_reset_crashkernel_spec.sh | 10 --- 3 files changed, 5 insertions(+), 168 deletions(-) diff --git a/kdumpctl b/kdumpctl index 113d8bc..6e4685f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1480,69 +1480,9 @@ _get_all_kernels_from_grubby() echo -n "$_kernels" } -GRUB_ETC_DEFAULT="/etc/default/grub" -# Update a kernel parameter in default grub conf -# -# If a value is specified, it will be inserted in the end. Otherwise it -# would remove given kernel parameter. -# -# Note this function doesn't address the following cases, -# 1. The kernel ignores everything on the command line after a '--'. So -# simply adding the new entry to the end will fail if the cmdline -# contains a --. -# 2. If the value for a parameter contains spaces it can be quoted using -# double quotes, for example param="value with spaces". This will -# break the [^[:space:]\"] regex for the value. -# 3. Dashes and underscores in the parameter name are equivalent. So -# some_parameter and some-parameter are identical. -# 4. Some parameters, e.g. efivar_ssdt, can be given multiple times. -# 5. Some kernel parameters, e.g. quiet, doesn't have value -# -# $1: the name of the kernel command line parameter -# $2: new value. If empty, given parameter would be removed -_update_kernel_arg_in_grub_etc_default() -{ - local _para=$1 _val=$2 _para_val - - if [[ $(uname -m) == s390x ]]; then - return - fi - - if [[ -n $_val ]]; then - _para_val="$_para=$_val" - fi - - # Update the command line /etc/default/grub, i.e. - # on the line that starts with 'GRUB_CMDLINE_LINUX=', - # 1) remove $para=$val if the it's the first arg - # 2) remove all occurences of $para=$val - # 3) insert $_para_val to end - # 4) remove duplicate spaces left over by 1) or 2) or 3) - # 5) remove space at the beginning of the string left over by 1) or 2) or 3) - # 6) remove space at the end of the string left over by 1) or 2) or 3) - sed -i -E "/^GRUB_CMDLINE_LINUX=/ { - s/\"${_para}=[^[:space:]\"]*/\"/g; - s/[[:space:]]+${_para}=[^[:space:]\"]*/ /g; - s/\"$/ ${_para_val}\"/ - s/[[:space:]]+/ /g; - s/(\")[[:space:]]+/\1/g; - s/[[:space:]]+(\")/\1/g; - }" "$GRUB_ETC_DEFAULT" -} - -# Read the kernel arg in default grub conf. - -# Note reading a kernel parameter that doesn't have a value isn't supported. -# -# $1: the name of the kernel command line parameter -_read_kernel_arg_in_grub_etc_default() -{ - sed -n -E "s/^GRUB_CMDLINE_LINUX=.*[[:space:]\"]${1}=([^[:space:]\"]*).*$/\1/p" "$GRUB_ETC_DEFAULT" -} - reset_crashkernel() { - local _opt _val _fadump_val _reboot _grubby_kernel_path _kernel _kernels + local _opt _val _reboot _grubby_kernel_path _kernel _kernels local _dump_mode _new_dump_mode local _has_changed _needs_reboot local _old_ck _new_ck @@ -1555,13 +1495,12 @@ reset_crashkernel() derror "Option --fadump only valid on PPC" exit 1 fi - _val=${_opt#*=} - if _dump_mode=$(get_dump_mode_by_fadump_val $_val); then - _fadump_val=$_val - else + _new_fadump=${_opt#*=} + if ! _dump_mode=$(get_dump_mode_by_fadump_val $_new_fadump); then derror "failed to determine dump mode" exit fi + [[ "$_new_fadump" == off ]] && _new_fadump="" ;; --kernel=*) _val=${_opt#*=} @@ -1598,29 +1537,6 @@ reset_crashkernel() [[ $(uname -m) != ppc64le ]] && _dump_mode=kdump - # If the dump mode is determined, we can also know the default crashkernel value - if [[ -n $_dump_mode ]]; then - _crashkernel=$(kdump_get_arch_recommend_crashkernel "$_dump_mode") - fi - - # If --kernel-path=ALL, update GRUB_CMDLINE_LINUX in /etc/default/grub. - # - # An exception case is when the ppc64le user doesn't specify the fadump value. - # In this case, the dump mode would be determined by parsing the kernel - # command line of the kernel(s) to be updated thus don't update GRUB_CMDLINE_LINUX. - # - # The following code has been simplified because of what has been done early, - # - set the dump mode as kdump for non-ppc64le cases - # - retrieved the default crashkernel value for given dump mode - if [[ $_grubby_kernel_path == ALL && -n $_dump_mode ]]; then - _update_kernel_arg_in_grub_etc_default crashkernel "$_crashkernel" - # remove the fadump if fadump is disabled - if [[ $_fadump_val == off ]]; then - _fadump_val="" - fi - _update_kernel_arg_in_grub_etc_default fadump "$_fadump_val" - fi - # If kernel-path not specified, either # - use KDUMP_KERNELVER if it's defined # - use current running kernel @@ -1638,15 +1554,13 @@ reset_crashkernel() _has_changed="" if [[ -z $_dump_mode ]]; then _new_dump_mode=$(get_dump_mode_by_kernel "$_kernel") - _new_ck=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") _new_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) else _new_dump_mode=$_dump_mode - _new_ck=$_crashkernel - _new_fadump=$_fadump_val fi _old_ck=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel) + _new_ck=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode") _old_fadump=$(get_grub_kernel_boot_parameter "$_kernel" fadump) if _update_kernel_cmdline "$_kernel" fadump "$_old_fadump" "$_new_fadump"; then _has_changed="Updated fadump=$_new_fadump" diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index 7304cd4..dcac2f8 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -155,73 +155,6 @@ Describe 'kdumpctl' End End - Describe '_update_kernel_arg_in_grub_etc_default()' - GRUB_ETC_DEFAULT=/tmp/default_grub - - cleanup() { - rm -rf "$GRUB_ETC_DEFAULT" - } - AfterAll 'cleanup' - - Context 'when the given parameter is in different positions' - Parameters - "crashkernel=222M fadump=on rhgb quiet" crashkernel 333M - " fadump=on crashkernel=222M rhgb quiet" crashkernel 333M - "fadump=on rhgb quiet crashkernel=222M" crashkernel 333M - "fadump=on rhgb quiet" crashkernel 333M - "fadump=on foo=bar1 rhgb quiet" foo bar2 - End - - It 'should update the kernel parameter correctly' - echo 'GRUB_CMDLINE_LINUX="'"$1"'"' >$GRUB_ETC_DEFAULT - When call _update_kernel_arg_in_grub_etc_default "$2" "$3" - # the updated kernel parameter should appear in the end - The contents of file $GRUB_ETC_DEFAULT should include "$2=$3\"" - End - End - - It 'should only update the given parameter and not update the parameter that has the given parameter as suffix' - echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT - _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M - When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val" - The contents of file $GRUB_ETC_DEFAULT should include "crashkernel=$_ck_val\"" - The contents of file $GRUB_ETC_DEFAULT should include "ckcrashkernel=222M" - End - - It 'should be able to handle the cases of there are multiple crashkernel entries' - echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet crashkernel=101M crashkernel=222M"' >$GRUB_ETC_DEFAULT - _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M - When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val" - The contents of file $GRUB_ETC_DEFAULT should include "crashkernel=$_ck_val\"" - The contents of file $GRUB_ETC_DEFAULT should not include "crashkernel=222M" - End - - Context 'when it removes a kernel parameter' - - It 'should remove all values for given arg' - echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M fadump=on crashkernel=222M"' >$GRUB_ETC_DEFAULT - When call _update_kernel_arg_in_grub_etc_default crashkernel - The contents of file $GRUB_ETC_DEFAULT should equal 'GRUB_CMDLINE_LINUX="fadump=on"' - End - - It 'should not remove args that have the given arg as suffix' - echo 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M crashkernel=11M ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT - When call _update_kernel_arg_in_grub_etc_default crashkernel - The contents of file $GRUB_ETC_DEFAULT should equal 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M ckcrashkernel=222M"' - End - End - - End - - Describe '_read_kernel_arg_in_grub_etc_default()' - GRUB_ETC_DEFAULT=/tmp/default_grub - It 'should read the value for given arg' - echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT - When call _read_kernel_arg_in_grub_etc_default crashkernel - The output should equal '11M' - End - End - Describe '_find_kernel_path_by_release()' grubby() { echo -e 'kernel="/boot/vmlinuz-6.2.11-200.fc37.x86_64"\nkernel="/boot/vmlinuz-5.14.0-322.el9.aarch64"\nkernel="/boot/vmlinuz-5.14.0-316.el9.aarch64+64k"' diff --git a/spec/kdumpctl_reset_crashkernel_spec.sh b/spec/kdumpctl_reset_crashkernel_spec.sh index 8fb4385..2e3b2ba 100644 --- a/spec/kdumpctl_reset_crashkernel_spec.sh +++ b/spec/kdumpctl_reset_crashkernel_spec.sh @@ -111,11 +111,6 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' fi } - _update_kernel_arg_in_grub_etc_default() { - # don't modify /etc/default/grub during the test - echo _update_kernel_arg_in_grub_etc_default "$@" - } - kdump_crashkernel=$(get_default_crashkernel kdump) fadump_crashkernel=$(get_default_crashkernel fadump) Context "when no --kernel specified" @@ -141,7 +136,6 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' grubby --args crashkernel=$ck --update-kernel ALL Specify 'kdumpctl should warn the user that crashkernel has been udpated' When call reset_crashkernel --kernel=ALL --fadump=on - The line 1 of output should include "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2" End @@ -200,8 +194,6 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' grubby --args fadump=on --update-kernel ALL Specify 'fadump=on to fadump=nocma' When call reset_crashkernel --kernel=ALL --fadump=nocma - The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" - The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump nocma" The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1" The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2" End @@ -213,8 +205,6 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' Specify 'fadump=nocma to fadump=on' When call reset_crashkernel --kernel=ALL --fadump=on - The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default crashkernel $fadump_crashkernel" - The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump on" The error should include "Updated fadump=on for kernel=$kernel1" End From 755ba199a77c464d4ba301725ba500f8397dfe42 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:44 +0200 Subject: [PATCH 733/806] kdump.conf: Remove option override_resettable When override_resettable was introduced in 2013 with 4b850d2 ("Check if block device as dump target is resettable") it was forgotten to add the new option to check_config (today the function is called parse_config). So if a user would have set override_resettable check_config would have returned an error ("Invalid kdump config option override_resettable") and starting the kdump service would have failed. As there has been no bug report in the last ~10 years it is safe to assume that the option was never used. Thus simply remove the option. Fixes: 4b850d2 ("Check if block device as dump target is resettable") Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- gen-kdump-conf.sh | 6 ------ kdump.conf.5 | 8 ------- mkdumprd | 55 ----------------------------------------------- 3 files changed, 69 deletions(-) diff --git a/gen-kdump-conf.sh b/gen-kdump-conf.sh index 4abcd39..a8e7fdd 100755 --- a/gen-kdump-conf.sh +++ b/gen-kdump-conf.sh @@ -157,12 +157,6 @@ generate() # force_no_rebuild and force_rebuild options are mutually # exclusive and they should not be set to 1 simultaneously. # -# override_resettable <0 | 1> -# - Usually an unresettable block device can't be a dump target. -# Specifying 1 when you want to dump even though the block -# target is unresettable -# By default, it is 0, which will not try dumping destined to fail. -# # dracut_args # - Pass extra dracut options when rebuilding kdump initrd. # diff --git a/kdump.conf.5 b/kdump.conf.5 index ec28552..9117aa7 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -218,14 +218,6 @@ force_no_rebuild and force_rebuild options are mutually exclusive and they should not be set to 1 simultaneously. .RE -.B override_resettable <0 | 1> -.RS -Usually an unresettable block device can't be a dump target. Specifying 1 means -that even though the block target is unresettable, the user wants to try dumping anyway. -By default, it's set to 0, which will not try something destined to fail. -.RE - - .B dracut_args .RS Kdump uses dracut to generate initramfs for second kernel. This option diff --git a/mkdumprd b/mkdumprd index 4feac28..31c4b76 100644 --- a/mkdumprd +++ b/mkdumprd @@ -24,7 +24,6 @@ fi SSH_KEY_LOCATION=$DEFAULT_SSHKEY SAVE_PATH=$(get_save_path) -OVERRIDE_RESETTABLE=0 extra_modules="" dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' --aggressive-strip -o "plymouth resume ifcfg earlykdump") @@ -309,56 +308,6 @@ handle_default_dump_target() check_size fs "$_target" } -# $1: function name -for_each_block_target() -{ - local dev majmin - - for dev in $(get_kdump_targets); do - [[ -b $dev ]] || continue - majmin=$(get_maj_min "$dev") - check_block_and_slaves "$1" "$majmin" && return 1 - done - - return 0 -} - -#judge if a specific device with $1 is unresettable -#return false if unresettable. -is_unresettable() -{ - local path device resettable=1 - - path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" - if [[ -f $path ]]; then - resettable="$(< "$path")" - [[ $resettable -eq 0 ]] && [[ $OVERRIDE_RESETTABLE -eq 0 ]] && { - device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') - derror "Error: Can not save vmcore because device $device is unresettable" - return 0 - } - fi - - return 1 -} - -#check if machine is resettable. -#return true if resettable -check_resettable() -{ - local _target _override_resettable - - _override_resettable=$(kdump_get_conf_val override_resettable) - OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE} - if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ]; then - perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid" - fi - - for_each_block_target is_unresettable && return - - return 1 -} - check_crypt() { local _dev @@ -370,10 +319,6 @@ check_crypt() done } -if ! check_resettable; then - exit 1 -fi - if ! check_crypt; then dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details." fi From 8e0b3598c1120b1ab182297c04be4c420760dbb1 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:45 +0200 Subject: [PATCH 734/806] spec: Clean up handling of dracut files Currently the dracut modules are first prepared in a temporary directory before they are moved to modules.d. All the preparation work can be done by a single call to 'install' per file. Thus get rid off the indirection and install the dracut modules directly to modules.d. While at it merge the three macros to remove the prefix into one. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kexec-tools.spec | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 897b6ff..a75c02c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -228,39 +228,28 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif -%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') -%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g') -%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g') +%define dracutdir %{_prefix}/lib/dracut/modules.d +%define remove_prefix() %(echo -n %2|sed 's/.*%1-//g') # deal with dracut modules -mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase -cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} -cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} -cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} -cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} -cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} -cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} -mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump -cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} -cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}} +mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase +install -m 755 %{SOURCE100} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE100}} +install -m 755 %{SOURCE101} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE101}} +install -m 644 %{SOURCE102} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE102}} +install -m 644 %{SOURCE104} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE104}} +install -m 644 %{SOURCE106} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE106}} +install -m 644 %{SOURCE107} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE107}} + +mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump +install -m 755 %{SOURCE108} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut %{SOURCE108}} +install -m 755 %{SOURCE109} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut-early-kdump %{SOURCE109}} + %ifarch ppc64 ppc64le -mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit -cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}} -cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}} -chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}} +mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit +install -m 755 %{SOURCE200} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE200}} +install -m 755 %{SOURCE201} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE201}} %endif - -%define dracutlibdir %{_prefix}/lib/dracut -#and move the custom dracut modules to the dracut directory -mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ -mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ - %post # Initial installation %systemd_post kdump.service @@ -363,7 +352,7 @@ fi %config %{_udevrulesdir} %{_udevrulesdir}/../kdump-udev-throttler %endif -%{dracutlibdir}/modules.d/* +%{dracutdir}/* %dir %{_localstatedir}/crash %dir %{_sysconfdir}/kdump %dir %{_sysconfdir}/kdump/pre.d From d89459c5ec701e2dec8d475a1e18a87893e3e23d Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:46 +0200 Subject: [PATCH 735/806] spec: Silence unversioned Obsolete warning rpmbuild throws a warning with line 80: It's not recommended to have unversioned Obsoletes: Obsoletes: diskdumputils netdump kexec-tools-eppic In that diskdump and netdump were last used in RHEL4 and kexec-tools-eppic was removed with Fedora 22. There is no supported update path in which a current package could replace one of these three. Thus simply drop the Obsoletes. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kexec-tools.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a75c02c..ef75fd0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -75,9 +75,6 @@ BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel b BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool -%ifarch %{ix86} x86_64 ppc64 ppc s390x ppc64le -Obsoletes: diskdumputils netdump kexec-tools-eppic -%endif %ifnarch s390x Requires: systemd-udev%{?_isa} From 64f2827a4bfa3f26974972f2f5a4477eec58f221 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:47 +0200 Subject: [PATCH 736/806] kdump-lib: Harden _crashkernel_add _crashkernel_add currently always assumes the good case, i.e. that the value of the crashkernel parameter has the correct syntax and that the delta added is a number. Both doesn't have to be true when the values are provided by users. Thus add some additional checks. Furthermore require the delta to have a explicit unit, i.e. no longer assume that is in megabytes, i.e. 100 -> 100M. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdump-lib.sh | 155 +++++++++++++++++++++++++++++------------ spec/kdump-lib_spec.sh | 38 ++++++---- 2 files changed, 134 insertions(+), 59 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 55c29bd..042ac87 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -853,62 +853,125 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 } -# $1 crashkernel="" -# $2 delta in unit of MB -_crashkernel_add() +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } + +# range defined for crashkernel parameter +# i.e. -[] +is_memrange() { - local _ck _add _entry _ret - local _range _size _offset + is_memsize "${1%-*}" || return 1 + [[ -n ${1#*-} ]] || return 0 + is_memsize "${1#*-}" +} - _ck="$1" - _add="$2" - _ret="" +to_bytes() +{ + local _s - if [[ "$_ck" == *@* ]]; then - _offset="@${_ck##*@}" - _ck=${_ck%@*} - elif [[ "$_ck" == *,high ]] || [[ "$_ck" == *,low ]]; then - _offset=",${_ck##*,}" - _ck=${_ck%,*} + _s="$1" + is_memsize "$_s" || return 1 + + case "${_s: -1}" in + K|k) + _s=${_s::-1} + _s="$((_s * 1024))" + ;; + M|m) + _s=${_s::-1} + _s="$((_s * 1024 * 1024))" + ;; + G|g) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024))" + ;; + *) + ;; + esac + echo "$_s" +} + +memsize_add() +{ + local -a units=("" "K" "M" "G") + local i a b + + a=$(to_bytes "$1") || return 1 + b=$(to_bytes "$2") || return 1 + i=0 + + (( a += b )) + while :; do + [[ $(( a / 1024 )) -eq 0 ]] && break + [[ $(( a % 1024 )) -ne 0 ]] && break + [[ $(( ${#units[@]} - 1 )) -eq $i ]] && break + + (( a /= 1024 )) + (( i += 1 )) + done + + echo "${a}${units[$i]}" +} + +_crashkernel_parse() +{ + local ck entry + local range size offset + + ck="$1" + + if [[ "$ck" == *@* ]]; then + offset="@${ck##*@}" + ck=${ck%@*} + elif [[ "$ck" == *,high ]] || [[ "$ck" == *,low ]]; then + offset=",${ck##*,}" + ck=${ck%,*} else - _offset='' + offset='' fi - while read -d , -r _entry; do - [[ -n "$_entry" ]] || continue - if [[ "$_entry" == *:* ]]; then - _range=${_entry%:*} - _size=${_entry#*:} + while read -d , -r entry; do + [[ -n "$entry" ]] || continue + if [[ "$entry" == *:* ]]; then + range=${entry%:*} + size=${entry#*:} else - _range="" - _size=${_entry} + range="" + size=${entry} fi - case "${_size: -1}" in - K) - _size=${_size::-1} - _size="$((_size + (_add * 1024)))K" - ;; - M) - _size=${_size::-1} - _size="$((_size + _add))M" - ;; - G) - _size=${_size::-1} - _size="$((_size * 1024 + _add))M" - ;; - *) - _size="$((_size + (_add * 1024 * 1024)))" - ;; - esac + echo "$size;$range;" + done <<< "$ck," + echo ";;$offset" +} - [[ -n "$_range" ]] && _ret+="$_range:" - _ret+="$_size," - done <<< "$_ck," +# $1 crashkernel command line parameter +# $2 size to be added +_crashkernel_add() +{ + local ck delta ret + local range size offset - _ret=${_ret%,} - [[ -n "$_offset" ]] && _ret+=$_offset - echo "$_ret" + ck="$1" + delta="$2" + ret="" + + while IFS=';' read -r size range offset; do + if [[ -n "$offset" ]]; then + ret="${ret%,}$offset" + break + fi + + [[ -n "$size" ]] || continue + if [[ -n "$range" ]]; then + is_memrange "$range" || return 1 + ret+="$range:" + fi + + size=$(memsize_add "$size" "$delta") || return 1 + ret+="$size," + done < <( _crashkernel_parse "$ck") + + echo "${ret%,}" } # get default crashkernel @@ -958,7 +1021,7 @@ kdump_get_arch_recommend_crashkernel() #4k kernel, mlx5 consumes extra 124M memory, and choose 150M has_mlx5 && ((_delta += 150)) fi - _ck_cmdline=$(_crashkernel_add "$_ck_cmdline" "$_delta") + _ck_cmdline=$(_crashkernel_add "$_ck_cmdline" "${_delta}M") elif [[ $_arch == "ppc64le" ]]; then if [[ $_dump_mode == "fadump" ]]; then _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 81f0f86..814f961 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -49,21 +49,33 @@ Describe 'kdump-lib' End Describe "_crashkernel_add()" - Context "when the input parameter is '1G-4G:256M,4G-64G:320M,64G-:576M'" - delta=100 + Context "For valid input values" Parameters - "1G-4G:256M,4G-64G:320M,64G-:576M" "1G-4G:356M,4G-64G:420M,64G-:676M" - "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" - "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" - "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" - "300M,high" "400M,high" - "300M,low" "400M,low" - "500M@1G" "600M@1G" + "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" + "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" + "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" + "1,high" "1" "2,high" + "1K,low" "1" "1025,low" + "1M@1G" "1k" "1025K@1G" + "500M@1G" "-100m" "400M@1G" + "1099511627776" "0" "1024G" End - It "should add delta to the values after ':'" - - When call _crashkernel_add "$1" "$delta" - The output should equal "$2" + It "should add delta to every value after ':'" + When call _crashkernel_add "$1" "$2" + The output should equal "$3" + End + End + Context "For invalid input values" + Parameters + "1G-4G:256M.4G-64G:320M" "100M" + "foo" "1" + "1" "bar" + End + It "shall return an error" + When call _crashkernel_add "$1" "$2" + The output should equal "" + The status should be failure End End End From 00c37d8c2c2d6112f9ff81eab2cfb930c0b0cac5 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:48 +0200 Subject: [PATCH 737/806] spec: Drop special handling for IA64 machines The two systems are IA64 based which is no longer supported by Fedora and was only supported in RHEL up to RHEL5. So it is safe to simply drop the special handling. In case it is still wanted nevertheless the special handling should be added to kdump-lib.sh:prepare_cmdline rather than editing the sysconfig in the spec file. Signed-off-by: Philipp Rudo --- kexec-tools.spec | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index ef75fd0..e51d496 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -258,28 +258,6 @@ servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/d servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null %endif -# This portion of the script is temporary. Its only here -# to fix up broken boxes that require special settings -# in /etc/sysconfig/kdump. It will be removed when -# These systems are fixed. - -if [ -d /proc/bus/mckinley ] -then - # This is for HP zx1 machines - # They require machvec=dig on the kernel command line - sed -e's/\(^KDUMP_COMMANDLINE_APPEND.*\)\("$\)/\1 machvec=dig"/' \ - /etc/sysconfig/kdump > /etc/sysconfig/kdump.new - mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump -elif [ -d /proc/sgi_sn ] -then - # This is for SGI SN boxes - # They require the --noio option to kexec - # since they don't support legacy io - sed -e's/\(^KEXEC_ARGS.*\)\("$\)/\1 --noio"/' \ - /etc/sysconfig/kdump > /etc/sysconfig/kdump.new - mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump -fi - %postun %systemd_postun_with_restart kdump.service From 2f52973feb59e9aee3a7d9dbac45b1fa1e513889 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:49 +0200 Subject: [PATCH 738/806] unit tests: Fix parse_config test case The test case for parse_config creates a default kdump.conf in the pwd. This fails when the pwd is read only. Thus move the default kdump.conf to /tmp just like it is done for the "bad" kdump.conf. This also allows to reuse the temporary file used for the "bad" case. Signed-off-by: Philipp Rudo --- spec/kdumpctl_general_spec.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index dcac2f8..243aeca 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -173,16 +173,14 @@ Describe 'kdumpctl' End Describe 'parse_config()' - bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) + KDUMP_CONFIG_FILE=$(mktemp -t kdump_conf.XXXXXXXXXX) cleanup() { - rm -f "$bad_kdump_conf" - rm -f kdump.conf + rm -f "$KDUMP_CONFIG_FILE" } AfterAll 'cleanup' It 'should not be happy with unkown option in kdump.conf' - KDUMP_CONFIG_FILE="$bad_kdump_conf" - echo blabla > "$bad_kdump_conf" + echo blabla > "$KDUMP_CONFIG_FILE" When call parse_config The status should be failure The stderr should include 'Invalid kdump config option blabla' @@ -191,10 +189,7 @@ Describe 'kdumpctl' Parameters:value aarch64 ppc64le s390x x86_64 It 'should be happy with the default kdump.conf' - ./gen-kdump-conf.sh "$1" > kdump.conf - # shellcheck disable=SC2034 - # override the KDUMP_CONFIG_FILE variable - KDUMP_CONFIG_FILE=./kdump.conf + ./gen-kdump-conf.sh "$1" > "$KDUMP_CONFIG_FILE" When call parse_config The status should be success End From 8bf11dc3f6e418d7513260eb5ab0fa8c63797b62 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 14 Sep 2023 15:27:48 +0800 Subject: [PATCH 739/806] unit tests: fix test failures "The param /boot/boot/vmlinuz-xxx is incorrect" Currently, some tests failed with "The param /boot/boot/vmlinuz-xxx is incorrect", for example, [root@fedora kexec-tools]# shellspec spec/kdumpctl_manage_reset_spec.sh Examples: 1) kdumpctl reset-crashkernel [--kernel] [--fadump] Test the kdump dump mode --kernel=ALL kdumpctl should warn the user that crashkernel has been udpated When call reset_crashkernel --kernel=ALL 1.1) The error should include Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64 expected "The param /boot/boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect The param /boot/boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-5.15.6-100.fc34.x86_64. Please reboot the system for the change to take effect. The param /boot/boot/vmlinuz-5.14.14-200.fc34.x86_64 is incorrect The param /boot/boot/vmlinuz-5.14.14-200.fc34.x86_64 is incorrect kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-5.14.14-200.fc34.x86_64. Please reboot the system for the change to take effect. The param /boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b is incorrect The param /boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b is incorrect kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b. Please reboot the system for the change to take effect." to include "Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64" # spec/kdumpctl_reset_crashkernel_spec.sh:69 This happens because when a system has a boot partition, grubby automatically prefixes a path with "/boot". The current boot loader entries used for tests already has the prefix "/boot" in the path and prefixing a path again will cause the above problem. grubby uses "mountpoint -q /boot" to tell if there is a boot partition. This patch mocks mountpoint so grubby knows the boot loader entries are for a system without a boot partition. Note this patch also avoids another error seen in the setup phase of the test "The param /boot/vmlinuz-xxx is incorrect". I believe this error is a bug of "grubby --update-kernel" in testing mode because running the grubby in normal mode actually works and "grubby --info=/boot/vmlinuz-*" also works in testing mode, [root@fedora support]# grubby --no-etc-grub-update --grub2 --bad-image-okay --env=grub_env -b boot_load_entries --args crashkernel=333M --update-kernel=/boot/vmlinuz-5.15.6-100.fc34.x86_64 The param /boot/vmlinuz-5.15.6-100.fc34.x86_64 is incorrect [root@fedora support]# grubby --no-etc-grub-update --grub2 --bad-image-okay --env=grub_env -b boot_load_entries --info=/boot/vmlinuz-5.15.6-100.fc34.x86_64 index=0 kernel="/boot/boot/vmlinuz-5.15.6-100.fc34.x86_64" [root@fedora support]]# grubby --args crashkernel=333M --update-kernel=/boot/vmlinuz-6.0.7-301.fc37.x86_64 && echo "succeed" succeed Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_manage_crashkernel_spec.sh | 8 +++++++- spec/kdumpctl_reset_crashkernel_spec.sh | 8 +++++++- spec/support/bin/@grubby | 3 --- 3 files changed, 14 insertions(+), 5 deletions(-) delete mode 100755 spec/support/bin/@grubby diff --git a/spec/kdumpctl_manage_crashkernel_spec.sh b/spec/kdumpctl_manage_crashkernel_spec.sh index bae3f31..3255d9a 100644 --- a/spec/kdumpctl_manage_crashkernel_spec.sh +++ b/spec/kdumpctl_manage_crashkernel_spec.sh @@ -42,6 +42,12 @@ Describe 'Management of the kernel crashkernel parameter.' rm -rf "$KDUMP_SPEC_TEST_RUN_DIR" } + # the boot loader entries are for a system without a boot partition, mock + # mountpoint to let grubby know it + Mock mountpoint + exit 1 + End + grubby() { # - --no-etc-grub-update, not update /etc/default/grub # - --bad-image-okay, don't check the validity of the image @@ -49,7 +55,7 @@ Describe 'Management of the kernel crashkernel parameter.' # the default /boot/grub2/grubenv # - --bls-directory, specify custom BootLoaderSpec config files to avoid # modifying the default /boot/loader/entries - @grubby --no-etc-grub-update --grub2 --config-file="$GRUB_CFG" --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" + /usr/sbin/grubby --no-etc-grub-update --grub2 --config-file="$GRUB_CFG" --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" } # The mocking breaks has_command. Mock it as well to fix the tests. diff --git a/spec/kdumpctl_reset_crashkernel_spec.sh b/spec/kdumpctl_reset_crashkernel_spec.sh index 2e3b2ba..88ff5a9 100644 --- a/spec/kdumpctl_reset_crashkernel_spec.sh +++ b/spec/kdumpctl_reset_crashkernel_spec.sh @@ -19,6 +19,12 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' BeforeAll 'setup' AfterAll 'cleanup' + # the boot loader entries are for a system without a boot partition, mock + # mountpoint to let grubby know it + Mock mountpoint + exit 1 + End + grubby() { # - --no-etc-grub-update, not update /etc/default/grub # - --bad-image-okay, don't check the validity of the image @@ -26,7 +32,7 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]' # the default /boot/grub2/grubenv # - --bls-directory, specify custom BootLoaderSpec config files to avoid # modifying the default /boot/loader/entries - @grubby --no-etc-grub-update --grub2 --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" + /usr/sbin/grubby --no-etc-grub-update --grub2 --bad-image-okay --env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b "$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@" } # The mocking breaks has_command. Mock it as well to fix the tests. diff --git a/spec/support/bin/@grubby b/spec/support/bin/@grubby deleted file mode 100755 index 2a9b33f..0000000 --- a/spec/support/bin/@grubby +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e -. "$SHELLSPEC_SUPPORT_BIN" -invoke grubby "$@" From fe6eb30e6756d3c13bb7485a08f066b18cd1594b Mon Sep 17 00:00:00 2001 From: Nayna Jain Date: Tue, 3 Oct 2023 23:41:46 -0400 Subject: [PATCH 740/806] powerpc: update kdumpctl to remove deletion of kernel signing key once loaded Kernel signing key is deleted once kdump is loaded. This causes confusion in debugging since key is no longer visible. Unless someone knows how kdumpctl script works, it is difficult to find out how kdump could be loaded when there is no key on .ima keyring. Remove deletion of kernel signing key once loaded. And then to prevent multiple loading of same key when kdump service is disabled/enabled, update key description field as well. Suggested-by: Mimi Zohar Signed-off-by: Nayna Jain Reviewed-by: Philipp Rudo --- kdumpctl | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/kdumpctl b/kdumpctl index 6e4685f..3d5d6dd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -678,19 +678,7 @@ function load_kdump_kernel_key() return fi - KDUMP_KEY_ID=$(keyctl padd asymmetric kernelkey-$RANDOM %:.ima < "/usr/share/doc/kernel-keys/$KDUMP_KERNELVER/kernel-signing-ppc.cer") -} - -# remove a previously loaded key. There's no real security implication -# to leaving it around, we choose to do this because it makes it easier -# to be idempotent and so as to reduce the potential for confusion. -function remove_kdump_kernel_key() -{ - if [[ -z $KDUMP_KEY_ID ]]; then - return - fi - - keyctl unlink "$KDUMP_KEY_ID" %:.ima + keyctl padd asymmetric "" %:.ima < "/usr/share/doc/kernel-keys/$KDUMP_KERNELVER/kernel-signing-ppc.cer" } # Load the kdump kernel specified in /etc/sysconfig/kdump @@ -742,8 +730,6 @@ load_kdump() set +x exec 2>&12 12>&- - remove_kdump_kernel_key - if [[ $ret == 0 ]]; then dinfo "kexec: loaded kdump kernel" return 0 From 4fa17b2ee4a6089cddd3c4b929840f4faf72ff98 Mon Sep 17 00:00:00 2001 From: Nayna Jain Date: Tue, 3 Oct 2023 23:41:47 -0400 Subject: [PATCH 741/806] powerpc: update kdumpctl to load kernel signing key for fadump On secure boot enabled systems with static keys, kexec with kexec_file_load(-s) fails as "Permission Denied" when fadump is enabled. Similar to kdump, load kernel signing key for fadump as well. Reported-by: Sachin P Bappalige Signed-off-by: Nayna Jain --- dracut-early-kdump.sh | 5 ----- kdump-lib.sh | 9 +++++++++ kdumpctl | 14 ++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 044f741..4fd8e90 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -45,11 +45,6 @@ early_kdump_load() EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") - if is_secure_boot_enforced; then - dinfo "Secure Boot is enabled. Using kexec file based syscall." - EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s" - fi - # Here, only output the messages, but do not save these messages # to a file because the target disk may not be mounted yet, the # earlykdump is too early. diff --git a/kdump-lib.sh b/kdump-lib.sh index 042ac87..ae39c23 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -501,6 +501,15 @@ prepare_kexec_args() fi fi fi + + # For secureboot enabled machines, use new kexec file based syscall. + # Old syscall will always fail as it does not have capability to do + # kernel signature verification. + if is_secure_boot_enforced; then + dinfo "Secure Boot is enabled. Using kexec file based syscall." + kexec_args="$kexec_args -s" + fi + echo "$kexec_args" } diff --git a/kdumpctl b/kdumpctl index 3d5d6dd..b6d5994 100755 --- a/kdumpctl +++ b/kdumpctl @@ -690,14 +690,6 @@ load_kdump() KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - # For secureboot enabled machines, use new kexec file based syscall. - # Old syscall will always fail as it does not have capability to - # to kernel signature verification. - if is_secure_boot_enforced; then - dinfo "Secure Boot is enabled. Using kexec file based syscall." - KEXEC_ARGS="$KEXEC_ARGS -s" - load_kdump_kernel_key - fi if is_uki "$KDUMP_KERNEL"; then uki=$KDUMP_KERNEL @@ -984,6 +976,12 @@ start_fadump() start_dump() { + # On secure boot enabled Power systems, load kernel signing key on .ima for signature + # verification using kexec file based syscall. + if [[ "$(uname -m)" == ppc64le ]] && is_secure_boot_enforced; then + load_kdump_kernel_key + fi + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then start_fadump else From 7af94019cf53b94919316cd786f9cbecf338a1da Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 10 Oct 2023 15:58:01 +0800 Subject: [PATCH 742/806] [packit] 2.0.27 upstream release Upstream tag: v2.0.27 Upstream commit: 2495ccfc --- 0001-kexec-tools-2.0.27.git.patch | 30 +++ 0002-build-fix-tarball-creation.patch | 43 +++++ ...ble-arm64-kexec_load-for-zboot-image.patch | 134 ++++++++++++++ ...oot-add-loongarch-kexec_load-support.patch | 171 ++++++++++++++++++ README.packit | 2 +- kexec-tools.spec | 15 ++ 6 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 0001-kexec-tools-2.0.27.git.patch create mode 100644 0002-build-fix-tarball-creation.patch create mode 100644 0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch create mode 100644 0004-zboot-add-loongarch-kexec_load-support.patch diff --git a/0001-kexec-tools-2.0.27.git.patch b/0001-kexec-tools-2.0.27.git.patch new file mode 100644 index 0000000..3939f62 --- /dev/null +++ b/0001-kexec-tools-2.0.27.git.patch @@ -0,0 +1,30 @@ +From 056c179cd3c2af0c3bd2762a8a3bfd1340278e9e Mon Sep 17 00:00:00 2001 +From: Simon Horman +Date: Fri, 1 Sep 2023 09:37:24 +0200 +Subject: [PATCH 1/4] kexec-tools 2.0.27.git + +Add .git to version so it doesn't look like a release. +This is just so when people build code from git it can +be identified as such from the version string. + +Signed-off-by: Simon Horman +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 192976c..352eefe 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4,7 +4,7 @@ dnl + dnl + + dnl ---Required +-AC_INIT(kexec-tools, 2.0.27) ++AC_INIT(kexec-tools, 2.0.27.git) + AC_CONFIG_AUX_DIR(./config) + AC_CONFIG_HEADERS([include/config.h]) + AC_LANG(C) +-- +2.41.0 + diff --git a/0002-build-fix-tarball-creation.patch b/0002-build-fix-tarball-creation.patch new file mode 100644 index 0000000..13837d3 --- /dev/null +++ b/0002-build-fix-tarball-creation.patch @@ -0,0 +1,43 @@ +From c3f35ff06e54daf452ac49a4381cf2643c934866 Mon Sep 17 00:00:00 2001 +From: Leah Neukirchen +Date: Mon, 28 Aug 2023 11:58:15 +0200 +Subject: [PATCH 2/4] build: fix tarball creation + +The fix in 41b77edac did not work, bsdtar still complains about +"hardlink pointing to itself". + +Simplify the code instead: since the staging directory contains +exactly the files we want, just package it as a whole. + +Signed-off-by: Leah Neukirchen +Signed-off-by: Simon Horman +--- + Makefile.in | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index 09bbd5c..3cad22a 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -179,8 +179,6 @@ GENERATED_SRCS:= $(SPEC) + TARBALL=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar + TARBALL.gz=$(TARBALL).gz + SRCS:= $(dist) +-PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) +-PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) + + MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE) + BINARIES_i386:=$(KEXEC_TEST) +@@ -223,8 +221,7 @@ $(TARBALL): $(SRCS) $(GENERATED_SRCS) + $(MKDIR) $(PACKAGE_NAME)-$(PACKAGE_VERSION) + $(TAR) -c $(SRCS) $(GENERATED_SRCS) | \ + $(TAR) -C $(PACKAGE_NAME)-$(PACKAGE_VERSION) -x +- $(TAR) -cf $@ $(PSRCS) +- $(TAR) -rf $@ $(PGSRCS) ++ $(TAR) -cf $@ $(PACKAGE_NAME)-$(PACKAGE_VERSION) + $(RM) -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION) + + $(TARBALL.gz): $(TARBALL) +-- +2.41.0 + diff --git a/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch b/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch new file mode 100644 index 0000000..86c8369 --- /dev/null +++ b/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch @@ -0,0 +1,134 @@ +From 8f08e3b51f25f585dc62f8e7aadc6095e06417cc Mon Sep 17 00:00:00 2001 +From: Dave Young +Date: Thu, 14 Sep 2023 16:49:59 +0800 +Subject: [PATCH 3/4] zboot: enable arm64 kexec_load for zboot image + +kexec_file_load support of zboot kernel image decompressed the vmlinuz, +so in kexec_load code just load the kernel with reading the decompressed +kernel fd into a new buffer and use it directly. + +Signed-off-by: Dave Young +Tested-by: Baoquan He +Reviewed-by: Pingfan Liu +Signed-off-by: Simon Horman +--- + include/kexec-pe-zboot.h | 3 ++- + kexec/arch/arm64/kexec-vmlinuz-arm64.c | 26 +++++++++++++++++++++++--- + kexec/kexec-pe-zboot.c | 4 +++- + kexec/kexec.c | 2 +- + kexec/kexec.h | 1 + + 5 files changed, 30 insertions(+), 6 deletions(-) + +diff --git a/include/kexec-pe-zboot.h b/include/kexec-pe-zboot.h +index e2e0448..374916c 100644 +--- a/include/kexec-pe-zboot.h ++++ b/include/kexec-pe-zboot.h +@@ -11,5 +11,6 @@ struct linux_pe_zboot_header { + uint32_t compress_type; + }; + +-int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd); ++int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd, ++ off_t *kernel_size); + #endif +diff --git a/kexec/arch/arm64/kexec-vmlinuz-arm64.c b/kexec/arch/arm64/kexec-vmlinuz-arm64.c +index c0ee47c..e291a34 100644 +--- a/kexec/arch/arm64/kexec-vmlinuz-arm64.c ++++ b/kexec/arch/arm64/kexec-vmlinuz-arm64.c +@@ -34,6 +34,7 @@ + #include "arch/options.h" + + static int kernel_fd = -1; ++static off_t decompressed_size; + + /* Returns: + * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format. +@@ -72,7 +73,7 @@ int pez_arm64_probe(const char *kernel_buf, off_t kernel_size) + return -1; + } + +- ret = pez_prepare(buf, buf_sz, &kernel_fd); ++ ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size); + + if (!ret) { + /* validate the arm64 specific header */ +@@ -98,8 +99,27 @@ bad_header: + int pez_arm64_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info) + { +- info->kernel_fd = kernel_fd; +- return image_arm64_load(argc, argv, buf, len, info); ++ if (kernel_fd > 0 && decompressed_size > 0) { ++ char *kbuf; ++ off_t nread; ++ int fd; ++ ++ info->kernel_fd = kernel_fd; ++ fd = dup(kernel_fd); ++ if (fd < 0) { ++ dbgprintf("%s: dup fd failed.\n", __func__); ++ return -1; ++ } ++ kbuf = slurp_fd(fd, NULL, decompressed_size, &nread); ++ if (!kbuf || nread != decompressed_size) { ++ dbgprintf("%s: slurp_fd failed.\n", __func__); ++ return -1; ++ } ++ return image_arm64_load(argc, argv, kbuf, decompressed_size, info); ++ } ++ ++ dbgprintf("%s: wrong kernel file descriptor.\n", __func__); ++ return -1; + } + + void pez_arm64_usage(void) +diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c +index 2f2e052..3abd17d 100644 +--- a/kexec/kexec-pe-zboot.c ++++ b/kexec/kexec-pe-zboot.c +@@ -37,7 +37,8 @@ + * + * crude_buf: the content, which is read from the kernel file without any processing + */ +-int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd) ++int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd, ++ off_t *kernel_size) + { + int ret = -1; + int fd = 0; +@@ -110,6 +111,7 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd) + goto fail_bad_header; + } + ++ *kernel_size = decompressed_size; + dbgprintf("%s: done\n", __func__); + + ret = 0; +diff --git a/kexec/kexec.c b/kexec/kexec.c +index c3b182e..1edbd34 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -489,7 +489,7 @@ static int add_backup_segments(struct kexec_info *info, + return 0; + } + +-static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread) ++char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread) + { + char *buf; + off_t progress; +diff --git a/kexec/kexec.h b/kexec/kexec.h +index ed3b499..0933389 100644 +--- a/kexec/kexec.h ++++ b/kexec/kexec.h +@@ -267,6 +267,7 @@ extern void die(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + extern void *xmalloc(size_t size); + extern void *xrealloc(void *ptr, size_t size); ++extern char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread); + extern char *slurp_file(const char *filename, off_t *r_size); + extern char *slurp_file_mmap(const char *filename, off_t *r_size); + extern char *slurp_file_len(const char *filename, off_t size, off_t *nread); +-- +2.41.0 + diff --git a/0004-zboot-add-loongarch-kexec_load-support.patch b/0004-zboot-add-loongarch-kexec_load-support.patch new file mode 100644 index 0000000..7a04237 --- /dev/null +++ b/0004-zboot-add-loongarch-kexec_load-support.patch @@ -0,0 +1,171 @@ +From 2495ccfc52069ecec46031587c94b03ae66ed5d2 Mon Sep 17 00:00:00 2001 +From: Dave Young +Date: Thu, 14 Sep 2023 16:50:00 +0800 +Subject: [PATCH 4/4] zboot: add loongarch kexec_load support + +Copy arm64 code and change for loongarch so that the kexec -c can load +a zboot image. +Note: probe zboot image first otherwise the pei-loongarch file type will +be used. + +Signed-off-by: Dave Young +Signed-off-by: Simon Horman +--- + kexec/arch/loongarch/Makefile | 1 + + kexec/arch/loongarch/image-header.h | 1 + + kexec/arch/loongarch/kexec-loongarch.c | 1 + + kexec/arch/loongarch/kexec-loongarch.h | 4 + + kexec/arch/loongarch/kexec-pez-loongarch.c | 90 ++++++++++++++++++++++ + 5 files changed, 97 insertions(+) + create mode 100644 kexec/arch/loongarch/kexec-pez-loongarch.c + +diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile +index 3b33b96..cee7e56 100644 +--- a/kexec/arch/loongarch/Makefile ++++ b/kexec/arch/loongarch/Makefile +@@ -6,6 +6,7 @@ loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-loongarch.c + loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pei-loongarch.c + loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-rel-loongarch.c + loongarch_KEXEC_SRCS += kexec/arch/loongarch/crashdump-loongarch.c ++loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pez-loongarch.c + + loongarch_MEM_REGIONS = kexec/mem_regions.c + +diff --git a/kexec/arch/loongarch/image-header.h b/kexec/arch/loongarch/image-header.h +index 3b75765..223d81f 100644 +--- a/kexec/arch/loongarch/image-header.h ++++ b/kexec/arch/loongarch/image-header.h +@@ -33,6 +33,7 @@ struct loongarch_image_header { + }; + + static const uint8_t loongarch_image_pe_sig[2] = {'M', 'Z'}; ++static const uint8_t loongarch_pe_machtype[6] = {'P','E', 0x0, 0x0, 0x64, 0x62}; + + /** + * loongarch_header_check_pe_sig - Helper to check the loongarch image header. +diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c +index f47c998..62ff8fd 100644 +--- a/kexec/arch/loongarch/kexec-loongarch.c ++++ b/kexec/arch/loongarch/kexec-loongarch.c +@@ -165,6 +165,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, + + struct file_type file_type[] = { + {"elf-loongarch", elf_loongarch_probe, elf_loongarch_load, elf_loongarch_usage}, ++ {"pez-loongarch", pez_loongarch_probe, pez_loongarch_load, pez_loongarch_usage}, + {"pei-loongarch", pei_loongarch_probe, pei_loongarch_load, pei_loongarch_usage}, + }; + int file_types = sizeof(file_type) / sizeof(file_type[0]); +diff --git a/kexec/arch/loongarch/kexec-loongarch.h b/kexec/arch/loongarch/kexec-loongarch.h +index 5120a26..2c7624f 100644 +--- a/kexec/arch/loongarch/kexec-loongarch.h ++++ b/kexec/arch/loongarch/kexec-loongarch.h +@@ -27,6 +27,10 @@ int pei_loongarch_probe(const char *buf, off_t len); + int pei_loongarch_load(int argc, char **argv, const char *buf, off_t len, + struct kexec_info *info); + void pei_loongarch_usage(void); ++int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size); ++int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len, ++ struct kexec_info *info); ++void pez_loongarch_usage(void); + + int loongarch_process_image_header(const struct loongarch_image_header *h); + +diff --git a/kexec/arch/loongarch/kexec-pez-loongarch.c b/kexec/arch/loongarch/kexec-pez-loongarch.c +new file mode 100644 +index 0000000..942a47c +--- /dev/null ++++ b/kexec/arch/loongarch/kexec-pez-loongarch.c +@@ -0,0 +1,90 @@ ++/* ++ * LoongArch PE compressed Image (vmlinuz, ZBOOT) support. ++ * Based on arm64 code ++ */ ++ ++#define _GNU_SOURCE ++#include ++#include ++#include ++#include "kexec.h" ++#include "kexec-loongarch.h" ++#include ++#include "arch/options.h" ++ ++static int kernel_fd = -1; ++static off_t decompressed_size; ++ ++/* Returns: ++ * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format. ++ */ ++int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size) ++{ ++ int ret = -1; ++ const struct loongarch_image_header *h; ++ char *buf; ++ off_t buf_sz; ++ ++ buf = (char *)kernel_buf; ++ buf_sz = kernel_size; ++ if (!buf) ++ return -1; ++ h = (const struct loongarch_image_header *)buf; ++ ++ dbgprintf("%s: PROBE.\n", __func__); ++ if (buf_sz < sizeof(struct loongarch_image_header)) { ++ dbgprintf("%s: Not large enough to be a PE image.\n", __func__); ++ return -1; ++ } ++ if (!loongarch_header_check_pe_sig(h)) { ++ dbgprintf("%s: Not an PE image.\n", __func__); ++ return -1; ++ } ++ ++ if (buf_sz < sizeof(struct loongarch_image_header) + h->pe_header) { ++ dbgprintf("%s: PE image offset larger than image.\n", __func__); ++ return -1; ++ } ++ ++ if (memcmp(&buf[h->pe_header], ++ loongarch_pe_machtype, sizeof(loongarch_pe_machtype))) { ++ dbgprintf("%s: PE header doesn't match machine type.\n", __func__); ++ return -1; ++ } ++ ++ ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size); ++ ++ /* Fixme: add sanity check of the decompressed kernel before return */ ++ return ret; ++} ++ ++int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len, ++ struct kexec_info *info) ++{ ++ if (kernel_fd > 0 && decompressed_size > 0) { ++ char *kbuf; ++ off_t nread; ++ ++ info->kernel_fd = kernel_fd; ++ /* ++ * slurp_fd will close kernel_fd, but it is safe here ++ * due to no kexec_file_load support. ++ */ ++ kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread); ++ if (!kbuf || nread != decompressed_size) { ++ dbgprintf("%s: slurp_fd failed.\n", __func__); ++ return -1; ++ } ++ return pei_loongarch_load(argc, argv, kbuf, decompressed_size, info); ++ } ++ ++ dbgprintf("%s: wrong kernel file descriptor.\n", __func__); ++ return -1; ++} ++ ++void pez_loongarch_usage(void) ++{ ++ printf( ++" An LoongArch vmlinuz, PE image of a compressed, little endian.\n" ++" kernel, built with ZBOOT enabled.\n\n"); ++} +-- +2.41.0 + diff --git a/README.packit b/README.packit index 159f693..daffcaa 100644 --- a/README.packit +++ b/README.packit @@ -1,3 +1,3 @@ This repository is maintained by packit. https://packit.dev/ -The file was generated using packit 0.79.0. +The file was generated using packit 0.80.0. diff --git a/kexec-tools.spec b/kexec-tools.spec index e51d496..67a6da6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -106,6 +106,18 @@ Requires: systemd-udev%{?_isa} # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch +# kexec-tools 2.0.27.git +# Author: Simon Horman +Patch602: 0001-kexec-tools-2.0.27.git.patch +# build: fix tarball creation +# Author: Leah Neukirchen +Patch603: 0002-build-fix-tarball-creation.patch +# zboot: enable arm64 kexec_load for zboot image +# Author: Dave Young +Patch604: 0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch +# zboot: add loongarch kexec_load support +# Author: Dave Young +Patch605: 0004-zboot-add-loongarch-kexec_load-support.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -360,6 +372,9 @@ fi %endif %changelog +* Tue Oct 10 2023 Coiby Xu - 2.0.27-1 +- kexec-tools 2.0.27 (Simon Horman) + * Thu Aug 31 2023 Coiby Xu - 2.0.27-1 - kexec-tools 2.0.27 (Simon Horman) From 5058cef90c2e24ff3a17a9c5560e16363e3281f5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 13 Oct 2023 11:00:07 +0800 Subject: [PATCH 743/806] Release 2.0.27-2 This release fixes https://datawarehouse.cki-project.org/kcidb/tests/9435999. Signed-off-by: Coiby Xu --- kexec-tools.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 67a6da6..d5740ef 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.27 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -134,6 +134,10 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch601 -p1 +%patch602 -p1 +%patch603 -p1 +%patch604 -p1 +%patch605 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -372,6 +376,9 @@ fi %endif %changelog +* Fri Oct 13 2023 Coiby Xu - 2.0.27-2 +- update to latest upstream kexec-tools + * Tue Oct 10 2023 Coiby Xu - 2.0.27-1 - kexec-tools 2.0.27 (Simon Horman) From 0ffce0ef4ef3414e9b44614de3281fa0fb42ca05 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 13 Oct 2023 17:49:56 +0800 Subject: [PATCH 744/806] Only try to reset crashkernel when kdump.service is enabled Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2243068 Currently, when kexec-tools is installed, the kernel will automatically have the crashkernel parameter set up. In the case where users only want the kexec reboot feature, this is not what users want as a 1G-RAM system will lose 192M memory. Considering Fedora's systemd preset policy has kdump.service disabled and RHEL' has kdump.service enabled, this patch makes kexec-tools only reset crashkernel when kdump.service is enabled. Reported-by: Chris Murphy Cc: Philipp Rudo Cc: Adam Williamson Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index b6d5994..01433e2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1649,6 +1649,10 @@ reset_crashkernel_for_installed_kernel() _update_crashkernel "$_installed_kernel" } +_should_reset_crashkernel() { + [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]] && systemctl is-enabled kdump &> /dev/null +} + main() { # Determine if the dump mode is kdump or fadump @@ -1715,12 +1719,12 @@ main() reset_crashkernel "$@" ;; _reset-crashkernel-after-update) - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then + if _should_reset_crashkernel; then reset_crashkernel_after_update fi ;; _reset-crashkernel-for-installed_kernel) - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then + if _should_reset_crashkernel; then reset_crashkernel_for_installed_kernel "$2" fi ;; From c9ac933cc20600b3d5792fe14226b54bcbc029e6 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 17 Oct 2023 13:54:48 +0800 Subject: [PATCH 745/806] Release 2.0.27-3 Signed-off-by: Coiby Xu --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index d5740ef..74422ee 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.27 -Release: 2%{?dist} +Release: 3%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -376,6 +376,9 @@ fi %endif %changelog +* Tue Oct 17 2023 Coiby Xu - 2.0.27-3 +- Only try to reset crashkernel when kdump.service is enabled + * Fri Oct 13 2023 Coiby Xu - 2.0.27-2 - update to latest upstream kexec-tools From 3d253ab81134d9f68d230aeeceb3158026b597aa Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 10 Oct 2023 14:31:36 +0800 Subject: [PATCH 746/806] Allow _crashkernel_add to address larger memory ranges Currently _crashkernel_add can't deal with larger memory ranges like terabyte. For example, '_crashkernel_add "128G-1T:4G" "0"' actually returns empty result. This patch allows _crashkernel_add to address terabyte, petabyte and exabyte memory ranges. Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu Acked-by: Baoquan He --- kdump-lib.sh | 16 ++++++++++++++-- spec/kdump-lib_spec.sh | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c23..9c1d9e1 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 } -is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; } # range defined for crashkernel parameter # i.e. -[] @@ -893,6 +893,18 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;; + T|t) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024))" + ;; + P|p) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; + E|e) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; *) ;; esac @@ -901,7 +913,7 @@ to_bytes() memsize_add() { - local -a units=("" "K" "M" "G") + local -a units=("" "K" "M" "G" "T" "P" "E") local i a b a=$(to_bytes "$1") || return 1 diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f961..f13372c 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,20 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M" "100" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low" + "128G-1T:4G" "0" "128G-1T:4G" + "10T-100T:1T" "0" "10T-100T:1T" + "128G-1T:4G" "0M" "128G-1T:4G" + "128G-1P:4G" "0M" "128G-1P:4G" + "128G-1E:4G" "0M" "128G-1E:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G" - "1099511627776" "0" "1024G" + "1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2" From 4841bc6a6dfe4d09640322f6703f60dbfe9f6f19 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Thu, 21 Sep 2023 18:01:02 +0800 Subject: [PATCH 747/806] kdump-lib.sh: add extra 64M to default crashkernel if sme/sev is active It's reported that kdump kernel failed to boot and can't dump vmcore when crashkernel=192M and SME/SEV is active. This is because swiotlb will be enabled and reserves 64M memory by default on system with SME/SEV enabled. Then kdump kernel will be out of memory after taking 64M away for swiotlb init. So here add extra 64M memory to default crashkernel value so that kdump kernel can function well as before. When doing that, search journalctl for the "Memory Encryption Features active: AMD" to check if SME or SEV is active. This line of log is printed out in kernel function as below and the type SME is mutual exclusive with type SEV. ***: arch/x86/mm/mem_encrypt.c:print_mem_encrypt_feature_info() Note: 1) The conditional check is relying on journalctl log because I didn't find available system interface to check if SEV is active. Even though we can check if SME is active via /proc/cpuinfo. For consistency, I take the same check for both SME and SEV by searching journalctl. 2) The conditional check is relying on journalctl log, means it won't work for crashkernel setting in anoconda because the installation kernel doesn't have the SME/SEV setting. So customer need manually run 'kdumpctl reset-crashkernel' to reset crashkernel to add the extra 64M after OS installation. 3) We need watch the line of log printing in print_mem_encrypt_feature_info() in kernel just in case people may change it in the future. Signed-off-by: Baoquan He Reviewed-by: Philipp Rudo --- kdump-lib.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 9c1d9e1..79714f9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -38,6 +38,11 @@ is_aws_aarch64() [[ "$(lscpu | grep "BIOS Model name")" =~ "AWS Graviton" ]] } +is_sme_or_sev_active() +{ + journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1 +} + is_squash_available() { local _version kmodule @@ -1001,6 +1006,7 @@ _crashkernel_add() kdump_get_arch_recommend_crashkernel() { local _arch _ck_cmdline _dump_mode + local _delta=0 if [[ -z "$1" ]]; then if is_fadump_capable; then @@ -1016,9 +1022,9 @@ kdump_get_arch_recommend_crashkernel() if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" + is_sme_or_sev_active && ((_delta += 64)) elif [[ $_arch == "aarch64" ]]; then local _running_kernel - local _delta=0 # Base line for 4K variant kernel. The formula is based on x86 plus extra = 64M _ck_cmdline="1G-4G:256M,4G-64G:320M,64G-:576M" @@ -1042,7 +1048,6 @@ kdump_get_arch_recommend_crashkernel() #4k kernel, mlx5 consumes extra 124M memory, and choose 150M has_mlx5 && ((_delta += 150)) fi - _ck_cmdline=$(_crashkernel_add "$_ck_cmdline" "${_delta}M") elif [[ $_arch == "ppc64le" ]]; then if [[ $_dump_mode == "fadump" ]]; then _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" @@ -1051,7 +1056,7 @@ kdump_get_arch_recommend_crashkernel() fi fi - echo -n "$_ck_cmdline" + echo -n "$(_crashkernel_add "$_ck_cmdline" "${_delta}M")" } # return recommended size based on current system RAM size From cb761c7224fc09c08731a8535eb4b44db010355c Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 8 Nov 2023 11:28:28 +0800 Subject: [PATCH 748/806] Release 2.0.27-4 Signed-off-by: Coiby Xu --- ...exclusion-of-slab-pages-on-Linux-6.2.patch | 81 ------------------- kexec-tools.spec | 11 ++- sources | 1 + 3 files changed, 8 insertions(+), 85 deletions(-) delete mode 100644 kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch diff --git a/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch b/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch deleted file mode 100644 index 5d91bc2..0000000 --- a/kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 5f17bdd2128998a3eeeb4521d136a192222fadb6 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Wed, 21 Dec 2022 11:06:39 +0900 -Subject: [PATCH] [PATCH] Fix wrong exclusion of slab pages on Linux 6.2-rc1 - -* Required for kernel 6.2 - -Kernel commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to -allow larger rcu_head"), which is contained in Linux 6.2-rc1 and later, -made the offset of slab.slabs equal to page.mapping's one. As a result, -"makedumpfile -d 8", which should exclude user data, excludes some slab -pages wrongly because isAnon() returns true when slab.slabs is an odd -number. With such dumpfiles, crash can fail to start session with an -error like this: - - # crash vmlinux dumpfile - ... - crash: page excluded: kernel virtual address: ffff8fa047ac2fe8 type: "xa_node shift" - -Make isAnon() check that the page is not slab to fix this. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 6 +++--- - makedumpfile.h | 9 +++------ - 2 files changed, 6 insertions(+), 9 deletions(-) - -diff --git a/makedumpfile-1.7.2/makedumpfile.c b/makedumpfile-1.7.2/makedumpfile.c -index ff821eb..f403683 100644 ---- a/makedumpfile-1.7.2/makedumpfile.c -+++ b/makedumpfile-1.7.2/makedumpfile.c -@@ -6502,7 +6502,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, - */ - else if ((info->dump_level & DL_EXCLUDE_CACHE) - && is_cache_page(flags) -- && !isPrivate(flags) && !isAnon(mapping)) { -+ && !isPrivate(flags) && !isAnon(mapping, flags)) { - pfn_counter = &pfn_cache; - } - /* -@@ -6510,7 +6510,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, - */ - else if ((info->dump_level & DL_EXCLUDE_CACHE_PRI) - && is_cache_page(flags) -- && !isAnon(mapping)) { -+ && !isAnon(mapping, flags)) { - if (isPrivate(flags)) - pfn_counter = &pfn_cache_private; - else -@@ -6522,7 +6522,7 @@ __exclude_unnecessary_pages(unsigned long mem_map, - * - hugetlbfs pages - */ - else if ((info->dump_level & DL_EXCLUDE_USER_DATA) -- && (isAnon(mapping) || isHugetlb(compound_dtor))) { -+ && (isAnon(mapping, flags) || isHugetlb(compound_dtor))) { - pfn_counter = &pfn_user; - } - /* -diff --git a/makedumpfile-1.7.2/makedumpfile.h b/makedumpfile-1.7.2/makedumpfile.h -index 70a1a91..21dec7d 100644 ---- a/makedumpfile-1.7.2/makedumpfile.h -+++ b/makedumpfile-1.7.2/makedumpfile.h -@@ -161,12 +161,9 @@ test_bit(int nr, unsigned long addr) - #define isSwapBacked(flags) test_bit(NUMBER(PG_swapbacked), flags) - #define isHWPOISON(flags) (test_bit(NUMBER(PG_hwpoison), flags) \ - && (NUMBER(PG_hwpoison) != NOT_FOUND_NUMBER)) -- --static inline int --isAnon(unsigned long mapping) --{ -- return ((unsigned long)mapping & PAGE_MAPPING_ANON) != 0; --} -+#define isSlab(flags) test_bit(NUMBER(PG_slab), flags) -+#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \ -+ && !isSlab(flags)) - - #define PTOB(X) (((unsigned long long)(X)) << PAGESHIFT()) - #define BTOP(X) (((unsigned long long)(X)) >> PAGESHIFT()) --- -2.39.0 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 74422ee..cb1a408 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,11 +1,11 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) -%global mkdf_ver 1.7.2 +%global mkdf_ver 1.7.4 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools Version: 2.0.27 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -105,7 +105,6 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # -Patch601: kexec-tools-2.0.26-makedumpfile-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch # kexec-tools 2.0.27.git # Author: Simon Horman Patch602: 0001-kexec-tools-2.0.27.git.patch @@ -133,7 +132,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch601 -p1 %patch602 -p1 %patch603 -p1 %patch604 -p1 @@ -376,6 +374,11 @@ fi %endif %changelog +* Wed Nov 08 2023 Coiby Xu - 2.0.27-4 +- update to makedumpfile-1.7.4 +- kdump-lib.sh: add extra 64M to default crashkernel if sme/sev is active +- Allow _crashkernel_add to address larger memory ranges + * Tue Oct 17 2023 Coiby Xu - 2.0.27-3 - Only try to reset crashkernel when kdump.service is enabled diff --git a/sources b/sources index 54a591c..fd41a48 100644 --- a/sources +++ b/sources @@ -1,3 +1,4 @@ SHA512 (kexec-tools-2.0.27.tar.xz) = 30b5ef7c2075dfd11fd1c3c33abe6b60673400257668d60145be08a2472356c7191a0810095da0fa32e327b9806a7578c73129ac0550d26c28ea6571c88c7b3c SHA512 (makedumpfile-1.7.2.tar.gz) = 324e303dd5f507703f66e2bd5dc9d24f9f50ba797be70c05702008ba77078f61ffcc884796ddf9ab737de1d124c3a9d881ab5ce4f3f459690ec00055af25ea9e SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 +SHA512 (makedumpfile-1.7.4.tar.gz) = 6c3455b711bd4e120173ee07fcc5ff708ae6d34eaee0f4c135eca7ee0e0475b4d391429c23cf68e848b156ee3edeab956e693a390d67ccc634c43224c7129a96 From 741861164e24247e995d47a8284b7493cb73b769 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 30 Oct 2023 14:51:59 +0800 Subject: [PATCH 749/806] kdumpctl: Only returns immediately after an error occurs in check_*_modified Currently is_system_modified will return immediately when check_*_modified return a non-zero value, and the remaining checks will not be executed. For example, if there is a fs-related error exists, and someone changes the kdump.conf, check_files_modified will return 1 and is_system_modified will return 1 immediately. This will cause kdumpctl to skip check_fs/drivers_modified, kdump.service will rebuild the initrd and start successfully, however, any errors should prevent kdump.service from starting. This patch will cause check_*_modifed to continue running until an error occurs or all execution ends. Signed-off-by: Lichen Liu Acked-by: Tao Liu --- kdumpctl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kdumpctl b/kdumpctl index 01433e2..3da5fff 100755 --- a/kdumpctl +++ b/kdumpctl @@ -605,6 +605,10 @@ check_fs_modified() is_system_modified() { local ret + local CONF_ERROR=2 + local CONF_MODIFY=1 + local CONF_NO_MODIFY=0 + local conf_status=$CONF_NO_MODIFY [[ -f $TARGET_INITRD ]] || return 1 @@ -617,9 +621,15 @@ is_system_modified() fi fi - check_files_modified || return - check_fs_modified || return - check_drivers_modified + for _func in check_files_modified check_fs_modified check_drivers_modified; do + $_func + ret=$? + # return immediately if an error occurred. + [[ $ret -eq "$CONF_ERROR" ]] && return "$ret" + [[ $ret -eq "$CONF_MODIFY" ]] && { conf_status="$CONF_MODIFY"; } + done + + return $conf_status } # need_initrd_rebuild - check whether the initrd needs to be rebuild From 0177e24832e8d3e5ea2e033c55b616bdd0cf3e9b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 7 Nov 2023 08:28:59 +0800 Subject: [PATCH 750/806] Use the same /etc/resolve.conf in kdump initrd if it's managed manually Resolves: https://issues.redhat.com/browse/RHEL-11897 Some users may choose to manage /etc/resolve.conf manually [1] by setting dns=none or use a symbolic link resolve.conf [2]. In this case, network dumping will not work because DNS resolution fails. Use the same /etc/resolve.conf in kdump initrd to fix this problem. [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd") Reported-by: Curtis Taylor Cc: Jie Li Signed-off-by: Coiby Xu Reviewed-by: Dave Young --- dracut-module-setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff53d08..ab6dc4f 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -563,6 +563,33 @@ kdump_collect_netif_usage() { fi } +kdump_install_resolv_conf() { + local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d + + # Some users may choose to manage /etc/resolve.conf manually [1] + # by setting dns=none or use a symbolic link resolve.conf [2]. + # So resolve.conf should be installed to kdump initrd as well. To prevent + # NM frome overwritting the user-configured resolve.conf in kdump initrd, + # also set dns=none for NM. + # + # Note: + # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a + # symbolic link. So exclude this case by teling if systemd-resolved is enabled. + # + # 2. It's harmless to blindly copy /etc/resolve.conf to the initrd because + # by default in initramfs this file will be overwritten by + # NetworkManager. If user manages it via a symbolic link, it's still + # preserved because NM won't touch a symbolic link file. + # + # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 + # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking + systemctl -q is-enabled systemd-resolved && return 0 + inst "$_resolv_conf" + if NetworkManager --print-config | grep -qs "^dns=none"; then + echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf + fi +} + # Setup dracut to bring up network interface that enable # initramfs accessing giving destination kdump_install_net() { @@ -575,6 +602,7 @@ kdump_install_net() { kdump_setup_znet kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" + kdump_install_resolv_conf fi } From bc31f6dd0fc5234eb62de884aa7a7a8686630d05 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 16 Nov 2023 10:19:19 +0800 Subject: [PATCH 751/806] Let %post scriptlet always exits with the zero exit status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2247940 Currently, CoreOS image fails to be built. This is because since commit 00c37d8c ("spec: Drop special handling for IA64 machines"), the last command is now servicelog_notify and it fails to run in such invocation environment. Thus the %post scriptlet returns a non-zero exit code which breaks package installation, Running scriptlet: kexec-tools-2.0.27-4.fc40.ppc64le /proc/ is not mounted. This is not a supported mode of operation. Please fix your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway. Your mileage may vary. servicelog_notify: is not supported on the Unknown platform warning: %post(kexec-tools-2.0.27-4.fc40.ppc64le) scriptlet failed, exit status 1 Error in POSTIN scriptlet in rpm package kexec-tools Quoting [1], > Non-zero exit codes from scriptlets can break installs/upgrades/erases > such that no further actions will be taken for that package in a > transaction (see Ordering), which may for example prevent an old version > of a package from being erased on upgrades, ... > > All scriptlets MUST exit with the zero exit status. Because RPM in its > default configuration does not execute shell scriptlets with the -e > argument to the shell, excluding explicit exit calls (frowned upon with > a non-zero argument!), the exit status of the last command in a > scriptlet determines its exit status... > > Usually the most important bit is to apply this to the last command > executed in a scriptlet, or to add a separate command such as plain “:” > or “exit 0” as the last one in a scriptlet. Following the above suggestion, add a separate command ":" as the last one to the %post scriptlet. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/ Reported-by: Colin Walters Cc: Dusty Mabe Cc: Philipp Rudo Fixes: 00c37d8c ("spec: Drop special handling for IA64 machines") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index cb1a408..19b0b69 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -271,6 +271,7 @@ touch /etc/kdump.conf servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null %endif +: %postun From 00d40c448b0368639681d482e86d382d1c65e6d9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 11 Dec 2023 18:17:57 +0800 Subject: [PATCH 752/806] Release 2.0.27-5 Signed-off-by: Coiby Xu --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 19b0b69..5040a4f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.27 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -375,6 +375,9 @@ fi %endif %changelog +* Mon Dec 11 2023 Coiby Xu - 2.0.27-5 +- Let %post scriptlet always exits with the zero exit status + * Wed Nov 08 2023 Coiby Xu - 2.0.27-4 - update to makedumpfile-1.7.4 - kdump-lib.sh: add extra 64M to default crashkernel if sme/sev is active From c752cbb2d393c9ae27475f184e2933ff65be50b1 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 6 Dec 2023 16:15:50 +0800 Subject: [PATCH 753/806] Explain the auto_reset_crashkernel option in more details Resolves: https://issues.redhat.com/browse/RHEL-17451 Explain what factors affect the default crashkernel value and ask users to reset it manually if needed. Cc: Baoquan He Cc: Jie Li Acked-by: Baoquan He Signed-off-by: Coiby Xu --- kdump.conf.5 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kdump.conf.5 b/kdump.conf.5 index 9117aa7..0e6ff21 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -29,7 +29,20 @@ understand how this configuration file affects the behavior of kdump. .B auto_reset_crashkernel .RS determine whether to reset kernel crashkernel parameter to the default value -or not when kexec-tools is updated or a new kernel is installed. +or not when kexec-tools is updated or a new kernel is installed. The default +crashkernel values are different for different architectures and also take the +following factors into consideration, + - AMD Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV) + - Mellanox 5th generation network driver + - aarch64 64k kernel + - Firmware-assisted dump (FADump) + +Since the kernel crasherkernel parameter will be only reset when kexec-tools is +updated or a new kernel is installed, you need to call "kdumpctl +reset-crashkernel [--kernel=path_to_kernel]" if you want to use the default +value set after having enabled features like SME/SEV for a specific kernel. And +you should also reboot the system for the new crashkernel value to take effect. +Also see kdumpctl(8). .B raw .RS From 38d9990389d80039964668a4db9cc9c039eac68f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 26 Dec 2023 11:17:29 +0800 Subject: [PATCH 754/806] Use the same /etc/resolve.conf in kdump initrd if it's managed manually Resolves: https://issues.redhat.com/browse/RHEL-11897 Previously fix 0177e248 ("Use the same /etc/resolve.conf in kdump initrd if it's managed manually") is problematic, 1) it generated .conf file unrecognized by NetowrkManager ; 2) this .conf file was installed to current file system instead of to the kdump initrd; 3) this incorrect .conf file prevented the starting of NetworkManager. This patch fixes the above issues and also suppresses a harmless warning when systemd-resolved.service doesn't exist, # systemctl -q is-enabled systemd-resolved Failed to get unit file state for systemd-resolved.service: No such file or directory Fixes: 0177e248 ("Use the same /etc/resolve.conf in kdump initrd if it's managed manually") Reported-by: Jie Li Cc: Dave Young Reviewed-by: Dave Young Signed-off-by: Coiby Xu --- dracut-module-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ab6dc4f..1dc88dc 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -583,10 +583,10 @@ kdump_install_resolv_conf() { # # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking - systemctl -q is-enabled systemd-resolved && return 0 + systemctl -q is-enabled systemd-resolved 2> /dev/null && return 0 inst "$_resolv_conf" if NetworkManager --print-config | grep -qs "^dns=none"; then - echo "[main]\ndns=none" > "$_nm_conf_dir"/90-dns-none.conf + printf "[main]\ndns=none\n" > "${initdir}/${_nm_conf_dir}"/90-dns-none.conf fi } From 0d90d580b4ff6e4fb7a09175bd7e6e35abbf6afd Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 9 Nov 2023 16:50:39 +0100 Subject: [PATCH 755/806] dracut-module-setup: consolidate s390 network device config (#1937048) This is a preparation for consolidating s390 network device config with https://github.com/dracutdevs/dracut/pull/2534 ("feat(znet): use zdev for consolidated device configuration") https://github.com/steffen-maier/s390utils/pull/1/commits ("znet: migrate to consolidated persistent device config with zdev (#1937046,#1937048))" ("znet: clean up old deprecated persistent device config (#1937046,#1937048)"). With above consolidation, s390-specific low-level configuration information will no longer be in NetworkManager connections (nor ifcfg files), but in the persistent configuration database of chzdev from s390-tools. Since the kdump dracut module here depends on the "znet" dracut module [1] and "znet" will copy all persistent configuration into initrd as of above commit, all s390-specific information would already be in the kdump initrd. [1] 08de71252814 ("Move some dracut module dependencies checks to module-setup.sh"), 7148c0a30dfc ("add s390x netdev setup") However, it is more appropriate and also removes the copy dependency from "znet" to introduce the consolidated zdev mechanism for importing just the required network device config from the current active system configuration. It does not depend on any of the pull requests above. It does not depend on any existing persistent configuration and can replace the old function code. This is similar to dracut block device dependency handling in s390-tools zdev/dracut/95zdev-kdump. The old code only seems to work if there is exactly one s390-specific nmconnection (or ifcfg file). Related commits: b5577c163aff ("Simplify setup_znet by copying connection profile to initrd"), 7d472515688f ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet"), 8b08b4f17ba0 ("Set up s390 znet cmdline by "nmcli --get-values""), ce0305d4f95c ("Add a new option 'rd.znet_ifname' in order to use it in udev rules"), 7148c0a30dfc ("add s390x netdev setup"). A bonding or teaming setup would have multiple following network interfaces, each of which would need a low-level config if they're s390 channel-attached network devices. The new code should be able to handle that by iterating the involved network interfaces. Chzdev only exports something if it's a device type it deems itself responsible for. Additional debugging output can be generated with e.g. dracut option "--stdlog 5" (or short -L5). It shows the chzdev export result, the output of chzdev export and import, and an overview of the resulting persistent config within the initrd. On systems, which default to using dracut option "--quiet", you might need an additional "--verbose" to counter "--quiet" so -L5 has effect. Typically combined with "--debug" to get a shell trace from building an initrd (Note: --debug does not increase the log levels). Signed-off-by: Steffen Maier Reviewed-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-module-setup.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1dc88dc..01efdeb 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -26,6 +26,9 @@ check() { if [[ -z $IN_KDUMP ]] || [[ ! -f /etc/kdump.conf ]]; then return 1 fi + if [[ "$(uname -m)" == "s390x" ]]; then + require_binaries chzdev || return 1 + fi return 0 } @@ -474,6 +477,8 @@ _find_znet_nmconnection() { # # Note part of code is extracted from ccw_init provided by s390utils kdump_setup_znet() { + local _netif + local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX) local _config_file _unique_name _NM_conf_dir local __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' @@ -481,6 +486,18 @@ kdump_setup_znet() { return fi + for _netif in $1; do + chzdev --export "$_tempfile" --active --by-interface "$_netif" \ + 2>&1 | ddebug + sed -i -e 's/^\[active /\[persistent /' "$_tempfile" + ddebug < "$_tempfile" + chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ + --yes --no-root-update --force 2>&1 | ddebug + lszdev --configured --persistent --info --by-interface "$_netif" \ + --base "/etc=$initdir/etc" 2>&1 | ddebug + done + rm -f "$_tempfile" + _NM_conf_dir="/etc/NetworkManager/system-connections" _config_file=$(_find_znet_nmconnection "$initdir/$_NM_conf_dir" "$__sed_discard_ignored_files") @@ -599,7 +616,7 @@ kdump_install_net() { if [[ -n "$_netifs" ]]; then kdump_install_nmconnections apply_nm_initrd_generator_timeouts - kdump_setup_znet + kdump_setup_znet "$_netifs" kdump_install_nm_netif_allowlist "$_netifs" kdump_install_nic_driver "$_netifs" kdump_install_resolv_conf From 73c9eb71e9a1709f86b7683e0c532067900608c8 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Thu, 9 Nov 2023 16:50:40 +0100 Subject: [PATCH 756/806] dracut-module-setup: remove old s390 network device config (#1937048) Since the previous commit reworks znet configuration to be based on the active system configuration, there is no dependency on any existing persistent configuration any more. Hence the old code handling systems with exactly one s390-specific nmconnection as persistent configuration can be removed. Migration of the old persistent device configuration mechanism with nmconnections (or ifcfg) to zdev is handled independently in s390utils. [https://github.com/steffen-maier/s390utils/pull/1/commits ("znet: migrate to consolidated persistent device config with zdev (#1937046,#1937048))"] Signed-off-by: Steffen Maier Reviewed-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-module-setup.sh | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 01efdeb..e39bc13 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -467,20 +467,10 @@ kdump_setup_vlan() { _save_kdump_netifs "$_parent_netif" } -_find_znet_nmconnection() { - LANG=C grep -s -E -i -l \ - "^s390-subchannels=([0-9]\.[0-9]\.[a-f0-9]+;){0,2}" \ - "$1"/*.nmconnection | LC_ALL=C sed -e "$2" -} - # setup s390 znet -# -# Note part of code is extracted from ccw_init provided by s390utils kdump_setup_znet() { local _netif local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX) - local _config_file _unique_name _NM_conf_dir - local __sed_discard_ignored_files='/\(~\|\.bak\|\.old\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' if [[ "$(uname -m)" != "s390x" ]]; then return @@ -497,32 +487,6 @@ kdump_setup_znet() { --base "/etc=$initdir/etc" 2>&1 | ddebug done rm -f "$_tempfile" - - _NM_conf_dir="/etc/NetworkManager/system-connections" - - _config_file=$(_find_znet_nmconnection "$initdir/$_NM_conf_dir" "$__sed_discard_ignored_files") - if [[ -n "$_config_file" ]]; then - ddebug "$_config_file has already contained the znet config" - return - fi - - _config_file=$(LANG=C grep -s -E -i -l \ - "^[[:space:]]*SUBCHANNELS=['\"]?([0-9]\.[0-9]\.[a-f0-9]+,){0,2}" \ - /etc/sysconfig/network-scripts/ifcfg-* \ - | LC_ALL=C sed -e "$__sed_discard_ignored_files") - - if [[ -z "$_config_file" ]]; then - _config_file=$(_find_znet_nmconnection "$_NM_conf_dir" "$__sed_discard_ignored_files") - fi - - if [[ -n "$_config_file" ]]; then - _unique_name=$(cat /proc/sys/kernel/random/uuid) - nmcli connection clone --temporary "$_config_file" "$_unique_name" &> >(ddebug) - nmcli connection modify --temporary "$_unique_name" connection.autoconnect false - inst "/run/NetworkManager/system-connections/${_unique_name}.nmconnection" "${_NM_conf_dir}/${_unique_name}.nmconnection" - nmcli connection del "$_unique_name" &> >(ddebug) - fi - } kdump_get_remote_ip() { From d78cab14bce98f4c6dfac295fe9e97b21c14e0c3 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 17 Jan 2024 13:46:51 +0800 Subject: [PATCH 757/806] 2.0.28 upstream release Upstream tag: v2.0.28 Upstream commit: adef8a8e Signed-off-by: Coiby Xu --- 0001-kexec-tools-2.0.27.git.patch | 30 --- 0002-build-fix-tarball-creation.patch | 43 ----- ...ble-arm64-kexec_load-for-zboot-image.patch | 134 -------------- ...oot-add-loongarch-kexec_load-support.patch | 171 ------------------ README.packit | 2 +- kexec-tools.spec | 25 +-- sources | 3 +- 7 files changed, 9 insertions(+), 399 deletions(-) delete mode 100644 0001-kexec-tools-2.0.27.git.patch delete mode 100644 0002-build-fix-tarball-creation.patch delete mode 100644 0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch delete mode 100644 0004-zboot-add-loongarch-kexec_load-support.patch diff --git a/0001-kexec-tools-2.0.27.git.patch b/0001-kexec-tools-2.0.27.git.patch deleted file mode 100644 index 3939f62..0000000 --- a/0001-kexec-tools-2.0.27.git.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 056c179cd3c2af0c3bd2762a8a3bfd1340278e9e Mon Sep 17 00:00:00 2001 -From: Simon Horman -Date: Fri, 1 Sep 2023 09:37:24 +0200 -Subject: [PATCH 1/4] kexec-tools 2.0.27.git - -Add .git to version so it doesn't look like a release. -This is just so when people build code from git it can -be identified as such from the version string. - -Signed-off-by: Simon Horman ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 192976c..352eefe 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -4,7 +4,7 @@ dnl - dnl - - dnl ---Required --AC_INIT(kexec-tools, 2.0.27) -+AC_INIT(kexec-tools, 2.0.27.git) - AC_CONFIG_AUX_DIR(./config) - AC_CONFIG_HEADERS([include/config.h]) - AC_LANG(C) --- -2.41.0 - diff --git a/0002-build-fix-tarball-creation.patch b/0002-build-fix-tarball-creation.patch deleted file mode 100644 index 13837d3..0000000 --- a/0002-build-fix-tarball-creation.patch +++ /dev/null @@ -1,43 +0,0 @@ -From c3f35ff06e54daf452ac49a4381cf2643c934866 Mon Sep 17 00:00:00 2001 -From: Leah Neukirchen -Date: Mon, 28 Aug 2023 11:58:15 +0200 -Subject: [PATCH 2/4] build: fix tarball creation - -The fix in 41b77edac did not work, bsdtar still complains about -"hardlink pointing to itself". - -Simplify the code instead: since the staging directory contains -exactly the files we want, just package it as a whole. - -Signed-off-by: Leah Neukirchen -Signed-off-by: Simon Horman ---- - Makefile.in | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/Makefile.in b/Makefile.in -index 09bbd5c..3cad22a 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -179,8 +179,6 @@ GENERATED_SRCS:= $(SPEC) - TARBALL=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar - TARBALL.gz=$(TARBALL).gz - SRCS:= $(dist) --PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) --PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s)) - - MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE) - BINARIES_i386:=$(KEXEC_TEST) -@@ -223,8 +221,7 @@ $(TARBALL): $(SRCS) $(GENERATED_SRCS) - $(MKDIR) $(PACKAGE_NAME)-$(PACKAGE_VERSION) - $(TAR) -c $(SRCS) $(GENERATED_SRCS) | \ - $(TAR) -C $(PACKAGE_NAME)-$(PACKAGE_VERSION) -x -- $(TAR) -cf $@ $(PSRCS) -- $(TAR) -rf $@ $(PGSRCS) -+ $(TAR) -cf $@ $(PACKAGE_NAME)-$(PACKAGE_VERSION) - $(RM) -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION) - - $(TARBALL.gz): $(TARBALL) --- -2.41.0 - diff --git a/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch b/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch deleted file mode 100644 index 86c8369..0000000 --- a/0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 8f08e3b51f25f585dc62f8e7aadc6095e06417cc Mon Sep 17 00:00:00 2001 -From: Dave Young -Date: Thu, 14 Sep 2023 16:49:59 +0800 -Subject: [PATCH 3/4] zboot: enable arm64 kexec_load for zboot image - -kexec_file_load support of zboot kernel image decompressed the vmlinuz, -so in kexec_load code just load the kernel with reading the decompressed -kernel fd into a new buffer and use it directly. - -Signed-off-by: Dave Young -Tested-by: Baoquan He -Reviewed-by: Pingfan Liu -Signed-off-by: Simon Horman ---- - include/kexec-pe-zboot.h | 3 ++- - kexec/arch/arm64/kexec-vmlinuz-arm64.c | 26 +++++++++++++++++++++++--- - kexec/kexec-pe-zboot.c | 4 +++- - kexec/kexec.c | 2 +- - kexec/kexec.h | 1 + - 5 files changed, 30 insertions(+), 6 deletions(-) - -diff --git a/include/kexec-pe-zboot.h b/include/kexec-pe-zboot.h -index e2e0448..374916c 100644 ---- a/include/kexec-pe-zboot.h -+++ b/include/kexec-pe-zboot.h -@@ -11,5 +11,6 @@ struct linux_pe_zboot_header { - uint32_t compress_type; - }; - --int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd); -+int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd, -+ off_t *kernel_size); - #endif -diff --git a/kexec/arch/arm64/kexec-vmlinuz-arm64.c b/kexec/arch/arm64/kexec-vmlinuz-arm64.c -index c0ee47c..e291a34 100644 ---- a/kexec/arch/arm64/kexec-vmlinuz-arm64.c -+++ b/kexec/arch/arm64/kexec-vmlinuz-arm64.c -@@ -34,6 +34,7 @@ - #include "arch/options.h" - - static int kernel_fd = -1; -+static off_t decompressed_size; - - /* Returns: - * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format. -@@ -72,7 +73,7 @@ int pez_arm64_probe(const char *kernel_buf, off_t kernel_size) - return -1; - } - -- ret = pez_prepare(buf, buf_sz, &kernel_fd); -+ ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size); - - if (!ret) { - /* validate the arm64 specific header */ -@@ -98,8 +99,27 @@ bad_header: - int pez_arm64_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info) - { -- info->kernel_fd = kernel_fd; -- return image_arm64_load(argc, argv, buf, len, info); -+ if (kernel_fd > 0 && decompressed_size > 0) { -+ char *kbuf; -+ off_t nread; -+ int fd; -+ -+ info->kernel_fd = kernel_fd; -+ fd = dup(kernel_fd); -+ if (fd < 0) { -+ dbgprintf("%s: dup fd failed.\n", __func__); -+ return -1; -+ } -+ kbuf = slurp_fd(fd, NULL, decompressed_size, &nread); -+ if (!kbuf || nread != decompressed_size) { -+ dbgprintf("%s: slurp_fd failed.\n", __func__); -+ return -1; -+ } -+ return image_arm64_load(argc, argv, kbuf, decompressed_size, info); -+ } -+ -+ dbgprintf("%s: wrong kernel file descriptor.\n", __func__); -+ return -1; - } - - void pez_arm64_usage(void) -diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c -index 2f2e052..3abd17d 100644 ---- a/kexec/kexec-pe-zboot.c -+++ b/kexec/kexec-pe-zboot.c -@@ -37,7 +37,8 @@ - * - * crude_buf: the content, which is read from the kernel file without any processing - */ --int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd) -+int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd, -+ off_t *kernel_size) - { - int ret = -1; - int fd = 0; -@@ -110,6 +111,7 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd) - goto fail_bad_header; - } - -+ *kernel_size = decompressed_size; - dbgprintf("%s: done\n", __func__); - - ret = 0; -diff --git a/kexec/kexec.c b/kexec/kexec.c -index c3b182e..1edbd34 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -489,7 +489,7 @@ static int add_backup_segments(struct kexec_info *info, - return 0; - } - --static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread) -+char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread) - { - char *buf; - off_t progress; -diff --git a/kexec/kexec.h b/kexec/kexec.h -index ed3b499..0933389 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -267,6 +267,7 @@ extern void die(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - extern void *xmalloc(size_t size); - extern void *xrealloc(void *ptr, size_t size); -+extern char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread); - extern char *slurp_file(const char *filename, off_t *r_size); - extern char *slurp_file_mmap(const char *filename, off_t *r_size); - extern char *slurp_file_len(const char *filename, off_t size, off_t *nread); --- -2.41.0 - diff --git a/0004-zboot-add-loongarch-kexec_load-support.patch b/0004-zboot-add-loongarch-kexec_load-support.patch deleted file mode 100644 index 7a04237..0000000 --- a/0004-zboot-add-loongarch-kexec_load-support.patch +++ /dev/null @@ -1,171 +0,0 @@ -From 2495ccfc52069ecec46031587c94b03ae66ed5d2 Mon Sep 17 00:00:00 2001 -From: Dave Young -Date: Thu, 14 Sep 2023 16:50:00 +0800 -Subject: [PATCH 4/4] zboot: add loongarch kexec_load support - -Copy arm64 code and change for loongarch so that the kexec -c can load -a zboot image. -Note: probe zboot image first otherwise the pei-loongarch file type will -be used. - -Signed-off-by: Dave Young -Signed-off-by: Simon Horman ---- - kexec/arch/loongarch/Makefile | 1 + - kexec/arch/loongarch/image-header.h | 1 + - kexec/arch/loongarch/kexec-loongarch.c | 1 + - kexec/arch/loongarch/kexec-loongarch.h | 4 + - kexec/arch/loongarch/kexec-pez-loongarch.c | 90 ++++++++++++++++++++++ - 5 files changed, 97 insertions(+) - create mode 100644 kexec/arch/loongarch/kexec-pez-loongarch.c - -diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile -index 3b33b96..cee7e56 100644 ---- a/kexec/arch/loongarch/Makefile -+++ b/kexec/arch/loongarch/Makefile -@@ -6,6 +6,7 @@ loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-loongarch.c - loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pei-loongarch.c - loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-rel-loongarch.c - loongarch_KEXEC_SRCS += kexec/arch/loongarch/crashdump-loongarch.c -+loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pez-loongarch.c - - loongarch_MEM_REGIONS = kexec/mem_regions.c - -diff --git a/kexec/arch/loongarch/image-header.h b/kexec/arch/loongarch/image-header.h -index 3b75765..223d81f 100644 ---- a/kexec/arch/loongarch/image-header.h -+++ b/kexec/arch/loongarch/image-header.h -@@ -33,6 +33,7 @@ struct loongarch_image_header { - }; - - static const uint8_t loongarch_image_pe_sig[2] = {'M', 'Z'}; -+static const uint8_t loongarch_pe_machtype[6] = {'P','E', 0x0, 0x0, 0x64, 0x62}; - - /** - * loongarch_header_check_pe_sig - Helper to check the loongarch image header. -diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c -index f47c998..62ff8fd 100644 ---- a/kexec/arch/loongarch/kexec-loongarch.c -+++ b/kexec/arch/loongarch/kexec-loongarch.c -@@ -165,6 +165,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - - struct file_type file_type[] = { - {"elf-loongarch", elf_loongarch_probe, elf_loongarch_load, elf_loongarch_usage}, -+ {"pez-loongarch", pez_loongarch_probe, pez_loongarch_load, pez_loongarch_usage}, - {"pei-loongarch", pei_loongarch_probe, pei_loongarch_load, pei_loongarch_usage}, - }; - int file_types = sizeof(file_type) / sizeof(file_type[0]); -diff --git a/kexec/arch/loongarch/kexec-loongarch.h b/kexec/arch/loongarch/kexec-loongarch.h -index 5120a26..2c7624f 100644 ---- a/kexec/arch/loongarch/kexec-loongarch.h -+++ b/kexec/arch/loongarch/kexec-loongarch.h -@@ -27,6 +27,10 @@ int pei_loongarch_probe(const char *buf, off_t len); - int pei_loongarch_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info); - void pei_loongarch_usage(void); -+int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size); -+int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info); -+void pez_loongarch_usage(void); - - int loongarch_process_image_header(const struct loongarch_image_header *h); - -diff --git a/kexec/arch/loongarch/kexec-pez-loongarch.c b/kexec/arch/loongarch/kexec-pez-loongarch.c -new file mode 100644 -index 0000000..942a47c ---- /dev/null -+++ b/kexec/arch/loongarch/kexec-pez-loongarch.c -@@ -0,0 +1,90 @@ -+/* -+ * LoongArch PE compressed Image (vmlinuz, ZBOOT) support. -+ * Based on arm64 code -+ */ -+ -+#define _GNU_SOURCE -+#include -+#include -+#include -+#include "kexec.h" -+#include "kexec-loongarch.h" -+#include -+#include "arch/options.h" -+ -+static int kernel_fd = -1; -+static off_t decompressed_size; -+ -+/* Returns: -+ * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format. -+ */ -+int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size) -+{ -+ int ret = -1; -+ const struct loongarch_image_header *h; -+ char *buf; -+ off_t buf_sz; -+ -+ buf = (char *)kernel_buf; -+ buf_sz = kernel_size; -+ if (!buf) -+ return -1; -+ h = (const struct loongarch_image_header *)buf; -+ -+ dbgprintf("%s: PROBE.\n", __func__); -+ if (buf_sz < sizeof(struct loongarch_image_header)) { -+ dbgprintf("%s: Not large enough to be a PE image.\n", __func__); -+ return -1; -+ } -+ if (!loongarch_header_check_pe_sig(h)) { -+ dbgprintf("%s: Not an PE image.\n", __func__); -+ return -1; -+ } -+ -+ if (buf_sz < sizeof(struct loongarch_image_header) + h->pe_header) { -+ dbgprintf("%s: PE image offset larger than image.\n", __func__); -+ return -1; -+ } -+ -+ if (memcmp(&buf[h->pe_header], -+ loongarch_pe_machtype, sizeof(loongarch_pe_machtype))) { -+ dbgprintf("%s: PE header doesn't match machine type.\n", __func__); -+ return -1; -+ } -+ -+ ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size); -+ -+ /* Fixme: add sanity check of the decompressed kernel before return */ -+ return ret; -+} -+ -+int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info) -+{ -+ if (kernel_fd > 0 && decompressed_size > 0) { -+ char *kbuf; -+ off_t nread; -+ -+ info->kernel_fd = kernel_fd; -+ /* -+ * slurp_fd will close kernel_fd, but it is safe here -+ * due to no kexec_file_load support. -+ */ -+ kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread); -+ if (!kbuf || nread != decompressed_size) { -+ dbgprintf("%s: slurp_fd failed.\n", __func__); -+ return -1; -+ } -+ return pei_loongarch_load(argc, argv, kbuf, decompressed_size, info); -+ } -+ -+ dbgprintf("%s: wrong kernel file descriptor.\n", __func__); -+ return -1; -+} -+ -+void pez_loongarch_usage(void) -+{ -+ printf( -+" An LoongArch vmlinuz, PE image of a compressed, little endian.\n" -+" kernel, built with ZBOOT enabled.\n\n"); -+} --- -2.41.0 - diff --git a/README.packit b/README.packit index daffcaa..d529207 100644 --- a/README.packit +++ b/README.packit @@ -1,3 +1,3 @@ This repository is maintained by packit. https://packit.dev/ -The file was generated using packit 0.80.0. +The file was generated using packit 0.87.1. diff --git a/kexec-tools.spec b/kexec-tools.spec index 5040a4f..e1b0bff 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -4,8 +4,8 @@ %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools -Version: 2.0.27 -Release: 5%{?dist} +Version: 2.0.28 +Release: 1%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -105,18 +105,6 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # -# kexec-tools 2.0.27.git -# Author: Simon Horman -Patch602: 0001-kexec-tools-2.0.27.git.patch -# build: fix tarball creation -# Author: Leah Neukirchen -Patch603: 0002-build-fix-tarball-creation.patch -# zboot: enable arm64 kexec_load for zboot image -# Author: Dave Young -Patch604: 0003-zboot-enable-arm64-kexec_load-for-zboot-image.patch -# zboot: add loongarch kexec_load support -# Author: Dave Young -Patch605: 0004-zboot-add-loongarch-kexec_load-support.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -132,10 +120,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch602 -p1 -%patch603 -p1 -%patch604 -p1 -%patch605 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -375,6 +359,11 @@ fi %endif %changelog +* Wed Jan 17 2024 Coiby Xu - 2.0.28-1 +- kexec-tools 2.0.28 (Simon Horman) +- Use the same /etc/resolve.conf in kdump initrd if it's managed manually +- dracut-module-setup: consolidate s390 network device config + * Mon Dec 11 2023 Coiby Xu - 2.0.27-5 - Let %post scriptlet always exits with the zero exit status diff --git a/sources b/sources index fd41a48..61c3db7 100644 --- a/sources +++ b/sources @@ -1,4 +1,3 @@ -SHA512 (kexec-tools-2.0.27.tar.xz) = 30b5ef7c2075dfd11fd1c3c33abe6b60673400257668d60145be08a2472356c7191a0810095da0fa32e327b9806a7578c73129ac0550d26c28ea6571c88c7b3c -SHA512 (makedumpfile-1.7.2.tar.gz) = 324e303dd5f507703f66e2bd5dc9d24f9f50ba797be70c05702008ba77078f61ffcc884796ddf9ab737de1d124c3a9d881ab5ce4f3f459690ec00055af25ea9e +SHA512 (kexec-tools-2.0.28.tar.xz) = 889a7bf1d26bb309e4ff7ce1c8dbcf48c01e47221ea3acf1c4ef2a98a652c496e31bddcdb627d3adebd85f7541d1fb9122c60e741e10b3726e31a9733cadc753 SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763 SHA512 (makedumpfile-1.7.4.tar.gz) = 6c3455b711bd4e120173ee07fcc5ff708ae6d34eaee0f4c135eca7ee0e0475b4d391429c23cf68e848b156ee3edeab956e693a390d67ccc634c43224c7129a96 From 753e5060d7b6ed5c5f81b14cbdd139f56b99216a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 21 Jan 2024 00:15:51 +0000 Subject: [PATCH 758/806] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index e1b0bff..c4c1664 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -359,6 +359,9 @@ fi %endif %changelog +* Sun Jan 21 2024 Fedora Release Engineering - 2.0.28-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Wed Jan 17 2024 Coiby Xu - 2.0.28-1 - kexec-tools 2.0.28 (Simon Horman) - Use the same /etc/resolve.conf in kdump initrd if it's managed manually From 6943de2cdcdb23534654ddaa883e42bdd4adc33d Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Fri, 5 Jan 2024 14:40:12 +0800 Subject: [PATCH 759/806] Print error msg when forget to specify user for ssh target Resolves: https://issues.redhat.com/browse/FC-1046 We require that be explicitly specified in 'ssh @'. When forgetting to specify, such as 'ssh 192.168.10.2', a useful error log should be printed instead of exiting directly. Signed-off-by: Lichen Liu Reviewed-by: Philipp Rudo --- kdumpctl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kdumpctl b/kdumpctl index 3da5fff..45277a7 100755 --- a/kdumpctl +++ b/kdumpctl @@ -748,7 +748,12 @@ check_ssh_config() [[ "${OPT[_fstype]}" == ssh ]] || return 0 target=$(ssh -G "${OPT[_target]}" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p") - [[ ${OPT[_target]} =~ .*@.* ]] || return 1 + + if [[ ${OPT[_target]} != *@* ]]; then + derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh @' and that it is properly formatted." + return 1 + fi + if [[ ${OPT[_target]#*@} != "$target" ]]; then derror "Invalid ssh destination ${OPT[_target]} provided." return 1 From 468336700df86b52cd673d68561ba460ff2390be Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Mon, 22 Jan 2024 15:59:09 +0800 Subject: [PATCH 760/806] dracut-module-setup: Skip initrd-cleanup and initrd-parse-etc in kdump When using multipath devices as the target for kdump, if user_friendly_name is also specified, devices default to names like "mpath*", e.g., mpatha. In dracut, we obtain a persistent device name via get_persistent_dev. However, dracut currently believes using /dev/mapper/mpath* could cause issues, thus alternatively names are used, here it's /dev/disk/by-uuid/. During the kdump boot progress, the /dev/disk/by-uuid/ will exist as soon as one of the path devices exists, but it won't be usable by systemd, since multipathd will claim that device as a path device. Then multipathd will get stopped before it can create the multipath device. Without user_friendly_name, /dev/mapper/ is considered a persistent device name, avoiding the issue. The exit of multipathd is due to two dependencies in the current dracut module 90multipath/multipathd.service, "Before=initrd-cleanup.service" and "Conflicts=initrd-cleanup.service". As per man 5 systemd.unit, if A.service has "Conflicts=B.service", starting B.service will stop A.service. This is useful during normal boot. However, we will never switch-root after capturing vmcore in kdump. We need to ensure that multipathd is not killed due to such dependency issue. Without modifying multipathd.service, we add ConditionPathExists=!/proc/vmcore to skip initrd-cleanup.service in kdump. This approach is beneficial as it avoid the potential termination of other services that conflict with initrd-cleanup.service. Also skip initrd-parse-etc.service as it will try to start initrd-cleanup.service. Both of these services are used for switch root, so they can be safely skipped in kdump. Suggested-by: Benjamin Marzinski Suggested-by: Dave Young Signed-off-by: Lichen Liu Reviewed-by: Philipp Rudo --- dracut-module-setup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e39bc13..daa6b26 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1070,6 +1070,15 @@ install() { 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ "${initdir}/etc/lvm/lvm.conf" &> /dev/null + # Skip initrd-cleanup.service and initrd-parse-etc.service becasue we don't + # need to switch root. Instead of removing them, we use ConditionPathExists + # to check if /proc/vmcore exists to determine if we are in kdump. + sed -i '/\[Unit\]/a ConditionPathExists=!\/proc\/vmcore' \ + "${initdir}/${systemdsystemunitdir}/initrd-cleanup.service" &> /dev/null + + sed -i '/\[Unit\]/a ConditionPathExists=!\/proc\/vmcore' \ + "${initdir}/${systemdsystemunitdir}/initrd-parse-etc.service" &> /dev/null + # Save more memory by dropping switch root capability dracut_no_switch_root } From 95f086ca9f24ee7b07ed74921b05e9c1c01e8fe3 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 24 Jan 2024 23:55:58 +0000 Subject: [PATCH 761/806] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index c4c1664..c15c994 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 2%{?dist} +Release: 3%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -359,6 +359,9 @@ fi %endif %changelog +* Wed Jan 24 2024 Fedora Release Engineering - 2.0.28-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Sun Jan 21 2024 Fedora Release Engineering - 2.0.28-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 97b3b962a956b16ea21424c7d24630c657a59845 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 4 Nov 2023 12:26:27 +0800 Subject: [PATCH 762/806] Get rid of "grep: warning: stray \ before /" Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2242185 grep (3.8) warnings when running the unit tests or running "kdumpctl reset-crashkernel" on >= F39, # unit tests Examples: 1) kdumpctl _find_kernel_path_by_release() returns the kernel path for the given release When call _find_kernel_path_by_release vmlinuz-6.2.11-200.fc37.x86_64 1.1) WARNING: There was output to stderr but not found expectation stderr: grep: warning: stray \ before / # spec/kdumpctl_general_spec.sh:169-172 # kdumpctl reset-crashkernel grep: warning: stray \ before / kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-6.6.8-200.fc39.x86_64. Please reboot the system for the change to take effect. This warning can be reproduced by echo 'kernel="/boot/vmlinuz-6.4.6-200.fc38.x86_64"' | grep -E "^kernel=.*$_release(\/\w+)?\"$" This patch removes unneeded backslash. It also adds a test for systemd-boot path. And for simplification, Parameters:dynamic is now used to generate test data dynamically. Fixes: 8af05dc4 ("kdumpctl: Add support for systemd-boot paths") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 2 +- spec/kdumpctl_general_spec.sh | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/kdumpctl b/kdumpctl index 45277a7..30eb27d 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1412,7 +1412,7 @@ _find_kernel_path_by_release() # Insert '/' before '+' to cope with grep's EREs _release=${_release//+/\\+} - _grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(\/\w+)?\"$") + _grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(/\w+)?\"$") _kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str") if [[ -z $_kernel_path ]]; then ddebug "kernel $_release doesn't exist" diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index 243aeca..b8a871c 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -156,16 +156,32 @@ Describe 'kdumpctl' End Describe '_find_kernel_path_by_release()' + # When the array length changes, the Parameters:dynamic should change as well + kernel_paths=(/boot/vmlinuz-6.2.11-200.fc37.x86_64 + /boot/vmlinuz-5.14.0-316.el9.aarch64+64k + /boot/vmlinuz-5.14.0-322.el9.aarch64 + /boot/efi/36b54597c46383/6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64/linux) + + kernels=(vmlinuz-6.2.11-200.fc37.x86_64 + vmlinuz-5.14.0-316.el9.aarch64+64k + vmlinuz-5.14.0-322.el9.aarch64 + 6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64) + grubby() { - echo -e 'kernel="/boot/vmlinuz-6.2.11-200.fc37.x86_64"\nkernel="/boot/vmlinuz-5.14.0-322.el9.aarch64"\nkernel="/boot/vmlinuz-5.14.0-316.el9.aarch64+64k"' + for key in "${!kernel_paths[@]}"; do + echo "kernel=\"${kernel_paths[$key]}\"" + done } - Parameters - # parameter answer - vmlinuz-6.2.11-200.fc37.x86_64 /boot/vmlinuz-6.2.11-200.fc37.x86_64 - vmlinuz-5.14.0-322.el9.aarch64 /boot/vmlinuz-5.14.0-322.el9.aarch64 - vmlinuz-5.14.0-316.el9.aarch64+64k /boot/vmlinuz-5.14.0-316.el9.aarch64+64k + Parameters:dynamic + # Due to a bug [1] in shellspec, hardcode the loop number instead of using the + # array length + # [1] https://github.com/shellspec/shellspec/issues/259 + for key in {0..3}; do + %data "${kernels[$key]}" "${kernel_paths[$key]}" + done End + It 'returns the kernel path for the given release' When call _find_kernel_path_by_release "$1" The output should equal "$2" From 2974fa3f262ad1ad262da33dd26eee2c1e7bfdb7 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 30 Jan 2024 01:54:05 +0800 Subject: [PATCH 763/806] kdump-dep-generator: source kdump-lib-initramfs.sh instead Currently kdump-dep-generator will source kdump-lib.sh. Notice kdump-dep-generator have #!/bin/sh so it should be POSIX, but kdump-lib.sh is a non-POSIX bash script. When Bash is configured to run in POSIX mode for #!/bin/sh scripts, it will fail with: /usr/lib/kdump/kdump-lib.sh: line 1042: syntax error near unexpected token `<' /usr/lib/kdump/kdump-lib.sh: line 1042: ` done < <( _crashkernel_parse "$ck")' This subshell call is easy to convert into a pipe but we should just source kdump-lib-initramfs.sh here, the only thing kdump-dep-generator needs is is_ssh_dump_target which is in kdump-lib-initramfs.sh, also prevents further POSIX violations. Signed-off-by: Kairui Song Reviewed-by: Philipp Rudo --- kdump-dep-generator.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump-dep-generator.sh b/kdump-dep-generator.sh index f48c8f6..70ae621 100644 --- a/kdump-dep-generator.sh +++ b/kdump-dep-generator.sh @@ -3,7 +3,7 @@ # More details about systemd generator: # http://www.freedesktop.org/wiki/Software/systemd/Generators/ -. /usr/lib/kdump/kdump-lib.sh +. /usr/lib/kdump/kdump-lib-initramfs.sh . /usr/lib/kdump/kdump-logger.sh # If invokded with no arguments for testing purpose, output to /tmp to From 4eec72b56b89c72dde1fae681423301e1830f9e2 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 2 Feb 2024 19:39:18 +0800 Subject: [PATCH 764/806] 2.0.28 upstream release Upstream tag: v2.0.28 Upstream commit: 328de8e0 Signed-off-by: Coiby Xu --- README.packit | 2 +- ...uilding-on-x86_64-with-binutils-2.41.patch | 92 +++++++++++++++++++ ...xec-don-t-use-kexec_file_load-on-XEN.patch | 60 ++++++++++++ kexec-tools.spec | 14 ++- 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch create mode 100644 kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch diff --git a/README.packit b/README.packit index d529207..00a8c4d 100644 --- a/README.packit +++ b/README.packit @@ -1,3 +1,3 @@ This repository is maintained by packit. https://packit.dev/ -The file was generated using packit 0.87.1. +The file was generated using packit 0.89.0. diff --git a/kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch b/kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch new file mode 100644 index 0000000..60b15f3 --- /dev/null +++ b/kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch @@ -0,0 +1,92 @@ +From 328de8e00e298f00d7ba6b25dc3950147e9642e6 Mon Sep 17 00:00:00 2001 +From: Michel Lind +Date: Tue, 30 Jan 2024 04:14:31 -0600 +Subject: [PATCH 2/2] Fix building on x86_64 with binutils 2.41 + +Newer versions of the GNU assembler (observed with binutils 2.41) will +complain about the ".arch i386" in files assembled with "as --64", +with the message "Error: 64bit mode not supported on 'i386'". + +Fix by moving ".arch i386" below the relevant ".code32" directive, so +that the assembler is no longer expecting 64-bit instructions to be used +by the time that the ".arch i386" directive is encountered. + +Based on similar iPXE fix: +https://github.com/ipxe/ipxe/commit/6ca597eee + +Signed-off-by: Michel Lind +Signed-off-by: Simon Horman +--- + purgatory/arch/i386/entry32-16-debug.S | 2 +- + purgatory/arch/i386/entry32-16.S | 2 +- + purgatory/arch/i386/entry32.S | 2 +- + purgatory/arch/i386/setup-x86.S | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/purgatory/arch/i386/entry32-16-debug.S b/purgatory/arch/i386/entry32-16-debug.S +index 5167944..12e1164 100644 +--- a/purgatory/arch/i386/entry32-16-debug.S ++++ b/purgatory/arch/i386/entry32-16-debug.S +@@ -25,10 +25,10 @@ + .globl entry16_debug_pre32 + .globl entry16_debug_first32 + .globl entry16_debug_old_first32 +- .arch i386 + .balign 16 + entry16_debug: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S +index c051aab..eace095 100644 +--- a/purgatory/arch/i386/entry32-16.S ++++ b/purgatory/arch/i386/entry32-16.S +@@ -20,10 +20,10 @@ + #undef i386 + .text + .globl entry16, entry16_regs +- .arch i386 + .balign 16 + entry16: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +diff --git a/purgatory/arch/i386/entry32.S b/purgatory/arch/i386/entry32.S +index f7a494f..8ce9e31 100644 +--- a/purgatory/arch/i386/entry32.S ++++ b/purgatory/arch/i386/entry32.S +@@ -20,10 +20,10 @@ + #undef i386 + + .text +- .arch i386 + .globl entry32, entry32_regs + entry32: + .code32 ++ .arch i386 + + /* Setup a gdt that should that is generally usefully */ + lgdt %cs:gdt +diff --git a/purgatory/arch/i386/setup-x86.S b/purgatory/arch/i386/setup-x86.S +index 201bb2c..a212eed 100644 +--- a/purgatory/arch/i386/setup-x86.S ++++ b/purgatory/arch/i386/setup-x86.S +@@ -21,10 +21,10 @@ + #undef i386 + + .text +- .arch i386 + .globl purgatory_start + purgatory_start: + .code32 ++ .arch i386 + + /* Load a gdt so I know what the segment registers are */ + lgdt %cs:gdt +-- +2.43.0 + diff --git a/kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch b/kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch new file mode 100644 index 0000000..2af234b --- /dev/null +++ b/kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch @@ -0,0 +1,60 @@ +From 94fbe64fb22d61726ca0c0996987574b6c783c19 Mon Sep 17 00:00:00 2001 +From: Jiri Bohac +Date: Tue, 16 Jan 2024 18:14:31 +0100 +Subject: [PATCH 1/2] kexec: don't use kexec_file_load on XEN + +Since commit 29fe5067ed07 ("kexec: make -a the default") +kexec tries the kexec_file_load syscall first and only falls back to kexec_load on +selected error codes. + +This effectively breaks kexec on XEN, unless -c is pecified to force the kexec_load +syscall. + +The XEN-specific functions (xen_kexec_load / xen_kexec_unload) are only called +from my_load / k_unload, i.e. the kexec_load code path. + +With -p (panic kernel) kexec_file_load on XEN fails with -EADDRNOTAVAIL (crash +kernel reservation is ignored by the kernel on XEN), which is not in the list +of return codes that cause the fallback to kexec_file. + +Without -p kexec_file_load actualy leads to a kernel oops on v6.4.0 +(needs to be dubugged separately). + +Signed-off-by: Jiri Bohac +Fixes: 29fe5067ed07 ("kexec: make -a the default") +Signed-off-by: Simon Horman +--- + kexec/kexec.8 | 1 + + kexec/kexec.c | 4 ++++ + 2 files changed, 5 insertions(+) + +diff --git a/kexec/kexec.8 b/kexec/kexec.8 +index b969cea..9e995fe 100644 +--- a/kexec/kexec.8 ++++ b/kexec/kexec.8 +@@ -162,6 +162,7 @@ Specify that the new kernel is of this + .TP + .BI \-s\ (\-\-kexec-file-syscall) + Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. ++Ignored on XEN. + .TP + .BI \-c\ (\-\-kexec-syscall) + Specify that the old KEXEC_LOAD syscall should be used exclusively. +diff --git a/kexec/kexec.c b/kexec/kexec.c +index 08edfca..9d0ec46 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -1685,6 +1685,10 @@ int main(int argc, char *argv[]) + } + } + } ++ if (xen_present()) { ++ do_kexec_file_syscall = 0; ++ do_kexec_fallback = 0; ++ } + if (do_kexec_file_syscall) { + if (do_load_jump_back_helper && !do_kexec_fallback) + die("--load-jump-back-helper not supported with kexec_file_load\n"); +-- +2.43.0 + diff --git a/kexec-tools.spec b/kexec-tools.spec index c15c994..af24741 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -89,6 +89,9 @@ Requires: systemd-udev%{?_isa} # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # +# Fix building on x86_64 with binutils 2.41 +# Author: Michel Lind +Patch101: kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -105,6 +108,9 @@ Requires: systemd-udev%{?_isa} # # Patches 601 onward are generic patches # +# kexec: don't use kexec_file_load on XEN +# Author: Jiri Bohac +Patch601: kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -120,6 +126,8 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} +%patch 101 -p1 +%patch 601 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -359,6 +367,10 @@ fi %endif %changelog +* Fri Feb 02 2024 Coiby Xu - 2.0.28-4 +- kexec: don't use kexec_file_load on XEN +- Fix building on x86_64 with binutils 2.41 + * Wed Jan 24 2024 Fedora Release Engineering - 2.0.28-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From ec3bccdf326881decd13f0ac7b4558f4a22875bd Mon Sep 17 00:00:00 2001 From: Carl George Date: Fri, 23 Feb 2024 16:32:28 -0600 Subject: [PATCH 765/806] Add a makedumpfile subpackage --- kexec-tools.spec | 72 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index af24741..6104e46 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -60,7 +60,7 @@ Source201: dracut-fadump-module-setup.sh Requires(post): servicelog Recommends: keyutils %endif -Requires(pre): coreutils sed zlib +Requires(pre): coreutils sed Requires: dracut >= 058 Requires: dracut-network >= 058 Requires: dracut-squash >= 058 @@ -71,8 +71,6 @@ Recommends: binutils Recommends: grubby Recommends: hostname BuildRequires: make -BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel -BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-rpm-macros BuildRequires: automake autoconf libtool @@ -119,6 +117,37 @@ normal or a panic reboot. This package contains the /sbin/kexec binary and ancillary utilities that together form the userspace component of the kernel's kexec feature. + +%package -n makedumpfile +Version: %{mkdf_ver} +Summary: make a small dumpfile of kdump +License: GPL-2.0-only +URL: https://github.com/makedumpfile/makedumpfile + +Conflicts: kexec-tools < 2.0.28-5 +Requires(pre): zlib +BuildRequires: make +BuildRequires: gcc +BuildRequires: zlib-devel +BuildRequires: elfutils-devel +BuildRequires: glib2-devel +BuildRequires: bzip2-devel +BuildRequires: ncurses-devel +BuildRequires: bison +BuildRequires: flex +BuildRequires: lzo-devel +BuildRequires: snappy-devel +BuildRequires: libzstd-devel +BuildRequires: pkgconfig +BuildRequires: intltool +BuildRequires: gettext + + +%description -n makedumpfile +makedumpfile is a tool to compress and filter out unneeded data from kernel +dumps to reduce its file size. It is typically used with the kdump mechanism. + + %prep %setup -q @@ -159,11 +188,12 @@ cp %{SOURCE34} . %{SOURCE4} %{_target_cpu} > kdump.conf make -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 + +# makedumpfile make -C eppic-%{eppic_ver}/libeppic make -C makedumpfile-%{mkdf_ver} LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libeppic -L../eppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so -%endif + %install mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin @@ -221,7 +251,7 @@ install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-gener install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install install -m 755 -D %{SOURCE33} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/92-crashkernel.install -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 +# makedumpfile install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8 install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5 @@ -229,7 +259,6 @@ install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sys install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -%endif %define dracutdir %{_prefix}/lib/dracut/modules.d %define remove_prefix() %(echo -n %2|sed 's/.*%1-//g') @@ -313,9 +342,6 @@ fi %files /usr/sbin/kexec -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -/usr/sbin/makedumpfile -%endif %ifarch ppc64 ppc64le /usr/sbin/mkfadumprd %{_prefix}/lib/kernel/install.d/60-fadump.install @@ -325,9 +351,6 @@ fi %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -%{_sysconfdir}/makedumpfile.conf.sample -%endif %config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump %config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf %ifnarch s390x @@ -342,12 +365,9 @@ fi %dir %{_sharedstatedir}/kdump %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -%{_mandir}/man8/makedumpfile.8.gz -%endif %{_mandir}/man8/mkdumprd.8.gz %{_mandir}/man8/vmcore-dmesg.8.gz -%{_mandir}/man5/* +%{_mandir}/man5/kdump.conf.5.gz %{_unitdir}/kdump.service %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %{_prefix}/lib/kernel/install.d/60-kdump.install @@ -361,12 +381,22 @@ fi %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %doc crashkernel-howto.txt -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 + + +%files -n makedumpfile +%license makedumpfile-%{mkdf_ver}/COPYING +%{_sbindir}/makedumpfile +%{_mandir}/man5/makedumpfile.conf.5.gz +%{_mandir}/man8/makedumpfile.8.gz +%{_sysconfdir}/makedumpfile.conf.sample %{_libdir}/eppic_makedumpfile.so -/usr/share/makedumpfile/ -%endif +%{_datadir}/makedumpfile/ + %changelog +* Fri Feb 23 2024 Carl George - 2.0.28-5 +- Add a makedumpfile subpackage + * Fri Feb 02 2024 Coiby Xu - 2.0.28-4 - kexec: don't use kexec_file_load on XEN - Fix building on x86_64 with binutils 2.41 From f9986edd25e8b414b2fc7f11f08d6d8f51a9b843 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 16 Mar 2024 10:22:54 +0800 Subject: [PATCH 766/806] Release 2.0.28-6 Resovles: https://bugzilla.redhat.com/show_bug.cgi?id=2269640 Let kexec-tools depends on makedumpfile. Signed-off-by: Coiby Xu --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 6104e46..0a0b342 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 5%{?dist} +Release: 6%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -61,6 +61,7 @@ Requires(post): servicelog Recommends: keyutils %endif Requires(pre): coreutils sed +Requires: makedumpfile Requires: dracut >= 058 Requires: dracut-network >= 058 Requires: dracut-squash >= 058 @@ -394,6 +395,9 @@ fi %changelog +* Sat Mar 16 2024 Coiby Xu - 2.0.28-6 +- let kexec-tools depends on makedumpfile + * Fri Feb 23 2024 Carl George - 2.0.28-5 - Add a makedumpfile subpackage From b6a066db5368d53a5e460ca1c948c0b43d66b1ef Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 8 Feb 2024 17:06:11 +0100 Subject: [PATCH 767/806] Supported targets: Import from CentOS Stream 9 In CentOS Stream a list of supported targets is maintained. Where "supported" means that these targets are tested regularly. Even though there are some small differences between CentOS Stream and Fedora when it comes to provided/supported packages and kernel configs, having this list in Fedora as well makes sense. As it provides a entry point for users to find out if a given setup is meant to work or not. Thus include the supported-kdump-targets.txt from CentOS Stream 9 [1] into Fedora. [1] https://gitlab.com/redhat/centos-stream/rpms/kexec-tools/-/blob/0a09d12d8914dd06929aa7de159c7209393c4bfa/supported-kdump-targets.txt Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- kexec-tools.spec | 3 + supported-kdump-targets.txt | 121 ++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 supported-kdump-targets.txt diff --git a/kexec-tools.spec b/kexec-tools.spec index 0a0b342..304bbb7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -39,6 +39,7 @@ Source34: crashkernel-howto.txt Source35: kdump-migrate-action.sh Source36: kdump-restart.sh Source37: 60-fadump.install +Source38: supported-kdump-targets.txt ####################################### # These are sources for mkdumpramfs @@ -183,6 +184,7 @@ cp %{SOURCE21} . cp %{SOURCE26} . cp %{SOURCE27} . cp %{SOURCE34} . +cp %{SOURCE38} . # Generate sysconfig file %{SOURCE3} %{_target_cpu} > kdump.sysconfig @@ -382,6 +384,7 @@ fi %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %doc crashkernel-howto.txt +%doc supported-kdump-targets.txt %files -n makedumpfile diff --git a/supported-kdump-targets.txt b/supported-kdump-targets.txt new file mode 100644 index 0000000..f282adf --- /dev/null +++ b/supported-kdump-targets.txt @@ -0,0 +1,121 @@ +Supported Kdump Targets + +This document try to list all supported kdump targets, and those supported +or unknown/tech-preview targets, this can help users to decide whether a dump +solution is available. + +Dump Target support status +========================== +This section tries to come up with some kind of guidelines in terms of +what dump targets are supported/not supported. Whatever is listed here +is not binding in any manner. It is just sharing of current understanding +and if something is not right, this section needs to be edited. + +Following are 3 lists. First one contains supported targets. These are +generic configurations which should work and some configuration most +likely has worked in testing. Second list is known unsupported targets. +These targets we know either don't work or we don't support. And third +list is unknown/tech-preview. We either don't yet know the status of kdump +on these targets or these are under tech-preview. + +Note, these lists are not set in stone and can be changed at any point of +time. Also these lists might not be complete. We will add/remove items to +it as we get more testing information. Also, there are many corner cases +which can't possibly be listed. For example in general we might be +supporting software iscsi but there might be some configurations of it +which don't work. + +So if any target is listed in supported section, it does not mean it works +in all possible configurations. It just means that in common configurations +it should work but there can be issues with particular configurations which +are not supported. As we come to know of particular issues, we will keep on +updating lists accordingly. + + +Supported Dump targets +---------------------- +storage: + LVM volume + Thin provisioning volume + FC disks (qla2xxx, lpfc, bnx2fc, bfa) + software initiator based iSCSI + software RAID (mdraid) + hardware RAID (smartpqi, hpsa, megaraid, mpt3sas, aacraid, mpi3mr) + SCSI/SATA disks + iSCSI HBA (all offload) + hardware FCoE (qla2xxx, lpfc) + software FCoE (bnx2fc) (Extra configuration required, + please read "Note on FCoE" section below) + NVMe-FC (qla2xxx, lpfc) + +network: + Hardware using kernel modules: (igb, ixgbe, ice, i40e, e1000e, igc, + tg3, bnx2x, bnxt_en, qede, cxgb4, be2net, enic, sfc, mlx4_en, + mlx5_core, r8169, atlantic, nfp, ionic; nicvf (aarch64 only)) + protocol: ipv4 + bonding + vlan + bridge + vlan tagged bonding + bridge over bond/vlan + +hypervisor: + kvm + xen (Supported in select configurations only) + +filesystem: + ext[234] + xfs + nfs + virtiofs + +firmware: + BIOS + UEFI + +hypervisor: + VMWare ESXi 4.x 5.x would not be tested/supported any more. + only support ESXi 6.6, 6.7, 7.0 + Hyper-V 2012 R2 (RHEL Gen1 UP Guest only), later version will + also be tested/supported + +Unsupported Dump targets +------------------------ +storage: + BIOS RAID + Software iSCSI with iBFT (bnx2i, cxgb3i, cxgb4i) + Software iSCSI with hybrid (be2iscsi) + FCoE + legacy IDE + glusterfs + gfs2/clvm/halvm + +network: + hardware using kernel modules: (sfc SRIOV, cxgb4vf, pch_gbe) + protocol: ipv6 + wireless + Infiniband (IB) + vlan over bridge/team + +filesystem: + btrfs + +Unknown/tech-preview +-------------------- +storage: + PCI Express based SSDs + +hypervisor: + Hyper-V 2008 + Hyper-V 2012 + + +Note on FCoE +===================== +If you are trying to dump to a software FCoE target, you may encounter OOM +issue, because some software FCoE requires more memory to work. In such case, +you may need to increase the kdump reserved memory size in "crashkernel=" +kernel parameter. + +For hardware FCoE, kdump should work naturally as firmware will do the +initialization job. The capture kernel and kdump tools will run just fine. From d2b6547f55ca960463de6dca6791db3c7d10ec06 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 8 Feb 2024 17:06:12 +0100 Subject: [PATCH 768/806] Supported targets: Merge hypervisor sections The supported targets list has two separate hypervisor sections. Merge them into one. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- supported-kdump-targets.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/supported-kdump-targets.txt b/supported-kdump-targets.txt index f282adf..936a42b 100644 --- a/supported-kdump-targets.txt +++ b/supported-kdump-targets.txt @@ -59,10 +59,6 @@ network: vlan tagged bonding bridge over bond/vlan -hypervisor: - kvm - xen (Supported in select configurations only) - filesystem: ext[234] xfs @@ -74,6 +70,8 @@ firmware: UEFI hypervisor: + kvm + xen (selected configurations only) VMWare ESXi 4.x 5.x would not be tested/supported any more. only support ESXi 6.6, 6.7, 7.0 Hyper-V 2012 R2 (RHEL Gen1 UP Guest only), later version will From 44a1b7da908a52c15a2b7ed286b59cfe7319b4c9 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Wed, 28 Feb 2024 22:51:15 +0530 Subject: [PATCH 769/806] ppc64le: replace kernel cmdline maxcpu=1 with nr_cpus=1 With patch series [1], PowerPC supports nr_cpus=1, so use nr_cpus=1 instead of maxcpu=1 in the kdump environment. Note this changes is dependent on kernel changes [1] [1] https://lore.kernel.org/all/170800202447.601034.7290612623478478380.b4-ty@ellerman.id.au/#t Signed-off-by: Sourabh Jain Cc: Hari Bathini Cc: Mahesh Salgaonkar Acked-by: Pingfan Liu --- gen-kdump-sysconfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen-kdump-sysconfig.sh b/gen-kdump-sysconfig.sh index 4a28350..78b0bb7 100755 --- a/gen-kdump-sysconfig.sh +++ b/gen-kdump-sysconfig.sh @@ -92,7 +92,7 @@ ppc64le) update_param KDUMP_COMMANDLINE_REMOVE \ "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" + "irqpoll nr_cpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" ;; s390x) update_param KEXEC_ARGS "-s" From d6e1edc677bfd15fb4553101ffb5a34130959861 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 13 Mar 2024 14:12:58 +0800 Subject: [PATCH 770/806] doc/kdump.conf: correctly align the options Currently, the other options like "raw " become child items of the auto_reset_crashkernel option, auto_reset_crashkernel ... raw ... nfs ... ... Fix it by ending the auto_reset_crashkernel with ".RE". Fixes: 73ced7f4 ("introduce the auto_reset_crashkernel option to kdump.conf") Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump.conf.5 | 1 + 1 file changed, 1 insertion(+) diff --git a/kdump.conf.5 b/kdump.conf.5 index 0e6ff21..f738dba 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -43,6 +43,7 @@ reset-crashkernel [--kernel=path_to_kernel]" if you want to use the default value set after having enabled features like SME/SEV for a specific kernel. And you should also reboot the system for the new crashkernel value to take effect. Also see kdumpctl(8). +.RE .B raw .RS From 858de28447ff05b15ef3c7004f60c7babf1ab15c Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 13 Mar 2024 14:18:24 +0800 Subject: [PATCH 771/806] doc/kdump.conf: properly format list man files doesn't preserve line breaks. Construct a list to list the cases where additional memory will be reserved. Fixes: c752cbb2 ("Explain the auto_reset_crashkernel option in more details") Reported-by: Jie Li Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdump.conf.5 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kdump.conf.5 b/kdump.conf.5 index f738dba..20b1620 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -32,17 +32,22 @@ determine whether to reset kernel crashkernel parameter to the default value or not when kexec-tools is updated or a new kernel is installed. The default crashkernel values are different for different architectures and also take the following factors into consideration, - - AMD Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV) - - Mellanox 5th generation network driver - - aarch64 64k kernel - - Firmware-assisted dump (FADump) - +.IP +\- AMD Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV) +.IP +\- Mellanox 5th generation network driver +.IP +\- aarch64 64k kernel +.IP +\- Firmware-assisted dump (FADump) +.PP Since the kernel crasherkernel parameter will be only reset when kexec-tools is updated or a new kernel is installed, you need to call "kdumpctl reset-crashkernel [--kernel=path_to_kernel]" if you want to use the default value set after having enabled features like SME/SEV for a specific kernel. And you should also reboot the system for the new crashkernel value to take effect. Also see kdumpctl(8). +.PP .RE .B raw From 20dc67f0ea5bd73289be99666cf0871c5ad7a6e6 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sun, 7 Apr 2024 14:49:11 +0800 Subject: [PATCH 772/806] Release 2.0.26-7 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2269991 Signed-off-by: Coiby Xu --- ...oc_entries_in_machine_apply_elf_rel_.patch | 95 ------------- ...vmalloc-start-address-from-vmcoreinf.patch | 132 ++++++++++++++++++ kexec-tools.spec | 8 +- 3 files changed, 139 insertions(+), 96 deletions(-) delete mode 100644 kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch create mode 100644 kexec-tools-2.0.28-makedumfpile-0001-PATCH-ppc64-get-vmalloc-start-address-from-vmcoreinf.patch diff --git a/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch b/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch deleted file mode 100644 index 10bc5ef..0000000 --- a/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch +++ /dev/null @@ -1,95 +0,0 @@ -commit 186e7b0752d8fce1618fa37519671c834c46340e -Author: Alexander Egorenkov -Date: Wed Dec 15 18:48:53 2021 +0100 - - s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel() - - Starting with gcc 11.3, the C compiler will generate PLT-relative function - calls even if they are local and do not require it. Later on during linking, - the linker will replace all PLT-relative calls to local functions with - PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is - not being linked as a regular executable or shared library would have been, - and therefore, all PLT-relative addresses remain in the generated purgatory - object code unresolved. This in turn lets kexec-tools fail with - "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types. - - Furthermore, the clang C compiler has always behaved like described above - and this commit should fix the purgatory code built with the latter. - - Because the purgatory code is no regular executable or shared library, - contains only calls to local functions and has no PLT, all R_390_PLT32DBL - relocation entries can be resolved just like a R_390_PC32DBL one. - - * https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.html#AEN1699 - - Relocation entries of purgatory code generated with gcc 11.3 - ------------------------------------------------------------ - - $ readelf -r purgatory/purgatory.o - - Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: - Offset Info Type Sym. Value Sym. Name + Addend - 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 - 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2 - 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2 - 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2 - 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 - 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2 - ... - 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2 - 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 - 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000 verify_sha256_digest + 2 - 000000000142 001700000014 R_390_PLT32DBL 0000000000000000 - post_verification[...] + 2 - - Relocation entries of purgatory code generated with gcc 11.2 - ------------------------------------------------------------ - - $ readelf -r purgatory/purgatory.o - - Relocation section '.rela.text' at offset 0x6e8 contains 27 entries: - Offset Info Type Sym. Value Sym. Name + Addend - 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2 - 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2 - 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2 - 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2 - 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102 - 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2 - ... - 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2 - 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122 - 000000000130 000f00000013 R_390_PC32DBL 0000000000000000 verify_sha256_digest + 2 - 000000000146 001700000013 R_390_PC32DBL 0000000000000000 post_verification[...] + 2 - - Corresponding s390 kernel discussion: - * https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux.ibm.com/T/#u - - Signed-off-by: Alexander Egorenkov - Reported-by: Tao Liu - Suggested-by: Philipp Rudo - Reviewed-by: Philipp Rudo - [hca@linux.ibm.com: changed commit message as requested by Philipp Rudo] - Signed-off-by: Heiko Carstens - Signed-off-by: Simon Horman - -diff --git a/kexec/arch/s390/kexec-elf-rel-s390.c b/kexec/arch/s390/kexec-elf-rel-s390.c -index a5e1b73455785ae3bc3aa72b3beee13ae202e82f..91ba86a9991dad4271b834fc3b24861c40309e52 100644 ---- a/kexec/arch/s390/kexec-elf-rel-s390.c -+++ b/kexec/arch/s390/kexec-elf-rel-s390.c -@@ -56,6 +56,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), - case R_390_PC16: /* PC relative 16 bit. */ - case R_390_PC16DBL: /* PC relative 16 bit shifted by 1. */ - case R_390_PC32DBL: /* PC relative 32 bit shifted by 1. */ -+ case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */ - case R_390_PC32: /* PC relative 32 bit. */ - case R_390_PC64: /* PC relative 64 bit. */ - val -= address; -@@ -63,7 +64,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), - *(unsigned short *) loc = val; - else if (r_type == R_390_PC16DBL) - *(unsigned short *) loc = val >> 1; -- else if (r_type == R_390_PC32DBL) -+ else if (r_type == R_390_PC32DBL || r_type == R_390_PLT32DBL) - *(unsigned int *) loc = val >> 1; - else if (r_type == R_390_PC32) - *(unsigned int *) loc = val; diff --git a/kexec-tools-2.0.28-makedumfpile-0001-PATCH-ppc64-get-vmalloc-start-address-from-vmcoreinf.patch b/kexec-tools-2.0.28-makedumfpile-0001-PATCH-ppc64-get-vmalloc-start-address-from-vmcoreinf.patch new file mode 100644 index 0000000..1ee904a --- /dev/null +++ b/kexec-tools-2.0.28-makedumfpile-0001-PATCH-ppc64-get-vmalloc-start-address-from-vmcoreinf.patch @@ -0,0 +1,132 @@ +From: Coiby Xu + +Subject: [PATCH] ppc64: get vmalloc start address from vmcoreinfo + +Bugzilla: https://bugzilla.redhat.com/2269991 + +commit 94241fd2feed059227a243618f2acc6aabf366e8 +Author: Aditya Gupta +Date: Sat Feb 24 00:33:42 2024 +0530 + + [PATCH] ppc64: get vmalloc start address from vmcoreinfo + + Below error was noticed when running makedumpfile on linux-next kernel + crash (linux-next tag next-20240121): + + Checking for memory holes : [100.0 %] | readpage_elf: Attempt to read non-existent page at 0xc000000000000. + [ 17.551718] kdump.sh[404]: readmem: type_addr: 0, addr:c00c000000000000, size:16384 + [ 17.551793] kdump.sh[404]: __exclude_unnecessary_pages: Can't read the buffer of struct page. + [ 17.551864] kdump.sh[404]: create_2nd_bitmap: Can't exclude unnecessary pages. + [ 17.562632] kdump.sh[404]: The kernel version is not supported. + [ 17.562708] kdump.sh[404]: The makedumpfile operation may be incomplete. + [ 17.562773] kdump.sh[404]: makedumpfile Failed. + [ 17.564335] kdump[406]: saving vmcore failed, _exitcode:1 + + Above error was due to 'vmap_area_list' and 'vmlist' symbols missing + from the vmcore. 'vmap_area_list' was removed in the linux kernel + 6.9-rc1 by the commit below: + + commit 55c49fee57af99f3c663e69dedc5b85e691bbe50 + mm/vmalloc: remove vmap_area_list + + Subsequently the commit also introduced 'VMALLOC_START' in vmcoreinfo to + get base address of vmalloc area, instead of depending on 'vmap_area_list' + + Hence if 'VMALLOC_START' symbol is there in vmcoreinfo: + 1. Set vmalloc_start based on 'VMALLOC_START' + 2. Don't error if vmap_area_list/vmlist are not defined + + Reported-by: Sachin Sant + Signed-off-by: Aditya Gupta + +Signed-off-by: Coiby Xu + +diff --git a/makedumpfile-1.7.4/arch/ppc64.c b/makedumpfile-1.7.4/arch/ppc64.c +index 3b4f91981f71d035b94282f6c7e33323a4e4c1fd..a54f9a04db7f26eac2f1bd065b134a7e2fdaeb67 100644 +--- a/makedumpfile-1.7.4/arch/ppc64.c ++++ b/makedumpfile-1.7.4/arch/ppc64.c +@@ -568,7 +568,9 @@ get_machdep_info_ppc64(void) + /* + * Get vmalloc_start value from either vmap_area_list or vmlist. + */ +- if ((SYMBOL(vmap_area_list) != NOT_FOUND_SYMBOL) ++ if (NUMBER(vmalloc_start) != NOT_FOUND_NUMBER) { ++ vmalloc_start = NUMBER(vmalloc_start); ++ } else if ((SYMBOL(vmap_area_list) != NOT_FOUND_SYMBOL) + && (OFFSET(vmap_area.va_start) != NOT_FOUND_STRUCTURE) + && (OFFSET(vmap_area.list) != NOT_FOUND_STRUCTURE)) { + if (!readmem(VADDR, SYMBOL(vmap_area_list) + OFFSET(list_head.next), +@@ -689,11 +691,16 @@ vaddr_to_paddr_ppc64(unsigned long vaddr) + if ((SYMBOL(vmap_area_list) == NOT_FOUND_SYMBOL) + || (OFFSET(vmap_area.va_start) == NOT_FOUND_STRUCTURE) + || (OFFSET(vmap_area.list) == NOT_FOUND_STRUCTURE)) { +- if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) +- || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) { +- ERRMSG("Can't get info for vmalloc translation.\n"); +- return NOT_PADDR; +- } ++ /* ++ * Don't depend on vmap_area_list/vmlist if vmalloc_start is set in ++ * vmcoreinfo, in that case proceed without error ++ */ ++ if (NUMBER(vmalloc_start) == NOT_FOUND_NUMBER) ++ if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) ++ || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) { ++ ERRMSG("Can't get info for vmalloc translation.\n"); ++ return NOT_PADDR; ++ } + } + + return ppc64_vtop_level4(vaddr); +diff --git a/makedumpfile-1.7.4/makedumpfile.c b/makedumpfile-1.7.4/makedumpfile.c +index 58c6639f289f19cdbf39ed3899be9893fdc317fe..d7f1dd41d2cab526d7d40e809ddccf656c586811 100644 +--- a/makedumpfile-1.7.4/makedumpfile.c ++++ b/makedumpfile-1.7.4/makedumpfile.c +@@ -2978,6 +2978,8 @@ read_vmcoreinfo(void) + READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); + READ_NUMBER("phys_base", phys_base); + READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE); ++ ++ READ_NUMBER_UNSIGNED("VMALLOC_START", vmalloc_start); + #ifdef __aarch64__ + READ_NUMBER("VA_BITS", VA_BITS); + READ_NUMBER("TCR_EL1_T1SZ", TCR_EL1_T1SZ); +@@ -2989,7 +2991,6 @@ read_vmcoreinfo(void) + READ_NUMBER("VA_BITS", va_bits); + READ_NUMBER_UNSIGNED("phys_ram_base", phys_ram_base); + READ_NUMBER_UNSIGNED("PAGE_OFFSET", page_offset); +- READ_NUMBER_UNSIGNED("VMALLOC_START", vmalloc_start); + READ_NUMBER_UNSIGNED("VMALLOC_END", vmalloc_end); + READ_NUMBER_UNSIGNED("VMEMMAP_START", vmemmap_start); + READ_NUMBER_UNSIGNED("VMEMMAP_END", vmemmap_end); +diff --git a/makedumpfile-1.7.4/makedumpfile.h b/makedumpfile-1.7.4/makedumpfile.h +index c04c330b69ecbe5fb232a2eabbd2d71f14b60cc0..c31f3a4371af8aae38dcba8cac4d6de1012b4cfd 100644 +--- a/makedumpfile-1.7.4/makedumpfile.h ++++ b/makedumpfile-1.7.4/makedumpfile.h +@@ -541,8 +541,6 @@ do { \ + * The value of dependence on machine + */ + #define PAGE_OFFSET (info->page_offset) +-#define VMALLOC_START (info->vmalloc_start) +-#define VMALLOC_END (info->vmalloc_end) + #define VMEMMAP_START (info->vmemmap_start) + #define VMEMMAP_END (info->vmemmap_end) + #define PMASK (0x7ffffffffffff000UL) +@@ -2263,6 +2261,9 @@ struct number_table { + long HUGETLB_PAGE_DTOR; + long phys_base; + long KERNEL_IMAGE_SIZE; ++ ++ unsigned long vmalloc_start; ++ + #ifdef __aarch64__ + long VA_BITS; + long TCR_EL1_T1SZ; +@@ -2273,7 +2274,6 @@ struct number_table { + long va_bits; + unsigned long phys_ram_base; + unsigned long page_offset; +- unsigned long vmalloc_start; + unsigned long vmalloc_end; + unsigned long vmemmap_start; + unsigned long vmemmap_end; diff --git a/kexec-tools.spec b/kexec-tools.spec index 304bbb7..2c7d88c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 6%{?dist} +Release: 7%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -112,6 +112,8 @@ Patch101: kexec-tools-2.0.28-Fix-building-on-x86_64-with-binutils-2.41.patch # Author: Jiri Bohac Patch601: kexec-tools-2.0.28-kexec-don-t-use-kexec_file_load-on-XEN.patch +Patch602: kexec-tools-2.0.28-makedumfpile-0001-PATCH-ppc64-get-vmalloc-start-address-from-vmcoreinf.patch + %description kexec-tools provides /sbin/kexec binary that facilitates a new kernel to boot using the kernel's kexec feature either on a @@ -159,6 +161,7 @@ tar -z -x -v -f %{SOURCE19} %patch 101 -p1 %patch 601 -p1 +%patch 602 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -398,6 +401,9 @@ fi %changelog +* Sun Apr 07 2024 Coiby Xu - 2.0.28-7 +- Release 2.0.28-7 + * Sat Mar 16 2024 Coiby Xu - 2.0.28-6 - let kexec-tools depends on makedumpfile From 372b4c6c1597c3d9aaddda2d691260474973989e Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 29 Feb 2024 10:23:51 +0800 Subject: [PATCH 773/806] Add kdump-utils subpackage Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 220 ++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 107 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2c7d88c..b18df5c 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.28 -Release: 7%{?dist} +Release: 8%{?dist} License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -57,28 +57,10 @@ Source109: dracut-early-kdump-module-setup.sh Source200: dracut-fadump-init-fadump.sh Source201: dracut-fadump-module-setup.sh -%ifarch ppc64 ppc64le -Requires(post): servicelog -Recommends: keyutils -%endif -Requires(pre): coreutils sed -Requires: makedumpfile -Requires: dracut >= 058 -Requires: dracut-network >= 058 -Requires: dracut-squash >= 058 -Requires: ethtool -Requires: util-linux -# Needed for UKI support -Recommends: binutils -Recommends: grubby -Recommends: hostname -BuildRequires: make -BuildRequires: systemd-rpm-macros -BuildRequires: automake autoconf libtool - -%ifnarch s390x -Requires: systemd-udev%{?_isa} -%endif +BuildRequires: automake +BuildRequires: autoconf +BuildRequires: libtool +BuildRequires: gcc #START INSERT @@ -152,6 +134,40 @@ makedumpfile is a tool to compress and filter out unneeded data from kernel dumps to reduce its file size. It is typically used with the kdump mechanism. +%package -n kdump-utils +Version: 1.0.42 +License: GPL-2.0-only AND LGPL-2.1-or-later +Summary: Kernel crash dump collection utilities + +%ifarch ppc64 ppc64le +Requires(post): servicelog +Recommends: keyutils +%endif +Requires(pre): coreutils +Requires(pre): sed +Requires: kexec-tools >= 2.0.28-8 +Requires: makedumpfile +Requires: dracut >= 058 +Requires: dracut-network >= 058 +Requires: dracut-squash >= 058 +Requires: ethtool +Requires: util-linux +# Needed for UKI support +Recommends: binutils +Recommends: grubby +Recommends: hostname +BuildRequires: systemd-rpm-macros + +%ifnarch s390x +Requires: systemd-udev%{?_isa} +%endif +%description -n kdump-utils +kdump-utils is responsible for collecting the crash kernel dump. It builds and +loads the kdump initramfs so when a kernel crashes, the system will boot the +kdump kernel and initramfs to save the collected crash kernel dump to specified +target. + + %prep %setup -q @@ -180,6 +196,9 @@ autoreconf %endif --sbindir=/usr/sbin rm -f kexec-tools.spec.in +make + +# kdump-utils # setup the docs cp %{SOURCE10} . cp %{SOURCE11} . @@ -193,7 +212,6 @@ cp %{SOURCE38} . %{SOURCE3} %{_target_cpu} > kdump.sysconfig %{SOURCE4} %{_target_cpu} > kdump.conf -make # makedumpfile make -C eppic-%{eppic_ver}/libeppic @@ -202,93 +220,76 @@ make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libep %install -mkdir -p -m755 $RPM_BUILD_ROOT/usr/sbin -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/pre.d -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump/post.d -mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash -mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ -mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ -mkdir -p -m755 $RPM_BUILD_ROOT%{_docdir} -mkdir -p -m755 $RPM_BUILD_ROOT%{_datadir}/kdump -mkdir -p -m755 $RPM_BUILD_ROOT%{_udevrulesdir} -mkdir -p $RPM_BUILD_ROOT%{_unitdir} -mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir} -mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} -mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump -mkdir -p -m755 $RPM_BUILD_ROOT%{_sharedstatedir}/kdump -install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl +%make_install +rm -f %{buildroot}/%{_libdir}/kexec-tools/kexec_test -install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec -install -m 755 build/sbin/vmcore-dmesg $RPM_BUILD_ROOT/usr/sbin/vmcore-dmesg -install -m 644 build/man/man8/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/ -install -m 644 build/man/man8/vmcore-dmesg.8 $RPM_BUILD_ROOT%{_mandir}/man8/ +# kdump-utils +mkdir -p -m755 %{buildroot}%{_sysconfdir}/kdump/pre.d +mkdir -p -m755 %{buildroot}%{_sysconfdir}/kdump/post.d +mkdir -p -m755 %{buildroot}%{_localstatedir}/crash +mkdir -p -m755 %{buildroot}%{_udevrulesdir} +mkdir -p -m755 %{buildroot}%{_sharedstatedir}/kdump -install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd -install -m 644 kdump.conf $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf -install -m 644 kdump.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump -install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 -install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 -install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 -install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh -install -m 755 %{SOURCE23} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh -install -m 755 %{SOURCE31} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-logger.sh +install -D -m 755 %{SOURCE1} %{buildroot}%{_bindir}/kdumpctl +install -D -m 755 %{SOURCE7} %{buildroot}%{_sbindir}/mkdumprd +install -D -m 644 kdump.conf %{buildroot}%{_sysconfdir}/kdump.conf +install -D -m 644 kdump.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/kdump +install -D -m 644 %{SOURCE12} %{SOURCE25} -t %{buildroot}%{_mandir}/man8 +install -D -m 755 %{SOURCE20} %{SOURCE23} %{SOURCE31} -t %{buildroot}%{_prefix}/lib/kdump %ifarch ppc64 ppc64le -install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd -install -m 755 %{SOURCE35} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-migrate-action.sh -install -m 755 %{SOURCE36} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-restart.sh +install -m 755 %{SOURCE32} %{buildroot}%{_sbindir}/mkfadumprd +install -m 755 %{SOURCE35} %{SOURCE36} -t %{buildroot}%{_prefix}/lib/kdump %endif %ifnarch s390x -install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_udevrulesdir}/../kdump-udev-throttler +install -m 755 %{SOURCE28} %{buildroot}%{_udevrulesdir}/../kdump-udev-throttler %endif %ifnarch s390x ppc64 ppc64le # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required -install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules +install -m 644 %{SOURCE13} %{buildroot}%{_udevrulesdir}/98-kexec.rules %endif %ifarch ppc64 ppc64le -install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules -install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install +install -m 644 %{SOURCE14} %{buildroot}%{_udevrulesdir}/98-kexec.rules +install -m 755 -D %{SOURCE37} %{buildroot}%{_prefix}/lib/kernel/install.d/60-fadump.install +%endif +install -D -m 644 %{SOURCE15} %{buildroot}%{_mandir}/man5/kdump.conf.5 +install -D -m 644 %{SOURCE16} %{buildroot}%{_unitdir}/kdump.service +install -m 755 -D %{SOURCE22} %{buildroot}%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh +install -m 755 -D %{SOURCE30} %{buildroot}%{_prefix}/lib/kernel/install.d/60-kdump.install +install -m 755 -D %{SOURCE33} %{buildroot}%{_prefix}/lib/kernel/install.d/92-crashkernel.install + +%define dracutdir %{_prefix}/lib/dracut/modules.d + +# deal with dracut modules +mkdir -p -m755 %{buildroot}/%{dracutdir}/99kdumpbase +install -m 755 %{SOURCE100} %{buildroot}/%{dracutdir}/99kdumpbase/kdump.sh +install -m 755 %{SOURCE101} %{buildroot}/%{dracutdir}/99kdumpbase/module-setup.sh +install -m 755 %{SOURCE102} %{buildroot}/%{dracutdir}/99kdumpbase/monitor_dd_progress.sh +install -m 644 %{SOURCE104} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-emergency.service +install -m 644 %{SOURCE106} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-capture.service +install -m 644 %{SOURCE107} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-emergency.target + +mkdir -p -m755 %{buildroot}/%{dracutdir}/99earlykdump +install -m 755 %{SOURCE108} %{buildroot}/%{dracutdir}/99earlykdump/kdump.sh +install -m 755 %{SOURCE109} %{buildroot}/%{dracutdir}/99earlykdump/kdump-module-setup.sh + +%ifarch ppc64 ppc64le +mkdir -p -m755 %{buildroot}/%{dracutdir}/99zz-fadumpinit +install -m 755 %{SOURCE200} %{buildroot}/%{dracutdir}/99zz-fadumpinit/init-fadump.sh +install -m 755 %{SOURCE201} %{buildroot}/%{dracutdir}/99zz-fadumpinit/module-setup.sh %endif -install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 -install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service -install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh -install -m 755 -D %{SOURCE30} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install -install -m 755 -D %{SOURCE33} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/92-crashkernel.install # makedumpfile install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8 install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5 install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 -D makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -%define dracutdir %{_prefix}/lib/dracut/modules.d -%define remove_prefix() %(echo -n %2|sed 's/.*%1-//g') -# deal with dracut modules -mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase -install -m 755 %{SOURCE100} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE100}} -install -m 755 %{SOURCE101} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE101}} -install -m 644 %{SOURCE102} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE102}} -install -m 644 %{SOURCE104} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE104}} -install -m 644 %{SOURCE106} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE106}} -install -m 644 %{SOURCE107} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE107}} - -mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump -install -m 755 %{SOURCE108} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut %{SOURCE108}} -install -m 755 %{SOURCE109} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut-early-kdump %{SOURCE109}} - -%ifarch ppc64 ppc64le -mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit -install -m 755 %{SOURCE200} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE200}} -install -m 755 %{SOURCE201} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE201}} -%endif - -%post +%post -n kdump-utils # Initial installation %systemd_post kdump.service @@ -301,20 +302,20 @@ servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match : -%postun +%postun -n kdump-utils %systemd_postun_with_restart kdump.service -%preun +%preun -n kdump-utils %ifarch ppc64 ppc64le servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/dev/null %endif %systemd_preun kdump.service -%triggerin -- kernel-kdump +%triggerin -n kdump-utils -- kernel-kdump touch %{_sysconfdir}/kdump.conf -%triggerpostun -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump +%triggerpostun -n kdump-utils -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump # List out the initrds here, strip out version nubmers # and search for corresponding kernel installs, if a kernel # is not found, remove the corresponding kdump initrd @@ -332,7 +333,7 @@ do fi done -%posttrans +%posttrans -n kdump-utils # Try to reset kernel crashkernel value to new default value or set up # crasherkernel value for new install # @@ -347,20 +348,26 @@ fi %files -/usr/sbin/kexec +%{_sbindir}/kexec +%{_mandir}/man8/kexec.8* +%{_sbindir}/vmcore-dmesg +%{_mandir}/man8/vmcore-dmesg.8* +%doc News +%license COPYING +%doc TODO + +%files -n kdump-utils %ifarch ppc64 ppc64le -/usr/sbin/mkfadumprd +%{_sbindir}/mkfadumprd %{_prefix}/lib/kernel/install.d/60-fadump.install %endif -/usr/sbin/mkdumprd -/usr/sbin/vmcore-dmesg +%{_sbindir}/mkdumprd %{_bindir}/* -%{_datadir}/kdump %{_prefix}/lib/kdump %config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump %config(noreplace,missingok) %verify(not mtime) %{_sysconfdir}/kdump.conf %ifnarch s390x -%config %{_udevrulesdir} +%{_udevrulesdir} %{_udevrulesdir}/../kdump-udev-throttler %endif %{dracutdir}/* @@ -369,18 +376,14 @@ fi %dir %{_sysconfdir}/kdump/pre.d %dir %{_sysconfdir}/kdump/post.d %dir %{_sharedstatedir}/kdump -%{_mandir}/man8/kdumpctl.8.gz -%{_mandir}/man8/kexec.8.gz -%{_mandir}/man8/mkdumprd.8.gz -%{_mandir}/man8/vmcore-dmesg.8.gz -%{_mandir}/man5/kdump.conf.5.gz +%{_mandir}/man8/kdumpctl.8* +%{_mandir}/man8/mkdumprd.8* +%{_mandir}/man5/kdump.conf.5* %{_unitdir}/kdump.service %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %{_prefix}/lib/kernel/install.d/60-kdump.install %{_prefix}/lib/kernel/install.d/92-crashkernel.install -%doc News %license COPYING -%doc TODO %doc kexec-kdump-howto.txt %doc early-kdump-howto.txt %doc fadump-howto.txt @@ -401,6 +404,9 @@ fi %changelog +* Tue Mar 19 2024 Coiby Xu - 2.0.28-8 +- Add a kdump-utils subpackage + * Sun Apr 07 2024 Coiby Xu - 2.0.28-7 - Release 2.0.28-7 From 5fe098fec8eb19a942a608f19324601066c0467d Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 29 Feb 2024 11:05:14 +0800 Subject: [PATCH 774/806] Don't systemctl preset kdump when updating kexec-tools to kdump-utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an old version of kexec-tools gets replaced by kdump-utils, "%systemd_post" will be executed in the post scriptlet which has the purpose to "systemctl preset kdump" for freshly installed kexec-tools. But in the case of kdump-utils replacing kexec-tools, it is not needed so skip this case. Signed-off-by: Coiby Xu Suggested-by: Zbigniew Jędrzejewski-Szmek Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index b18df5c..c8f89f0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -290,8 +290,16 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar %post -n kdump-utils -# Initial installation -%systemd_post kdump.service +# don't try to systemctl preset the kdump service for old kexec-tools +# +# when the old kexec-tools gets removed, this trigger will be excuted to +# create a file. So later the posttrans scriptlet will know there is no need to +# systemctl preset the kdump service. +# This solution can be dropped in F41 when we assume no users will use old +# version of kexec-tools. +%define kexec_tools_no_preset %{_localstatedir}/lib/rpm-state/kexec-tools.no-preset +%triggerun -- kexec-tools +touch %{kexec_tools_no_preset} touch /etc/kdump.conf @@ -334,6 +342,14 @@ do done %posttrans -n kdump-utils +# don't try to systemctl preset the kdump service for old kexec-tools +if [[ -f %{kexec_tools_no_preset} ]]; then + # this if branch can be removed in F41 when we assume no users will use the old kexec-tools + rm %{kexec_tools_no_preset} +else + # Initial installation + %systemd_post kdump.service +fi # Try to reset kernel crashkernel value to new default value or set up # crasherkernel value for new install # From c7683d8aabdbbbaaefdeee4a3e6c35482dca48c7 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 29 Feb 2024 11:18:00 +0800 Subject: [PATCH 775/806] Don't disrupt current kdump users Majority of current kexec-tools users have installed kexec-tools out of the need for the kdump feature. To ensure a smooth transition, add kdump-utils as weak dependency. If users only want to use kexec-tools, they can uninstall kdump-utils. Signed-off-by: Coiby Xu Suggested-by: Carl George Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index c8f89f0..2dfe7fb 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -10,6 +10,7 @@ License: GPL-2.0-only Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz +Recommends: kdump-utils Source1: kdumpctl Source3: gen-kdump-sysconfig.sh Source4: gen-kdump-conf.sh From a442b4e51222114cbed354f298fce8f37c88cc75 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 26 Mar 2024 19:08:00 +0800 Subject: [PATCH 776/806] Remove unused scriptlets Suggested-by: Philipp Rudo Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 2dfe7fb..a5d8bba 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -320,27 +320,6 @@ servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/de %endif %systemd_preun kdump.service -%triggerin -n kdump-utils -- kernel-kdump -touch %{_sysconfdir}/kdump.conf - - -%triggerpostun -n kdump-utils -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump -# List out the initrds here, strip out version nubmers -# and search for corresponding kernel installs, if a kernel -# is not found, remove the corresponding kdump initrd - - -IMGDIR=/boot -for i in `ls $IMGDIR/initramfs*kdump.img 2>/dev/null` -do - KDVER=`echo $i | sed -e's/^.*initramfs-//' -e's/kdump.*$//'` - if [ ! -e $IMGDIR/vmlinuz-$KDVER ] - then - # We have found an initrd with no corresponding kernel - # so we should be able to remove it - rm -f $i - fi -done %posttrans -n kdump-utils # don't try to systemctl preset the kdump service for old kexec-tools From f7bd239656269ea777454fe6c541aa0decaa4545 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 9 Apr 2024 07:26:13 +0800 Subject: [PATCH 777/806] makedumpfile: re-use source Makefile's install logic Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a5d8bba..ce3a97b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -281,14 +281,12 @@ install -m 755 %{SOURCE201} %{buildroot}/%{dracutdir}/99zz-fadumpinit/module-set %endif # makedumpfile -install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8 $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8 -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5 -install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 -D makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so -mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +make DESTDIR=%{buildroot} -C makedumpfile-%{mkdf_ver} install +install -m 644 -D makedumpfile-%{mkdf_ver}/makedumpfile.conf %{buildroot}/%{_sysconfdir}/makedumpfile.conf.sample +rm %{buildroot}/%{_sbindir}/makedumpfile-R.pl + +install -m 755 -D makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so %{buildroot}/%{_libdir}/eppic_makedumpfile.so %post -n kdump-utils # don't try to systemctl preset the kdump service for old kexec-tools @@ -392,8 +390,8 @@ fi %files -n makedumpfile %license makedumpfile-%{mkdf_ver}/COPYING %{_sbindir}/makedumpfile -%{_mandir}/man5/makedumpfile.conf.5.gz -%{_mandir}/man8/makedumpfile.8.gz +%{_mandir}/man5/makedumpfile.conf.5.* +%{_mandir}/man8/makedumpfile.8.* %{_sysconfdir}/makedumpfile.conf.sample %{_libdir}/eppic_makedumpfile.so %{_datadir}/makedumpfile/ From 3fa5df9a684f63e9aa5b42a4c9de538d3be457ed Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 8 Apr 2024 13:17:23 +0800 Subject: [PATCH 778/806] Add URL for kexec-tools and kump-utils Suggested-by: Dave Young Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kexec-tools.spec b/kexec-tools.spec index ce3a97b..f1d4ff9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -6,6 +6,7 @@ Name: kexec-tools Version: 2.0.28 Release: 8%{?dist} +URL: https://kernel.org/pub/linux/utils/kernel/kexec License: GPL-2.0-only Summary: The kexec/kdump userspace component @@ -138,6 +139,7 @@ dumps to reduce its file size. It is typically used with the kdump mechanism. %package -n kdump-utils Version: 1.0.42 License: GPL-2.0-only AND LGPL-2.1-or-later +URL: https://github.com/rhkdump/kdump-utils Summary: Kernel crash dump collection utilities %ifarch ppc64 ppc64le From fe372afddde500249cd02fc3f152a164cfed321f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 1 Mar 2024 17:37:24 +0800 Subject: [PATCH 779/806] Upstream kdump-utils This patch upstreams the to-be-split-out kdump-utils to https://github.com/rhkdump/kdump-utils. And it also simplify the .spec file by putting the installation logic into a Makefile. Cc: Philipp Rudo Cc: Carl George Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- COPYING | 339 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 83 ++++++++++++ kexec-tools.spec | 139 +++---------------- 3 files changed, 438 insertions(+), 123 deletions(-) create mode 100644 COPYING create mode 100644 Makefile diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e1a511c --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +prefix ?= /usr +libdir ?= ${prefix}/lib +datadir ?= ${prefix}/share +pkglibdir ?= ${libdir}/kdump +sysconfdir ?= /etc +bindir ?= ${prefix}/bin +sbindir ?= ${prefix}/sbin +mandir ?= ${prefix}/share/man +localstatedir ?= /var +sharedstatedir ?= /var/lib +udevrulesdir ?= ${libdir}/udev/rules.d +systemdsystemunitdir ?= ${libdir}/systemd/system/ +ARCH ?= $(shell uname -m) +dracutmoddir = $(DESTDIR)${libdir}/dracut/modules.d +kdumpbasemoddir = $(dracutmoddir)/99kdumpbase + +dracut-modules: + mkdir -p $(dracutmoddir) + mkdir -p -m755 $(kdumpbasemoddir) + + install -m 755 dracut-kdump.sh $(kdumpbasemoddir)/kdump.sh + install -m 755 dracut-module-setup.sh $(kdumpbasemoddir)/module-setup.sh + install -m 755 dracut-monitor_dd_progress.sh $(kdumpbasemoddir)/monitor_dd_progress.sh + install -m 644 dracut-kdump-emergency.service $(kdumpbasemoddir)/kdump-emergency.service + install -m 644 dracut-kdump-capture.service $(kdumpbasemoddir)/kdump-capture.service + install -m 644 dracut-kdump-emergency.target $(kdumpbasemoddir)/kdump-emergency.target + + mkdir -p -m755 $(dracutmoddir)/99earlykdump + install -m 755 dracut-early-kdump.sh $(dracutmoddir)/99earlykdump/kdump.sh + install -m 755 dracut-early-kdump-module-setup.sh $(dracutmoddir)/99earlykdump/kdump-module-setup.sh + +ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) + mkdir -p -m755 $(dracutmoddir)/99zz-fadumpinit + install -m 755 dracut-fadump-init-fadump.sh $(dracutmoddir)/99zz-fadumpinit/init-fadump.sh + install -m 755 dracut-fadump-module-setup.sh $(dracutmoddir)/99zz-fadumpinit/module-setup.sh +endif + +kdump-conf: gen-kdump-conf.sh + ./gen-kdump-conf.sh $(ARCH) > kdump.conf + +kdump-sysconfig: gen-kdump-sysconfig.sh + ./gen-kdump-sysconfig.sh $(ARCH) > kdump.sysconfig + +manpages: + install -D -m 644 mkdumprd.8 kdumpctl.8 -t $(DESTDIR)$(mandir)/man8 + install -D -m 644 kdump.conf.5 $(DESTDIR)$(mandir)/man5/kdump.conf.5 + +install: dracut-modules kdump-conf kdump-sysconfig manpages + mkdir -p $(DESTDIR)$(pkglibdir) + mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/pre.d + mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/post.d + mkdir -p -m755 $(DESTDIR)$(localstatedir)/crash + mkdir -p -m755 $(DESTDIR)$(udevrulesdir) + mkdir -p -m755 $(DESTDIR)$(sharedstatedir)/kdump + mkdir -p -m755 $(DESTDIR)$(libdir)/kernel/install.d/ + + install -D -m 755 kdumpctl $(DESTDIR)$(bindir)/kdumpctl + install -D -m 755 mkdumprd $(DESTDIR)$(sbindir)/mkdumprd + install -D -m 644 kdump.conf $(DESTDIR)$(sysconfdir) + install -D -m 644 kdump.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/kdump + install -D -m 755 kdump-lib.sh kdump-lib-initramfs.sh kdump-logger.sh -t $(DESTDIR)$(pkglibdir) + +ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) + install -m 755 mkfadumprd $(DESTDIR)$(sbindir) + install -m 755 kdump-migrate-action.sh kdump-restart.sh -t $(DESTDIR)$(pkglibdir) + install -m 755 60-fadump.install $(DESTDIR)$(libdir)/kernel/install.d/ +endif + +ifneq ($(ARCH),s390x) + install -m 755 kdump-udev-throttler $(DESTDIR)$(udevrulesdir)/../kdump-udev-throttler + # For s390x the ELF header is created in the kdump kernel and therefore kexec + # udev rules are not required +ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) + install -m 644 98-kexec.rules.ppc64 $(DESTDIR)$(udevrulesdir)/98-kexec.rules +else + install -m 644 98-kexec.rules $(DESTDIR)$(udevrulesdir)/98-kexec.rules +endif +endif + + install -D -m 644 kdump.service $(DESTDIR)$(systemdsystemunitdir)/kdump.service + install -m 755 -D kdump-dep-generator.sh $(DESTDIR)$(libdir)/systemd/system-generators/kdump-dep-generator.sh + install -m 755 60-kdump.install $(DESTDIR)$(libdir)/kernel/install.d/ + install -m 755 92-crashkernel.install $(DESTDIR)$(libdir)/kernel/install.d/ diff --git a/kexec-tools.spec b/kexec-tools.spec index f1d4ff9..cf88e5b 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,7 @@ %global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 %global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) %global mkdf_ver 1.7.4 +%global kdump_utils_ver 1.0.42 %global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7}) Name: kexec-tools @@ -12,52 +13,9 @@ Summary: The kexec/kdump userspace component Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Recommends: kdump-utils -Source1: kdumpctl -Source3: gen-kdump-sysconfig.sh -Source4: gen-kdump-conf.sh -Source7: mkdumprd +Source1: https://github.com/rhkdump/kdump-utils/archive/v%{kdump_utils_ver}/kdump-utils-%{kdump_utils_ver}.tar.gz Source9: https://github.com/makedumpfile/makedumpfile/archive/%{mkdf_ver}/makedumpfile-%{mkdf_shortver}.tar.gz -Source10: kexec-kdump-howto.txt -Source11: fadump-howto.txt -Source12: mkdumprd.8 -Source13: 98-kexec.rules -Source14: 98-kexec.rules.ppc64 -Source15: kdump.conf.5 -Source16: kdump.service Source19: https://github.com/lucchouina/eppic/archive/%{eppic_ver}/eppic-%{eppic_shortver}.tar.gz -Source20: kdump-lib.sh -Source21: kdump-in-cluster-environment.txt -Source22: kdump-dep-generator.sh -Source23: kdump-lib-initramfs.sh -Source25: kdumpctl.8 -Source26: live-image-kdump-howto.txt -Source27: early-kdump-howto.txt -Source28: kdump-udev-throttler -Source30: 60-kdump.install -Source31: kdump-logger.sh -Source32: mkfadumprd -Source33: 92-crashkernel.install -Source34: crashkernel-howto.txt -Source35: kdump-migrate-action.sh -Source36: kdump-restart.sh -Source37: 60-fadump.install -Source38: supported-kdump-targets.txt - -####################################### -# These are sources for mkdumpramfs -# Which is currently in development -####################################### -Source100: dracut-kdump.sh -Source101: dracut-module-setup.sh -Source102: dracut-monitor_dd_progress -Source104: dracut-kdump-emergency.service -Source106: dracut-kdump-capture.service -Source107: dracut-kdump-emergency.target -Source108: dracut-early-kdump.sh -Source109: dracut-early-kdump-module-setup.sh - -Source200: dracut-fadump-init-fadump.sh -Source201: dracut-fadump-module-setup.sh BuildRequires: automake BuildRequires: autoconf @@ -174,6 +132,8 @@ target. %prep %setup -q +tar -z -x -v -f %{SOURCE1} + mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} @@ -201,21 +161,6 @@ autoreconf rm -f kexec-tools.spec.in make -# kdump-utils -# setup the docs -cp %{SOURCE10} . -cp %{SOURCE11} . -cp %{SOURCE21} . -cp %{SOURCE26} . -cp %{SOURCE27} . -cp %{SOURCE34} . -cp %{SOURCE38} . - -# Generate sysconfig file -%{SOURCE3} %{_target_cpu} > kdump.sysconfig -%{SOURCE4} %{_target_cpu} > kdump.conf - - # makedumpfile make -C eppic-%{eppic_ver}/libeppic make -C makedumpfile-%{mkdf_ver} LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on @@ -227,60 +172,8 @@ make -C makedumpfile-%{mkdf_ver} LDFLAGS="$LDFLAGS -I../eppic-%{eppic_ver}/libep rm -f %{buildroot}/%{_libdir}/kexec-tools/kexec_test # kdump-utils -mkdir -p -m755 %{buildroot}%{_sysconfdir}/kdump/pre.d -mkdir -p -m755 %{buildroot}%{_sysconfdir}/kdump/post.d -mkdir -p -m755 %{buildroot}%{_localstatedir}/crash -mkdir -p -m755 %{buildroot}%{_udevrulesdir} -mkdir -p -m755 %{buildroot}%{_sharedstatedir}/kdump - -install -D -m 755 %{SOURCE1} %{buildroot}%{_bindir}/kdumpctl -install -D -m 755 %{SOURCE7} %{buildroot}%{_sbindir}/mkdumprd -install -D -m 644 kdump.conf %{buildroot}%{_sysconfdir}/kdump.conf -install -D -m 644 kdump.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/kdump -install -D -m 644 %{SOURCE12} %{SOURCE25} -t %{buildroot}%{_mandir}/man8 -install -D -m 755 %{SOURCE20} %{SOURCE23} %{SOURCE31} -t %{buildroot}%{_prefix}/lib/kdump -%ifarch ppc64 ppc64le -install -m 755 %{SOURCE32} %{buildroot}%{_sbindir}/mkfadumprd -install -m 755 %{SOURCE35} %{SOURCE36} -t %{buildroot}%{_prefix}/lib/kdump -%endif -%ifnarch s390x -install -m 755 %{SOURCE28} %{buildroot}%{_udevrulesdir}/../kdump-udev-throttler -%endif -%ifnarch s390x ppc64 ppc64le -# For s390x the ELF header is created in the kdump kernel and therefore kexec -# udev rules are not required -install -m 644 %{SOURCE13} %{buildroot}%{_udevrulesdir}/98-kexec.rules -%endif -%ifarch ppc64 ppc64le -install -m 644 %{SOURCE14} %{buildroot}%{_udevrulesdir}/98-kexec.rules -install -m 755 -D %{SOURCE37} %{buildroot}%{_prefix}/lib/kernel/install.d/60-fadump.install -%endif -install -D -m 644 %{SOURCE15} %{buildroot}%{_mandir}/man5/kdump.conf.5 -install -D -m 644 %{SOURCE16} %{buildroot}%{_unitdir}/kdump.service -install -m 755 -D %{SOURCE22} %{buildroot}%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh -install -m 755 -D %{SOURCE30} %{buildroot}%{_prefix}/lib/kernel/install.d/60-kdump.install -install -m 755 -D %{SOURCE33} %{buildroot}%{_prefix}/lib/kernel/install.d/92-crashkernel.install - -%define dracutdir %{_prefix}/lib/dracut/modules.d - -# deal with dracut modules -mkdir -p -m755 %{buildroot}/%{dracutdir}/99kdumpbase -install -m 755 %{SOURCE100} %{buildroot}/%{dracutdir}/99kdumpbase/kdump.sh -install -m 755 %{SOURCE101} %{buildroot}/%{dracutdir}/99kdumpbase/module-setup.sh -install -m 755 %{SOURCE102} %{buildroot}/%{dracutdir}/99kdumpbase/monitor_dd_progress.sh -install -m 644 %{SOURCE104} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-emergency.service -install -m 644 %{SOURCE106} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-capture.service -install -m 644 %{SOURCE107} %{buildroot}/%{dracutdir}/99kdumpbase/kdump-emergency.target - -mkdir -p -m755 %{buildroot}/%{dracutdir}/99earlykdump -install -m 755 %{SOURCE108} %{buildroot}/%{dracutdir}/99earlykdump/kdump.sh -install -m 755 %{SOURCE109} %{buildroot}/%{dracutdir}/99earlykdump/kdump-module-setup.sh - -%ifarch ppc64 ppc64le -mkdir -p -m755 %{buildroot}/%{dracutdir}/99zz-fadumpinit -install -m 755 %{SOURCE200} %{buildroot}/%{dracutdir}/99zz-fadumpinit/init-fadump.sh -install -m 755 %{SOURCE201} %{buildroot}/%{dracutdir}/99zz-fadumpinit/module-setup.sh -%endif +%define kdump_utils_dir kdump-utils-%{kdump_utils_ver} +make DESTDIR=%{buildroot} -C %kdump_utils_dir install # makedumpfile @@ -366,7 +259,7 @@ fi %{_udevrulesdir} %{_udevrulesdir}/../kdump-udev-throttler %endif -%{dracutdir}/* +%{_prefix}/lib/dracut/modules.d/* %dir %{_localstatedir}/crash %dir %{_sysconfdir}/kdump %dir %{_sysconfdir}/kdump/pre.d @@ -379,14 +272,14 @@ fi %{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %{_prefix}/lib/kernel/install.d/60-kdump.install %{_prefix}/lib/kernel/install.d/92-crashkernel.install -%license COPYING -%doc kexec-kdump-howto.txt -%doc early-kdump-howto.txt -%doc fadump-howto.txt -%doc kdump-in-cluster-environment.txt -%doc live-image-kdump-howto.txt -%doc crashkernel-howto.txt -%doc supported-kdump-targets.txt +%license %kdump_utils_dir/COPYING +%doc %kdump_utils_dir/kexec-kdump-howto.txt +%doc %kdump_utils_dir/early-kdump-howto.txt +%doc %kdump_utils_dir/fadump-howto.txt +%doc %kdump_utils_dir/kdump-in-cluster-environment.txt +%doc %kdump_utils_dir/live-image-kdump-howto.txt +%doc %kdump_utils_dir/crashkernel-howto.txt +%doc %kdump_utils_dir/supported-kdump-targets.txt %files -n makedumpfile @@ -400,7 +293,7 @@ fi %changelog -* Tue Mar 19 2024 Coiby Xu - 2.0.28-8 +* Tue Apr 09 2024 Coiby Xu - 2.0.28-8 - Add a kdump-utils subpackage * Sun Apr 07 2024 Coiby Xu - 2.0.28-7 From a5c17afe7e871f7a2593d04b97e8e77fb434642c Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 12 Jan 2024 20:00:53 +0800 Subject: [PATCH 780/806] Fix potential-bashisms in monitor_dd_progress As suggested by Carl [1], > /usr/lib/dracut/modules.d/99kdumpbase/monitor_dd_progress has some > inconsistencies with other scripts in that directory. It is missing the > .sh extension and is not executable. The latter is resulting in an > rpmlint error. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2239566#c2 Suggested-by: Carl George Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- dracut-kdump.sh | 2 +- dracut-module-setup.sh | 3 +-- dracut-monitor_dd_progress => dracut-monitor_dd_progress.sh | 0 3 files changed, 2 insertions(+), 3 deletions(-) rename dracut-monitor_dd_progress => dracut-monitor_dd_progress.sh (100%) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 1fc2231..7b3ad7a 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -377,7 +377,7 @@ dump_raw() if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then _src_size=$(stat --format %s /proc/vmcore) _src_size_mb=$((_src_size / 1048576)) - /kdumpscripts/monitor_dd_progress $_src_size_mb & + /kdumpscripts/monitor_dd_progress.sh $_src_size_mb & fi dinfo "saving vmcore" diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index daa6b26..7e1cb9f 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -1020,8 +1020,7 @@ install() { kdump_install_random_seed fi dracut_install -o /etc/adjtime /etc/localtime - inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress" - chmod +x "${initdir}/kdumpscripts/monitor_dd_progress" + inst "$moddir/monitor_dd_progress.sh" "/kdumpscripts/monitor_dd_progress.sh" inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date" diff --git a/dracut-monitor_dd_progress b/dracut-monitor_dd_progress.sh similarity index 100% rename from dracut-monitor_dd_progress rename to dracut-monitor_dd_progress.sh From 2ed88633ade0f1e5523d8097d96df3fde1287ea7 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 9 Apr 2024 09:04:11 +0800 Subject: [PATCH 781/806] kexec-tools: use make_install use consistent build flags %make_install to have the benefits like enabling parallel building automatically. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index cf88e5b..32fddaf 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -159,7 +159,7 @@ autoreconf %endif --sbindir=/usr/sbin rm -f kexec-tools.spec.in -make +%make_build # makedumpfile make -C eppic-%{eppic_ver}/libeppic From b3620b0dbc3e0fb9a92ab5faf34ac3b4e7bb7bd9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 9 Apr 2024 09:25:48 +0800 Subject: [PATCH 782/806] makedumpfile: remove explicit-lib-dependency zlib Fix the following error found by rpmlint, makedumpfile.x86_64: E: explicit-lib-dependency zlib You must let rpm find the library dependencies by itself. Do not put unneeded explicit Requires: tags. Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo Reviewed-by: Dave Young --- kexec-tools.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 32fddaf..254d88a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -71,7 +71,6 @@ License: GPL-2.0-only URL: https://github.com/makedumpfile/makedumpfile Conflicts: kexec-tools < 2.0.28-5 -Requires(pre): zlib BuildRequires: make BuildRequires: gcc BuildRequires: zlib-devel From 5be9c9af09b8d883861707f07c344dfbfde993da Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 13 Apr 2024 09:59:41 +0800 Subject: [PATCH 783/806] Use upstream source Signed-off-by: Coiby Xu --- 60-fadump.install | 31 - 60-kdump.install | 36 - 92-crashkernel.install | 13 - 98-kexec.rules | 16 - 98-kexec.rules.ppc64 | 22 - COPYING | 339 ------ Makefile | 83 -- crashkernel-howto.txt | 120 -- dracut-early-kdump-module-setup.sh | 65 - dracut-early-kdump.sh | 79 -- dracut-fadump-init-fadump.sh | 48 - dracut-fadump-module-setup.sh | 23 - dracut-kdump-capture.service | 30 - dracut-kdump-emergency.service | 27 - dracut-kdump-emergency.target | 14 - dracut-kdump.sh | 624 ---------- dracut-module-setup.sh | 1083 ----------------- dracut-monitor_dd_progress.sh | 28 - early-kdump-howto.txt | 95 -- fadump-howto.txt | 359 ------ gen-kdump-conf.sh | 225 ---- gen-kdump-sysconfig.sh | 114 -- kdump-dep-generator.sh | 23 - kdump-in-cluster-environment.txt | 91 -- kdump-lib-initramfs.sh | 173 --- kdump-lib.sh | 1117 ------------------ kdump-logger.sh | 355 ------ kdump-migrate-action.sh | 8 - kdump-restart.sh | 8 - kdump-udev-throttler | 42 - kdump.conf.5 | 397 ------- kdump.service | 17 - kdumpctl | 1770 ---------------------------- kdumpctl.8 | 72 -- kexec-kdump-howto.txt | 1055 ----------------- live-image-kdump-howto.txt | 25 - mkdumprd | 417 ------- mkdumprd.8 | 39 - mkfadumprd | 74 -- sources | 1 + supported-kdump-targets.txt | 119 -- zanata-notes.txt | 79 -- 42 files changed, 1 insertion(+), 9355 deletions(-) delete mode 100755 60-fadump.install delete mode 100755 60-kdump.install delete mode 100755 92-crashkernel.install delete mode 100644 98-kexec.rules delete mode 100644 98-kexec.rules.ppc64 delete mode 100644 COPYING delete mode 100644 Makefile delete mode 100644 crashkernel-howto.txt delete mode 100755 dracut-early-kdump-module-setup.sh delete mode 100755 dracut-early-kdump.sh delete mode 100755 dracut-fadump-init-fadump.sh delete mode 100644 dracut-fadump-module-setup.sh delete mode 100644 dracut-kdump-capture.service delete mode 100644 dracut-kdump-emergency.service delete mode 100644 dracut-kdump-emergency.target delete mode 100755 dracut-kdump.sh delete mode 100755 dracut-module-setup.sh delete mode 100644 dracut-monitor_dd_progress.sh delete mode 100644 early-kdump-howto.txt delete mode 100644 fadump-howto.txt delete mode 100755 gen-kdump-conf.sh delete mode 100755 gen-kdump-sysconfig.sh delete mode 100644 kdump-dep-generator.sh delete mode 100644 kdump-in-cluster-environment.txt delete mode 100755 kdump-lib-initramfs.sh delete mode 100755 kdump-lib.sh delete mode 100755 kdump-logger.sh delete mode 100755 kdump-migrate-action.sh delete mode 100644 kdump-restart.sh delete mode 100755 kdump-udev-throttler delete mode 100644 kdump.conf.5 delete mode 100644 kdump.service delete mode 100755 kdumpctl delete mode 100644 kdumpctl.8 delete mode 100644 kexec-kdump-howto.txt delete mode 100644 live-image-kdump-howto.txt delete mode 100644 mkdumprd delete mode 100644 mkdumprd.8 delete mode 100755 mkfadumprd delete mode 100644 supported-kdump-targets.txt delete mode 100644 zanata-notes.txt diff --git a/60-fadump.install b/60-fadump.install deleted file mode 100755 index 75318ff..0000000 --- a/60-fadump.install +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/bash - -COMMAND="$1" -KERNEL_VERSION="$2" - -if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then - exit 0 -fi - -# Currently, fadump is supported only in environments with -# writable /boot directory. -if [[ ! -w "/boot" ]]; then - exit 0 -fi - -FADUMP_INITRD="/boot/.initramfs-${KERNEL_VERSION}.img.default" -FADUMP_INITRD_CHECKSUM="$FADUMP_INITRD.checksum" - -ret=0 -case "$COMMAND" in - add) - # Do nothing, fadump initramfs is strictly host only - # and managed by kdump service - ;; - remove) - rm -f -- "$FADUMP_INITRD" - rm -f -- "$FADUMP_INITRD_CHECKSUM" - ret=$? - ;; -esac -exit $ret diff --git a/60-kdump.install b/60-kdump.install deleted file mode 100755 index 5b0e021..0000000 --- a/60-kdump.install +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/bash - -COMMAND="$1" -KERNEL_VERSION="$2" -KDUMP_INITRD_DIR_ABS="$3" -KERNEL_IMAGE="$4" - -if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then - exit 0 -fi - -if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then - KDUMP_INITRD="initrdkdump" -else - # If `KDUMP_BOOTDIR` is not writable, then the kdump - # initrd must have been placed at `/var/lib/kdump` - if [[ ! -w "/boot" ]]; then - KDUMP_INITRD_DIR_ABS="/var/lib/kdump" - else - KDUMP_INITRD_DIR_ABS="/boot" - fi - KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img" -fi - -ret=0 -case "$COMMAND" in - add) - # Do nothing, kdump initramfs is strictly host only - # and managed by kdump service - ;; - remove) - rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD" - ret=$? - ;; -esac -exit $ret diff --git a/92-crashkernel.install b/92-crashkernel.install deleted file mode 100755 index 19bd078..0000000 --- a/92-crashkernel.install +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/bash - -COMMAND="$1" -KERNEL_VERSION="$2" -KDUMP_INITRD_DIR_ABS="$3" -KERNEL_IMAGE="$4" - -case "$COMMAND" in -add) - kdumpctl _reset-crashkernel-for-installed_kernel "$KERNEL_VERSION" - exit 0 - ;; -esac diff --git a/98-kexec.rules b/98-kexec.rules deleted file mode 100644 index b73b701..0000000 --- a/98-kexec.rules +++ /dev/null @@ -1,16 +0,0 @@ -SUBSYSTEM=="cpu", ACTION=="add", GOTO="kdump_reload" -SUBSYSTEM=="cpu", ACTION=="remove", GOTO="kdump_reload" -SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload" -SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload" - -GOTO="kdump_reload_end" - -LABEL="kdump_reload" - -# If kdump is not loaded, calling kdump-udev-throttle will end up -# doing nothing, but systemd-run will always generate extra logs for -# each call, so trigger the kdump-udev-throttler only if kdump -# service is active to avoid unnecessary logs -RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" - -LABEL="kdump_reload_end" diff --git a/98-kexec.rules.ppc64 b/98-kexec.rules.ppc64 deleted file mode 100644 index e9db276..0000000 --- a/98-kexec.rules.ppc64 +++ /dev/null @@ -1,22 +0,0 @@ -SUBSYSTEM=="cpu", ACTION=="online", GOTO="kdump_reload_cpu" -SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload_mem" -SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload_mem" - -GOTO="kdump_reload_end" - -# If kdump is not loaded, calling kdump-udev-throttle will end up -# doing nothing, but systemd-run will always generate extra logs for -# each call, so trigger the kdump-udev-throttler only if kdump -# service is active to avoid unnecessary logs - -LABEL="kdump_reload_mem" - -RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" - -GOTO="kdump_reload_end" - -LABEL="kdump_reload_cpu" - -RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; ! test -f /sys/kernel/fadump/enabled || cat /sys/kernel/fadump/enabled | grep 0 || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'" - -LABEL="kdump_reload_end" diff --git a/COPYING b/COPYING deleted file mode 100644 index d159169..0000000 --- a/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/Makefile b/Makefile deleted file mode 100644 index e1a511c..0000000 --- a/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -prefix ?= /usr -libdir ?= ${prefix}/lib -datadir ?= ${prefix}/share -pkglibdir ?= ${libdir}/kdump -sysconfdir ?= /etc -bindir ?= ${prefix}/bin -sbindir ?= ${prefix}/sbin -mandir ?= ${prefix}/share/man -localstatedir ?= /var -sharedstatedir ?= /var/lib -udevrulesdir ?= ${libdir}/udev/rules.d -systemdsystemunitdir ?= ${libdir}/systemd/system/ -ARCH ?= $(shell uname -m) -dracutmoddir = $(DESTDIR)${libdir}/dracut/modules.d -kdumpbasemoddir = $(dracutmoddir)/99kdumpbase - -dracut-modules: - mkdir -p $(dracutmoddir) - mkdir -p -m755 $(kdumpbasemoddir) - - install -m 755 dracut-kdump.sh $(kdumpbasemoddir)/kdump.sh - install -m 755 dracut-module-setup.sh $(kdumpbasemoddir)/module-setup.sh - install -m 755 dracut-monitor_dd_progress.sh $(kdumpbasemoddir)/monitor_dd_progress.sh - install -m 644 dracut-kdump-emergency.service $(kdumpbasemoddir)/kdump-emergency.service - install -m 644 dracut-kdump-capture.service $(kdumpbasemoddir)/kdump-capture.service - install -m 644 dracut-kdump-emergency.target $(kdumpbasemoddir)/kdump-emergency.target - - mkdir -p -m755 $(dracutmoddir)/99earlykdump - install -m 755 dracut-early-kdump.sh $(dracutmoddir)/99earlykdump/kdump.sh - install -m 755 dracut-early-kdump-module-setup.sh $(dracutmoddir)/99earlykdump/kdump-module-setup.sh - -ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) - mkdir -p -m755 $(dracutmoddir)/99zz-fadumpinit - install -m 755 dracut-fadump-init-fadump.sh $(dracutmoddir)/99zz-fadumpinit/init-fadump.sh - install -m 755 dracut-fadump-module-setup.sh $(dracutmoddir)/99zz-fadumpinit/module-setup.sh -endif - -kdump-conf: gen-kdump-conf.sh - ./gen-kdump-conf.sh $(ARCH) > kdump.conf - -kdump-sysconfig: gen-kdump-sysconfig.sh - ./gen-kdump-sysconfig.sh $(ARCH) > kdump.sysconfig - -manpages: - install -D -m 644 mkdumprd.8 kdumpctl.8 -t $(DESTDIR)$(mandir)/man8 - install -D -m 644 kdump.conf.5 $(DESTDIR)$(mandir)/man5/kdump.conf.5 - -install: dracut-modules kdump-conf kdump-sysconfig manpages - mkdir -p $(DESTDIR)$(pkglibdir) - mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/pre.d - mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/post.d - mkdir -p -m755 $(DESTDIR)$(localstatedir)/crash - mkdir -p -m755 $(DESTDIR)$(udevrulesdir) - mkdir -p -m755 $(DESTDIR)$(sharedstatedir)/kdump - mkdir -p -m755 $(DESTDIR)$(libdir)/kernel/install.d/ - - install -D -m 755 kdumpctl $(DESTDIR)$(bindir)/kdumpctl - install -D -m 755 mkdumprd $(DESTDIR)$(sbindir)/mkdumprd - install -D -m 644 kdump.conf $(DESTDIR)$(sysconfdir) - install -D -m 644 kdump.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/kdump - install -D -m 755 kdump-lib.sh kdump-lib-initramfs.sh kdump-logger.sh -t $(DESTDIR)$(pkglibdir) - -ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) - install -m 755 mkfadumprd $(DESTDIR)$(sbindir) - install -m 755 kdump-migrate-action.sh kdump-restart.sh -t $(DESTDIR)$(pkglibdir) - install -m 755 60-fadump.install $(DESTDIR)$(libdir)/kernel/install.d/ -endif - -ifneq ($(ARCH),s390x) - install -m 755 kdump-udev-throttler $(DESTDIR)$(udevrulesdir)/../kdump-udev-throttler - # For s390x the ELF header is created in the kdump kernel and therefore kexec - # udev rules are not required -ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) - install -m 644 98-kexec.rules.ppc64 $(DESTDIR)$(udevrulesdir)/98-kexec.rules -else - install -m 644 98-kexec.rules $(DESTDIR)$(udevrulesdir)/98-kexec.rules -endif -endif - - install -D -m 644 kdump.service $(DESTDIR)$(systemdsystemunitdir)/kdump.service - install -m 755 -D kdump-dep-generator.sh $(DESTDIR)$(libdir)/systemd/system-generators/kdump-dep-generator.sh - install -m 755 60-kdump.install $(DESTDIR)$(libdir)/kernel/install.d/ - install -m 755 92-crashkernel.install $(DESTDIR)$(libdir)/kernel/install.d/ diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt deleted file mode 100644 index 54e1141..0000000 --- a/crashkernel-howto.txt +++ /dev/null @@ -1,120 +0,0 @@ -Introduction -============ - -This document describes features the kexec-tools package provides for setting -and estimating the crashkernel value. - -Kdump lives in a pre-reserved chunk of memory, and the size of the reserved -memory is specified by the `crashkernel=` kernel parameter. It's hard to -estimate an accurate `crashkernel=` value, so it's always recommended to test -kdump after you updated the `crashkernel=` value or changed the dump target. - - -Default crashkernel value -========================= - -Latest kexec-tools provides "kdumpctl get-default-crashkernel" to retrieve -the default crashkernel value, - - $ echo $(kdumpctl get-default-crashkernel) - 1G-4G:192M,4G-64G:256M,64G-:512M - -It will be taken as the default value of 'crashkernel=', you can use -this value as a reference for setting crashkernel value manually. - - -New installed system -==================== - -Anaconda is the OS installer which sets all the kernel boot cmdline on a newly -installed system. If kdump is enabled during Anaconda installation, Anaconda -will use the default crashkernel value as the default `crashkernel=` value on -the newly installed system. - -Users can override the value during Anaconda installation manually. - - -Auto update of crashkernel boot parameter -========================================= - -A new release of kexec-tools could update the default crashkernel value. By -default, kexec-tools would reset crashkernel to the new default value if it -detects the old default crashkernel value is used by installed kernels. If you -don't want kexec-tools to update the old default crashkernel to the new default -crashkernel, you can change auto_reset_crashkernel to no in kdump.conf. - -Supported Bootloaders ---------------------- - -This auto update only works with GRUB2 and ZIPL, as kexec-tools heavily depends -on `grubby`. If other boot loaders are used, the user will have to update the -`crashkernel=` value manually. - - -Reset crashkernel to default value -================================== - -kexec-tools only perform the auto update of crashkernel value when it can -confirm the boot kernel's crashkernel value is using its corresponding default -value and auto_reset_crashkernel=yes in kdump.conf. In other cases, the user -can reset the crashkernel value by themselves. - -Reset using kdumpctl --------------------- - -To make it easier to reset the `crashkernel=` kernel cmdline to this default -value properly, `kdumpctl` also provides a sub-command: - - `kdumpctl reset-crashkernel [--kernel=path_to_kernel] [--reboot]` - -This command will reset the bootloader's kernel cmdline to the default value. -It will also update bootloader config if the bootloader has a standalone config -file. User will have to reboot the machine after this command to make it take -effect if --reboot is not specified. For more details, please refer to the -reset-crashkernel command in `man kdumpctl`. - -Reset manually --------------- - -To reset the crashkernel value manually, it's recommended to use utils like -`grubby`. A one liner script for resetting `crashkernel=` value of all installed -kernels to the default value is: - - grubby --update-kernel ALL --args "crashkernel=$(kdumpctl get-default-crashkernel)" - -NOTE: On s390x you also need to run zipl for the change to take effect. - -Estimate crashkernel -==================== - -The best way to estimate a usable crashkernel value is by testing kdump -manually. And you can set crashkernel to a large value, then adjust the -crashkernel value to an acceptable value gradually. - -`kdumpctl` also provides a sub-command for doing rough estimating without -triggering kdump: - - `kdumpctl estimate` - -The output will be like this: - -``` - Encrypted kdump target requires extra memory, assuming using the keyslot with minimum memory requirement - - Reserved crashkernel: 256M - Recommended crashkernel: 655M - - Kernel image size: 47M - Kernel modules size: 12M - Initramfs size: 19M - Runtime reservation: 64M - LUKS required size: 512M - Large modules: - xfs: 1892352 - nouveau: 2318336 - WARNING: Current crashkernel size is lower than recommended size 655M. -``` - -It will generate a summary report about the estimated memory consumption -of each component of kdump. The value may not be accurate enough, but -would be a good start for finding a suitable crashkernel value. diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh deleted file mode 100755 index 0451118..0000000 --- a/dracut-early-kdump-module-setup.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -. /etc/sysconfig/kdump - -KDUMP_KERNEL="" -KDUMP_INITRD="" - -check() { - if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]] \ - || [[ -n ${IN_KDUMP} ]]; then - return 1 - fi - return 255 -} - -depends() { - echo "base shutdown" - return 0 -} - -prepare_kernel_initrd() { - . /lib/kdump/kdump-lib.sh - - prepare_kdump_bootinfo - - # $kernel is a variable from dracut - if [[ $KDUMP_KERNELVER != "$kernel" ]]; then - dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ - "but the initramfs is generated for kernel version '$kernel'" - fi -} - -install() { - prepare_kernel_initrd - if [[ ! -f $KDUMP_KERNEL ]]; then - derror "Could not find required kernel for earlykdump," \ - "earlykdump will not work!" - return 1 - fi - if [[ ! -f $KDUMP_INITRD ]]; then - derror "Could not find required kdump initramfs for earlykdump," \ - "please ensure kdump initramfs is generated first," \ - "earlykdump will not work!" - return 1 - fi - - inst_multiple tail find cut dirname hexdump - inst_simple "/etc/sysconfig/kdump" - inst_binary "/usr/sbin/kexec" - inst_binary "/usr/bin/gawk" "/usr/bin/awk" - inst_binary "/usr/bin/logger" "/usr/bin/logger" - inst_binary "/usr/bin/printf" "/usr/bin/printf" - inst_binary "/usr/bin/xargs" "/usr/bin/xargs" - inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" - inst_script "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump/kdump-lib-initramfs.sh" - inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" - inst_hook cmdline 00 "$moddir/early-kdump.sh" - inst_binary "$KDUMP_KERNEL" - inst_binary "$KDUMP_INITRD" - - ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump" - ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump" - - chmod -x "${initdir}/$KDUMP_KERNEL" -} diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh deleted file mode 100755 index 4fd8e90..0000000 --- a/dracut-early-kdump.sh +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/bash - -KEXEC=/sbin/kexec -standard_kexec_args="-p" - -EARLY_KDUMP_INITRD="" -EARLY_KDUMP_KERNEL="" -EARLY_KDUMP_CMDLINE="" -EARLY_KEXEC_ARGS="" - -. /etc/sysconfig/kdump -. /lib/dracut-lib.sh -. /lib/kdump-lib.sh -. /lib/kdump-logger.sh - -# initiate the kdump logger -if ! dlog_init; then - echo "failed to initiate the kdump logger." - exit 1 -fi - -prepare_parameters() -{ - EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump" - EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump" -} - -early_kdump_load() -{ - if ! check_kdump_feasibility; then - return 1 - fi - - if is_fadump_capable; then - dwarn "WARNING: early kdump doesn't support fadump." - return 1 - fi - - if is_kernel_loaded "kdump"; then - return 1 - fi - - prepare_parameters - - EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") - - # Here, only output the messages, but do not save these messages - # to a file because the target disk may not be mounted yet, the - # earlykdump is too early. - ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \ - --command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \ - $EARLY_KDUMP_KERNEL" - - # shellcheck disable=SC2086 - if $KEXEC $EARLY_KEXEC_ARGS $standard_kexec_args \ - --command-line="$EARLY_KDUMP_CMDLINE" \ - --initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL; then - dinfo "kexec: loaded early-kdump kernel" - return 0 - else - derror "kexec: failed to load early-kdump kernel" - return 1 - fi -} - -set_early_kdump() -{ - if getargbool 0 rd.earlykdump; then - dinfo "early-kdump is enabled." - early_kdump_load - else - dinfo "early-kdump is disabled." - fi - - return 0 -} - -set_early_kdump diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh deleted file mode 100755 index 94a3751..0000000 --- a/dracut-fadump-init-fadump.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -export PATH=/usr/bin:/usr/sbin -export SYSTEMD_IN_INITRD=lenient - -[ -e /proc/mounts ] || - (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc) - -grep -q '^sysfs /sys sysfs' /proc/mounts || - (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys) - -grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1 - -if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then - mkdir /newroot - mount -t ramfs ramfs /newroot - - if [ $ROOTFS_IS_RAMFS ]; then - for FILE in $(ls -A /fadumproot/); do - mv /fadumproot/$FILE /newroot/ - done - exec switch_root /newroot /init - else - mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot - - grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev - grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run - mount --move /sys /newroot/sys - mount --move /proc /newroot/proc - - cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/ - cd /newroot && pivot_root . oldroot - - loop=1 - while [ $loop ]; do - unset loop - while read -r _ mp _; do - case $mp in - /oldroot/*) umount -d "$mp" && loop=1 ;; - esac - done $KDUMP_CONF_PARSED - -get_kdump_confs() -{ - while read -r config_opt config_val; do - # remove inline comments after the end of a directive. - case "$config_opt" in - path) - KDUMP_PATH="$config_val" - ;; - core_collector) - [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" - ;; - sshkey) - if [ -f "$config_val" ]; then - SSH_KEY_LOCATION=$config_val - fi - ;; - kdump_pre) - KDUMP_PRE="$config_val" - ;; - kdump_post) - KDUMP_POST="$config_val" - ;; - fence_kdump_args) - FENCE_KDUMP_ARGS="$config_val" - ;; - fence_kdump_nodes) - FENCE_KDUMP_NODES="$config_val" - ;; - failure_action | default) - case $config_val in - shell) - FAILURE_ACTION="kdump_emergency_shell" - ;; - reboot) - FAILURE_ACTION="systemctl reboot -f && exit" - ;; - halt) - FAILURE_ACTION="halt && exit" - ;; - poweroff) - FAILURE_ACTION="systemctl poweroff -f && exit" - ;; - dump_to_rootfs) - FAILURE_ACTION="dump_to_rootfs" - ;; - esac - ;; - final_action) - case $config_val in - reboot) - FINAL_ACTION="systemctl reboot -f" - ;; - halt) - FINAL_ACTION="halt" - ;; - poweroff) - FINAL_ACTION="systemctl poweroff -f" - ;; - esac - ;; - esac - done < "$KDUMP_CONF_PARSED" - - if [ -z "$CORE_COLLECTOR" ]; then - CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" - if is_ssh_dump_target || is_raw_dump_target; then - CORE_COLLECTOR="$CORE_COLLECTOR -F" - fi - fi -} - -# store the kexec kernel log to a file. -save_log() -{ - # LOG_OP is empty when log can't be saved, eg. raw target - [ -n "$KDUMP_LOG_OP" ] || return - - dmesg -T > $KDUMP_LOG_FILE - - if command -v journalctl > /dev/null; then - journalctl -ab >> $KDUMP_LOG_FILE - fi - chmod 600 $KDUMP_LOG_FILE - - dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/" - - eval "$KDUMP_LOG_OP" -} - -# $1: dump path, must be a mount point -dump_fs() -{ - ddebug "dump_fs _mp=$1" - - if ! is_mounted "$1"; then - dinfo "dump path '$1' is not mounted, trying to mount..." - if ! mount --target "$1"; then - derror "failed to dump to '$1', it's not a mount point!" - return 1 - fi - fi - - # Remove -F in makedumpfile case. We don't want a flat format dump here. - case $CORE_COLLECTOR in - *makedumpfile*) - CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") - ;; - esac - - _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) - dinfo "saving to $_dump_fs_path" - - # Only remount to read-write mode if the dump target is mounted read-only. - _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) - case $_dump_mnt_op in - ro*) - dinfo "Remounting the dump target in rw mode." - mount -o remount,rw "$1" || return 1 - ;; - esac - - mkdir -p "$_dump_fs_path" || return 1 - - save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" - save_opalcore_fs "$_dump_fs_path" - - dinfo "saving vmcore" - KDUMP_LOG_DEST=$_dump_fs_path/ - KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'" - - $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" - _dump_exitcode=$? - if [ $_dump_exitcode -eq 0 ]; then - sync -f "$_dump_fs_path/vmcore-incomplete" - _sync_exitcode=$? - if [ $_sync_exitcode -eq 0 ]; then - mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" - dinfo "saving vmcore complete" - else - derror "sync vmcore failed, exitcode:$_sync_exitcode" - return 1 - fi - else - derror "saving vmcore failed, exitcode:$_dump_exitcode" - return 1 - fi - - # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure - return 0 -} - -# $1: dmesg collector -# $2: dump path -save_vmcore_dmesg_fs() -{ - dinfo "saving vmcore-dmesg.txt to $2" - if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then - mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" - chmod 600 "$2/vmcore-dmesg.txt" - - # Make sure file is on disk. There have been instances where later - # saving vmcore failed and system rebooted without sync and there - # was no vmcore-dmesg.txt available. - sync - dinfo "saving vmcore-dmesg.txt complete" - else - if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then - chmod 600 "$2/vmcore-dmesg-incomplete.txt" - fi - derror "saving vmcore-dmesg.txt failed" - fi -} - -# $1: dump path -save_opalcore_fs() -{ - if [ ! -f $OPALCORE ]; then - # Check if we are on an old kernel that uses a different path - if [ -f /sys/firmware/opal/core ]; then - OPALCORE="/sys/firmware/opal/core" - else - return 0 - fi - fi - - dinfo "saving opalcore:$OPALCORE to $1/opalcore" - if ! cp $OPALCORE "$1/opalcore"; then - derror "saving opalcore failed" - return 1 - fi - - sync - dinfo "saving opalcore complete" - return 0 -} - -dump_to_rootfs() -{ - - if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then - dinfo "Trying to bring up initqueue for rootfs mount" - systemctl start dracut-initqueue - fi - - dinfo "Clean up dead systemd services" - systemctl cancel - dinfo "Waiting for rootfs mount, will timeout after 90 seconds" - systemctl start --no-block sysroot.mount - - _loop=0 - while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do - sleep 1 - _loop=$((_loop + 1)) - done - - if ! is_mounted /sysroot; then - derror "Failed to mount rootfs" - return - fi - - ddebug "NEWROOT=$NEWROOT" - dump_fs $NEWROOT -} - -kdump_emergency_shell() -{ - ddebug "Switching to kdump emergency shell..." - - [ -f /etc/profile ] && . /etc/profile - export PS1='kdump:${PWD}# ' - - . /lib/dracut-lib.sh - if [ -f /dracut-state.sh ]; then - . /dracut-state.sh 2> /dev/null - fi - - source_conf /etc/conf.d - - type plymouth > /dev/null 2>&1 && plymouth quit - - source_hook "emergency" - while read -r _tty rest; do - ( - echo - echo - echo 'Entering kdump emergency mode.' - echo 'Type "journalctl" to view system logs.' - echo 'Type "rdsosreport" to generate a sosreport, you can then' - echo 'save it elsewhere and attach it to a bug report.' - echo - echo - ) > "/dev/$_tty" - done < /proc/consoles - sh -i -l - /bin/rm -f -- /.console_lock -} - -do_failure_action() -{ - dinfo "Executing failure action $FAILURE_ACTION" - eval $FAILURE_ACTION -} - -do_final_action() -{ - dinfo "Executing final action $FINAL_ACTION" - eval $FINAL_ACTION -} - -do_dump() -{ - eval $DUMP_INSTRUCTION - _ret=$? - - if [ $_ret -ne 0 ]; then - derror "saving vmcore failed" - fi - - return $_ret -} - -do_kdump_pre() -{ - if [ -n "$KDUMP_PRE" ]; then - "$KDUMP_PRE" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$KDUMP_PRE exited with $_ret status" - return $_ret - fi - fi - - # if any script fails, it just raises warning and continues - if [ -d /etc/kdump/pre.d ]; then - for file in /etc/kdump/pre.d/*; do - "$file" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$file exited with $_ret status" - fi - done - fi - return 0 -} - -do_kdump_post() -{ - if [ -d /etc/kdump/post.d ]; then - for file in /etc/kdump/post.d/*; do - "$file" "$1" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$file exited with $_ret status" - fi - done - fi - - if [ -n "$KDUMP_POST" ]; then - "$KDUMP_POST" "$1" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "$KDUMP_POST exited with $_ret status" - fi - fi -} - -# $1: block target, eg. /dev/sda -dump_raw() -{ - [ -b "$1" ] || return 1 - - dinfo "saving to raw disk $1" - - if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then - _src_size=$(stat --format %s /proc/vmcore) - _src_size_mb=$((_src_size / 1048576)) - /kdumpscripts/monitor_dd_progress.sh $_src_size_mb & - fi - - dinfo "saving vmcore" - $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 - sync - - dinfo "saving vmcore complete" - return 0 -} - -# $1: ssh key file -# $2: ssh address in @ format -dump_ssh() -{ - _ret=0 - _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" - _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" - if is_ipv6_address "$2"; then - _scp_address=${2%@*}@"[${2#*@}]" - else - _scp_address=$2 - fi - - dinfo "saving to $2:$_ssh_dir" - - cat /var/lib/random-seed > /dev/urandom - ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 - - save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" - - dinfo "saving vmcore" - - KDUMP_LOG_DEST=$2:$_ssh_dir/ - KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE' '$_scp_address:$_ssh_dir/'" - - save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" - - if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then - scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" - _ret=$? - _vmcore="vmcore" - else - $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" - _ret=$? - _vmcore="vmcore.flat" - fi - - if [ $_ret -eq 0 ]; then - ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "moving vmcore failed, exitcode:$_ret" - else - dinfo "saving vmcore complete" - fi - else - derror "saving vmcore failed, exitcode:$_ret" - fi - - return $_ret -} - -# $1: dump path -# $2: ssh opts -# $3: ssh address in @ format -# $4: scp address, similar with ssh address but IPv6 addresses are quoted -save_opalcore_ssh() -{ - if [ ! -f $OPALCORE ]; then - # Check if we are on an old kernel that uses a different path - if [ -f /sys/firmware/opal/core ]; then - OPALCORE="/sys/firmware/opal/core" - else - return 0 - fi - fi - - dinfo "saving opalcore:$OPALCORE to $3:$1" - - if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then - derror "saving opalcore failed" - return 1 - fi - - ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" - dinfo "saving opalcore complete" - return 0 -} - -# $1: dmesg collector -# $2: dump path -# $3: ssh opts -# $4: ssh address in @ format -save_vmcore_dmesg_ssh() -{ - dinfo "saving vmcore-dmesg.txt to $4:$2" - if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then - ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" - dinfo "saving vmcore-dmesg.txt complete" - else - derror "saving vmcore-dmesg.txt failed" - fi -} - -wait_online_network() -{ - # In some cases, network may still not be ready because nm-online is called - # with "-s" which means to wait for NetworkManager startup to complete, rather - # than waiting for network connectivity specifically. Wait 10mins more for the - # network to be truely ready in these cases. - _loop=0 - while [ $_loop -lt 600 ]; do - sleep 1 - _loop=$((_loop + 1)) - if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then - printf "%s" "$_route" - return - else - dwarn "Waiting for network to be ready (${_loop}s / 10min)" - fi - done - - derror "Oops. The network still isn't ready after waiting 10mins." - exit 1 -} - -get_host_ip() -{ - - if ! is_nfs_dump_target && ! is_ssh_dump_target; then - return 0 - fi - - _kdump_remote_ip=$(getarg kdump_remote_ip=) - - if [ -z "$_kdump_remote_ip" ]; then - derror "failed to get remote IP address!" - return 1 - fi - - if ! _route=$(wait_online_network "$_kdump_remote_ip"); then - return 1 - fi - - _netdev=$(kdump_get_ip_route_field "$_route" "dev") - - if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then - derror "Failed to get IP of $_netdev" - return 1 - fi - - _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') - _kdumpip="${_kdumpip%%/*}" - HOST_IP=$_kdumpip -} - -read_kdump_confs() -{ - if [ ! -f "$KDUMP_CONFIG_FILE" ]; then - derror "$KDUMP_CONFIG_FILE not found" - return - fi - - get_kdump_confs - - # rescan for add code for dump target - while read -r config_opt config_val; do - # remove inline comments after the end of a directive. - case "$config_opt" in - dracut_args) - config_val=$(get_dracut_args_target "$config_val") - if [ -n "$config_val" ]; then - config_val=$(get_mntpoint_from_target "$config_val") - DUMP_INSTRUCTION="dump_fs $config_val" - fi - ;; - ext[234] | xfs | btrfs | minix | nfs | virtiofs) - config_val=$(get_mntpoint_from_target "$config_val") - DUMP_INSTRUCTION="dump_fs $config_val" - ;; - raw) - DUMP_INSTRUCTION="dump_raw $config_val" - ;; - ssh) - DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" - ;; - esac - done < "$KDUMP_CONF_PARSED" -} - -fence_kdump_notify() -{ - if [ -n "$FENCE_KDUMP_NODES" ]; then - # shellcheck disable=SC2086 - $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & - fi -} - -if [ "$1" = "--error-handler" ]; then - get_kdump_confs - do_failure_action - do_final_action - - exit $? -fi - -# continue here only if we have to save dump. -if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then - exit 0 -fi - -read_kdump_confs -fence_kdump_notify - -if ! get_host_ip; then - derror "get_host_ip exited with non-zero status!" - exit 1 -fi - -if [ -z "$DUMP_INSTRUCTION" ]; then - DUMP_INSTRUCTION="dump_fs $NEWROOT" -fi - -if ! do_kdump_pre; then - derror "kdump_pre script exited with non-zero status!" - do_final_action - # During systemd service to reboot the machine, stop this shell script running - exit 1 -fi -make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' -do_dump -DUMP_RETVAL=$? - -if ! do_kdump_post $DUMP_RETVAL; then - derror "kdump_post script exited with non-zero status!" -fi - -save_log - -if [ $DUMP_RETVAL -ne 0 ]; then - exit 1 -fi - -do_final_action diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh deleted file mode 100755 index 7e1cb9f..0000000 --- a/dracut-module-setup.sh +++ /dev/null @@ -1,1083 +0,0 @@ -#!/bin/bash - -_DRACUT_KDUMP_NM_TMP_DIR="$DRACUT_TMPDIR/$$-DRACUT_KDUMP_NM" - -_save_kdump_netifs() { - unique_netifs[$1]=1 -} - -_get_kdump_netifs() { - echo -n "${!unique_netifs[@]}" -} - -kdump_module_init() { - if ! [[ -d "${initdir}/tmp" ]]; then - mkdir -p "${initdir}/tmp" - fi - - mkdir -p "$_DRACUT_KDUMP_NM_TMP_DIR" - - . /lib/kdump/kdump-lib.sh -} - -check() { - [[ $debug ]] && set -x - #kdumpctl sets this explicitly - if [[ -z $IN_KDUMP ]] || [[ ! -f /etc/kdump.conf ]]; then - return 1 - fi - if [[ "$(uname -m)" == "s390x" ]]; then - require_binaries chzdev || return 1 - fi - return 0 -} - -depends() { - local _dep="base shutdown" - - kdump_module_init - - add_opt_module() { - [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" - } - - if is_squash_available; then - add_opt_module squash - else - dwarning "Required modules to build a squashed kdump image is missing!" - fi - - if is_wdt_active; then - add_opt_module watchdog - fi - - if is_ssh_dump_target; then - _dep="$_dep ssh-client" - fi - - if is_lvm2_thinp_dump_target; then - if dracut --list-modules | grep -q lvmthinpool-monitor; then - add_opt_module lvmthinpool-monitor - else - dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057." - fi - fi - - if [[ "$(uname -m)" == "s390x" ]]; then - _dep="$_dep znet" - fi - - if [[ -n "$(ls -A /sys/class/drm 2> /dev/null)" ]] || [[ -d /sys/module/hyperv_fb ]]; then - add_opt_module drm - fi - - if is_generic_fence_kdump || is_pcs_fence_kdump; then - _dep="$_dep network" - fi - - echo "$_dep" -} - -kdump_is_bridge() { - [[ -d /sys/class/net/"$1"/bridge ]] -} - -kdump_is_bond() { - [[ -d /sys/class/net/"$1"/bonding ]] -} - -kdump_is_team() { - [[ -f /usr/bin/teamnl ]] && teamnl "$1" ports &> /dev/null -} - -kdump_is_vlan() { - [[ -f /proc/net/vlan/"$1" ]] -} - -# $1: repeat times -# $2: string to be repeated -# $3: separator -repeatedly_join_str() { - local _count="$1" - local _str="$2" - local _separator="$3" - local i _res - - if [[ $_count -le 0 ]]; then - echo -n "" - return - fi - - i=0 - _res="$_str" - ((_count--)) - - while [[ $i -lt $_count ]]; do - ((i++)) - _res="${_res}${_separator}${_str}" - done - echo -n "$_res" -} - -# $1: prefix -# $2: ipv6_flag="-6" indicates it's IPv6 -# Given a prefix, calculate the netmask (equivalent of "ipcalc -m") -# by concatenating three parts, -# 1) the groups with all bits set 1 -# 2) a group with partial bits set to 0 -# 3) the groups with all bits set to 0 -cal_netmask_by_prefix() { - local _prefix="$1" - local _ipv6_flag="$2" _ipv6 - local _bits_per_octet=8 - local _count _res _octets_per_group _octets_total _seperator _total_groups - local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits - - if [[ $_ipv6_flag == "-6" ]]; then - _ipv6=1 - else - _ipv6=0 - fi - - if [[ $_prefix -lt 0 || $_prefix -gt 128 ]] \ - || ( ((!_ipv6)) && [[ $_prefix -gt 32 ]]); then - derror "Bad prefix:$_prefix for calculating netmask" - exit 1 - fi - - if ((_ipv6)); then - _octets_per_group=2 - _octets_total=16 - _seperator=":" - else - _octets_per_group=1 - _octets_total=4 - _seperator="." - fi - - _total_groups=$((_octets_total / _octets_per_group)) - _bits_per_group=$((_octets_per_group * _bits_per_octet)) - _max_group_value=$(((1 << _bits_per_group) - 1)) - - if ((_ipv6)); then - _max_group_value_repr=$(printf "%x" $_max_group_value) - else - _max_group_value_repr="$_max_group_value" - fi - - _count=$((_prefix / _octets_per_group / _bits_per_octet)) - _first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator") - _res="$_first_part" - - _tmp=$((_octets_total * _bits_per_octet - _prefix)) - _zero_bits=$((_tmp % _bits_per_group)) - if [[ $_zero_bits -ne 0 ]]; then - _second_part=$((_max_group_value >> _zero_bits << _zero_bits)) - if ((_ipv6)); then - _second_part=$(printf "%x" $_second_part) - fi - ((_count++)) - if [[ -z $_first_part ]]; then - _res="$_second_part" - else - _res="${_first_part}${_seperator}${_second_part}" - fi - fi - - _count=$((_total_groups - _count)) - if [[ $_count -eq 0 ]]; then - echo -n "$_res" - return - fi - - if ((_ipv6)) && [[ $_count -gt 1 ]]; then - # use condensed notion for IPv6 - _third_part=":" - else - _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator") - fi - - if [[ -z $_res ]] && ((!_ipv6)); then - echo -n "${_third_part}" - else - echo -n "${_res}${_seperator}${_third_part}" - fi -} - -kdump_get_mac_addr() { - cat "/sys/class/net/$1/address" -} - -#Bonding or team master modifies the mac address -#of its slaves, we should use perm address -kdump_get_perm_addr() { - local addr - addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') - if [[ -z $addr ]] || [[ $addr == "00:00:00:00:00:00" ]]; then - derror "Can't get the permanent address of $1" - else - echo "$addr" - fi -} - -apply_nm_initrd_generator_timeouts() { - local _timeout_conf - - _timeout_conf=$_DRACUT_KDUMP_NM_TMP_DIR/timeout_conf - cat << EOF > "$_timeout_conf" -[device-95-kdump] -carrier-wait-timeout=30000 - -[connection-95-kdump] -ipv4.dhcp-timeout=90 -ipv6.dhcp-timeout=90 -EOF - - inst "$_timeout_conf" "/etc/NetworkManager/conf.d/95-kdump-timeouts.conf" -} - -use_ipv4_or_ipv6() { - local _netif=$1 _uuid=$2 - - if [[ -v "ipv4_usage[$_netif]" ]]; then - nmcli connection modify --temporary "$_uuid" ipv4.may-fail no &> >(ddebug) - fi - - if [[ -v "ipv6_usage[$_netif]" ]]; then - nmcli connection modify --temporary "$_uuid" ipv6.may-fail no &> >(ddebug) - fi - - if [[ -v "ipv4_usage[$_netif]" ]] && [[ ! -v "ipv6_usage[$_netif]" ]]; then - nmcli connection modify --temporary "$_uuid" ipv6.method disabled &> >(ddebug) - elif [[ ! -v "ipv4_usage[$_netif]" ]] && [[ -v "ipv6_usage[$_netif]" ]]; then - nmcli connection modify --temporary "$_uuid" ipv4.method disabled &> >(ddebug) - fi -} - -_clone_nmconnection() { - local _clone_output _name _unique_id - - _unique_id=$1 - _name=$(nmcli --get-values connection.id connection show "$_unique_id") - if _clone_output=$(nmcli connection clone --temporary uuid "$_unique_id" "$_name"); then - sed -E -n "s/.* \(.*\) cloned as.*\((.*)\)\.$/\1/p" <<< "$_clone_output" - return 0 - fi - - return 1 -} - -_match_nmconnection_by_mac() { - local _unique_id _dev _mac _mac_field - - _unique_id=$1 - _dev=$2 - - _mac=$(kdump_get_perm_addr "$_dev") - [[ $_mac != 'not set' ]] || return - _mac_field=$(nmcli --get-values connection.type connection show "$_unique_id").mac-address - nmcli connection modify --temporary "$_unique_id" "$_mac_field" "$_mac" &> >(ddebug) - nmcli connection modify --temporary "$_unique_id" "connection.interface-name" "" &> >(ddebug) -} - -# Clone and modify NM connection profiles -# -# This function makes use of "nmcli clone" to automatically convert ifcfg-* -# files to Networkmanager .nmconnection connection profiles and also modify the -# properties of .nmconnection if necessary. -clone_and_modify_nmconnection() { - local _dev _cloned_nmconnection_file_path _tmp_nmconnection_file_path _old_uuid _uuid - - _dev=$1 - _nmconnection_file_path=$2 - - _old_uuid=$(nmcli --get-values connection.uuid connection show filename "$_nmconnection_file_path") - - if ! _uuid=$(_clone_nmconnection "$_old_uuid"); then - derror "Failed to clone $_old_uuid" - exit 1 - fi - - use_ipv4_or_ipv6 "$_dev" "$_uuid" - - nmcli connection modify --temporary uuid "$_uuid" connection.wait-device-timeout 60000 &> >(ddebug) - # For physical NIC i.e. non-user created NIC, ask NM to match a - # connection profile based on MAC address - _match_nmconnection_by_mac "$_uuid" "$_dev" - - # If a value contain ":", nmcli by default escape it with "\:" because it - # also uses ":" as the delimiter to separate values. In our case, escaping is not needed. - _cloned_nmconnection_file_path=$(nmcli --escape no --get-values UUID,FILENAME connection show | sed -n "s/^${_uuid}://p") - _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename "$_nmconnection_file_path") - cp "$_cloned_nmconnection_file_path" "$_tmp_nmconnection_file_path" - # change uuid back to old value in case it's refered by other connection - # profile e.g. connection.master could be interface name of the master - # device or UUID of the master connection. - sed -i -E "s/(^uuid=).*$/\1${_old_uuid}/g" "$_tmp_nmconnection_file_path" - nmcli connection del "$_uuid" &> >(ddebug) - echo -n "$_tmp_nmconnection_file_path" -} - -_install_nmconnection() { - local _src _nmconnection_name _dst - - _src=$1 - _nmconnection_name=$(basename "$_src") - _dst="/etc/NetworkManager/system-connections/$_nmconnection_name" - inst "$_src" "$_dst" -} - -kdump_install_nmconnections() { - local _netif _nm_conn_path _cloned_nm_path - - while IFS=: read -r _netif _nm_conn_path; do - [[ -v "unique_netifs[$_netif]" ]] || continue - if _cloned_nm_path=$(clone_and_modify_nmconnection "$_netif" "$_nm_conn_path"); then - _install_nmconnection "$_cloned_nm_path" - else - derror "Failed to install the .nmconnection for $_netif" - exit 1 - fi - done <<< "$(nmcli -t -f device,filename connection show --active)" - - # Stop dracut 35network-manger to calling nm-initrd-generator. - # Note this line of code can be removed after NetworkManager >= 1.35.2 - # gets released. - echo > "${initdir}/usr/libexec/nm-initrd-generator" -} - -kdump_install_nm_netif_allowlist() { - local _netif _except_netif _netif_allowlist _netif_allowlist_nm_conf - - for _netif in $1; do - _per_mac=$(kdump_get_perm_addr "$_netif") - if [[ "$_per_mac" != 'not set' ]]; then - _except_netif="mac:$_per_mac" - else - _except_netif="interface-name:$_netif" - fi - _netif_allowlist="${_netif_allowlist}except:${_except_netif};" - done - - _netif_allowlist_nm_conf=$_DRACUT_KDUMP_NM_TMP_DIR/netif_allowlist_nm_conf - cat << EOF > "$_netif_allowlist_nm_conf" -[device-others] -match-device=${_netif_allowlist} -managed=false -EOF - - inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf" -} - -_get_nic_driver() { - ethtool -i "$1" | sed -n -E "s/driver: (.*)/\1/p" -} - -_get_hpyerv_physical_driver() { - local _physical_nic - - _physical_nic=$(find /sys/class/net/"$1"/ -name 'lower_*' | sed -En "s/\/.*lower_(.*)/\1/p") - [[ -n $_physical_nic ]] || return - _get_nic_driver "$_physical_nic" -} - -kdump_install_nic_driver() { - local _netif _driver _drivers - - _drivers=() - - for _netif in $1; do - [[ $_netif == lo ]] && continue - _driver=$(_get_nic_driver "$_netif") - if [[ -z $_driver ]]; then - derror "Failed to get the driver of $_netif" - exit 1 - fi - - if [[ $_driver == "802.1Q VLAN Support" ]]; then - # ethtool somehow doesn't return the driver name for a VLAN NIC - _driver=8021q - elif [[ $_driver == "team" ]]; then - # install the team mode drivers like team_mode_roundrobin.ko as well - _driver='=drivers/net/team' - elif [[ $_driver == "hv_netvsc" ]]; then - # A Hyper-V VM may have accelerated networking - # https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview - # Install the driver of physical NIC as well - _drivers+=("$(_get_hpyerv_physical_driver "$_netif")") - fi - - _drivers+=("$_driver") - done - - [[ -n ${_drivers[*]} ]] || return - instmods "${_drivers[@]}" -} - -kdump_setup_bridge() { - local _netdev=$1 - local _dev - for _dev in "/sys/class/net/$_netdev/brif/"*; do - [[ -e $_dev ]] || continue - _dev=${_dev##*/} - if kdump_is_bond "$_dev"; then - kdump_setup_bond "$_dev" || return 1 - elif kdump_is_team "$_dev"; then - kdump_setup_team "$_dev" - elif kdump_is_vlan "$_dev"; then - kdump_setup_vlan "$_dev" - fi - _save_kdump_netifs "$_dev" - done -} - -kdump_setup_bond() { - local _netdev="$1" - local _dev - - for _dev in $(< "/sys/class/net/$_netdev/bonding/slaves"); do - _save_kdump_netifs "$_dev" - done -} - -kdump_setup_team() { - local _netdev=$1 - local _dev - for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do - _save_kdump_netifs "$_dev" - done -} - -kdump_setup_vlan() { - local _netdev=$1 - local _parent_netif - - _parent_netif="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")" - - #Just support vlan over bond and team - if kdump_is_bridge "$_parent_netif"; then - derror "Vlan over bridge is not supported!" - exit 1 - elif kdump_is_bond "$_parent_netif"; then - kdump_setup_bond "$_parent_netif" || return 1 - elif kdump_is_team "$_parent_netif"; then - kdump_setup_team "$_parent_netif" || return 1 - fi - - _save_kdump_netifs "$_parent_netif" -} - -# setup s390 znet -kdump_setup_znet() { - local _netif - local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX) - - if [[ "$(uname -m)" != "s390x" ]]; then - return - fi - - for _netif in $1; do - chzdev --export "$_tempfile" --active --by-interface "$_netif" \ - 2>&1 | ddebug - sed -i -e 's/^\[active /\[persistent /' "$_tempfile" - ddebug < "$_tempfile" - chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ - --yes --no-root-update --force 2>&1 | ddebug - lszdev --configured --persistent --info --by-interface "$_netif" \ - --base "/etc=$initdir/etc" 2>&1 | ddebug - done - rm -f "$_tempfile" -} - -kdump_get_remote_ip() { - local _remote _remote_temp - _remote=$(get_remote_host "$1") - if is_hostname "$_remote"; then - _remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1) - if [[ -z $_remote_temp ]]; then - _remote_temp=$(getent ahosts "$_remote" | head -n 1) - fi - _remote=$(echo "$_remote_temp" | awk '{print $1}') - fi - echo "$_remote" -} - -# Collect netifs needed by kdump -# $1: destination host -kdump_collect_netif_usage() { - local _destaddr _srcaddr _route _netdev - - _destaddr=$(kdump_get_remote_ip "$1") - - if ! _route=$(kdump_get_ip_route "$_destaddr"); then - derror "Bad kdump network destination: $_destaddr" - exit 1 - fi - - _srcaddr=$(kdump_get_ip_route_field "$_route" "src") - _netdev=$(kdump_get_ip_route_field "$_route" "dev") - - if kdump_is_bridge "$_netdev"; then - kdump_setup_bridge "$_netdev" - elif kdump_is_bond "$_netdev"; then - kdump_setup_bond "$_netdev" || return 1 - elif kdump_is_team "$_netdev"; then - kdump_setup_team "$_netdev" - elif kdump_is_vlan "$_netdev"; then - kdump_setup_vlan "$_netdev" - fi - _save_kdump_netifs "$_netdev" - - if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then - # network-manager module needs this parameter - echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf" - fi - - if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpip.conf ]]; then - echo "kdump_remote_ip=$_destaddr" > "${initdir}/etc/cmdline.d/60kdumpip.conf" - fi - - if is_ipv6_address "$_srcaddr"; then - ipv6_usage[$_netdev]=1 - else - ipv4_usage[$_netdev]=1 - fi -} - -kdump_install_resolv_conf() { - local _resolv_conf=/etc/resolv.conf _nm_conf_dir=/etc/NetworkManager/conf.d - - # Some users may choose to manage /etc/resolve.conf manually [1] - # by setting dns=none or use a symbolic link resolve.conf [2]. - # So resolve.conf should be installed to kdump initrd as well. To prevent - # NM frome overwritting the user-configured resolve.conf in kdump initrd, - # also set dns=none for NM. - # - # Note: - # 1. When resolv.conf is managed by systemd-resolved.service, it could also be a - # symbolic link. So exclude this case by teling if systemd-resolved is enabled. - # - # 2. It's harmless to blindly copy /etc/resolve.conf to the initrd because - # by default in initramfs this file will be overwritten by - # NetworkManager. If user manages it via a symbolic link, it's still - # preserved because NM won't touch a symbolic link file. - # - # [1] https://bugzilla.gnome.org/show_bug.cgi?id=690404 - # [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking - systemctl -q is-enabled systemd-resolved 2> /dev/null && return 0 - inst "$_resolv_conf" - if NetworkManager --print-config | grep -qs "^dns=none"; then - printf "[main]\ndns=none\n" > "${initdir}/${_nm_conf_dir}"/90-dns-none.conf - fi -} - -# Setup dracut to bring up network interface that enable -# initramfs accessing giving destination -kdump_install_net() { - local _netifs - - _netifs=$(_get_kdump_netifs) - if [[ -n "$_netifs" ]]; then - kdump_install_nmconnections - apply_nm_initrd_generator_timeouts - kdump_setup_znet "$_netifs" - kdump_install_nm_netif_allowlist "$_netifs" - kdump_install_nic_driver "$_netifs" - kdump_install_resolv_conf - fi -} - -# install etc/kdump/pre.d and /etc/kdump/post.d -kdump_install_pre_post_conf() { - if [[ -d /etc/kdump/pre.d ]]; then - for file in /etc/kdump/pre.d/*; do - if [[ -x $file ]]; then - dracut_install "$file" - elif [[ $file != "/etc/kdump/pre.d/*" ]]; then - echo "$file is not executable" - fi - done - fi - - if [[ -d /etc/kdump/post.d ]]; then - for file in /etc/kdump/post.d/*; do - if [[ -x $file ]]; then - dracut_install "$file" - elif [[ $file != "/etc/kdump/post.d/*" ]]; then - echo "$file is not executable" - fi - done - fi -} - -default_dump_target_install_conf() { - local _target _fstype - local _mntpoint _save_path - - is_user_configured_dump_target && return - - _save_path=$(get_bind_mount_source "$(get_save_path)") - _target=$(get_target_from_path "$_save_path") - _mntpoint=$(get_mntpoint_from_target "$_target") - - _fstype=$(get_fs_type_from_target "$_target") - if is_fs_type_nfs "$_fstype"; then - kdump_collect_netif_usage "$_target" - _fstype="nfs" - else - _target=$(kdump_get_persistent_dev "$_target") - fi - - echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf" - - # don't touch the path under root mount - if [[ $_mntpoint != "/" ]]; then - _save_path=${_save_path##"$_mntpoint"} - fi - - #erase the old path line, then insert the parsed path - sed -i "/^path/d" "${initdir}/tmp/$$-kdump.conf" - echo "path $_save_path" >> "${initdir}/tmp/$$-kdump.conf" -} - -#install kdump.conf and what user specifies in kdump.conf -kdump_install_conf() { - local _opt _val _pdev - - kdump_read_conf > "${initdir}/tmp/$$-kdump.conf" - - while read -r _opt _val; do - # remove inline comments after the end of a directive. - case "$_opt" in - raw) - _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val") - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" - ;; - ext[234] | xfs | btrfs | minix | virtiofs) - _pdev=$(kdump_get_persistent_dev "$_val") - sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf" - ;; - ssh | nfs) - kdump_collect_netif_usage "$_val" - ;; - dracut_args) - if [[ $(get_dracut_args_fstype "$_val") == nfs* ]]; then - kdump_collect_netif_usage "$(get_dracut_args_target "$_val")" - fi - ;; - kdump_pre | kdump_post | extra_bins) - # shellcheck disable=SC2086 - dracut_install $_val - ;; - core_collector) - dracut_install "${_val%%[[:blank:]]*}" - ;; - esac - done <<< "$(kdump_read_conf)" - - kdump_install_pre_post_conf - - default_dump_target_install_conf - - kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf" - inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf" - rm -f "${initdir}/tmp/$$-kdump.conf" -} - -# Default sysctl parameters should suffice for kdump kernel. -# Remove custom configurations sysctl.conf & sysctl.d/* -remove_sysctl_conf() { - - # As custom configurations like vm.min_free_kbytes can lead - # to OOM issues in kdump kernel, avoid them - rm -f "${initdir}/etc/sysctl.conf" - rm -rf "${initdir}/etc/sysctl.d" - rm -rf "${initdir}/run/sysctl.d" - rm -rf "${initdir}/usr/lib/sysctl.d" -} - -kdump_iscsi_get_rec_val() { - - local result - - # The open-iscsi 742 release changed to using flat files in - # /var/lib/iscsi. - - result=$(/sbin/iscsiadm --show -m session -r "$1" | grep "^${2} = ") - result=${result##* = } - echo "$result" -} - -kdump_get_iscsi_initiator() { - local _initiator - local initiator_conf="/etc/iscsi/initiatorname.iscsi" - - [[ -f $initiator_conf ]] || return 1 - - while read -r _initiator; do - [[ -z ${_initiator%%#*} ]] && continue # Skip comment lines - - case $_initiator in - InitiatorName=*) - initiator=${_initiator#InitiatorName=} - echo "rd.iscsi.initiator=${initiator}" - return 0 - ;; - *) ;; - esac - done < ${initiator_conf} - - return 1 -} - -# Figure out iBFT session according to session type -is_ibft() { - [[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" == fw ]] -} - -kdump_setup_iscsi_device() { - local path=$1 - local tgt_name - local tgt_ipaddr - local username - local password - local userpwd_str - local username_in - local password_in - local userpwd_in_str - local netroot_str - local initiator_str - local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" - local initiator_conf="/etc/iscsi/initiatorname.iscsi" - - dinfo "Found iscsi component $1" - - # Check once before getting explicit values, so we can bail out early, - # e.g. in case of pure-hardware(all-offload) iscsi. - if ! /sbin/iscsiadm -m session -r "$path" &> /dev/null; then - return 1 - fi - - if is_ibft "$path"; then - return - fi - - # Remove software iscsi cmdline generated by 95iscsi, - # and let kdump regenerate here. - rm -f "${initdir}/etc/cmdline.d/95iscsi.conf" - - tgt_name=$(kdump_iscsi_get_rec_val "$path" "node.name") - tgt_ipaddr=$(kdump_iscsi_get_rec_val "$path" "node.conn\[0\].address") - - # get and set username and password details - username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username") - [[ $username == "" ]] && username="" - password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password") - [[ $password == "" ]] && password="" - username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in") - [[ -n $username ]] && userpwd_str="$username:$password" - - # get and set incoming username and password details - [[ $username_in == "" ]] && username_in="" - password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in") - [[ $password_in == "" ]] && password_in="" - - [[ -n $username_in ]] && userpwd_in_str=":$username_in:$password_in" - - kdump_collect_netif_usage "$tgt_ipaddr" - - # prepare netroot= command line - # FIXME: Do we need to parse and set other parameters like protocol, port - # iscsi_iface_name, netdev_name, LUN etc. - - if is_ipv6_address "$tgt_ipaddr"; then - tgt_ipaddr="[$tgt_ipaddr]" - fi - netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name" - - [[ -f $netroot_conf ]] || touch "$netroot_conf" - - # If netroot target does not exist already, append. - if ! grep -q "$netroot_str" "$netroot_conf"; then - echo "$netroot_str" >> "$netroot_conf" - dinfo "Appended $netroot_str to $netroot_conf" - fi - - # Setup initator - if ! initiator_str=$(kdump_get_iscsi_initiator); then - derror "Failed to get initiator name" - return 1 - fi - - # If initiator details do not exist already, append. - if ! grep -q "$initiator_str" "$netroot_conf"; then - echo "$initiator_str" >> "$netroot_conf" - dinfo "Appended $initiator_str to $netroot_conf" - fi -} - -kdump_check_iscsi_targets() { - # If our prerequisites are not met, fail anyways. - type -P iscsistart > /dev/null || return 1 - - kdump_check_setup_iscsi() { - local _dev - _dev=$1 - - [[ -L /sys/dev/block/$_dev ]] || return - cd "$(readlink -f "/sys/dev/block/$_dev")" || return 1 - until [[ -d sys || -d iscsi_session ]]; do - cd .. - done - [[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD" - } - - [[ $hostonly ]] || [[ $mount_needs ]] && { - for_each_host_dev_and_slaves_all kdump_check_setup_iscsi - } -} - -# hostname -a is deprecated, do it by ourself -get_alias() { - local ips - local entries - local alias_set - - ips=$(hostname -I) - for ip in $ips; do - # in /etc/hosts, alias can come at the 2nd column - if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then - alias_set="$alias_set $entries" - fi - done - - echo "$alias_set" -} - -is_localhost() { - local hostnames - local shortnames - local aliasname - local nodename=$1 - - hostnames=$(hostname -A) - shortnames=$(hostname -A -s) - aliasname=$(get_alias) - hostnames="$hostnames $shortnames $aliasname" - - for name in ${hostnames}; do - if [[ $name == "$nodename" ]]; then - return 0 - fi - done - return 1 -} - -# retrieves fence_kdump nodes from Pacemaker cluster configuration -get_pcs_fence_kdump_nodes() { - local nodes - - pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1 - # get cluster nodes from cluster cib, get interface and ip address - nodelist=$(pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -) - - # nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"' - # we need to convert each to node1, node2 ... nodeX in each iteration - for node in ${nodelist}; do - # convert $node from 'uname="nodeX"' to 'nodeX' - eval "$node" - nodename="$uname" - # Skip its own node name - if is_localhost "$nodename"; then - continue - fi - nodes="$nodes $nodename" - done - - echo "$nodes" -} - -# retrieves fence_kdump args from config file -get_pcs_fence_kdump_args() { - if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then - . "$FENCE_KDUMP_CONFIG_FILE" - echo "$FENCE_KDUMP_OPTS" - fi -} - -get_generic_fence_kdump_nodes() { - local filtered - local nodes - - nodes=$(kdump_get_conf_val "fence_kdump_nodes") - for node in ${nodes}; do - # Skip its own node name - if is_localhost "$node"; then - continue - fi - filtered="$filtered $node" - done - echo "$filtered" -} - -# setup fence_kdump in cluster -# setup proper network and install needed files -kdump_configure_fence_kdump() { - local kdump_cfg_file=$1 - local nodes - local args - - if is_generic_fence_kdump; then - nodes=$(get_generic_fence_kdump_nodes) - - elif is_pcs_fence_kdump; then - nodes=$(get_pcs_fence_kdump_nodes) - - # set appropriate options in kdump.conf - echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}" - - args=$(get_pcs_fence_kdump_args) - if [[ -n $args ]]; then - echo "fence_kdump_args $args" >> "${kdump_cfg_file}" - fi - - else - # fence_kdump not configured - return 1 - fi - - # setup network for each node - for node in ${nodes}; do - kdump_collect_netif_usage "$node" - done - - dracut_install /etc/hosts - dracut_install /etc/nsswitch.conf - dracut_install "$FENCE_KDUMP_SEND" -} - -# Install a random seed used to feed /dev/urandom -# By the time kdump service starts, /dev/uramdom is already fed by systemd -kdump_install_random_seed() { - local poolsize - - poolsize=$(< /proc/sys/kernel/random/poolsize) - - if [[ ! -d "${initdir}/var/lib/" ]]; then - mkdir -p "${initdir}/var/lib/" - fi - - dd if=/dev/urandom of="${initdir}/var/lib/random-seed" \ - bs="$poolsize" count=1 2> /dev/null -} - -kdump_install_systemd_conf() { - # Kdump turns out to require longer default systemd mount timeout - # than 1st kernel(90s by default), we use default 300s for kdump. - if ! grep -q -r "^[[:space:]]*DefaultTimeoutStartSec=" "${initdir}/etc/systemd/system.conf"*; then - mkdir -p "${initdir}/etc/systemd/system.conf.d" - echo "[Manager]" > "${initdir}/etc/systemd/system.conf.d/kdump.conf" - echo "DefaultTimeoutStartSec=300s" >> "${initdir}/etc/systemd/system.conf.d/kdump.conf" - fi - - # Forward logs to console directly, and don't read Kmsg, this avoids - # unneccessary memory consumption and make console output more useful. - # Only do so for non fadump image. - mkdir -p "${initdir}/etc/systemd/journald.conf.d" - echo "[Journal]" > "${initdir}/etc/systemd/journald.conf.d/kdump.conf" - echo "Storage=volatile" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" - echo "ReadKMsg=no" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" - echo "ForwardToConsole=yes" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf" -} - -remove_cpu_online_rule() { - local file=${initdir}/usr/lib/udev/rules.d/40-redhat.rules - - if [[ -f $file ]]; then - sed -i '/SUBSYSTEM=="cpu"/d' "$file" - fi -} - -install() { - declare -A unique_netifs ipv4_usage ipv6_usage - local arch - - kdump_module_init - kdump_install_conf - remove_sysctl_conf - - # Onlining secondary cpus breaks kdump completely on KVM on Power hosts - # Though we use maxcpus=1 by default but 40-redhat.rules will bring up all - # possible cpus by default. (rhbz1270174 rhbz1266322) - # Thus before we get the kernel fix and the systemd rule fix let's remove - # the cpu online rule in kdump initramfs. - arch=$(uname -m) - if [[ "$arch" = "ppc64le" ]] || [[ "$arch" = "ppc64" ]]; then - remove_cpu_online_rule - fi - - if is_ssh_dump_target; then - kdump_install_random_seed - fi - dracut_install -o /etc/adjtime /etc/localtime - inst "$moddir/monitor_dd_progress.sh" "/kdumpscripts/monitor_dd_progress.sh" - inst "/bin/dd" "/bin/dd" - inst "/bin/tail" "/bin/tail" - inst "/bin/date" "/bin/date" - inst "/bin/sync" "/bin/sync" - inst "/bin/cut" "/bin/cut" - inst "/bin/head" "/bin/head" - inst "/bin/awk" "/bin/awk" - inst "/bin/sed" "/bin/sed" - inst "/bin/stat" "/bin/stat" - inst "/sbin/makedumpfile" "/sbin/makedumpfile" - inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg" - inst "/usr/bin/printf" "/sbin/printf" - inst "/usr/bin/logger" "/sbin/logger" - inst "/usr/bin/chmod" "/sbin/chmod" - inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" - inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" - inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" - inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" - systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service - # Replace existing emergency service and emergency target - cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service" - cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target" - # Also redirect dracut-emergency to kdump error handler - ln_r "$systemdsystemunitdir/emergency.service" "$systemdsystemunitdir/dracut-emergency.service" - - # Check for all the devices and if any device is iscsi, bring up iscsi - # target. Ideally all this should be pushed into dracut iscsi module - # at some point of time. - kdump_check_iscsi_targets - - kdump_install_systemd_conf - - # nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail - if is_nfs_dump_target || is_ssh_dump_target; then - inst "ip" - fi - - kdump_install_net - - # For the lvm type target under kdump, in /etc/lvm/lvm.conf we can - # safely replace "reserved_memory=XXXX"(default value is 8192) with - # "reserved_memory=1024" to lower memory pressure under kdump. We do - # it unconditionally here, if "/etc/lvm/lvm.conf" doesn't exist, it - # actually does nothing. - sed -i -e \ - 's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \ - "${initdir}/etc/lvm/lvm.conf" &> /dev/null - - # Skip initrd-cleanup.service and initrd-parse-etc.service becasue we don't - # need to switch root. Instead of removing them, we use ConditionPathExists - # to check if /proc/vmcore exists to determine if we are in kdump. - sed -i '/\[Unit\]/a ConditionPathExists=!\/proc\/vmcore' \ - "${initdir}/${systemdsystemunitdir}/initrd-cleanup.service" &> /dev/null - - sed -i '/\[Unit\]/a ConditionPathExists=!\/proc\/vmcore' \ - "${initdir}/${systemdsystemunitdir}/initrd-parse-etc.service" &> /dev/null - - # Save more memory by dropping switch root capability - dracut_no_switch_root -} diff --git a/dracut-monitor_dd_progress.sh b/dracut-monitor_dd_progress.sh deleted file mode 100644 index e139d33..0000000 --- a/dracut-monitor_dd_progress.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -SRC_FILE_MB=$1 - -while true -do - DD_PID=`pidof dd` - if [ -n "$DD_PID" ]; then - break - fi -done - -while true -do - sleep 5 - if [ ! -d /proc/$DD_PID ]; then - break - fi - - kill -s USR1 $DD_PID - CURRENT_SIZE=`tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g"` - [ -n "$CURRENT_SIZE" ] && { - CURRENT_MB=$(($CURRENT_SIZE / 1048576)) - echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r" - } -done - -rm -f /tmp/dd_progress_file diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt deleted file mode 100644 index 68b23c7..0000000 --- a/early-kdump-howto.txt +++ /dev/null @@ -1,95 +0,0 @@ -Early Kdump HOWTO - -Introduction ------------- - -Early kdump is a mechanism to make kdump operational earlier than normal kdump -service. The kdump service starts early enough for general crash cases, but -there are some cases where it has no chance to make kdump operational in boot -sequence, such as detecting devices and starting early services. If you hit -such a case, early kdump may allow you to get more information of it. - -Early kdump is implemented as a dracut module. It adds a kernel (vmlinuz) and -initramfs for kdump to your system's initramfs in order to load them as early -as possible. After that, if you provide "rd.earlykdump" in kernel command line, -then in the initramfs, early kdump will load those files like the normal kdump -service. This is disabled by default. - -For the normal kdump service, it can check whether the early kdump has loaded -the crash kernel and initramfs. It has no conflict with the early kdump. - -How to configure early kdump ----------------------------- - -We assume if you're reading this document, you should already have kexec-tools -installed. - -You can rebuild the initramfs with earlykdump support with below steps: - -1. start kdump service to make sure kdump initramfs is created. - - # systemctl start kdump - - NOTE: If a crash occurs during boot process, early kdump captures a vmcore - and reboot the system by default, so the system might go into crash loop. - You can avoid such a crash loop by adding the following settings, which - power off the system after dump capturing, to kdump.conf in advance: - - final_action poweroff - failure_action poweroff - - For the failure_action, you can choose anything other than "reboot". - -2. rebuild system initramfs with earlykdump support. - - # dracut --force --add earlykdump - - NOTE: Recommend to backup the original system initramfs before performing - this step to put it back if something happens during boot-up. - -3. add rd.earlykdump in grub kernel command line. - -After making said changes, reboot your system to take effect. Of course, if you -want to disable early kdump, you can simply remove "rd.earlykdump" from kernel -boot parameters in grub, and reboot system like above. - -Once the boot is completed, you can check the status of the early kdump support -on the command prompt: - - # journalctl -b | grep early-kdump - -Then, you will see some useful logs, for example: - -- if early kdump is successful. - -Mar 09 09:57:56 localhost dracut-cmdline[190]: early-kdump is enabled. -Mar 09 09:57:56 localhost dracut-cmdline[190]: kexec: loaded early-kdump kernel - -- if early kdump is disabled. - -Mar 09 10:02:47 localhost dracut-cmdline[189]: early-kdump is disabled. - -Notes ------ - -- The size of early kdump initramfs will be large because it includes vmlinuz - and kdump initramfs. - -- Early kdump inherits the settings of normal kdump, so any changes that - caused normal kdump rebuilding also require rebuilding the system initramfs - to make sure that the changes take effect for early kdump. Therefore, after - the rebuilding of kdump initramfs is completed, provide a prompt message to - tell the fact. - -- If you install an updated kernel and reboot the system with it, the early - kdump will be disabled by default. To enable it with the new kernel, you - need to take the above steps again. - -Limitation ----------- - -- At present, early kdump doesn't support fadump. - -- Early kdump loads a crash kernel and initramfs at the beginning of the - process in system's initramfs, so a crash at earlier than that (e.g. in - kernel initialization) cannot be captured even with the early kdump. diff --git a/fadump-howto.txt b/fadump-howto.txt deleted file mode 100644 index 2fe76cf..0000000 --- a/fadump-howto.txt +++ /dev/null @@ -1,359 +0,0 @@ -Firmware assisted dump (fadump) HOWTO - -Introduction - -Firmware assisted dump is a new feature in the 3.4 mainline kernel supported -only on powerpc architecture. The goal of firmware-assisted dump is to enable -the dump of a crashed system, and to do so from a fully-reset system, and to -minimize the total elapsed time until the system is back in production use. A -complete documentation on implementation can be found at -Documentation/powerpc/firmware-assisted-dump.txt in upstream linux kernel tree -from 3.4 version and above. - -Please note that the firmware-assisted dump feature is only available on Power6 -and above systems with recent firmware versions. - -Overview - -Fadump - -Fadump is a robust kernel crash dumping mechanism to get reliable kernel crash -dump with assistance from firmware. This approach does not use kexec, instead -firmware assists in booting the kdump kernel while preserving memory contents. -Unlike kdump, the system is fully reset, and loaded with a fresh copy of the -kernel. In particular, PCI and I/O devices are reinitialized and are in a -clean, consistent state. This second kernel, often called a capture kernel, -boots with very little memory and captures the dump image. - -The first kernel registers the sections of memory with the Power firmware for -dump preservation during OS initialization. These registered sections of memory -are reserved by the first kernel during early boot. When a system crashes, the -Power firmware fully resets the system, preserves all the system memory -contents, save the low memory (boot memory of size larger of 5% of system -RAM or 256MB) of RAM to the previous registered region. It will also save -system registers, and hardware PTE's. - -Fadump is supported only on ppc64 platform. The standard kernel and capture -kernel are one and the same on ppc64. - -If you're reading this document, you should already have kexec-tools -installed. If not, you install it via the following command: - - # dnf install kexec-tools - -Fadump Operational Flow: - -Like kdump, fadump also exports the ELF formatted kernel crash dump through -/proc/vmcore. Hence existing kdump infrastructure can be used to capture fadump -vmcore. The idea is to keep the functionality transparent to end user. From -user perspective there is no change in the way kdump init script works. - -However, unlike kdump, fadump does not pre-load kdump kernel and initrd into -reserved memory, instead it always uses default OS initrd during second boot -after crash. Hence, for fadump, we rebuild the new kdump initrd and replace it -with default initrd. Before replacing existing default initrd we take a backup -of original default initrd for user's reference. The dracut package has been -enhanced to rebuild the default initrd with vmcore capture steps. The initrd -image is rebuilt as per the configuration in /etc/kdump.conf file. - -The control flow of fadump works as follows: -01. System panics. -02. At the crash, kernel informs power firmware that kernel has crashed. -03. Firmware takes the control and reboots the entire system preserving - only the memory (resets all other devices). -04. The reboot follows the normal booting process (non-kexec). -05. The boot loader loads the default kernel and initrd from /boot -06. The default initrd loads and runs /init -07. dracut-kdump.sh script present in fadump aware default initrd checks if - '/proc/device-tree/rtas/ibm,kernel-dump' file exists before executing - steps to capture vmcore. - (This check will help to bypass the vmcore capture steps during normal boot - process.) -09. Captures dump according to /etc/kdump.conf -10. Is dump capture successful (yes goto 12, no goto 11) -11. Perform the failure action specified in /etc/kdump.conf - (The default failure action is reboot, if unspecified) -12. Perform the final action specified in /etc/kdump.conf - (The default final action is reboot, if unspecified) - - -How to configure fadump: - -Again, we assume if you're reading this document, you should already have -kexec-tools installed. If not, you install it via the following command: - - # dnf install kexec-tools - -Make the kernel to be configured with FADump as the default boot entry, if -it isn't already: - - # grubby --set-default=/boot/vmlinuz- - -Boot into the kernel to be configured for FADump. To be able to do much of -anything interesting in the way of debug analysis, you'll also need to install -the kernel-debuginfo package, of the same arch as your running kernel, and the -crash utility: - - # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash - -Next up, we can enable firmware assisted dump and reserve the memory for boot -memory preservation as specified in in the table of 'FADump Memory Requirements' -section: - - # kdumpctl reset-crashkernel --fadump=on - -Alternatively, you can use grubby to reserve custom amount of memory: - - # grubby --args="fadump=on crashkernel=6G" --update-kernel=/boot/vmlinuz-`uname -r` - -By default, FADump reserved memory will be initialized as CMA area to make the -memory available through CMA allocator on the production kernel. We can opt out -of this, making reserved memory unavailable to production kernel, by booting the -linux kernel with 'fadump=nocma' instead of 'fadump=on': - - # kdumpctl reset-crashkernel --fadump=nocma - -The term 'boot memory' means size of the low memory chunk that is required for -a kernel to boot successfully when booted with restricted memory. By default, -the boot memory size will be the larger of 5% of system RAM or 256MB. -Alternatively, user can also specify boot memory size through boot parameter -'fadump_reserve_mem=' which will override the default calculated size. Use this -option if default boot memory size is not sufficient for second kernel to boot -successfully. - -After making said changes, reboot your system, so that the specified memory is -reserved and left untouched by the normal system. Take note that the output of -'free -m' will show X MB less memory than without this parameter, which is -expected. If you see OOM (Out Of Memory) error messages while loading capture -kernel, then you should bump up the memory reservation size. - -Now that you've got that reserved memory region set up, you want to turn on -the kdump init script: - - # systemctl enable kdump.service - -Then, start up kdump as well: - - # systemctl start kdump.service - -This should turn on the firmware assisted functionality in kernel by -echo'ing 1 to /sys/kernel/fadump/registered, leaving the system ready -to capture a vmcore upon crashing. For journaling filesystems like XFS an -additional step is required to ensure bootloader does not pick the -older initrd (without vmcore capture scripts): - - * If /boot is a separate partition, run the below commands as the root user, - or as a user with CAP_SYS_ADMIN rights: - - # fsfreeze -f - # fsfreeze -u - - * If /boot is not a separate partition, reboot the system. - -After reboot check if the kdump service is up and running with: - - # systemctl status kdump.service - -To test out whether FADump is configured properly, you can force-crash your -system by echo'ing a 'c' into /proc/sysrq-trigger: - - # echo c > /proc/sysrq-trigger - -You should see some panic output, followed by the system reset and booting into -fresh copy of kernel. When default initrd loads and runs /init, vmcore should -be copied out to disk (by default, in /var/crash//vmcore), -then the system rebooted back into your normal kernel. - -Once back to your normal kernel, you can use the previously installed crash -kernel in conjunction with the previously installed kernel-debuginfo to -perform postmortem analysis: - - # crash /usr/lib/debug/lib/modules/2.6.17-1.2621.el5/vmlinux - /var/crash/2006-08-23-15:34/vmcore - - crash> bt - -and so on... - -Saving vmcore-dmesg.txt ------------------------ -Kernel log bufferes are one of the most important information available -in vmcore. Now before saving vmcore, kernel log bufferes are extracted -from /proc/vmcore and saved into a file vmcore-dmesg.txt. After -vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for -vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will -not be available if dump target is raw device. - -FADump Memory Requirements: - - System Memory Recommended memory ---------------------- ---------------------- - 4 GB - 16 GB : 768 MB - 16 GB - 64 GB : 1024 MB - 64 GB - 128 GB : 2 GB - 128 GB - 1 TB : 4 GB - 1 TB - 2 TB : 6 GB - 2 TB - 4 TB : 12 GB - 4 TB - 8 TB : 20 GB - 8 TB - 16 TB : 36 GB - 16 TB - 32 TB : 64 GB - 32 TB - 64 TB : 128 GB - 64 TB & above : 180 GB - -Things to remember: - -1) The memory required to boot capture Kernel is a moving target that depends - on many factors like hardware attached to the system, kernel and modules in - use, packages installed and services enabled, there is no one-size-fits-all. - But the above recommendations are based on system memory. So, the above - recommendations for FADump come with a few assumptions, based on available - system memory, about the resources the system could have. So, please take - the recommendations with a pinch of salt and remember to try capturing dump - a few times to confirm that the system is configured successfully with dump - capturing support. - -2) Though the memory requirements for FADump seem high, this memory is not - completely set aside but made available for userspace applications to use, - through the CMA allocator. - -3) As the same initrd is used for booting production kernel as well as capture - kernel and with dump being captured in a restricted memory environment, few - optimizations (like not inclding network dracut module, disabling multipath - and such) are applied while building the initrd. In case, the production - environment needs these optimizations to be avoided, dracut_args option in - /etc/kdump.conf file could be leveraged. For example, if a user wishes for - network module to be included in the initrd, adding the below entry in - /etc/kdump.conf file and restarting kdump service would take care of it. - - dracut_args --add "network" - -4) If FADump is configured to capture vmcore to a remote dump target using SSH - or NFS protocol, the corresponding network interface '' is - renamed to 'kdump-', if it is generic (like *eth# or net#). - It happens because vmcore capture scripts in the initial RAM disk (initrd) - add the 'kdump-' prefix to the network interface name to secure persistent - naming. And as capture kernel and production kernel use the same initrd in - case of FADump, the interface name is changed for the production kernel too. - This is likely to impact network configuration setup for production kernel. - So, it is recommended to use a non-generic name for a network interface, - before setting up FADump to capture vmcore to a remote dump target based on - that network interface, to avoid running into network configuration issues. - -Dump Triggering methods: - -This section talks about the various ways, other than a Kernel Panic, in which -fadump can be triggered. The following methods assume that fadump is configured -on your system, with the scripts enabled as described in the section above. - -1) AltSysRq C - -FAdump can be triggered with the combination of the 'Alt','SysRq' and 'C' -keyboard keys. Please refer to the following link for more details: - -https://fedoraproject.org/wiki/QA/Sysrq - -In addition, on PowerPC boxes, fadump can also be triggered via Hardware -Management Console(HMC) using 'Ctrl', 'O' and 'C' keyboard keys. - -2) Kernel OOPs - -If we want to generate a dump everytime the Kernel OOPses, we can achieve this -by setting the 'Panic On OOPs' option as follows: - - # echo 1 > /proc/sys/kernel/panic_on_oops - -3) PowerPC specific methods: - -On IBM PowerPC machines, issuing a soft reset invokes the XMON debugger(if -XMON is configured). To configure XMON one needs to compile the kernel with -the CONFIG_XMON and CONFIG_XMON_DEFAULT options, or by compiling with -CONFIG_XMON and booting the kernel with xmon=on option. - -Following are the ways to remotely issue a soft reset on PowerPC boxes, which -would drop you to XMON. Pressing a 'X' (capital alphabet X) followed by an -'Enter' here will trigger the dump. - -3.1) HMC - -Hardware Management Console(HMC) available on Power4 and Power5 machines allow -partitions to be reset remotely. This is specially useful in hang situations -where the system is not accepting any keyboard inputs. - -Once you have HMC configured, the following steps will enable you to trigger -fadump via a soft reset: - -On Power4 - Using GUI - - * In the right pane, right click on the partition you wish to dump. - * Select "Operating System->Reset". - * Select "Soft Reset". - * Select "Yes". - - Using HMC Commandline - - # reset_partition -m -p -t soft - -On Power5 - Using GUI - - * In the right pane, right click on the partition you wish to dump. - * Select "Restart Partition". - * Select "Dump". - * Select "OK". - - Using HMC Commandline - - # chsysstate -m -n -o dumprestart -r lpar - -3.2) Blade Management Console for Blade Center - -To initiate a dump operation, go to Power/Restart option under "Blade Tasks" in -the Blade Management Console. Select the corresponding blade for which you want -to initate the dump and then click "Restart blade with NMI". This issues a -system reset and invokes xmon debugger. - - -Advanced Setups & Failure action: - -Kdump and fadump exhibit similar behavior in terms of setup & failure action. -For fadump advanced setup related information see section "Advanced Setups" in -"kexec-kdump-howto.txt" document. Refer to "Failure action" section in "kexec- -kdump-howto.txt" document for fadump failure action related information. - -Compression and filtering - -Refer "Compression and filtering" section in "kexec-kdump-howto.txt" document. -Compression and filtering are same for kdump & fadump. - - -Notes on rootfs mount: -Dracut is designed to mount rootfs by default. If rootfs mounting fails it -will refuse to go on. So fadump leaves rootfs mounting to dracut currently. -We make the assumtion that proper root= cmdline is being passed to dracut -initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in -/etc/sysconfig/kdump, you will need to make sure that appropriate root= -options are copied from /proc/cmdline. In general it is best to append -command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing -the original command line completely. - -How to disable FADump: - -Remove "fadump=on"/"fadump=nocma" from kernel cmdline parameters OR replace -it with "fadump=off" kernel cmdline parameter: - - # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=on" -or - # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="fadump=nocma" -OR - # grubby --update-kernel=/boot/vmlinuz-`uname -r` --args="fadump=off" - -Remove "crashkernel=" from kernel cmdline parameters: - - # grubby --update-kernel=/boot/vmlinuz-`uname -r` --remove-args="crashkernel" - -If KDump is to be used as the dump capturing mechanism, reset the crashkernel parameter: - - # kdumpctl reset-crashkernel --fadump=off - -Reboot the system for the settings to take effect. diff --git a/gen-kdump-conf.sh b/gen-kdump-conf.sh deleted file mode 100755 index a8e7fdd..0000000 --- a/gen-kdump-conf.sh +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash -# $1: target arch - -SED_EXP="" - -generate() -{ - sed "$SED_EXP" << EOF -# This file contains a series of commands to perform (in order) in the kdump -# kernel after a kernel crash in the crash kernel(1st kernel) has happened. -# -# Directives in this file are only applicable to the kdump initramfs, and have -# no effect once the root filesystem is mounted and the normal init scripts are -# processed. -# -# Currently, only one dump target and path can be specified. If the dumping to -# the configured target fails, the failure action which can be configured via -# the "failure_action" directive will be performed. -# -# Supported options: -# -# auto_reset_crashkernel -# - 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. -# The default value is yes. -# -# raw -# - Will dd /proc/vmcore into . -# Use persistent device names for partition devices, -# such as /dev/vg/. -# -# nfs -# - Will mount nfs to , and copy /proc/vmcore to -# //%HOST-%DATE/, supports DNS. -# -# ssh -# - Will save /proc/vmcore to :/%HOST-%DATE/, -# supports DNS. -# NOTE: make sure the user has write permissions on the server. -# -# sshkey -# - Will use the sshkey to do ssh dump. -# Specify the path of the ssh key to use when dumping -# via ssh. The default value is /root/.ssh/kdump_id_rsa. -# -# -# - Will mount -t , and copy -# /proc/vmcore to //%HOST_IP-%DATE/. -# NOTE: can be a device node, label or uuid. -# It's recommended to use persistent device names -# such as /dev/vg/. -# Otherwise it's suggested to use label or uuid. -# Supported fs types: ext[234], xfs, btrfs, minix, virtiofs -# -# path -# - "path" represents the file system path in which vmcore -# will be saved. If a dump target is specified in -# kdump.conf, then "path" is relative to the specified -# dump target. -# -# Interpretation of "path" changes a bit if the user didn't -# specify any dump target explicitly in kdump.conf. In this -# case, "path" represents the absolute path from root. The -# dump target and adjusted path are arrived at automatically -# depending on what's mounted in the current system. -# -# Ignored for raw device dumps. If unset, will use the default -# "/var/crash". -# -# core_collector -# - This allows you to specify the command to copy -# the vmcore. The default is makedumpfile, which on -# some architectures can drastically reduce vmcore size. -# See /sbin/makedumpfile --help for a list of options. -# Note that the -i and -g options are not needed here, -# as the initrd will automatically be populated with a -# config file appropriate for the running kernel. -# The default core_collector for raw/ssh dump is: -# "makedumpfile -F -l --message-level 7 -d 31". -# The default core_collector for other targets is: -# "makedumpfile -l --message-level 7 -d 31". -# -# "makedumpfile -F" will create a flattened vmcore. -# You need to use "makedumpfile -R" to rearrange the dump data to -# a normal dumpfile readable with analysis tools. For example: -# "makedumpfile -R vmcore < vmcore.flat". -# -# For core_collector format details, you can refer to -# kexec-kdump-howto.txt or kdump.conf manpage. -# -# kdump_post -# - This directive allows you to run a executable binary -# or script after the vmcore dump process terminates. -# The exit status of the current dump process is fed to -# the executable binary or script as its first argument. -# All files under /etc/kdump/post.d are collectively sorted -# and executed in lexical order, before binary or script -# specified kdump_post parameter is executed. -# -# kdump_pre -# - Works like the "kdump_post" directive, but instead of running -# after the dump process, runs immediately before it. -# Exit status of this binary is interpreted as follows: -# 0 - continue with dump process as usual -# non 0 - run the final action (reboot/poweroff/halt) -# All files under /etc/kdump/pre.d are collectively sorted and -# executed in lexical order, after binary or script specified -# kdump_pre parameter is executed. -# Even if the binary or script in /etc/kdump/pre.d directory -# returns non 0 exit status, the processing is continued. -# -# extra_bins -# - This directive allows you to specify additional binaries or -# shell scripts to be included in the kdump initrd. -# Generally they are useful in conjunction with a kdump_post -# or kdump_pre binary or script which depends on these extra_bins. -# -# extra_modules -# - This directive allows you to specify extra kernel modules -# that you want to be loaded in the kdump initrd. -# Multiple modules can be listed, separated by spaces, and any -# dependent modules will automatically be included. -# -# failure_action -# - Action to perform in case dumping fails. -# reboot: Reboot the system. -# halt: Halt the system. -# poweroff: Power down the system. -# shell: Drop to a bash shell. -# Exiting the shell reboots the system by default, -# or perform "final_action". -# dump_to_rootfs: Dump vmcore to rootfs from initramfs context and -# reboot by default or perform "final_action". -# Useful when non-root dump target is specified. -# The default option is "reboot". -# -# default -# - Same as the "failure_action" directive above, but this directive -# is obsolete and will be removed in the future. -# -# final_action -# - Action to perform in case dumping succeeds. Also performed -# when "shell" or "dump_to_rootfs" failure action finishes. -# Each action is same as the "failure_action" directive above. -# The default is "reboot". -# -# force_rebuild <0 | 1> -# - By default, kdump initrd will only be rebuilt when necessary. -# Specify 1 to force rebuilding kdump initrd every time when kdump -# service starts. -# -# force_no_rebuild <0 | 1> -# - By default, kdump initrd will be rebuilt when necessary. -# Specify 1 to bypass rebuilding of kdump initrd. -# -# force_no_rebuild and force_rebuild options are mutually -# exclusive and they should not be set to 1 simultaneously. -# -# dracut_args -# - Pass extra dracut options when rebuilding kdump initrd. -# -# fence_kdump_args -# - Command line arguments for fence_kdump_send (it can contain -# all valid arguments except hosts to send notification to). -# -# fence_kdump_nodes -# - List of cluster node(s) except localhost, separated by spaces, -# to send fence_kdump notifications to. -# (this option is mandatory to enable fence_kdump). -# - -#raw /dev/vg/lv_kdump -#ext4 /dev/vg/lv_kdump -#ext4 LABEL=/boot -#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 -#virtiofs myfs -#nfs my.server.com:/export/tmp -#nfs [2001:db8::1:2:3:4]:/export/tmp -#ssh user@my.server.com -#ssh user@2001:db8::1:2:3:4 -#sshkey /root/.ssh/kdump_id_rsa -auto_reset_crashkernel yes -path /var/crash -core_collector makedumpfile -l --message-level 7 -d 31 -#core_collector scp -#kdump_post /var/crash/scripts/kdump-post.sh -#kdump_pre /var/crash/scripts/kdump-pre.sh -#extra_bins /usr/bin/lftp -#extra_modules gfs2 -#failure_action shell -#force_rebuild 1 -#force_no_rebuild 1 -#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" -#fence_kdump_args -p 7410 -f auto -c 0 -i 10 -#fence_kdump_nodes node1 node2 -EOF -} - -update_param() -{ - SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;" -} - -case "$1" in -aarch64) ;; - -i386) ;; - -ppc64) ;; - -ppc64le) ;; - -s390x) - update_param core_collector \ - "makedumpfile -c --message-level 7 -d 31" - ;; -x86_64) ;; - -*) - echo "Warning: Unknown architecture '$1', using default kdump.conf template." >&2 - ;; -esac - -generate diff --git a/gen-kdump-sysconfig.sh b/gen-kdump-sysconfig.sh deleted file mode 100755 index 78b0bb7..0000000 --- a/gen-kdump-sysconfig.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# $1: target arch - -SED_EXP="" - -generate() -{ - sed "$SED_EXP" << EOF -# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump -# If no version is specified, then the init script will try to find a -# kdump kernel with the same version number as the running kernel. -KDUMP_KERNELVER="" - -# The kdump commandline is the command line that needs to be passed off to -# the kdump kernel. This will likely match the contents of the grub kernel -# line. For example: -# KDUMP_COMMANDLINE="ro root=LABEL=/" -# Dracut depends on proper root= options, so please make sure that appropriate -# root= options are copied from /proc/cmdline. In general it is best to append -# command line options using "KDUMP_COMMANDLINE_APPEND=". -# If a command line is not specified, the default will be taken from -# /proc/cmdline -KDUMP_COMMANDLINE="" - -# This variable lets us remove arguments from the current kdump commandline -# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline -# NOTE: some arguments such as crashkernel will always be removed -KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb cma hugetlb_cma ignition.firstboot" - -# This variable lets us append arguments to the current kdump commandline -# after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1 reset_devices novmcoredd cma=0 hugetlb_cma=0" - -# Any additional kexec arguments required. In most situations, this should -# be left empty -# -# Example: -# KEXEC_ARGS="--elf32-core-headers" -KEXEC_ARGS="" - -#Where to find the boot image -#KDUMP_BOOTDIR="/boot" - -#What is the image type used for kdump -KDUMP_IMG="vmlinuz" - -#What is the images extension. Relocatable kernels don't have one -KDUMP_IMG_EXT="" - -# Logging is controlled by following variables in the first kernel: -# - @var KDUMP_STDLOGLVL - logging level to standard error (console output) -# - @var KDUMP_SYSLOGLVL - logging level to syslog (by logger command) -# - @var KDUMP_KMSGLOGLVL - logging level to /dev/kmsg (only for boot-time) -# -# In the second kernel, kdump will use the rd.kdumploglvl option to set the -# log level in the above KDUMP_COMMANDLINE_APPEND. -# - @var rd.kdumploglvl - logging level to syslog (by logger command) -# - for example: add the rd.kdumploglvl=3 option to KDUMP_COMMANDLINE_APPEND -# -# Logging levels: no logging(0), error(1),warn(2),info(3),debug(4) -# -# KDUMP_STDLOGLVL=3 -# KDUMP_SYSLOGLVL=0 -# KDUMP_KMSGLOGLVL=0 -EOF -} - -update_param() -{ - SED_EXP="${SED_EXP}s/^$1=.*$/$1=\"$2\"/;" -} - -case "$1" in -aarch64) - update_param KEXEC_ARGS "-s" - update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory udev.children-max=2 panic=10 swiotlb=noforce novmcoredd cma=0 hugetlb_cma=0" - ;; -i386) - update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll nr_cpus=1 reset_devices numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd cma=0 hugetlb_cma=0" - ;; -ppc64) - update_param KEXEC_ARGS "--dt-no-old-root" - update_param KDUMP_COMMANDLINE_REMOVE \ - "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" - update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll maxcpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" - ;; -ppc64le) - update_param KEXEC_ARGS "--dt-no-old-root -s" - update_param KDUMP_COMMANDLINE_REMOVE \ - "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb hugetlb_cma ignition.firstboot" - update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll nr_cpus=1 noirqdistrib reset_devices cgroup_disable=memory numa=off udev.children-max=2 ehea.use_mcs=0 panic=10 kvm_cma_resv_ratio=0 transparent_hugepage=never novmcoredd hugetlb_cma=0" - ;; -s390x) - update_param KEXEC_ARGS "-s" - update_param KDUMP_COMMANDLINE_REMOVE \ - "hugepages hugepagesz slub_debug quiet log_buf_len swiotlb vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot zfcp.allow_lun_scan" - update_param KDUMP_COMMANDLINE_APPEND \ - "nr_cpus=1 cgroup_disable=memory numa=off udev.children-max=2 panic=10 transparent_hugepage=never novmcoredd vmcp_cma=0 cma=0 hugetlb_cma=0" - ;; -x86_64) - update_param KEXEC_ARGS "-s" - update_param KDUMP_COMMANDLINE_APPEND \ - "irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 acpi_no_memhotplug transparent_hugepage=never nokaslr hest_disable novmcoredd cma=0 hugetlb_cma=0" - ;; -*) - echo "Warning: Unknown architecture '$1', using default sysconfig template." >&2 - ;; -esac - -generate diff --git a/kdump-dep-generator.sh b/kdump-dep-generator.sh deleted file mode 100644 index 70ae621..0000000 --- a/kdump-dep-generator.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# More details about systemd generator: -# http://www.freedesktop.org/wiki/Software/systemd/Generators/ - -. /usr/lib/kdump/kdump-lib-initramfs.sh -. /usr/lib/kdump/kdump-logger.sh - -# If invokded with no arguments for testing purpose, output to /tmp to -# avoid overriding the existing. -dest_dir="/tmp" - -if [ -n "$1" ]; then - dest_dir=$1 -fi - -systemd_dir=/usr/lib/systemd/system -kdump_wants=$dest_dir/kdump.service.wants - -if is_ssh_dump_target; then - mkdir -p $kdump_wants - ln -sf $systemd_dir/network-online.target $kdump_wants/ -fi diff --git a/kdump-in-cluster-environment.txt b/kdump-in-cluster-environment.txt deleted file mode 100644 index de1eb5e..0000000 --- a/kdump-in-cluster-environment.txt +++ /dev/null @@ -1,91 +0,0 @@ -Kdump-in-cluster-environment HOWTO - -Introduction - -Kdump is a kexec based crash dumping mechansim for Linux. This docuement -illustrate how to configure kdump in cluster environment to allow the kdump -crash recovery service complete without being preempted by traditional power -fencing methods. - -Overview - -Kexec/Kdump - -Details about Kexec/Kdump are available in Kexec-Kdump-howto file and will not -be described here. - -fence_kdump - -fence_kdump is an I/O fencing agent to be used with the kdump crash recovery -service. When the fence_kdump agent is invoked, it will listen for a message -from the failed node that acknowledges that the failed node is executing the -kdump crash kernel. Note that fence_kdump is not a replacement for traditional -fencing methods. The fence_kdump agent can only detect that a node has entered -the kdump crash recovery service. This allows the kdump crash recovery service -complete without being preempted by traditional power fencing methods. - -fence_kdump_send - -fence_kdump_send is a utility used to send messages that acknowledge that the -node itself has entered the kdump crash recovery service. The fence_kdump_send -utility is typically run in the kdump kernel after a cluster node has -encountered a kernel panic. Once the cluster node has entered the kdump crash -recovery service, fence_kdump_send will periodically send messages to all -cluster nodes. When the fence_kdump agent receives a valid message from the -failed nodes, fencing is complete. - -How to configure Pacemaker cluster environment: - -If we want to use kdump in Pacemaker cluster environment, fence-agents-kdump -should be installed in every nodes in the cluster. You can achieve this via -the following command: - - # yum install -y fence-agents-kdump - -Next is to add kdump_fence to the cluster. Assuming that the cluster consists -of three nodes, they are node1, node2 and node3, and use Pacemaker to perform -resource management and pcs as cli configuration tool. - -With pcs it is easy to add a stonith resource to the cluster. For example, add -a stonith resource named mykdumpfence with fence type of fence_kdump via the -following commands: - - # pcs stonith create mykdumpfence fence_kdump \ - pcmk_host_check=static-list pcmk_host_list="node1 node2 node3" - # pcs stonith update mykdumpfence pcmk_monitor_action=metadata --force - # pcs stonith update mykdumpfence pcmk_status_action=metadata --force - # pcs stonith update mykdumpfence pcmk_reboot_action=off --force - -Then enable stonith - # pcs property set stonith-enabled=true - -How to configure kdump: - -Actually there are two ways how to configure fence_kdump support: - -1) Pacemaker based clusters - If you have successfully configured fence_kdump in Pacemaker, there is - no need to add some special configuration in kdump. So please refer to - Kexec-Kdump-howto file for more information. - -2) Generic clusters - For other types of clusters there are two configuration options in - kdump.conf which enables fence_kdump support: - - fence_kdump_nodes - Contains list of cluster node(s) separated by space to send - fence_kdump notification to (this option is mandatory to enable - fence_kdump) - - fence_kdump_args - Command line arguments for fence_kdump_send (it can contain - all valid arguments except hosts to send notification to) - - These options will most probably be configured by your cluster software, - so please refer to your cluster documentation how to enable fence_kdump - support. - -Please be aware that these two ways cannot be combined and 2) has precedence -over 1). It means that if fence_kdump is configured using fence_kdump_nodes -and fence_kdump_args options in kdump.conf, Pacemaker configuration is not -used even if it exists. diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh deleted file mode 100755 index f7b58a2..0000000 --- a/kdump-lib-initramfs.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/sh -# -# The code in this file will be used in initramfs environment, bash may -# not be the default shell. Any code added must be POSIX compliant. - -DEFAULT_PATH="/var/crash/" -DEFAULT_SSHKEY="/root/.ssh/kdump_id_rsa" -KDUMP_CONFIG_FILE="/etc/kdump.conf" -FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" -FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" -LVM_CONF="/etc/lvm/lvm.conf" - -# Read kdump config in well formated style -kdump_read_conf() -{ - # Following steps are applied in order: strip trailing comment, strip trailing space, - # strip heading space, match non-empty line, remove duplicated spaces between conf name and value - [ -f "$KDUMP_CONFIG_FILE" ] && sed -n -e "s/#.*//;s/\s*$//;s/^\s*//;s/\(\S\+\)\s*\(.*\)/\1 \2/p" $KDUMP_CONFIG_FILE -} - -# Retrieves config value defined in kdump.conf -# $1: config name, sed regexp compatible -kdump_get_conf_val() -{ - # For lines matching "^\s*$1\s+", remove matched part (config name including space), - # remove tailing comment, space, then store in hold space. Print out the hold buffer on last line. - [ -f "$KDUMP_CONFIG_FILE" ] && - sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE -} - -is_mounted() -{ - [ -n "$1" ] && findmnt -k -n "$1" > /dev/null 2>&1 -} - -# $1: info type -# $2: mount source type -# $3: mount source -# $4: extra args -get_mount_info() -{ - __kdump_mnt=$(findmnt -k -n -r -o "$1" "--$2" "$3" $4) - - [ -z "$__kdump_mnt" ] && [ -e "/etc/fstab" ] && __kdump_mnt=$(findmnt -s -n -r -o "$1" "--$2" "$3" $4) - - echo "$__kdump_mnt" -} - -is_ipv6_address() -{ - echo "$1" | grep -q ":" -} - -is_fs_type_nfs() -{ - [ "$1" = "nfs" ] || [ "$1" = "nfs4" ] -} - -is_fs_type_virtiofs() -{ - [ "$1" = "virtiofs" ] -} - -# If $1 contains dracut_args "--mount", return -get_dracut_args_fstype() -{ - echo "$1" | sed -n "s/.*--mount .\(.*\)/\1/p" | cut -d' ' -f3 -} - -# If $1 contains dracut_args "--mount", return -get_dracut_args_target() -{ - echo "$1" | sed -n "s/.*--mount .\(.*\)/\1/p" | cut -d' ' -f1 -} - -get_save_path() -{ - __kdump_path=$(kdump_get_conf_val path) - [ -z "$__kdump_path" ] && __kdump_path=$DEFAULT_PATH - - # strip the duplicated "/" - echo "$__kdump_path" | tr -s / -} - -get_root_fs_device() -{ - findmnt -k -f -n -o SOURCE / -} - -# Return the current underlying device of a path, ignore bind mounts -get_target_from_path() -{ - __kdump_target=$(df "$1" 2> /dev/null | tail -1 | awk '{print $1}') - [ "$__kdump_target" = "/dev/root" ] && [ ! -e /dev/root ] && __kdump_target=$(get_root_fs_device) - echo "$__kdump_target" -} - -get_fs_type_from_target() -{ - get_mount_info FSTYPE source "$1" -f -} - -get_mntpoint_from_target() -{ - # --source is applied to ensure non-bind mount is returned - get_mount_info TARGET source "$1" -f -} - -is_ssh_dump_target() -{ - kdump_get_conf_val ssh | grep -q @ -} - -is_raw_dump_target() -{ - [ -n "$(kdump_get_conf_val raw)" ] -} - -is_virtiofs_dump_target() -{ - if [ -n "$(kdump_get_conf_val virtiofs)" ]; then - return 0 - fi - - if is_fs_type_virtiofs "$(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)")"; then - return 0 - fi - - if is_fs_type_virtiofs "$(get_fs_type_from_target "$(get_target_from_path "$(get_save_path)")")"; then - return 0 - fi - - return 1 -} - -is_nfs_dump_target() -{ - if [ -n "$(kdump_get_conf_val nfs)" ]; then - return 0 - fi - - if is_fs_type_nfs "$(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)")"; then - return 0 - fi - - if is_fs_type_nfs "$(get_fs_type_from_target "$(get_target_from_path "$(get_save_path)")")"; then - return 0 - fi - - return 1 -} - -is_lvm2_thinp_device() -{ - _device_path=$1 - _lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \ - --nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null) - - [ -n "$_lvm2_thin_device" ] -} - -kdump_get_ip_route() -{ - if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then - exit 1 - fi - echo "$_route" -} - -kdump_get_ip_route_field() -{ - echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" -} diff --git a/kdump-lib.sh b/kdump-lib.sh deleted file mode 100755 index 79714f9..0000000 --- a/kdump-lib.sh +++ /dev/null @@ -1,1117 +0,0 @@ -#!/bin/bash -# -# Kdump common variables and functions -# -if [[ ${__SOURCED__:+x} ]]; then - . ./kdump-lib-initramfs.sh -else - . /lib/kdump/kdump-lib-initramfs.sh -fi - -FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump/enabled" -FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump/registered" - -is_uki() -{ - local img - - img="$1" - - [[ -f "$img" ]] || return - [[ "$(file -b --mime-type "$img")" == application/x-dosexec ]] || return - objdump -h -j .linux "$img" &> /dev/null -} - -is_fadump_capable() -{ - # Check if firmware-assisted dump is enabled - # if no, fallback to kdump check - if [[ -f $FADUMP_ENABLED_SYS_NODE ]]; then - rc=$(< $FADUMP_ENABLED_SYS_NODE) - [[ $rc -eq 1 ]] && return 0 - fi - return 1 -} - -is_aws_aarch64() -{ - [[ "$(lscpu | grep "BIOS Model name")" =~ "AWS Graviton" ]] -} - -is_sme_or_sev_active() -{ - journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1 -} - -is_squash_available() -{ - local _version kmodule - - _version=$(_get_kdump_kernel_version) - for kmodule in squashfs overlay loop; do - modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1 - done -} - -has_command() -{ - [[ -x $(command -v "$1") ]] -} - -dracut_have_option() -{ - local _option=$1 - ! dracut "$_option" 2>&1 | grep -q "unrecognized option" -} - -perror_exit() -{ - derror "$@" - exit 1 -} - -# Check if fence kdump is configured in Pacemaker cluster -is_pcs_fence_kdump() -{ - # no pcs or fence_kdump_send executables installed? - type -P pcs > /dev/null || return 1 - [[ -x $FENCE_KDUMP_SEND ]] || return 1 - - # fence kdump not configured? - (pcs cluster cib | grep 'type="fence_kdump"') &> /dev/null || return 1 -} - -# Check if fence_kdump is configured using kdump options -is_generic_fence_kdump() -{ - [[ -x $FENCE_KDUMP_SEND ]] || return 1 - - [[ $(kdump_get_conf_val fence_kdump_nodes) ]] -} - -to_dev_name() -{ - local dev="${1//\"/}" - - case "$dev" in - UUID=*) - blkid -U "${dev#UUID=}" - ;; - LABEL=*) - blkid -L "${dev#LABEL=}" - ;; - *) - echo "$dev" - ;; - esac -} - -is_user_configured_dump_target() -{ - [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh\|virtiofs") ]] || is_mount_in_dracut_args -} - -get_block_dump_target() -{ - local _target _fstype - - if is_ssh_dump_target || is_nfs_dump_target; then - return - fi - - _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|virtiofs") - [[ -n $_target ]] && to_dev_name "$_target" && return - - _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")") - [[ -b $_target ]] && to_dev_name "$_target" && return - - _fstype=$(get_dracut_args_fstype "$(kdump_get_conf_val "dracut_args")") - is_fs_type_virtiofs "$_fstype" && echo "$_target" && return - - _target=$(get_target_from_path "$(get_save_path)") - [[ -b $_target ]] && to_dev_name "$_target" && return - - _fstype=$(get_fs_type_from_target "$_target") - is_fs_type_virtiofs "$_fstype" && echo "$_target" && return -} - -is_dump_to_rootfs() -{ - [[ $(kdump_get_conf_val 'failure_action\|default') == dump_to_rootfs ]] -} - -is_lvm2_thinp_dump_target() -{ - _target=$(get_block_dump_target) - [ -n "$_target" ] && is_lvm2_thinp_device "$_target" -} - -get_failure_action_target() -{ - local _target - - if is_dump_to_rootfs; then - # Get rootfs device name - _target=$(get_root_fs_device) - [[ -b $_target ]] && to_dev_name "$_target" && return - is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return - # Then, must be nfs root - echo "nfs" - fi -} - -# Get kdump targets(including root in case of dump_to_rootfs). -get_kdump_targets() -{ - local _target _root - local kdump_targets - - _target=$(get_block_dump_target) - if [[ -n $_target ]]; then - kdump_targets=$_target - elif is_ssh_dump_target; then - kdump_targets="ssh" - else - kdump_targets="nfs" - fi - - # Add the root device if dump_to_rootfs is specified. - _root=$(get_failure_action_target) - if [[ -n $_root ]] && [[ $kdump_targets != "$_root" ]]; then - kdump_targets="$kdump_targets $_root" - fi - - echo "$kdump_targets" -} - -# Return the bind mount source path, return the path itself if it's not bind mounted -# Eg. if /path/to/src is bind mounted to /mnt/bind, then: -# /mnt/bind -> /path/to/src, /mnt/bind/dump -> /path/to/src/dump -# -# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] -# in the SOURCE column for bind-mounts, then if $_src equals to -# $_src_nofsroot, the mountpoint is not bind mounted directory. -# -# Below is just an example for mount info -# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the -# directory is bind mounted. The former part represents the device path, rest -# part is the bind mounted directory which quotes by bracket "[]". -get_bind_mount_source() -{ - local _mnt _path _src _opt _fstype - local _fsroot _src_nofsroot - - _mnt=$(df "$1" | tail -1 | awk '{print $NF}') - _path=${1#"$_mnt"} - - _src=$(get_mount_info SOURCE target "$_mnt" -f) - _opt=$(get_mount_info OPTIONS target "$_mnt" -f) - _fstype=$(get_mount_info FSTYPE target "$_mnt" -f) - - # bind mount in fstab - if [[ -d $_src ]] && [[ $_fstype == none ]] && (echo "$_opt" | grep -q "\bbind\b"); then - echo "$_src$_path" && return - fi - - # direct mount - _src_nofsroot=$(get_mount_info SOURCE target "$_mnt" -v -f) - if [[ $_src_nofsroot == "$_src" ]]; then - echo "$_mnt$_path" && return - fi - - _fsroot=${_src#"${_src_nofsroot}"[} - _fsroot=${_fsroot%]} - _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f) - - # for btrfs, _fsroot will also contain the subvol value as well, strip it - if [[ $_fstype == btrfs ]]; then - local _subvol - _subvol=${_opt#*subvol=} - _subvol=${_subvol%,*} - _fsroot=${_fsroot#"$_subvol"} - fi - echo "$_mnt$_fsroot$_path" -} - -get_mntopt_from_target() -{ - get_mount_info OPTIONS source "$1" -f -} - -# Get the path where the target will be mounted in kdump kernel -# $1: kdump target device -get_kdump_mntpoint_from_target() -{ - local _mntpoint - - _mntpoint=$(get_mntpoint_from_target "$1") - # mount under /sysroot if dump to root disk or mount under - # mount under /kdumproot if dump target is not mounted in first kernel - # mount under /kdumproot/$_mntpoint in other cases in 2nd kernel. - # systemd will be in charge to umount it. - if [[ -z $_mntpoint ]]; then - _mntpoint="/kdumproot" - else - if [[ $_mntpoint == "/" ]]; then - _mntpoint="/sysroot" - else - _mntpoint="/kdumproot/$_mntpoint" - fi - fi - - # strip duplicated "/" - echo $_mntpoint | tr -s "/" -} - -kdump_get_persistent_dev() -{ - local dev="${1//\"/}" - - case "$dev" in - UUID=*) - dev=$(blkid -U "${dev#UUID=}") - ;; - LABEL=*) - dev=$(blkid -L "${dev#LABEL=}") - ;; - esac - get_persistent_dev "$dev" -} - -is_ostree() -{ - test -f /run/ostree-booted -} - -# get ip address or hostname from nfs/ssh config value -get_remote_host() -{ - local _config_val=$1 - - # ipv6 address in kdump.conf is around with "[]", - # factor out the ipv6 address - _config_val=${_config_val#*@} - _config_val=${_config_val%:/*} - _config_val=${_config_val#[} - _config_val=${_config_val%]} - echo "$_config_val" -} - -is_hostname() -{ - local _hostname - - _hostname=$(echo "$1" | grep ":") - if [[ -n $_hostname ]]; then - return 1 - fi - echo "$1" | grep -q "[a-zA-Z]" -} - -# Get value by a field using "nmcli -g" -# Usage: get_nmcli_value_by_field -# -# "nmcli --get-values" allows us to retrive value(s) by field, for example, -# nmcli --get-values connection show /org/freedesktop/NetworkManager/ActiveConnection/1 -# returns the following value for the corresponding field respectively, -# Field Value -# IP4.DNS "10.19.42.41 | 10.11.5.19 | 10.5.30.160" -# 802-3-ethernet.s390-subchannels "" -# bond.options "mode=balance-rr" -get_nmcli_value_by_field() -{ - LANG=C nmcli --get-values "$@" -} - -is_wdt_active() -{ - local active - - [[ -d /sys/class/watchdog ]] || return 1 - for dir in /sys/class/watchdog/*; do - [[ -f "$dir/state" ]] || continue - active=$(< "$dir/state") - [[ $active == "active" ]] && return 0 - done - return 1 -} - -have_compression_in_dracut_args() -{ - [[ "$(kdump_get_conf_val dracut_args)" =~ (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress|squash-compressor)([[:space:]]|$) ]] -} - -# If "dracut_args" contains "--mount" information, use it -# directly without any check(users are expected to ensure -# its correctness). -is_mount_in_dracut_args() -{ - [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]] -} - -get_reserved_mem_size() -{ - local reserved_mem_size=0 - - if is_fadump_capable; then - reserved_mem_size=$(< /sys/kernel/fadump/mem_reserved) - else - reserved_mem_size=$(< /sys/kernel/kexec_crash_size) - fi - - echo "$reserved_mem_size" -} - -check_crash_mem_reserved() -{ - local mem_reserved - - mem_reserved=$(get_reserved_mem_size) - if [[ $mem_reserved -eq 0 ]]; then - derror "No memory reserved for crash kernel" - return 1 - fi - - return 0 -} - -check_kdump_feasibility() -{ - if [[ ! -e /sys/kernel/kexec_crash_loaded ]]; then - derror "Kdump is not supported on this kernel" - return 1 - fi - check_crash_mem_reserved - return $? -} - -is_kernel_loaded() -{ - local _sysfs _mode - - _mode=$1 - - case "$_mode" in - kdump) - _sysfs="/sys/kernel/kexec_crash_loaded" - ;; - fadump) - _sysfs="$FADUMP_REGISTER_SYS_NODE" - ;; - *) - derror "Unknown dump mode '$_mode' provided" - return 1 - ;; - esac - - if [[ ! -f $_sysfs ]]; then - derror "$_mode is not supported on this kernel" - return 1 - fi - - [[ $(< $_sysfs) -eq 1 ]] -} - -# -# This function returns the "apicid" of the boot -# cpu (cpu 0) if present. -# -get_bootcpu_apicid() -{ - awk ' \ - BEGIN { CPU = "-1"; } \ - $1=="processor" && $2==":" { CPU = $NF; } \ - CPU=="0" && /^apicid/ { print $NF; } \ - ' \ - /proc/cpuinfo -} - -# This function check iomem and determines if we have more than -# 4GB of ram available. Returns 1 if we do, 0 if we dont -need_64bit_headers() -{ - return "$(tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); - print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }')" -} - -# Check if secure boot is being enforced. -# -# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and -# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four -# bytes are the attributes associated with the variable and can safely be -# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot -# is 1 and SetupMode is 0, then secure boot is being enforced. -# -# Assume efivars is mounted at /sys/firmware/efi/efivars. -is_secure_boot_enforced() -{ - local secure_boot_file setup_mode_file - local secure_boot_byte setup_mode_byte - - # On powerpc, secure boot is enforced if: - # host secure boot: /ibm,secure-boot/os-secureboot-enforcing DT property exists - # guest secure boot: /ibm,secure-boot >= 2 - if [[ -f /proc/device-tree/ibm,secureboot/os-secureboot-enforcing ]]; then - return 0 - fi - if [[ -f /proc/device-tree/ibm,secure-boot ]] && - [[ $(lsprop /proc/device-tree/ibm,secure-boot | tail -1) -ge 2 ]]; then - return 0 - fi - - # Detect secure boot on x86 and arm64 - secure_boot_file=$(find /sys/firmware/efi/efivars -name "SecureBoot-*" 2> /dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name "SetupMode-*" 2> /dev/null) - - if [[ -f $secure_boot_file ]] && [[ -f $setup_mode_file ]]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' "$secure_boot_file" | cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' "$setup_mode_file" | cut -d' ' -f 5) - - if [[ $secure_boot_byte == "1" ]] && [[ $setup_mode_byte == "0" ]]; then - return 0 - fi - fi - - # Detect secure boot on s390x - if [[ -e "/sys/firmware/ipl/secure" && "$(< /sys/firmware/ipl/secure)" == "1" ]]; then - return 0 - fi - - return 1 -} - -# -# prepare_kexec_args -# This function prepares kexec argument. -# -prepare_kexec_args() -{ - local kexec_args=$1 - local found_elf_args - - ARCH=$(uname -m) - if [[ $ARCH == "i686" ]] || [[ $ARCH == "i386" ]]; then - need_64bit_headers - if [[ $? == 1 ]]; then - found_elf_args=$(echo "$kexec_args" | grep elf32-core-headers) - if [[ -n $found_elf_args ]]; then - dwarn "Warning: elf32-core-headers overrides correct elf64 setting" - else - kexec_args="$kexec_args --elf64-core-headers" - fi - else - found_elf_args=$(echo "$kexec_args" | grep elf64-core-headers) - if [[ -z $found_elf_args ]]; then - kexec_args="$kexec_args --elf32-core-headers" - fi - fi - fi - - # For secureboot enabled machines, use new kexec file based syscall. - # Old syscall will always fail as it does not have capability to do - # kernel signature verification. - if is_secure_boot_enforced; then - dinfo "Secure Boot is enabled. Using kexec file based syscall." - kexec_args="$kexec_args -s" - fi - - echo "$kexec_args" -} - -# prepare_kdump_kernel -# This function return kdump_kernel given a kernel version. -prepare_kdump_kernel() -{ - local kdump_kernelver=$1 - local dir img boot_dirlist boot_imglist kdump_kernel machine_id - read -r machine_id < /etc/machine-id - - boot_dirlist=${KDUMP_BOOTDIR:-"/boot /boot/efi /efi /"} - boot_imglist="$KDUMP_IMG-$kdump_kernelver$KDUMP_IMG_EXT \ - $machine_id/$kdump_kernelver/$KDUMP_IMG \ - EFI/Linux/$machine_id-$kdump_kernelver.efi" - - # The kernel of OSTree based systems is not in the standard locations. - if is_ostree; then - boot_dirlist="$(echo /boot/ostree/*) $boot_dirlist" - fi - - # Use BOOT_IMAGE as reference if possible, strip the GRUB root device prefix in (hd0,gpt1) format - boot_img="$(grep -P -o '^BOOT_IMAGE=(\S+)' /proc/cmdline | sed "s/^BOOT_IMAGE=\((\S*)\)\?\(\S*\)/\2/")" - if [[ "$boot_img" == *"$kdump_kernelver" ]]; then - boot_imglist="$boot_img $boot_imglist" - fi - - for dir in $boot_dirlist; do - for img in $boot_imglist; do - if [[ -f "$dir/$img" ]]; then - kdump_kernel=$(echo "$dir/$img" | tr -s '/') - break 2 - fi - done - done - echo "$kdump_kernel" -} - -_is_valid_kver() -{ - [[ -f /usr/lib/modules/$1/modules.dep ]] -} - -# This function is introduced since 64k variant may be installed on 4k or vice versa -# $1 the kernel path name. -parse_kver_from_path() -{ - local _img _kver - - [[ -z "$1" ]] && return - - _img=$1 - BLS_ENTRY_TOKEN=$( - _kver=${_img##*/vmlinuz-} - _kver=${_kver%"$KDUMP_IMG_EXT"} - if _is_valid_kver "$_kver"; then - echo "$_kver" - return - fi - - # BLS recommended image names, i.e. $BOOT///linux - _kver=${_img##*/"$BLS_ENTRY_TOKEN"/} - _kver=${_kver%%/*} - if _is_valid_kver "$_kver"; then - echo "$_kver" - return - fi - - # Fedora UKI installation, i.e. $BOOT/efi/EFI/Linux/-.efi - _kver=${_img##*/"$BLS_ENTRY_TOKEN"-} - _kver=${_kver%.efi} - if _is_valid_kver "$_kver"; then - echo "$_kver" - return - fi - - ddebug "Could not parse version from $_img" -} - -_get_kdump_kernel_version() -{ - local _version _version_nondebug - - if [[ -n "$KDUMP_KERNELVER" ]]; then - echo "$KDUMP_KERNELVER" - return - fi - - _version=$(uname -r) - if [[ ! "$_version" =~ [+|-]debug$ ]]; then - echo "$_version" - return - fi - - _version_nondebug=${_version%+debug} - _version_nondebug=${_version_nondebug%-debug} - if _is_valid_kver "$_version_nondebug"; then - dinfo "Use of debug kernel detected. Trying to use $_version_nondebug" - echo "$_version_nondebug" - else - dinfo "Use of debug kernel detected but cannot find $_version_nondebug. Falling back to $_version" - echo "$_version" - fi -} - -# -# Detect initrd and kernel location, results are stored in global environmental variables: -# KDUMP_BOOTDIR, KDUMP_KERNELVER, KDUMP_KERNEL, DEFAULT_INITRD, and KDUMP_INITRD -# -# Expectes KDUMP_BOOTDIR, KDUMP_IMG, KDUMP_IMG_EXT, KDUMP_KERNELVER to be loaded from config already -# and will prefer already set values so user can specify custom kernel/initramfs location -# -prepare_kdump_bootinfo() -{ - local boot_initrdlist default_initrd_base var_target_initrd_dir - - KDUMP_KERNELVER=$(_get_kdump_kernel_version) - KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER") - - if ! [[ -e $KDUMP_KERNEL ]]; then - derror "Failed to detect kdump kernel location" - return 1 - fi - - # For 64k variant, e.g. vmlinuz-5.14.0-327.el9.aarch64+64k-debug - if [[ "$KDUMP_KERNEL" == *"+debug" || "$KDUMP_KERNEL" == *"64k-debug" ]]; then - dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value." - fi - - # Set KDUMP_BOOTDIR to where kernel image is stored - if is_uki "$KDUMP_KERNEL"; then - KDUMP_BOOTDIR=/boot - else - KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL") - fi - - # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR - boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" - for initrd in $boot_initrdlist; do - if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then - default_initrd_base="$initrd" - DEFAULT_INITRD="$KDUMP_BOOTDIR/$default_initrd_base" - break - fi - done - - # Create kdump initrd basename from default initrd basename - # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img - # initrd => initrdkdump - if [[ -z $default_initrd_base ]]; then - kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img - elif [[ $default_initrd_base == *.* ]]; then - kdump_initrd_base=${default_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} - else - kdump_initrd_base=${default_initrd_base}kdump - fi - - # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable - if [[ ! -w $KDUMP_BOOTDIR ]]; then - var_target_initrd_dir="/var/lib/kdump" - mkdir -p "$var_target_initrd_dir" - KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base" - else - KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base" - fi -} - -get_watchdog_drvs() -{ - local _wdtdrvs _drv _dir - - for _dir in /sys/class/watchdog/*; do - # device/modalias will return driver of this device - [[ -f "$_dir/device/modalias" ]] || continue - _drv=$(< "$_dir/device/modalias") - _drv=$(modprobe --set-version "$KDUMP_KERNELVER" -R "$_drv" 2> /dev/null) - for i in $_drv; do - if ! [[ " $_wdtdrvs " == *" $i "* ]]; then - _wdtdrvs="$_wdtdrvs $i" - fi - done - done - - echo "$_wdtdrvs" -} - -_cmdline_parse() -{ - local opt val - - while read -r opt; do - if [[ $opt =~ = ]]; then - val=${opt#*=} - opt=${opt%%=*} - # ignore options like 'foo=' - [[ -z $val ]] && continue - # xargs removes quotes, add them again - [[ $val =~ [[:space:]] ]] && val="\"$val\"" - else - val="" - fi - - echo "$opt $val" - done <<< "$(echo "$1" | xargs -n 1 echo)" -} - -# -# prepare_cmdline -# This function performs a series of edits on the command line. -# Store the final result in global $KDUMP_COMMANDLINE. -prepare_cmdline() -{ - local in out append opt val id drv - local -A remove - - in=${1:-$(< /proc/cmdline)} - while read -r opt val; do - [[ -n "$opt" ]] || continue - remove[$opt]=1 - done <<< "$(_cmdline_parse "$2")" - append=$3 - - - # These params should always be removed - remove[crashkernel]=1 - remove[panic_on_warn]=1 - - # Always remove "root=X", as we now explicitly generate all kinds - # of dump target mount information including root fs. - # - # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares - # about it(e.g. for debug purpose), then can pass "root=X" using - # KDUMP_COMMANDLINE_APPEND. - remove[root]=1 - - # With the help of "--hostonly-cmdline", we can avoid some interitage. - remove[rd.lvm.lv]=1 - remove[rd.luks.uuid]=1 - remove[rd.dm.uuid]=1 - remove[rd.md.uuid]=1 - remove[fcoe]=1 - - # Remove netroot, rd.iscsi.initiator and iscsi_initiator since - # we get duplicate entries for the same in case iscsi code adds - # it as well. - remove[netroot]=1 - remove[rd.iscsi.initiator]=1 - remove[iscsi_initiator]=1 - - while read -r opt val; do - [[ -n "$opt" ]] || continue - [[ -n "${remove[$opt]}" ]] && continue - - if [[ -n "$val" ]]; then - out+="$opt=$val " - else - out+="$opt " - fi - done <<< "$(_cmdline_parse "$in")" - - out+="$append " - - id=$(get_bootcpu_apicid) - if [[ -n "${id}" ]]; then - out+="disable_cpu_apicid=$id " - fi - - # If any watchdog is used, set it's pretimeout to 0. pretimeout let - # watchdog panic the kernel first, and reset the system after the - # panic. If the system is already in kdump, panic is not helpful - # and only increase the chance of watchdog failure. - for drv in $(get_watchdog_drvs); do - out+="$drv.pretimeout=0 " - - if [[ $drv == hpwdt ]]; then - # hpwdt have a special parameter kdumptimeout, it is - # only supposed to be set to non-zero in first kernel. - # In kdump, non-zero value could prevent the watchdog - # from resetting the system. - out+="$drv.kdumptimeout=0 " - fi - done - - # This is a workaround on AWS platform. Always remove irqpoll since it - # may cause the hot-remove of some pci hotplug device. - is_aws_aarch64 && out=$(echo "$out" | sed -e "/\//") - - # Always disable gpt-auto-generator as it hangs during boot of the - # crash kernel. Furthermore we know which disk will be used for dumping - # (if at all) and add it explicitly. - is_uki "$KDUMP_KERNEL" && out+="rd.systemd.gpt_auto=no " - - # Trim unnecessary whitespaces - echo "$out" | sed -e "s/^ *//g" -e "s/ *$//g" -e "s/ \+/ /g" -} - -PROC_IOMEM=/proc/iomem -#get system memory size i.e. memblock.memory.total_size in the unit of GB -get_system_size() -{ - sum=$(sed -n "s/\s*\([0-9a-fA-F]\+\)-\([0-9a-fA-F]\+\) : System RAM$/+ 0x\2 - 0x\1 + 1/p" $PROC_IOMEM) - echo $(( (sum) / 1024 / 1024 / 1024)) -} - -# Return the recommended size for the reserved crashkernel memory -# depending on the system memory size. -# -# This functions is expected to be consistent with the parse_crashkernel_mem() -# in kernel i.e. how kernel allocates the kdump memory given the crashkernel -# parameter crashkernel=range1:size1[,range2:size2,…] and the system memory -# size. -get_recommend_size() -{ - local mem_size=$1 - local _ck_cmdline=$2 - local range start start_unit end end_unit size - - while read -r -d , range; do - # need to use non-default IFS as double spaces are used as a - # single delimiter while commas aren't... - IFS=, read -r start start_unit end end_unit size <<< \ - "$(echo "$range" | sed -n "s/\([0-9]\+\)\([GT]\?\)-\([0-9]*\)\([GT]\?\):\([0-9]\+[MG]\)/\1,\2,\3,\4,\5/p")" - - # aka. 102400T - end=${end:-104857600} - [[ "$end_unit" == T ]] && end=$((end * 1024)) - [[ "$start_unit" == T ]] && start=$((start * 1024)) - - if [[ $mem_size -ge $start ]] && [[ $mem_size -lt $end ]]; then - echo "$size" - return - fi - - # append a ',' as read expects the 'file' to end with a delimiter - done <<< "$_ck_cmdline," - - # no matching range found - echo "0M" -} - -has_mlx5() -{ - [[ -d /sys/bus/pci/drivers/mlx5_core ]] -} - -has_aarch64_smmu() -{ - ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 -} - -is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; } - -# range defined for crashkernel parameter -# i.e. -[] -is_memrange() -{ - is_memsize "${1%-*}" || return 1 - [[ -n ${1#*-} ]] || return 0 - is_memsize "${1#*-}" -} - -to_bytes() -{ - local _s - - _s="$1" - is_memsize "$_s" || return 1 - - case "${_s: -1}" in - K|k) - _s=${_s::-1} - _s="$((_s * 1024))" - ;; - M|m) - _s=${_s::-1} - _s="$((_s * 1024 * 1024))" - ;; - G|g) - _s=${_s::-1} - _s="$((_s * 1024 * 1024 * 1024))" - ;; - T|t) - _s=${_s::-1} - _s="$((_s * 1024 * 1024 * 1024 * 1024))" - ;; - P|p) - _s=${_s::-1} - _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024))" - ;; - E|e) - _s=${_s::-1} - _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024 * 1024))" - ;; - *) - ;; - esac - echo "$_s" -} - -memsize_add() -{ - local -a units=("" "K" "M" "G" "T" "P" "E") - local i a b - - a=$(to_bytes "$1") || return 1 - b=$(to_bytes "$2") || return 1 - i=0 - - (( a += b )) - while :; do - [[ $(( a / 1024 )) -eq 0 ]] && break - [[ $(( a % 1024 )) -ne 0 ]] && break - [[ $(( ${#units[@]} - 1 )) -eq $i ]] && break - - (( a /= 1024 )) - (( i += 1 )) - done - - echo "${a}${units[$i]}" -} - -_crashkernel_parse() -{ - local ck entry - local range size offset - - ck="$1" - - if [[ "$ck" == *@* ]]; then - offset="@${ck##*@}" - ck=${ck%@*} - elif [[ "$ck" == *,high ]] || [[ "$ck" == *,low ]]; then - offset=",${ck##*,}" - ck=${ck%,*} - else - offset='' - fi - - while read -d , -r entry; do - [[ -n "$entry" ]] || continue - if [[ "$entry" == *:* ]]; then - range=${entry%:*} - size=${entry#*:} - else - range="" - size=${entry} - fi - - echo "$size;$range;" - done <<< "$ck," - echo ";;$offset" -} - -# $1 crashkernel command line parameter -# $2 size to be added -_crashkernel_add() -{ - local ck delta ret - local range size offset - - ck="$1" - delta="$2" - ret="" - - while IFS=';' read -r size range offset; do - if [[ -n "$offset" ]]; then - ret="${ret%,}$offset" - break - fi - - [[ -n "$size" ]] || continue - if [[ -n "$range" ]]; then - is_memrange "$range" || return 1 - ret+="$range:" - fi - - size=$(memsize_add "$size" "$delta") || return 1 - ret+="$size," - done < <( _crashkernel_parse "$ck") - - echo "${ret%,}" -} - -# get default crashkernel -# $1 dump mode, if not specified, dump_mode will be judged by is_fadump_capable -# $2 kernel-release, if not specified, got by _get_kdump_kernel_version -kdump_get_arch_recommend_crashkernel() -{ - local _arch _ck_cmdline _dump_mode - local _delta=0 - - if [[ -z "$1" ]]; then - if is_fadump_capable; then - _dump_mode=fadump - else - _dump_mode=kdump - fi - else - _dump_mode=$1 - fi - - _arch=$(uname -m) - - if [[ $_arch == "x86_64" ]] || [[ $_arch == "s390x" ]]; then - _ck_cmdline="1G-4G:192M,4G-64G:256M,64G-:512M" - is_sme_or_sev_active && ((_delta += 64)) - elif [[ $_arch == "aarch64" ]]; then - local _running_kernel - - # Base line for 4K variant kernel. The formula is based on x86 plus extra = 64M - _ck_cmdline="1G-4G:256M,4G-64G:320M,64G-:576M" - if [[ -z "$2" ]]; then - _running_kernel=$(_get_kdump_kernel_version) - else - _running_kernel=$2 - fi - - # the naming convention of 64k variant suffixes with +64k, e.g. "vmlinuz-5.14.0-312.el9.aarch64+64k" - if echo "$_running_kernel" | grep -q 64k; then - # Without smmu, the diff of MemFree between 4K and 64K measured on a high end aarch64 machine is 82M. - # Picking up 100M to cover this diff. And finally, we have "1G-4G:356M;4G-64G:420M;64G-:676M" - ((_delta += 100)) - # On a 64K system, the extra 384MB is calculated by: cmdq_num * 16 bytes + evtq_num * 32B + priq_num * 16B - # While on a 4K system, it is negligible - has_aarch64_smmu && ((_delta += 384)) - #64k kernel, mlx5 consumes extra 188M memory, and choose 200M - has_mlx5 && ((_delta += 200)) - else - #4k kernel, mlx5 consumes extra 124M memory, and choose 150M - has_mlx5 && ((_delta += 150)) - fi - elif [[ $_arch == "ppc64le" ]]; then - if [[ $_dump_mode == "fadump" ]]; then - _ck_cmdline="4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G" - else - _ck_cmdline="2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G" - fi - fi - - echo -n "$(_crashkernel_add "$_ck_cmdline" "${_delta}M")" -} - -# return recommended size based on current system RAM size -# $1: kernel version, if not set, will defaults to $(uname -r) -kdump_get_arch_recommend_size() -{ - local _ck_cmdline _sys_mem - - if ! [[ -r "/proc/iomem" ]]; then - echo "Error, can not access /proc/iomem." - return 1 - fi - _sys_mem=$(get_system_size) - _ck_cmdline=$(kdump_get_arch_recommend_crashkernel) - _ck_cmdline=${_ck_cmdline//-:/-102400T:} - get_recommend_size "$_sys_mem" "$_ck_cmdline" -} - -# Print all underlying crypt devices of a block device -# print nothing if device is not on top of a crypt device -# $1: the block device to be checked in maj:min format -get_luks_crypt_dev() -{ - local _type - - [[ -b /dev/block/$1 ]] || return 1 - - _type=$(blkid -u filesystem,crypto -o export -- "/dev/block/$1" | \ - sed -n -E "s/^TYPE=(.*)$/\1/p") - [[ $_type == "crypto_LUKS" ]] && echo "$1" - - for _x in "/sys/dev/block/$1/slaves/"*; do - [[ -f $_x/dev ]] || continue - [[ $_x/subsystem -ef /sys/class/block ]] || continue - get_luks_crypt_dev "$(< "$_x/dev")" - done -} - -# kdump_get_maj_min -# Prints the major and minor of a device node. -# Example: -# $ get_maj_min /dev/sda2 -# 8:2 -kdump_get_maj_min() -{ - local _majmin - _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" - printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" -} - -get_all_kdump_crypt_dev() -{ - local _dev - - for _dev in $(get_block_dump_target); do - get_luks_crypt_dev "$(kdump_get_maj_min "$_dev")" - done -} diff --git a/kdump-logger.sh b/kdump-logger.sh deleted file mode 100755 index 3fd433d..0000000 --- a/kdump-logger.sh +++ /dev/null @@ -1,355 +0,0 @@ -#!/bin/sh -# -# This comes from the dracut-logger.sh -# -# The logger defined 4 logging levels: -# - ddebug (4) -# The DEBUG Level designates fine-grained informational events that are most -# useful to debug an application. -# - dinfo (3) -# The INFO level designates informational messages that highlight the -# progress of the application at coarse-grained level. -# - dwarn (2) -# The WARN level designates potentially harmful situations. -# - derror (1) -# The ERROR level designates error events that might still allow the -# application to continue running. -# -# Logging is controlled by following global variables: -# - @var kdump_stdloglvl - logging level to standard error (console output) -# - @var kdump_sysloglvl - logging level to syslog (by logger command) -# - @var kdump_kmsgloglvl - logging level to /dev/kmsg (only for boot-time) -# -# If any of the variables is not set, the function dlog_init() sets it to default: -# - In the first kernel: -# - @var kdump_stdloglvl = 3 (info) -# - @var kdump_sysloglvl = 0 (no logging) -# - @var kdump_kmsgloglvl = 0 (no logging) -# -# -In the second kernel: -# - @var kdump_stdloglvl = 0 (no logging) -# - @var kdump_sysloglvl = 3 (info) -# - @var kdump_kmsgloglvl = 0 (no logging) -# -# First of all you have to start with dlog_init() function which initializes -# required variables. Don't call any other logging function before that one! -# -# The code in this file might be run in an environment without bash. -# Any code added must be POSIX compliant. - -# Define vairables for the log levels in this module. -kdump_stdloglvl="" -kdump_sysloglvl="" -kdump_kmsgloglvl="" - -# The dracut-lib.sh is only available in the second kernel, and it won't -# be used in the first kernel because the dracut-lib.sh is invisible in -# the first kernel. -if [ -f /lib/dracut-lib.sh ]; then - . /lib/dracut-lib.sh -fi - -# @brief Get the log level from kernel command line. -# @retval 1 if something has gone wrong -# @retval 0 on success. -# -get_kdump_loglvl() -{ - [ -f /lib/dracut-lib.sh ] && kdump_sysloglvl=$(getarg rd.kdumploglvl) - [ -z "$kdump_sysloglvl" ] && return 1; - - if [ -f /lib/dracut-lib.sh ] && ! isdigit "$kdump_sysloglvl"; then - return 1 - fi - - return 0 -} - -# @brief Check the log level. -# @retval 1 if something has gone wrong -# @retval 0 on success. -# -check_loglvl() -{ - case "$1" in - 0|1|2|3|4) - return 0 - ;; - *) - return 1 - ;; - esac -} - -# @brief Initializes Logger. -# @retval 1 if something has gone wrong -# @retval 0 on success. -# -dlog_init() { - ret=0 - - if [ -s /proc/vmcore ];then - if ! get_kdump_loglvl; then - logger -t "kdump[$$]" -p warn -- "Kdump is using the default log level(3)." - kdump_sysloglvl=3 - fi - kdump_stdloglvl=0 - kdump_kmsgloglvl=0 - else - kdump_stdloglvl=$KDUMP_STDLOGLVL - kdump_sysloglvl=$KDUMP_SYSLOGLVL - kdump_kmsgloglvl=$KDUMP_KMSGLOGLVL - fi - - [ -z "$kdump_stdloglvl" ] && kdump_stdloglvl=3 - [ -z "$kdump_sysloglvl" ] && kdump_sysloglvl=0 - [ -z "$kdump_kmsgloglvl" ] && kdump_kmsgloglvl=0 - - for loglvl in "$kdump_stdloglvl" "$kdump_kmsgloglvl" "$kdump_sysloglvl"; do - if ! check_loglvl "$loglvl"; then - echo "Illegal log level: $kdump_stdloglvl $kdump_kmsgloglvl $kdump_sysloglvl" - return 1 - fi - done - - # Skip initialization if it's already done. - [ -n "$kdump_maxloglvl" ] && return 0 - - if [ "$UID" -ne 0 ]; then - kdump_kmsgloglvl=0 - kdump_sysloglvl=0 - fi - - if [ "$kdump_sysloglvl" -gt 0 ]; then - if [ -d /run/systemd/journal ] \ - && systemd-cat --version 1>/dev/null 2>&1 \ - && systemctl --quiet is-active systemd-journald.socket 1>/dev/null 2>&1; then - readonly _systemdcatfile="/var/tmp/systemd-cat" - mkfifo "$_systemdcatfile" 1>/dev/null 2>&1 - readonly _dlogfd=15 - systemd-cat -t 'kdump' --level-prefix=true <"$_systemdcatfile" & - exec 15>"$_systemdcatfile" - elif ! [ -S /dev/log ] && [ -w /dev/log ] || ! command -v logger >/dev/null; then - # We cannot log to syslog, so turn this facility off. - kdump_kmsgloglvl=$kdump_sysloglvl - kdump_sysloglvl=0 - ret=1 - errmsg="No '/dev/log' or 'logger' included for syslog logging" - fi - fi - - kdump_maxloglvl=0 - for _dlog_lvl in $kdump_stdloglvl $kdump_sysloglvl $kdump_kmsgloglvl; do - [ $_dlog_lvl -gt $kdump_maxloglvl ] && kdump_maxloglvl=$_dlog_lvl - done - readonly kdump_maxloglvl - export kdump_maxloglvl - - if [ $kdump_stdloglvl -lt 4 ] && [ $kdump_kmsgloglvl -lt 4 ] && [ $kdump_sysloglvl -lt 4 ]; then - unset ddebug - ddebug() { :; }; - fi - - if [ $kdump_stdloglvl -lt 3 ] && [ $kdump_kmsgloglvl -lt 3 ] && [ $kdump_sysloglvl -lt 3 ]; then - unset dinfo - dinfo() { :; }; - fi - - if [ $kdump_stdloglvl -lt 2 ] && [ $kdump_kmsgloglvl -lt 2 ] && [ $kdump_sysloglvl -lt 2 ]; then - unset dwarn - dwarn() { :; }; - unset dwarning - dwarning() { :; }; - fi - - if [ $kdump_stdloglvl -lt 1 ] && [ $kdump_kmsgloglvl -lt 1 ] && [ $kdump_sysloglvl -lt 1 ]; then - unset derror - derror() { :; }; - fi - - [ -n "$errmsg" ] && derror "$errmsg" - - return $ret -} - -## @brief Converts numeric level to logger priority defined by POSIX.2. -# -# @param $1: Numeric logging level in range from 1 to 4. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes logger priority. -_lvl2syspri() { - case "$1" in - 1) echo error;; - 2) echo warning;; - 3) echo info;; - 4) echo debug;; - *) return 1;; - esac -} - -## @brief Converts logger numeric level to syslog log level -# -# @param $1: Numeric logging level in range from 1 to 4. -# @retval 1 if @a lvl is out of range. -# @retval 0 if @a lvl is correct. -# @result Echoes kernel console numeric log level -# -# Conversion is done as follows: -# -# -# none -> LOG_EMERG (0) -# none -> LOG_ALERT (1) -# none -> LOG_CRIT (2) -# ERROR(1) -> LOG_ERR (3) -# WARN(2) -> LOG_WARNING (4) -# none -> LOG_NOTICE (5) -# INFO(3) -> LOG_INFO (6) -# DEBUG(4) -> LOG_DEBUG (7) -# -# -# @see /usr/include/sys/syslog.h -_dlvl2syslvl() { - case "$1" in - 1) set -- 3;; - 2) set -- 4;; - 3) set -- 6;; - 4) set -- 7;; - *) return 1;; - esac - - # The number is constructed by multiplying the facility by 8 and then - # adding the level. - # About The Syslog Protocol, please refer to the RFC5424 for more details. - echo $((24 + $1)) -} - -## @brief Prints to stderr, to syslog and/or /dev/kmsg given message with -# given level (priority). -# -# @param $1: Numeric logging level. -# @param $2: Message. -# @retval 0 It's always returned, even if logging failed. -# -# @note This function is not supposed to be called manually. Please use -# dinfo(), ddebug(), or others instead which wrap this one. -# -# This is core logging function which logs given message to standard error -# and/or syslog (with POSIX shell command logger) and/or to /dev/kmsg. -# The format is following: -# -# X: some message -# -# where @c X is the first letter of logging level. See module description for -# details on that. -# -# Message to syslog is sent with tag @c kdump. Priorities are mapped as -# following: -# - @c ERROR to @c error -# - @c WARN to @c warning -# - @c INFO to @c info -# - @c DEBUG to @c debug -_do_dlog() { - [ "$1" -le $kdump_stdloglvl ] && printf -- 'kdump: %s\n' "$2" >&2 - - if [ "$1" -le $kdump_sysloglvl ]; then - if [ "$_dlogfd" ]; then - printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$1") & 7))" "$2" 1>&$_dlogfd - else - logger -t "kdump[$$]" -p "$(_lvl2syspri "$1")" -- "$2" - fi - fi - - [ "$1" -le $kdump_kmsgloglvl ] && \ - echo "<$(_dlvl2syslvl "$1")>kdump[$$] $2" >/dev/kmsg -} - -## @brief Internal helper function for _do_dlog() -# -# @param $1: Numeric logging level. -# @param $2 [...]: Message. -# @retval 0 It's always returned, even if logging failed. -# -# @note This function is not supposed to be called manually. Please use -# dinfo(), ddebug(), or others instead which wrap this one. -# -# This function calls _do_dlog() either with parameter msg, or if -# none is given, it will read standard input and will use every line as -# a message. -# -# This enables: -# dwarn "This is a warning" -# echo "This is a warning" | dwarn -dlog() { - [ -z "$kdump_maxloglvl" ] && return 0 - [ "$1" -le "$kdump_maxloglvl" ] || return 0 - - if [ $# -gt 1 ]; then - _dlog_lvl=$1; shift - _do_dlog "$_dlog_lvl" "$*" - else - while read -r line || [ -n "$line" ]; do - _do_dlog "$1" "$line" - done - fi -} - -## @brief Logs message at DEBUG level (4) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -ddebug() { - set +x - dlog 4 "$@" - if [ -n "$debug" ]; then - set -x - fi -} - -## @brief Logs message at INFO level (3) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dinfo() { - set +x - dlog 3 "$@" - if [ -n "$debug" ]; then - set -x - fi -} - -## @brief Logs message at WARN level (2) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dwarn() { - set +x - dlog 2 "$@" - if [ -n "$debug" ]; then - set -x - fi -} - -## @brief It's an alias to dwarn() function. -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -dwarning() { - set +x - dwarn "$@" - if [ -n "$debug" ]; then - set -x - fi -} - -## @brief Logs message at ERROR level (1) -# -# @param msg Message. -# @retval 0 It's always returned, even if logging failed. -derror() { - set +x - dlog 1 "$@" - if [ -n "$debug" ]; then - set -x - fi -} diff --git a/kdump-migrate-action.sh b/kdump-migrate-action.sh deleted file mode 100755 index c516639..0000000 --- a/kdump-migrate-action.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -systemctl is-active kdump -if [ $? -ne 0 ]; then - exit 0 -fi - -/usr/lib/kdump/kdump-restart.sh diff --git a/kdump-restart.sh b/kdump-restart.sh deleted file mode 100644 index a9ecfc1..0000000 --- a/kdump-restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -export PATH="$PATH:/usr/bin:/usr/sbin" - -exec >>/var/log/kdump-migration.log 2>&1 - -echo "kdump: Partition Migration detected. Rebuilding initramfs image to reload." -/usr/bin/kdumpctl rebuild -/usr/bin/kdumpctl reload diff --git a/kdump-udev-throttler b/kdump-udev-throttler deleted file mode 100755 index cd77a31..0000000 --- a/kdump-udev-throttler +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# This util helps to reduce the workload of kdump service restarting -# on udev event. When hotplugging memory / CPU, multiple udev -# events may be triggered concurrently, and obviously, we don't want -# to restart kdump service for each event. - -# This script will be called by udev, and make sure kdump service is -# restart after all events we are watching are settled. - -# On each call, this script will update try to aquire the $throttle_lock -# The first instance acquired the file lock will keep waiting for events -# to settle and then reload kdump. Other instances will just exit -# In this way, we can make sure kdump service is restarted immediately -# and for exactly once after udev events are settled. - -throttle_lock="/var/lock/kdump-udev-throttle" - -exec 9>$throttle_lock -if [ $? -ne 0 ]; then - echo "Failed to create the lock file! Fallback to non-throttled kdump service restart" - /bin/kdumpctl reload - exit 1 -fi - -flock -n 9 -if [ $? -ne 0 ]; then - echo "Throttling kdump restart for concurrent udev event" - exit 0 -fi - -# Wait for at least 1 second, at most 4 seconds for udev to settle -# Idealy we will have a less than 1 second lag between udev events settle -# and kdump reload -sleep 1 && udevadm settle --timeout 3 - -# Release the lock, /bin/kdumpctl will block and make the process -# holding two locks at the same time and we might miss some events -exec 9>&- - -/bin/kdumpctl reload - -exit 0 diff --git a/kdump.conf.5 b/kdump.conf.5 deleted file mode 100644 index 20b1620..0000000 --- a/kdump.conf.5 +++ /dev/null @@ -1,397 +0,0 @@ -.TH KDUMP.CONF 5 "07/23/2008" "kexec-tools" - -.SH NAME -kdump.conf \- configuration file for kdump kernel. - -.SH DESCRIPTION - -kdump.conf is a configuration file for the kdump kernel crash -collection service. - -kdump.conf provides post-kexec instructions to the kdump kernel. It is -stored in the initrd file managed by the kdump service. If you change -this file and do not want to reboot in order for the changes to take -effect, restart the kdump service to rebuild the initrd. - -For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf. - -.B NOTE: -For filesystem dumps the dump target must be mounted before building -kdump initramfs. - -kdump.conf only affects the behavior of the initramfs. Please read the -kdump operational flow section of kexec-kdump-howto.txt in the docs to better -understand how this configuration file affects the behavior of kdump. - -.SH OPTIONS - -.B auto_reset_crashkernel -.RS -determine whether to reset kernel crashkernel parameter to the default value -or not when kexec-tools is updated or a new kernel is installed. The default -crashkernel values are different for different architectures and also take the -following factors into consideration, -.IP -\- AMD Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV) -.IP -\- Mellanox 5th generation network driver -.IP -\- aarch64 64k kernel -.IP -\- Firmware-assisted dump (FADump) -.PP -Since the kernel crasherkernel parameter will be only reset when kexec-tools is -updated or a new kernel is installed, you need to call "kdumpctl -reset-crashkernel [--kernel=path_to_kernel]" if you want to use the default -value set after having enabled features like SME/SEV for a specific kernel. And -you should also reboot the system for the new crashkernel value to take effect. -Also see kdumpctl(8). -.PP -.RE - -.B raw -.RS -Will dd /proc/vmcore into . Use persistent device names for -partition devices, such as /dev/vg/. -.RE - -.B nfs -.RS -Will mount nfs to , and copy /proc/vmcore to //%HOST-%DATE/, -supports DNS. Note that a fqdn should be used as the server name in the -mount point. -.RE - -.B ssh -.RS -Will save /proc/vmcore through ssh pipe to :/%HOST-%DATE/, -supports DNS. NOTE: make sure user has necessary write permissions on -server and that a fqdn is used as the server name. -.RE - -.B sshkey -.RS -Specify the path of the ssh key to use when dumping via ssh. -The default value is /root/.ssh/kdump_id_rsa. -.RE - -.B -.RS -Will mount -t , and copy /proc/vmcore to -//%HOST_IP-%DATE/. NOTE: can be a device node, label -or uuid. It's recommended to use persistent device names such as -/dev/vg/. Otherwise it's suggested to use label or uuid. -.RE - -.B path -.RS -"path" represents the file system path in which vmcore will be saved. -If a dump target is specified in kdump.conf, then "path" is relative to the -specified dump target. -.PP -Interpretation of "path" changes a bit if the user didn't specify any dump -target explicitly in kdump.conf. In this case, "path" represents the -absolute path from root. The dump target and adjusted path are arrived -at automatically depending on what's mounted in the current system. -.PP -Ignored for raw device dumps. If unset, will use the default "/var/crash". -.RE - -.B core_collector -.RS -This allows you to specify the command to copy the vmcore. -The default is makedumpfile, which on some architectures can drastically reduce -core file size. See /sbin/makedumpfile --help for a list of options. -Note that the -i and -g options are not needed here, as the initrd -will automatically be populated with a config file appropriate -for the running kernel. -.PP -Note 1: About default core collector: -The default core_collector for raw/ssh dump is: -"makedumpfile -F -l --message-level 7 -d 31". -The default core_collector for other targets is: -"makedumpfile -l --message-level 7 -d 31". -Even if core_collector option is commented out in kdump.conf, makedumpfile -is the default core collector and kdump uses it internally. -If one does not want makedumpfile as default core_collector, then they -need to specify one using core_collector option to change the behavior. -.PP -Note 2: If "makedumpfile -F" is used then you will get a flattened format -vmcore.flat, you will need to use "makedumpfile -R" to rearrange the -dump data from standard input to a normal dumpfile (readable with analysis -tools). -ie. "makedumpfile -R vmcore < vmcore.flat" -.PP -Note 3: If specified core_collector simply copy the vmcore file to the -dump target (eg: cp, scp), the vmcore could be significantly large. -Please make sure the dump target has enough space, at leaset larger -than the system's RAM. - -.RE - -.B kdump_post -.RS -This directive allows you to run a specified executable -just after the vmcore dump process terminates. The exit -status of the current dump process is fed to the kdump_post -executable as its first argument($1). Executable can modify -it to indicate the new exit status of succeeding dump process, -.PP -All files under /etc/kdump/post.d are collectively sorted -and executed in lexical order, before binary or script -specified kdump_post parameter is executed. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt. - -.RE - -.B kdump_pre -.RS -Works just like the "kdump_post" directive, but instead -of running after the dump process, runs immediately -before. Exit status of this binary is interpreted -as follows: -.PP -0 - continue with dump process as usual -.PP -non 0 - run the final action (reboot/poweroff/halt) -.PP -All files under /etc/kdump/pre.d are collectively sorted and -executed in lexical order, after binary or script specified -kdump_pre parameter is executed. -Even if the binary or script in /etc/kdump/pre.d directory -returns non 0 exit status, the processing is continued. -.PP -Note that scripts written for use with this directive must use the /bin/bash -interpreter. And since these scripts run in kdump enviroment, the reference to -the storage or network device in the scripts should adhere to the section -'Supported dump target types and requirements' in kexec-kdump-howto.txt. - -.RE - -.B extra_bins -.RS -This directive allows you to specify additional -binaries or shell scripts you'd like to include in -your kdump initrd. Generally only useful in -conjunction with a kdump_post binary or script that -relies on other binaries or scripts. -.RE - -.B extra_modules -.RS -This directive allows you to specify extra kernel -modules that you want to be loaded in the kdump -initrd, typically used to set up access to -non-boot-path dump targets that might otherwise -not be accessible in the kdump environment. Multiple -modules can be listed, separated by spaces, and any -dependent modules will automatically be included. -.RE - -.B failure_action -.RS -Action to perform in case dumping to the intended target fails. The default is "reboot". -reboot: Reboot the system (this is what most people will want, as it returns the system -to a normal state). halt: Halt the system and lose the vmcore. poweroff: The system -will be powered down. shell: Drop to a shell session inside the initramfs, from which -you can manually perform additional recovery actions. Exiting this shell reboots the -system by default or performs "final_action". -Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump -target is specified, the failure action can be set as dump_to_rootfs. That means when -dumping to target fails, dump vmcore to rootfs from initramfs context and reboot -by default or perform "final_action". -.RE - -.B default -.RS -Same as the "failure_action" directive above, but this directive is obsolete -and will be removed in the future. -.RE - -.B final_action -.RS -Action to perform in case dumping to the intended target succeeds. -Also performed when "shell" or "dump_to_rootfs" failure action finishes. -Each action is same as the "failure_action" directive above. -The default is "reboot". -.RE - -.B force_rebuild <0 | 1> -.RS -By default, kdump initrd will only be rebuilt when necessary. -Specify 1 to force rebuilding kdump initrd every time when kdump service starts. -.RE - -.B force_no_rebuild <0 | 1> -.RS -By default, kdump initrd will be rebuilt when necessary. -Specify 1 to bypass rebuilding of kdump initrd. - -.PP -force_no_rebuild and force_rebuild options are mutually exclusive and -they should not be set to 1 simultaneously. -.RE - -.B dracut_args -.RS -Kdump uses dracut to generate initramfs for second kernel. This option -allows a user to pass arguments to dracut directly. -.RE - - -.B fence_kdump_args -.RS -Command line arguments for fence_kdump_send (it can contain all valid -arguments except hosts to send notification to). -.RE - - -.B fence_kdump_nodes -.RS -List of cluster node(s) except localhost, separated by spaces, to send fence_kdump notification -to (this option is mandatory to enable fence_kdump). -.RE - - -.SH DEPRECATED OPTIONS - -.B net | -.RS -net option is replaced by nfs and ssh options. Use nfs or ssh options -directly. -.RE - -.B options