From f447d5d00eaaa369da8a80f330eebaedce52f249 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 9 Feb 2022 08:04:39 +0800 Subject: [PATCH 001/208] 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 8c72b6135ea3b0e970f2db360e962615747f3746 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 14 Feb 2022 12:07:08 +0800 Subject: [PATCH 002/208] 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 d8968f43d9372357e9e3332185757fcf50f8a554 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Wed, 16 Feb 2022 14:26:38 +0800 Subject: [PATCH 003/208] 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 685e07eccdb5dcafed050a6411910c2336d36f80 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 11 Feb 2022 13:11:17 +0800 Subject: [PATCH 004/208] 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 1f98ed97bd36d08215e345b0790f5a9dfdcf7444 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 15 Feb 2022 13:24:19 +0800 Subject: [PATCH 005/208] 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 ee97b48d7b4bcfb628b0522022f2379f1d743e70 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Wed, 16 Feb 2022 09:42:54 +0800 Subject: [PATCH 006/208] 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 85888c8d233c0d115fcb145c022065028b12e3af Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 1 Mar 2022 13:09:00 +0800 Subject: [PATCH 007/208] 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 c6b2a4b26ba75e14af39ce990a6f20d38edd0b60 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 2 Apr 2022 12:00:46 +0800 Subject: [PATCH 008/208] purgatory: do not enable vectorization automatically for purgatory compiling Resolves: bz2057391 Upstream: Fedora Conflict: None commit 1b03cf7adc3c156ecab2618acb1ec585336a3f75 Author: Baoquan He Date: Tue Mar 29 18:12:28 2022 +0800 purgatory: do not enable vectorization automatically for purgatory compiling Redhat CKI reported kdump kernel will hang a while very early after crash triggered, then reset to firmware to reboot. This failure can only be observed with kdump or kexec reboot via kexec_load system call. With kexec_file_load interface, both kdump and kexec reboot work very well. And further investigation shows that gcc version 11 doesn't have this issue, while gcc version 12 does. After checking the release notes of the latest gcc, Dave found out it's because gcc 12 enables auto-vectorization for -O2 optimization level. Please see below link for more information: https://www.phoronix.com/scan.php?page=news_item&px=GCC-12-Auto-Vec-O2 Adding -fno-tree-vectorize to Makefile of purgatory can fix the issue. Signed-off-by: Baoquan He Signed-off-by: Simon Horman --- ...-enable-vectorization-automatically-.patch | 44 +++++++++++++++++++ kexec-tools.spec | 3 ++ 2 files changed, 47 insertions(+) create mode 100644 kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch diff --git a/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch b/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch new file mode 100644 index 0000000..85ae7e6 --- /dev/null +++ b/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch @@ -0,0 +1,44 @@ +From 1b03cf7adc3c156ecab2618acb1ec585336a3f75 Mon Sep 17 00:00:00 2001 +From: Baoquan He +Date: Tue, 29 Mar 2022 18:12:28 +0800 +Subject: [PATCH] purgatory: do not enable vectorization automatically for + purgatory compiling + +Redhat CKI reported kdump kernel will hang a while very early after crash +triggered, then reset to firmware to reboot. + +This failure can only be observed with kdump or kexec reboot via +kexec_load system call. With kexec_file_load interface, both kdump and +kexec reboot work very well. And further investigation shows that gcc +version 11 doesn't have this issue, while gcc version 12 does. + +After checking the release notes of the latest gcc, Dave found out it's +because gcc 12 enables auto-vectorization for -O2 optimization level. +Please see below link for more information: + + https://www.phoronix.com/scan.php?page=news_item&px=GCC-12-Auto-Vec-O2 + +Adding -fno-tree-vectorize to Makefile of purgatory can fix the issue. + +Signed-off-by: Baoquan He +Signed-off-by: Simon Horman +--- + purgatory/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/purgatory/Makefile b/purgatory/Makefile +index 2dd6c47..15adb12 100644 +--- a/purgatory/Makefile ++++ b/purgatory/Makefile +@@ -49,7 +49,7 @@ $(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ + $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ + -Os -fno-builtin -ffreestanding \ + -fno-zero-initialized-in-bss \ +- -fno-PIC -fno-PIE -fno-stack-protector ++ -fno-PIC -fno-PIE -fno-stack-protector -fno-tree-vectorize + + $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ + -I$(srcdir)/purgatory/include \ +-- +2.34.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 6b7ef14..9ccb727 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -112,6 +112,8 @@ Patch401: ./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machi # # Patches 601 onward are generic patches # +Patch601: ./kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch + %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -128,6 +130,7 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch401 -p1 +%patch601 -p1 %ifarch ppc %define archdef ARCH=ppc From 39789963fb3385d23500d9cfb6aceb1dac4e2271 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 2 Apr 2022 12:06:42 +0800 Subject: [PATCH 009/208] arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC rela Resolves: bz2052949 Upstream: Fedora Conflict: None commit 8e3f663a4dfe39b303e25ea2b945a4fab9fef7ae Author: Pingfan Liu Date: Thu Mar 31 11:38:05 2022 +0800 arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC rela GCC 12 has some changes, which affects the generated AArch64 code of kexec-tools. Accordingly, a new rel type R_AARCH64_LDST128_ABS_LO12_NC is confronted by machine_apply_elf_rel() on AArch64. This fails the load of kernel with the message "machine_apply_elf_rel: ERROR Unknown type: 299" Citing from objdump -rDSl purgatory/purgatory.ro 0000000000000f80 : sha256_starts(): f80: 90000001 adrp x1, 0 f80: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfa0 f84: a9007c1f stp xzr, xzr, [x0] f88: 3dc00021 ldr q1, [x1] f88: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfa0 f8c: 90000001 adrp x1, 0 f8c: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfb0 f90: 3dc00020 ldr q0, [x1] f90: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfb0 f94: ad008001 stp q1, q0, [x0, #16] f98: d65f03c0 ret f9c: d503201f nop fa0: 6a09e667 .inst 0x6a09e667 ; undefined fa4: bb67ae85 .inst 0xbb67ae85 ; undefined fa8: 3c6ef372 .inst 0x3c6ef372 ; undefined fac: a54ff53a ld3w {z26.s-z28.s}, p5/z, [x9, #-3, mul vl] fb0: 510e527f sub wsp, w19, #0x394 fb4: 9b05688c madd x12, x4, x5, x26 fb8: 1f83d9ab .inst 0x1f83d9ab ; undefined fbc: 5be0cd19 .inst 0x5be0cd19 ; undefined Here, gcc generates codes, which make loads and stores carried out using the 128-bits floating-point registers. And a new rel type R_AARCH64_LDST128_ABS_LO12_NC should be handled. Make machine_apply_elf_rel() coped with this new reloc, so kexec-tools can work smoothly. Signed-off-by: Pingfan Liu Signed-off-by: Simon Horman --- ...4-add-support-for-R_AARCH64_LDST128_.patch | 94 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 96 insertions(+) create mode 100644 kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch diff --git a/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch b/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch new file mode 100644 index 0000000..da5d8c9 --- /dev/null +++ b/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch @@ -0,0 +1,94 @@ +From 8e3f663a4dfe39b303e25ea2b945a4fab9fef7ae Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Thu, 31 Mar 2022 11:38:05 +0800 +Subject: [PATCH] arm64/kexec-arm64: add support for + R_AARCH64_LDST128_ABS_LO12_NC rela + +GCC 12 has some changes, which affects the generated AArch64 code of kexec-tools. +Accordingly, a new rel type R_AARCH64_LDST128_ABS_LO12_NC is confronted +by machine_apply_elf_rel() on AArch64. This fails the load of kernel +with the message "machine_apply_elf_rel: ERROR Unknown type: 299" + +Citing from objdump -rDSl purgatory/purgatory.ro + +0000000000000f80 : +sha256_starts(): + f80: 90000001 adrp x1, 0 + f80: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfa0 + f84: a9007c1f stp xzr, xzr, [x0] + f88: 3dc00021 ldr q1, [x1] + f88: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfa0 + f8c: 90000001 adrp x1, 0 + f8c: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfb0 + f90: 3dc00020 ldr q0, [x1] + f90: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfb0 + f94: ad008001 stp q1, q0, [x0, #16] + f98: d65f03c0 ret + f9c: d503201f nop + fa0: 6a09e667 .inst 0x6a09e667 ; undefined + fa4: bb67ae85 .inst 0xbb67ae85 ; undefined + fa8: 3c6ef372 .inst 0x3c6ef372 ; undefined + fac: a54ff53a ld3w {z26.s-z28.s}, p5/z, [x9, #-3, mul vl] + fb0: 510e527f sub wsp, w19, #0x394 + fb4: 9b05688c madd x12, x4, x5, x26 + fb8: 1f83d9ab .inst 0x1f83d9ab ; undefined + fbc: 5be0cd19 .inst 0x5be0cd19 ; undefined + +Here, gcc generates codes, which make loads and stores carried out using +the 128-bits floating-point registers. And a new rel type +R_AARCH64_LDST128_ABS_LO12_NC should be handled. + +Make machine_apply_elf_rel() coped with this new reloc, so kexec-tools +can work smoothly. + +Signed-off-by: Pingfan Liu +Signed-off-by: Simon Horman +Signed-off-by: Coiby Xu +--- + kexec/arch/arm64/kexec-arm64.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c +index 9dd072c..e25f600 100644 +--- a/kexec/arch/arm64/kexec-arm64.c ++++ b/kexec/arch/arm64/kexec-arm64.c +@@ -1248,6 +1248,10 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), + + #if !defined(R_AARCH64_LDST64_ABS_LO12_NC) + # define R_AARCH64_LDST64_ABS_LO12_NC 286 ++#endif ++ ++#if !defined(R_AARCH64_LDST128_ABS_LO12_NC) ++# define R_AARCH64_LDST128_ABS_LO12_NC 299 + #endif + + uint64_t *loc64; +@@ -1309,6 +1313,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), + *loc32 = cpu_to_le32(le32_to_cpu(*loc32) + + (((value - address) >> 2) & 0x3ffffff)); + break; ++ /* encode imm field with bits [11:3] of value */ + case R_AARCH64_LDST64_ABS_LO12_NC: + if (value & 7) + die("%s: ERROR Unaligned value: %lx\n", __func__, +@@ -1318,6 +1323,17 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), + *loc32 = cpu_to_le32(le32_to_cpu(*loc32) + + ((value & 0xff8) << (10 - 3))); + break; ++ ++ /* encode imm field with bits [11:4] of value */ ++ case R_AARCH64_LDST128_ABS_LO12_NC: ++ if (value & 15) ++ die("%s: ERROR Unaligned value: %lx\n", __func__, ++ value); ++ type = "LDST128_ABS_LO12_NC"; ++ loc32 = ptr; ++ imm = value & 0xff0; ++ *loc32 = cpu_to_le32(le32_to_cpu(*loc32) + (imm << (10 - 4))); ++ break; + default: + die("%s: ERROR Unknown type: %lu\n", __func__, r_type); + break; +-- +2.34.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 9ccb727..819d68d 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -108,6 +108,7 @@ Patch401: ./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machi # # Patches 501 through 600 are meant for ARM kexec-tools enablement # +Patch501: ./kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch # # Patches 601 onward are generic patches @@ -130,6 +131,7 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch401 -p1 +%patch501 -p1 %patch601 -p1 %ifarch ppc From 01a7da83f7a49579f77767bc3097b9bf31777738 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 2 Apr 2022 12:19:35 +0800 Subject: [PATCH 010/208] Release 2.0.23-6 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 819d68d..e0f5b5e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -412,6 +412,10 @@ fi %endif %changelog +* Sat Apr 2 2022 +- arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC rela +- purgatory: do not enable vectorization automatically for purgatory compiling + * 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 From 873fe47f78afce8928b88411768fc8f1ab14c312 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 23 May 2022 18:36:47 +0800 Subject: [PATCH 011/208] Revert "s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel()" This reverts commit ca5a33855ff637d53c70e71282e73f3c67d85c86. Signed-off-by: Coiby Xu --- ...oc_entries_in_machine_apply_elf_rel_.patch | 95 ------------------- kexec-tools.spec | 2 - 2 files changed, 97 deletions(-) delete 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 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.spec b/kexec-tools.spec index e0f5b5e..e5d1428 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -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 @@ -130,7 +129,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch401 -p1 %patch501 -p1 %patch601 -p1 From 799ff6c49a4b415cc5302ccf03f2cde6172d6734 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 23 May 2022 18:37:44 +0800 Subject: [PATCH 012/208] Revert "purgatory: do not enable vectorization automatically for purgatory compiling" This reverts commit c6b2a4b26ba75e14af39ce990a6f20d38edd0b60. Signed-off-by: Coiby Xu --- ...-enable-vectorization-automatically-.patch | 44 ------------------- kexec-tools.spec | 3 -- 2 files changed, 47 deletions(-) delete mode 100644 kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch diff --git a/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch b/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch deleted file mode 100644 index 85ae7e6..0000000 --- a/kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 1b03cf7adc3c156ecab2618acb1ec585336a3f75 Mon Sep 17 00:00:00 2001 -From: Baoquan He -Date: Tue, 29 Mar 2022 18:12:28 +0800 -Subject: [PATCH] purgatory: do not enable vectorization automatically for - purgatory compiling - -Redhat CKI reported kdump kernel will hang a while very early after crash -triggered, then reset to firmware to reboot. - -This failure can only be observed with kdump or kexec reboot via -kexec_load system call. With kexec_file_load interface, both kdump and -kexec reboot work very well. And further investigation shows that gcc -version 11 doesn't have this issue, while gcc version 12 does. - -After checking the release notes of the latest gcc, Dave found out it's -because gcc 12 enables auto-vectorization for -O2 optimization level. -Please see below link for more information: - - https://www.phoronix.com/scan.php?page=news_item&px=GCC-12-Auto-Vec-O2 - -Adding -fno-tree-vectorize to Makefile of purgatory can fix the issue. - -Signed-off-by: Baoquan He -Signed-off-by: Simon Horman ---- - purgatory/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 2dd6c47..15adb12 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -49,7 +49,7 @@ $(PURGATORY): CFLAGS=$(PURGATORY_EXTRA_CFLAGS) \ - $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ - -Os -fno-builtin -ffreestanding \ - -fno-zero-initialized-in-bss \ -- -fno-PIC -fno-PIE -fno-stack-protector -+ -fno-PIC -fno-PIE -fno-stack-protector -fno-tree-vectorize - - $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ - -I$(srcdir)/purgatory/include \ --- -2.34.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index e5d1428..3c8d5e7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -112,8 +112,6 @@ Patch501: ./kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST1 # # Patches 601 onward are generic patches # -Patch601: ./kexec-tools-2.0.23-purgatory-do-not-enable-vectorization-automatically-.patch - %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -130,7 +128,6 @@ tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} %patch501 -p1 -%patch601 -p1 %ifarch ppc %define archdef ARCH=ppc From 1c7c89a76b1bd7e69333a393ae728fa14651e3a5 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 23 May 2022 18:38:40 +0800 Subject: [PATCH 013/208] Revert "arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC rela" This reverts commit 39789963fb3385d23500d9cfb6aceb1dac4e2271. Signed-off-by: Coiby Xu --- ...4-add-support-for-R_AARCH64_LDST128_.patch | 94 ------------------- kexec-tools.spec | 3 - 2 files changed, 97 deletions(-) delete mode 100644 kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch diff --git a/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch b/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch deleted file mode 100644 index da5d8c9..0000000 --- a/kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 8e3f663a4dfe39b303e25ea2b945a4fab9fef7ae Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Thu, 31 Mar 2022 11:38:05 +0800 -Subject: [PATCH] arm64/kexec-arm64: add support for - R_AARCH64_LDST128_ABS_LO12_NC rela - -GCC 12 has some changes, which affects the generated AArch64 code of kexec-tools. -Accordingly, a new rel type R_AARCH64_LDST128_ABS_LO12_NC is confronted -by machine_apply_elf_rel() on AArch64. This fails the load of kernel -with the message "machine_apply_elf_rel: ERROR Unknown type: 299" - -Citing from objdump -rDSl purgatory/purgatory.ro - -0000000000000f80 : -sha256_starts(): - f80: 90000001 adrp x1, 0 - f80: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfa0 - f84: a9007c1f stp xzr, xzr, [x0] - f88: 3dc00021 ldr q1, [x1] - f88: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfa0 - f8c: 90000001 adrp x1, 0 - f8c: R_AARCH64_ADR_PREL_PG_HI21 .text+0xfb0 - f90: 3dc00020 ldr q0, [x1] - f90: R_AARCH64_LDST128_ABS_LO12_NC .text+0xfb0 - f94: ad008001 stp q1, q0, [x0, #16] - f98: d65f03c0 ret - f9c: d503201f nop - fa0: 6a09e667 .inst 0x6a09e667 ; undefined - fa4: bb67ae85 .inst 0xbb67ae85 ; undefined - fa8: 3c6ef372 .inst 0x3c6ef372 ; undefined - fac: a54ff53a ld3w {z26.s-z28.s}, p5/z, [x9, #-3, mul vl] - fb0: 510e527f sub wsp, w19, #0x394 - fb4: 9b05688c madd x12, x4, x5, x26 - fb8: 1f83d9ab .inst 0x1f83d9ab ; undefined - fbc: 5be0cd19 .inst 0x5be0cd19 ; undefined - -Here, gcc generates codes, which make loads and stores carried out using -the 128-bits floating-point registers. And a new rel type -R_AARCH64_LDST128_ABS_LO12_NC should be handled. - -Make machine_apply_elf_rel() coped with this new reloc, so kexec-tools -can work smoothly. - -Signed-off-by: Pingfan Liu -Signed-off-by: Simon Horman -Signed-off-by: Coiby Xu ---- - kexec/arch/arm64/kexec-arm64.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 9dd072c..e25f600 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -1248,6 +1248,10 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), - - #if !defined(R_AARCH64_LDST64_ABS_LO12_NC) - # define R_AARCH64_LDST64_ABS_LO12_NC 286 -+#endif -+ -+#if !defined(R_AARCH64_LDST128_ABS_LO12_NC) -+# define R_AARCH64_LDST128_ABS_LO12_NC 299 - #endif - - uint64_t *loc64; -@@ -1309,6 +1313,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), - *loc32 = cpu_to_le32(le32_to_cpu(*loc32) - + (((value - address) >> 2) & 0x3ffffff)); - break; -+ /* encode imm field with bits [11:3] of value */ - case R_AARCH64_LDST64_ABS_LO12_NC: - if (value & 7) - die("%s: ERROR Unaligned value: %lx\n", __func__, -@@ -1318,6 +1323,17 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym), - *loc32 = cpu_to_le32(le32_to_cpu(*loc32) - + ((value & 0xff8) << (10 - 3))); - break; -+ -+ /* encode imm field with bits [11:4] of value */ -+ case R_AARCH64_LDST128_ABS_LO12_NC: -+ if (value & 15) -+ die("%s: ERROR Unaligned value: %lx\n", __func__, -+ value); -+ type = "LDST128_ABS_LO12_NC"; -+ loc32 = ptr; -+ imm = value & 0xff0; -+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32) + (imm << (10 - 4))); -+ break; - default: - die("%s: ERROR Unknown type: %lu\n", __func__, r_type); - break; --- -2.34.1 - diff --git a/kexec-tools.spec b/kexec-tools.spec index 3c8d5e7..0b61b21 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -107,7 +107,6 @@ Requires: systemd-udev%{?_isa} # # Patches 501 through 600 are meant for ARM kexec-tools enablement # -Patch501: ./kexec-tools-2.0.23-arm64-kexec-arm64-add-support-for-R_AARCH64_LDST128_.patch # # Patches 601 onward are generic patches @@ -127,8 +126,6 @@ mkdir -p -m755 kcp tar -z -x -v -f %{SOURCE9} tar -z -x -v -f %{SOURCE19} -%patch501 -p1 - %ifarch ppc %define archdef ARCH=ppc %endif From 4b6445a794521755899b2663be015ebaff811bf7 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 23 May 2022 18:39:49 +0800 Subject: [PATCH 014/208] Revert "Release 2.0.23-6" This reverts commit 01a7da83f7a49579f77767bc3097b9bf31777738. Signed-off-by: Coiby Xu --- kexec-tools.spec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 0b61b21..b4b80e6 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -5,7 +5,7 @@ Name: kexec-tools Version: 2.0.23 -Release: 6%{?dist} +Release: 5%{?dist} License: GPLv2 Summary: The kexec/kdump userspace component @@ -404,10 +404,6 @@ fi %endif %changelog -* Sat Apr 2 2022 -- arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC rela -- purgatory: do not enable vectorization automatically for purgatory compiling - * 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 From 677da8a59bdf00c661bc6e05c96f2b59a99cfb63 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 1 Aug 2022 23:25:48 +0800 Subject: [PATCH 015/208] 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 016/208] 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 017/208] 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 018/208] 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 019/208] 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 020/208] 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 021/208] 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 022/208] 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 023/208] 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 024/208] 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 025/208] 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 026/208] 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 027/208] 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 028/208] 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 029/208] 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 030/208] 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 031/208] 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 032/208] 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 033/208] 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 034/208] 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 035/208] 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 036/208] 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 037/208] 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 038/208] 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 039/208] 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 040/208] 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 041/208] 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 042/208] 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 043/208] 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 044/208] 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 045/208] 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 046/208] 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 047/208] 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 048/208] 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 049/208] 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 050/208] 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 051/208] 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 052/208] 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 053/208] 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 054/208] 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 055/208] 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 056/208] 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 057/208] 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 058/208] 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 059/208] 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 060/208] 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 061/208] 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 062/208] 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 063/208] 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 064/208] 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 065/208] 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 066/208] 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 067/208] 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 068/208] 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 069/208] 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 070/208] 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 071/208] 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 072/208] 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 073/208] 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 074/208] 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 075/208] 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 076/208] 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 077/208] 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 078/208] 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 079/208] 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 080/208] 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 081/208] 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 082/208] 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 083/208] 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 084/208] 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 085/208] 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 086/208] 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 087/208] 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 088/208] 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 089/208] 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 090/208] 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 091/208] 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 092/208] 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 093/208] 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 094/208] 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 095/208] 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 096/208] 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 097/208] 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 098/208] 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 099/208] 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 100/208] 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 101/208] 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 102/208] 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 103/208] 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 104/208] 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 105/208] 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 106/208] 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 107/208] 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 108/208] 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 109/208] 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 110/208] 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 111/208] 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 112/208] 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 113/208] 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 114/208] 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 115/208] 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 116/208] 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 117/208] 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 118/208] 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 119/208] 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 120/208] 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 121/208] 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 122/208] 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 123/208] 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 124/208] 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 125/208] [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 126/208] 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 127/208] 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 128/208] 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 129/208] 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 130/208] 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 131/208] 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 132/208] 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 133/208] 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 134/208] 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 135/208] 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 136/208] 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 137/208] 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 138/208] 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 139/208] 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 140/208] 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 141/208] 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 142/208] 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 143/208] 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 144/208] [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 145/208] 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 146/208] 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 147/208] 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 148/208] 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 149/208] 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 150/208] 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 151/208] 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 152/208] 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 153/208] 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 154/208] 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 155/208] 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 156/208] 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 157/208] 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 158/208] 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 159/208] 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 160/208] 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 161/208] 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 162/208] 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 163/208] 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 164/208] 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 165/208] 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 166/208] 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 167/208] 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 168/208] 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 169/208] 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 170/208] 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 171/208] 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 172/208] 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 173/208] 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 174/208] 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 175/208] 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 176/208] 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 177/208] 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 178/208] 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 179/208] 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 180/208] 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 181/208] 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 182/208] 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 183/208] 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 184/208] 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 185/208] 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