The package rpms/kexec-tools.git has added or updated architecture specific content in
its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/kexec-tools.git/commit/?id=311b5b....
Change:
+%ifarch ppc64 ppc64le
Thanks.
Full change:
============
commit f1f9612420c1ad507b1b6b81c6e20b87684b12c8
Merge: 4b6445a 6f9653b
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon May 23 18:40:59 2022 +0800
Merge branch 'rawhide' into f36
commit 4b6445a794521755899b2663be015ebaff811bf7
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon May 23 18:39:49 2022 +0800
Revert "Release 2.0.23-6"
This reverts commit 01a7da83f7a49579f77767bc3097b9bf31777738.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
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 <coxu(a)redhat.com> - 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
commit 1c7c89a76b1bd7e69333a393ae728fa14651e3a5
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon May 23 18:38:40 2022 +0800
Revert "arm64/kexec-arm64: add support for R_AARCH64_LDST128_ABS_LO12_NC
rela"
This reverts commit 39789963fb3385d23500d9cfb6aceb1dac4e2271.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
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 <piliu(a)redhat.com>
-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>:
-sha256_starts():
- f80: 90000001 adrp x1, 0 <verify_sha256_digest>
- 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 <verify_sha256_digest>
- 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 <piliu(a)redhat.com>
-Signed-off-by: Simon Horman <horms(a)verge.net.au>
-Signed-off-by: Coiby Xu <coiby.xu(a)gmail.com>
----
- 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
commit 799ff6c49a4b415cc5302ccf03f2cde6172d6734
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon May 23 18:37:44 2022 +0800
Revert "purgatory: do not enable vectorization automatically for purgatory
compiling"
This reverts commit c6b2a4b26ba75e14af39ce990a6f20d38edd0b60.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
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 <bhe(a)redhat.com>
-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 <bhe(a)redhat.com>
-Signed-off-by: Simon Horman <horms(a)verge.net.au>
----
- 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
commit 873fe47f78afce8928b88411768fc8f1ab14c312
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon May 23 18:36:47 2022 +0800
Revert "s390: handle R_390_PLT32DBL reloc entries in
machine_apply_elf_rel()"
This reverts commit ca5a33855ff637d53c70e71282e73f3c67d85c86.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
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 <egorenar(a)linux.ibm.com>
-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.ht...
-
- 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...
-
- Signed-off-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
- Reported-by: Tao Liu <ltao(a)redhat.com>
- Suggested-by: Philipp Rudo <prudo(a)redhat.com>
- Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
- [hca(a)linux.ibm.com: changed commit message as requested by Philipp Rudo]
- Signed-off-by: Heiko Carstens <hca(a)linux.ibm.com>
- Signed-off-by: Simon Horman <horms(a)verge.net.au>
-
-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
commit 6f9653b9183b710008b8271e6cc51ea47c2585bd
Author: Coiby Xu <coxu(a)redhat.com>
Date: Sun Apr 24 09:48:05 2022 +0800
Release 2.0.24-3
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 9b8218d..9c6ea8d 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -5,7 +5,7 @@
Name: kexec-tools
Version: 2.0.24
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
@@ -405,6 +405,13 @@ fi
%endif
%changelog
+* Mon May 23 2022 Coiby <coxu(a)redhat.com> - 2.0.24-3
+- Update makedumpfile to 1.7.1
+- unit tests: add tests for get_system_size and get_recommend_size
+- improve get_recommend_size
+- fix a calculation error in get_system_size
+- logger: save log after all kdump progress finished
+
* Sun Apr 24 2022 Coiby <coxu(a)redhat.com> - 2.0.24-2
- remove the upper bound of default crashkernel value example
- update fadump-howto
commit 8f7ffb1a0054e48f833590d908a7d051008986f7
Author: Coiby Xu <coxu(a)redhat.com>
Date: Sun Apr 24 09:47:26 2022 +0800
Update makedumpfile to 1.7.1
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 6673000..9b8218d 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -1,6 +1,6 @@
%global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554
%global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7})
-%global mkdf_ver 1.7.0
+%global mkdf_ver 1.7.1
%global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7})
Name: kexec-tools
@@ -220,8 +220,8 @@ install -m 755 -D %{SOURCE33}
$RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/92-
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile
$RPM_BUILD_ROOT/usr/sbin/makedumpfile
-install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8.gz
$RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz
-install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5.gz
$RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz
+install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.8
$RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8
+install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf.5
$RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5
install -m 644 makedumpfile-%{mkdf_ver}/makedumpfile.conf
$RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample
install -m 755 makedumpfile-%{mkdf_ver}/eppic_makedumpfile.so
$RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so
mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
diff --git a/sources b/sources
index 95c0fc6..d0190bb 100644
--- a/sources
+++ b/sources
@@ -1,3 +1,3 @@
SHA512 (eppic-e8844d3.tar.gz) =
d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763
SHA512 (kexec-tools-2.0.24.tar.xz) =
ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822
-SHA512 (makedumpfile-1.7.0.tar.gz) =
579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7
+SHA512 (makedumpfile-1.7.1.tar.gz) =
93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632
commit 218d9917c03f25bc9872f076491c587815d16efb
Author: Dusty Mabe <dusty(a)dustymabe.com>
Date: Mon May 16 14:04:12 2022 -0400
kdump.sysconfig*: add ignition.firstboot to KDUMP_COMMANDLINE_REMOVE
For CoreOS based systems we use Ignition for provisioning machines
in the initramfs on first boot. We trigger Ignition right now by
the presence of `ignition.firstboot` in the kernel command line. The
kernel argument is only present on first boot so after a reboot it
no longer is in the kernel command line.
If a kernel crash happens before the first reboot of a machine we
want the `ignition.firstboot` kernel argument to be removed and not
passed on to the crash kernel.
diff --git a/kdump.sysconfig b/kdump.sysconfig
index 70ebf04..c1143f3 100644
--- a/kdump.sysconfig
+++ b/kdump.sysconfig
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64
index 67a2af7..df75f94 100644
--- a/kdump.sysconfig.aarch64
+++ b/kdump.sysconfig.aarch64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386
index 7e18c1c..d8bf5f6 100644
--- a/kdump.sysconfig.i386
+++ b/kdump.sysconfig.i386
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64
index ebb22f6..1b0cdc7 100644
--- a/kdump.sysconfig.ppc64
+++ b/kdump.sysconfig.ppc64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le
index 270a2cf..d951def 100644
--- a/kdump.sysconfig.ppc64le
+++ b/kdump.sysconfig.ppc64le
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x
index 234cfe9..2971ae7 100644
--- a/kdump.sysconfig.s390x
+++ b/kdump.sysconfig.s390x
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
vmcp_cma cma hugetlb_cma prot_virt"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
vmcp_cma cma hugetlb_cma prot_virt ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64
index 188ba3c..6a3ba6e 100644
--- a/kdump.sysconfig.x86_64
+++ b/kdump.sysconfig.x86_64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb
cma hugetlb_cma ignition.firstboot"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
commit 1101190e1cc11c25c50f26af61120154eeed1133
Author: Coiby Xu <coxu(a)redhat.com>
Date: Wed Apr 27 19:17:32 2022 +0800
unit tests: add tests for get_system_size and get_recommend_size
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh
new file mode 100644
index 0000000..8c91480
--- /dev/null
+++ b/spec/kdump-lib_spec.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+Describe 'kdump-lib'
+ Include ./kdump-lib.sh
+
+ Describe 'get_system_size()'
+
+ PROC_IOMEM=$(mktemp -t spec_test_proc_iomem_file.XXXXXXXXXX)
+
+ cleanup() {
+ rm -rf "$PROC_IOMEM"
+ }
+
+ AfterAll 'cleanup'
+
+ ONE_GIGABYTE='000000-3fffffff : System RAM'
+ Parameters
+ 1
+ 3
+ End
+
+ It 'should return correct system RAM size'
+ echo -n >"$PROC_IOMEM"
+ for _ in $(seq 1 "$1"); do echo "$ONE_GIGABYTE"
>>"$PROC_IOMEM"; done
+ When call get_system_size
+ The output should equal "$1"
+ End
+
+ End
+
+ Describe 'get_recommend_size()'
+ # Testing stragety:
+ # 1. inclusive for the lower bound of the range of crashkernel
+ # 2. exclusive for the upper bound of the range of crashkernel
+ # 3. supports ranges not sorted in increasing order
+
+ ck="4G-64G:256M,2G-4G:192M,64G-1T:512M,1T-:12345M"
+ Parameters
+ 1 0M
+ 2 192M
+ 64 512M
+ 1024 12345M
+ "$((64 * 1024))" 12345M
+ End
+
+ It 'should handle all cases correctly'
+ When call get_recommend_size "$1" $ck
+ The output should equal "$2"
+ End
+ End
+
+End
commit 4f702c81e9d14a90d22d6b587de37733d0126960
Author: Coiby Xu <coxu(a)redhat.com>
Date: Thu May 12 10:48:31 2022 +0800
improve get_recommend_size
This patch rewrites get_recommend_size to get rid of the following
limitations,
1. only supports ranges in crashkernel sorted in increasing order
2. the first entry of crashkernel should have only a single digit and
it's in gigabytes
Suggested-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
diff --git a/kdump-lib.sh b/kdump-lib.sh
index ed28df3..b137c89 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -796,33 +796,40 @@ get_system_size()
echo $(( (sum) / 1024 / 1024 / 1024))
}
+# Return the recommended size for the reserved crashkernel memory
+# depending on the system memory size.
+#
+# This functions is expected to be consistent with the parse_crashkernel_mem()
+# in kernel i.e. how kernel allocates the kdump memory given the crashkernel
+# parameter crashkernel=range1:size1[,range2:size2,…] and the system memory
+# size.
get_recommend_size()
{
local mem_size=$1
local _ck_cmdline=$2
- local OLDIFS="$IFS"
+ local range start start_unit end end_unit size
- start=${_ck_cmdline::1}
- if [[ $mem_size -lt $start ]]; then
- echo "0M"
- return
- fi
- IFS=','
- for i in $_ck_cmdline; do
- end=$(echo "$i" | awk -F "-" '{ print $2 }' | awk -F
":" '{ print $1 }')
- recommend=$(echo "$i" | awk -F "-" '{ print $2 }' | awk -F
":" '{ print $2 }')
- size=${end::-1}
- unit=${end: -1}
- if [[ $unit == 'T' ]]; then
- size=$((size * 1024))
- fi
- if [[ $mem_size -lt $size ]]; then
- echo "$recommend"
- IFS="$OLDIFS"
+ while read -r -d , range; do
+ # need to use non-default IFS as double spaces are used as a
+ # single delimiter while commas aren't...
+ IFS=, read start start_unit end end_unit size <<< \
+ "$(echo "$range" | sed -n
"s/\([0-9]\+\)\([GT]\?\)-\([0-9]*\)\([GT]\?\):\([0-9]\+[MG]\)/\1,\2,\3,\4,\5/p")"
+
+ # aka. 102400T
+ end=${end:-104857600}
+ [[ "$end_unit" == T ]] && end=$((end * 1024))
+ [[ "$start_unit" == T ]] && start=$((start * 1024))
+
+ if [[ $mem_size -ge $start ]] && [[ $mem_size -lt $end ]]; then
+ echo "$size"
return
fi
- done
- IFS="$OLDIFS"
+
+ # append a ',' as read expects the 'file' to end with a delimiter
+ done <<< "$_ck_cmdline,"
+
+ # no matching range found
+ echo "0M"
}
# get default crashkernel
commit 5c23b6ebb79c5e06ff713d437cb54fb2843aa12d
Author: Coiby Xu <coxu(a)redhat.com>
Date: Sat May 7 16:30:39 2022 +0800
fix a calculation error in get_system_size
Recently, it's found 'kdumpctl estimate' returns 512M while the system
reserves 1024M kdump memory in a case. This happens because the ranges
in /proc/iomem are inclusively. For example, "0-1: System RAM" means 2
bytes of system memory other than 1 byte. Fix this error by adding one
more byte.
Note
1. the function has been simplified as well.
2. define PROC_IOMEM as /proc/iomem for the sake of unit tests
Reported-by: Ruowen Qin <ruqin(a)redhat.com>
Fixes: 1813189 ("kdump-lib.sh: introduce functions to return recommened mem
size")
Suggested-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 557eff6..ed28df3 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -788,17 +788,12 @@ prepare_cmdline()
echo "$cmdline"
}
-#get system memory size in the unit of GB
+PROC_IOMEM=/proc/iomem
+#get system memory size i.e. memblock.memory.total_size in the unit of GB
get_system_size()
{
- result=$(grep "System RAM" /proc/iomem | awk -F ":" '{ print $1
}' | tr "[:lower:]" "[:upper:]" | paste -sd+)
- result="+$result"
- # replace '-' with '+0x' and '+' with '-0x'
- sum=$(echo "$result" | sed -e 's/-/K0x/g' -e 's/+/-0x/g' -e
's/K/+/g')
- size=$(printf "%d\n" $((sum)))
- size=$((size / 1024 / 1024 / 1024))
-
- echo "$size"
+ sum=$(sed -n "s/\s*\([0-9a-fA-F]\+\)-\([0-9a-fA-F]\+\) : System RAM$/+ 0x\2 - 0x\1
+ 1/p" $PROC_IOMEM)
+ echo $(( (sum) / 1024 / 1024 / 1024))
}
get_recommend_size()
commit 3d70f8b04958c6f7a4a6b937fb828f9970d0c525
Author: Kairui Song <kasong(a)tencent.com>
Date: Sat Apr 23 21:07:31 2022 +0800
logger: save log after all kdump progress finished
Make log saving the last step of kdump.sh, so it can catch more info,
for example, the output of post.d hooks will be covered by the log now.
Signed-off-by: Kairui Song <kasong(a)tencent.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b17455a..f4456a1 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -15,6 +15,8 @@ fi
KDUMP_PATH="/var/crash"
KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log"
+KDUMP_LOG_DEST=""
+KDUMP_LOG_OP=""
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
@@ -113,12 +115,19 @@ get_kdump_confs()
# store the kexec kernel log to a file.
save_log()
{
+ # LOG_OP is empty when log can't be saved, eg. raw target
+ [ -n "$KDUMP_LOG_OP" ] || return
+
dmesg -T > $KDUMP_LOG_FILE
if command -v journalctl > /dev/null; then
journalctl -ab >> $KDUMP_LOG_FILE
fi
chmod 600 $KDUMP_LOG_FILE
+
+ dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/"
+
+ eval "$KDUMP_LOG_OP"
}
# $1: dump path, must be a mount point
@@ -159,6 +168,9 @@ dump_fs()
save_opalcore_fs "$_dump_fs_path"
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$_dump_fs_path/
+ KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'"
+
$CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete"
_dump_exitcode=$?
if [ $_dump_exitcode -eq 0 ]; then
@@ -167,12 +179,6 @@ dump_fs()
dinfo "saving vmcore complete"
else
derror "saving vmcore failed, exitcode:$_dump_exitcode"
- fi
-
- dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/"
- save_log
- mv "$KDUMP_LOG_FILE" "$_dump_fs_path/"
- if [ $_dump_exitcode -ne 0 ]; then
return 1
fi
@@ -395,8 +401,12 @@ dump_ssh()
ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1
save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir"
"$_ssh_opt" "$2"
+
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$2:$_ssh_dir/
+ KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE'
'$_scp_address:$_ssh_dir/'"
+
save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2"
"$_scp_address"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
@@ -421,12 +431,6 @@ dump_ssh()
derror "saving vmcore failed, exitcode:$_ret"
fi
- dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/"
- save_log
- if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then
- derror "saving log file failed, _exitcode:$_ret"
- fi
-
return $_ret
}
@@ -576,6 +580,8 @@ if ! do_kdump_post $DUMP_RETVAL; then
derror "kdump_post script exited with non-zero status!"
fi
+save_log
+
if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi
commit 1facd0c11876bcbe83a9c52c67c1ce7a59f681dd
Author: Coiby Xu <coxu(a)redhat.com>
Date: Sun Apr 24 11:38:04 2022 +0800
fix incorrect date format in changelog
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 8b1acf5..6673000 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -405,7 +405,7 @@ fi
%endif
%changelog
-* Apr 24 2022 Coiby <coxu(a)redhat.com> - 2.0.24-2
+* Sun Apr 24 2022 Coiby <coxu(a)redhat.com> - 2.0.24-2
- remove the upper bound of default crashkernel value example
- update fadump-howto
- update kexec-kdump-howto
commit d5b01d7ef0f05c5ecb028aa1e8942ec099cbd9dd
Author: Coiby Xu <coxu(a)redhat.com>
Date: Sun Apr 24 09:39:22 2022 +0800
Release 2.0.24-2
A issue of bogus date in %changelog is fixed as well.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kexec-tools.spec b/kexec-tools.spec
index db6374c..8b1acf5 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -5,7 +5,7 @@
Name: kexec-tools
Version: 2.0.24
-Release: 1%{?dist}
+Release: 2%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
@@ -405,6 +405,21 @@ fi
%endif
%changelog
+* Apr 24 2022 Coiby <coxu(a)redhat.com> - 2.0.24-2
+- remove the upper bound of default crashkernel value example
+- update fadump-howto
+- update kexec-kdump-howto
+- update crashkernel-howto
+- add man documentation for kdumpctl get-default-crashkernel
+- unit tests: add check_config with with the default kdump.conf
+- unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh
+- unit tests: add tests for "kdumpctl reset-crashkernel"
+- unit tests: add tests for _{update,read}_kernel_arg_in_grub_etc_default in kdumpctl
+- unit tests: add tests for kdumpctl read_proc_environ_var and _is_osbuild
+- unit tests: add tests for get_dump_mode_by_fadump_val
+- unit tests: add tests for get_grub_kernel_boot_parameter
+- unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested
+
* Mon Apr 11 2022 Coiby <coxu(a)redhat.com> - 2.0.24-1
- Update kexec-tools to 2.0.24
- kdumpctl: remove kdump_get_conf_val in save_raw
@@ -472,7 +487,7 @@ fi
- sysconfig: make kexec_file_load as default option on aarch64
- Enable zstd compression for makedumpfile in kexec-tools.spec
-* Mon Nov 18 2021 Coiby <coxu(a)redhat.com> - 2.0.23-1
+* Thu Nov 18 2021 Coiby <coxu(a)redhat.com> - 2.0.23-1
- Update kexec-tools to 2.0.23
- Rebase makedumpfile to 1.7.0
- fix broken extra_bins when installing multiple binaries
commit be20580b06dc3fe92556933046ec8d2fd3a9b4b5
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Mar 1 17:33:24 2022 +0800
remove the upper bound of default crashkernel value example
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt
index 94f4e52..6573847 100644
--- a/crashkernel-howto.txt
+++ b/crashkernel-howto.txt
@@ -17,7 +17,7 @@ Latest kexec-tools provides "kdumpctl get-default-crashkernel"
to retrieve
the default crashkernel value,
$ echo $(kdumpctl get-default-crashkernel)
- 1G-4G:192M,4G-64G:256M,64G-102400T:512M
+ 1G-4G:192M,4G-64G:256M,64G-:512M
It will be taken as the default value of 'crashkernel=', you can use
this value as a reference for setting crashkernel value manually.
commit 695e5b8676ecbdf999ed535eae4074db8c3ef7aa
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Mar 1 17:30:30 2022 +0800
update fadump-howto
1. yum is deprecated so use dnf instead
2. use the "kdumpctl reset-crashkernel --fadump=on" API
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/fadump-howto.txt b/fadump-howto.txt
index bc87644..9773f78 100644
--- a/fadump-howto.txt
+++ b/fadump-howto.txt
@@ -39,7 +39,7 @@ kernel are one and the same on ppc64.
If you're reading this document, you should already have kexec-tools
installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
Fadump Operational Flow:
@@ -82,7 +82,7 @@ How to configure fadump:
Again, we assume if you're reading this document, you should already have
kexec-tools installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
Make the kernel to be configured with FADump as the default boot entry, if
it isn't already:
@@ -94,20 +94,24 @@ anything interesting in the way of debug analysis, you'll also
need to install
the kernel-debuginfo package, of the same arch as your running kernel, and the
crash utility:
- # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
+ # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
-Next up, we need to modify some boot parameters to enable firmware assisted
-dump. With the help of grubby, it's very easy to append "fadump=on" to the
end
-of your kernel boot parameters. To reserve the appropriate amount of memory
-for boot memory preservation, pass 'crashkernel=X' kernel cmdline parameter.
-For the recommended value of X, see 'FADump Memory Requirements' section.
+Next up, we can enable firmware assisted dump and reserve the memory for boot
+memory preservation as specified in in the table of 'FADump Memory Requirements'
+section:
+
+ # kdumpctl reset-crashkernel --fadump=on
+
+Alternatively, you can use grubby to reserve custom amount of memory:
# grubby --args="fadump=on crashkernel=6G"
--update-kernel=/boot/vmlinuz-`uname -r`
By default, FADump reserved memory will be initialized as CMA area to make the
memory available through CMA allocator on the production kernel. We can opt out
of this, making reserved memory unavailable to production kernel, by booting the
-linux kernel with 'fadump=nocma' instead of 'fadump=on'.
+linux kernel with 'fadump=nocma' instead of 'fadump=on':
+
+ # kdumpctl reset-crashkernel --fadump=nocma
The term 'boot memory' means size of the low memory chunk that is required for
a kernel to boot successfully when booted with restricted memory. By default,
@@ -350,6 +354,6 @@ Remove "crashkernel=" from kernel cmdline parameters:
If KDump is to be used as the dump capturing mechanism, reset the crashkernel parameter:
- # kdumpctl reset-crashkernel `uname -r`
+ # kdumpctl reset-crashkernel --fadump=off
Reboot the system for the settings to take effect.
commit 1e7df3e1f355da4fe0eca6422479963f7e772bf8
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Mar 1 17:30:50 2022 +0800
update kexec-kdump-howto
1. yum is deprecated so use dnf instead
2. use the "kdumpctl reset-crashkernel" API
3. ask the users to refer to crashkernel-howto.txt for setting custom
crashkernel value
4. fix a typo
Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index 1aeffc7..6741faf 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -44,7 +44,7 @@ ia64 and ppc64.
If you're reading this document, you should already have kexec-tools
installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
Now load a kernel with kexec:
@@ -66,23 +66,31 @@ How to configure kdump
Again, we assume if you're reading this document, you should already have
kexec-tools installed. If not, you install it via the following command:
- # yum install kexec-tools
+ # dnf install kexec-tools
To be able to do much of anything interesting in the way of debug analysis,
you'll also need to install the kernel-debuginfo package, of the same arch
as your running kernel, and the crash utility:
- # yum --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
+ # dnf --enablerepo=\*debuginfo install kernel-debuginfo.$(uname -m) crash
-Next up, we need to modify some boot parameters to reserve a chunk of memory for
-the capture kernel. With the help of grubby, it's very easy to append
-"crashkernel=128M" to the end of your kernel boot parameters. Note that the X
-values are such that X = the amount of memory to reserve for the capture kernel.
-And based on arch and system configuration, one might require more than 128M to
-be reserved for kdump. One need to experiment and test kdump, if 128M is not
-sufficient, try reserving more memory.
+Next up, we need to reserve a chunk of memory for the capture kernel. To use
+the default crashkernel value, you can kdumpctl:
- # grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r`
+ # kdumpctl reset-crashkernel --kernel=/boot/vmlinuz-`uname -r`
+
+If the default value does not work for your setup you can use
+
+ # grubby --args="crashkernel=256M" --update-kernel=/boot/vmlinuz-`uname -r`
+
+to specify a larger value, in this case 256M. You need to experiment to
+find the best value that works for your setup. To begin with
+
+ # kdumpctl estimate
+
+gives you an estimation for the crashkernel value based on the currently
+running kernel. For more details, please refer to the "Estimate crashkernel"
+section in /usr/share/doc/kexec-tools/crashkernel-howto.txt.
Note that there is an alternative form in which to specify a crashkernel
memory reservation, in the event that more control is needed over the size and
@@ -135,7 +143,7 @@ in /var/crash/<YYYY-MM-DD-HH:MM>/vmcore), then the system
rebooted back into
your normal kernel.
Once back to your normal kernel, you can use the previously installed crash
-kernel in conjunction with the previously installed kernel-debuginfo to
+utility in conjunction with the previously installed kernel-debuginfo to
perform postmortem analysis:
# crash /usr/lib/debug/lib/modules/2.6.17-1.2621.el5/vmlinux
commit 683ff878213ea2a58971902f90f9dd77d4e64b8f
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon Apr 18 15:54:53 2022 +0800
update crashkernel-howto
1. clean up left crashkernel.default
2. fix a few typos and grammar mistakes
3. ask the users to refer to `man kdumpctl` for reset-crashkernel
Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/crashkernel-howto.txt b/crashkernel-howto.txt
index 1ba79ab..94f4e52 100644
--- a/crashkernel-howto.txt
+++ b/crashkernel-howto.txt
@@ -37,10 +37,10 @@ Users can override the value during Anaconda installation manually.
Auto update of crashkernel boot parameter
=========================================
-A new release of kexec-tools could update the default crashkernel value.
-By default, kexec-tools would reset crashkernel to the new default value if it
-detects old default crashkernel value is used by installed kernels. If you don't
-want kexec-tools to update the old default crashkernel to the new default
+A new release of kexec-tools could update the default crashkernel value. By
+default, kexec-tools would reset crashkernel to the new default value if it
+detects the old default crashkernel value is used by installed kernels. If you
+don't want kexec-tools to update the old default crashkernel to the new default
crashkernel, you can change auto_reset_crashkernel to no in kdump.conf.
Supported Bootloaders
@@ -67,19 +67,18 @@ value properly, `kdumpctl` also provides a sub-command:
`kdumpctl reset-crashkernel [--kernel=path_to_kernel] [--reboot]`
-This command will read from the `crashkernel.default` file and reset
-bootloader's kernel cmdline to the default value. It will also update bootloader
-config if the bootloader has a standalone config file. User will have to reboot
-the machine after this command to make it take effect if --reboot is not specified.
-For ppc64le, an optional "[--fadump=[on|off|nocma]]" can also be specified to
toggle
-FADump on/off.
+This command will reset the bootloader's kernel cmdline to the default value.
+It will also update bootloader config if the bootloader has a standalone config
+file. User will have to reboot the machine after this command to make it take
+effect if --reboot is not specified. For more details, please refer to the
+reset-crashkernel command in `man kdumpctl`.
Reset manually
--------------
To reset the crashkernel value manually, it's recommended to use utils like
`grubby`. A one liner script for resetting `crashkernel=` value of all installed
-kernels to current boot kernel's crashkernel.default` is:
+kernels to the default value is:
grubby --update-kernel ALL --args "crashkernel=$(kdumpctl
get-default-crashkernel)"
@@ -98,7 +97,7 @@ triggering kdump:
The output will be like this:
```
- Encrypted kdump target requires extra memory, assuming using the keyslot with
minimun memory requirement
+ Encrypted kdump target requires extra memory, assuming using the keyslot with
minimum memory requirement
Reserved crashkernel: 256M
Recommended crashkernel: 655M
commit a1c63fa6449740f771349f931748b0ccc8a67ec7
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Mar 1 17:35:39 2022 +0800
add man documentation for kdumpctl get-default-crashkernel
A few typos and grammar issues are fixed as well.
Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl.8 b/kdumpctl.8
index 067117b..33c1115 100644
--- a/kdumpctl.8
+++ b/kdumpctl.8
@@ -14,7 +14,7 @@ In most cases, you should use
.B systemctl
to start / stop / enable kdump service instead. However,
.B kdumpctl
-provides more details for debug and a helper to setup ssh key authentication.
+provides more details for debugging and a helper to set up ssh key authentication.
.SH COMMANDS
.TP
@@ -26,14 +26,14 @@ Stop the service.
.TP
.I status
Prints the current status of kdump service.
-It returns non-zero value if kdump is not operational.
+It returns a non-zero value if kdump is not operational.
.TP
.I restart
Is equal to
.I start; stop
.TP
.I reload
-reload crash kernel image and initramfs without triggering a rebuild.
+reload the crash kernel image and initramfs without triggering a rebuild.
.TP
.I rebuild
rebuild the crash kernel initramfs.
@@ -43,20 +43,23 @@ Helps to setup key authentication for ssh storage since it's
impossible to use password authentication during kdump.
.TP
.I showmem
-Prints the size of reserved memory for crash kernel in megabytes.
+Prints the size of reserved memory for the crash kernel in megabytes.
.TP
.I estimate
-Estimate a suitable crashkernel value for current machine. This is a
-best-effort estimate. It will print a recommanded crashkernel value
-based on current kdump setup, and list some details of memory usage.
+Estimate a suitable crashkernel value for the current machine. This is a
+best-effort estimate. It will print a recommended crashkernel value
+based on the current kdump setup, and list some details of memory usage.
+.TP
+.I get-default-crashkernel
+Return the default crashkernel value provided by kexec-tools.
.TP
.I reset-crashkernel [--kernel=path_to_kernel] [--reboot]
Reset crashkernel to default value recommended by kexec-tools. If no kernel
is specified, will reset KDUMP_KERNELVER if it's defined in /etc/sysconfig/kdump
-or current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You can
+or the current running kernel's crashkernel value if KDUMP_KERNELVER is empty. You
can
also specify --kernel=ALL and --kernel=DEFAULT which have the same meaning as
grubby's kernel-path=ALL and kernel-path=DEFAULT. ppc64le supports FADump and
-supports an additonal [--fadump=[on|off|nocma]] parameter to toggle FADump
+supports an additional [--fadump=[on|off|nocma]] parameter to toggle FADump
on/off.
Note: The memory requirements for kdump varies heavily depending on the
commit 3d4cb38d96e45cf5da1460daf3345dd318fdee2f
Author: Coiby Xu <coxu(a)redhat.com>
Date: Fri Jan 7 16:00:08 2022 +0800
unit tests: add check_config with with the default kdump.conf
This test prevents the mistake of adding an option to kdump.conf
without changing check_config as is the case with commit 73ced7f
("introduce the auto_reset_crashkernel option to kdump.conf").
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index e72bf1d..5a3ce1c 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -174,4 +174,29 @@ Describe 'kdumpctl'
End
End
+ Describe 'parse_config()'
+ bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX)
+ cleanup() {
+ rm -f "$bad_kdump_conf"
+ }
+ AfterAll 'cleanup'
+
+ It 'should not be happy with unkown option in kdump.conf'
+ KDUMP_CONFIG_FILE="$bad_kdump_conf"
+ echo blabla > "$bad_kdump_conf"
+ When call parse_config
+ The status should be failure
+ The stderr should include 'Invalid kdump config option blabla'
+ End
+
+ It 'should be happy with the default kdump.conf'
+ # shellcheck disable=SC2034
+ # override the KDUMP_CONFIG_FILE variable
+ KDUMP_CONFIG_FILE=./kdump.conf
+ When call parse_config
+ The status should be success
+ End
+
+ End
+
End
commit e28a1399a3c9e60806a64216e6457e928a594dc8
Author: Coiby Xu <coxu(a)redhat.com>
Date: Thu Jan 6 14:24:22 2022 +0800
unit tests: add tests for kdump_get_conf_val in kdump-lib-initramfs.sh
kdump_get_conf_val allows to retrieves config value defined in
kdump.conf and it also supports sed regex like
"ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh".
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdump-lib-initramfs_spec.sh b/spec/kdump-lib-initramfs_spec.sh
new file mode 100644
index 0000000..dc50793
--- /dev/null
+++ b/spec/kdump-lib-initramfs_spec.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+Describe 'kdump-lib-initramfs'
+ Include ./kdump-lib-initramfs.sh
+
+ Describe 'Test kdump_get_conf_val'
+ KDUMP_CONFIG_FILE=/tmp/kdump_shellspec_test.conf
+ kdump_config() {
+ %text
+ #|default shell
+ #|nfs my.server.com:/export/tmp # trailing comment
+ #| failure_action shell
+ #|dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2
ext3"
+ #|sshkey /root/.ssh/kdump_id_rsa
+ #|ssh user(a)my.server.com
+ }
+ kdump_config >$KDUMP_CONFIG_FILE
+ Context 'Given different cases'
+ # Test the following cases:
+ # - there is trailing comment
+ # - there is space before the parameter
+ # - complicate value for dracut_args
+ # - Given two parameters, retrive one parameter that has value specified
+ # - Given two parameters (in reverse order), retrive one parameter that has value
specified
+ Parameters
+ "#1" nfs my.server.com:/export/tmp
+ "#2" ssh user(a)my.server.com
+ "#3" failure_action shell
+ "#4" dracut_args '--omit-drivers "cfg80211 snd" --add-drivers
"ext2 ext3"'
+ "#5" 'ssh\|aaa' user(a)my.server.com
+ "#6" 'aaa\|ssh' user(a)my.server.com
+ End
+
+ It 'should handle all cases correctly'
+ When call kdump_get_conf_val "$2"
+ The output should equal "$3"
+ End
+ End
+
+ End
+
+End
commit e00b45d75fa00a1d47b6cab0f609faf089ff563e
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Jan 4 15:24:34 2022 +0800
unit tests: add tests for "kdumpctl reset-crashkernel"
This commit adds a relatively thorough test suite for
kdumpctl reset-crashkernel [--fadump=[on|off|nocma]] [--kernel=path_to_kernel]
[--reboot]
as implemented in commit 140da74 ("rewrite reset_crashkernel to support
fadump and to used by RPM scriptlet").
grubby have a few options to support its own testing,
- --no-etc-grub-update, not update /etc/default/grub
- --bad-image-okay, don't check the validity of the image
- --env, specify custom grub2 environment block file to avoid modifying
the default /boot/grub2/grubenv
- --bls-directory, specify custom BootLoaderSpec config files to avoid
modifying the default /boot/loader/entries
So the grubby called by kdumpctl is mocked as
@grubby --grub2 --no-etc-grub-update --bad-image-okay --env=$SPEC_TEST_DIR/env_temp -b
$SPEC_TEST_DIR/boot_load_entries "$@"
in the tests. To be able to call the actual grubby in the mock function [1],
ShellSpec provides the following command
$ shellspec --gen-bin @grubby
to generate spec/support/bins/@grubby which is used to call the actual grubby.
kdumpctl has implemented its own version of updating /etc/default/grub
in _update_kernel_cmdline_in_grub_etc_default. To avoiding writing to
/etc/default/grub, this function is mocked as outputting its name and
received arguments similar to python unitest's assert_called_with.
[1]
https://github.com/shellspec/shellspec#execute-the-actual-command-within-...
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdumpctl_reset_crashkernel_spec.sh
b/spec/kdumpctl_reset_crashkernel_spec.sh
new file mode 100644
index 0000000..28d9277
--- /dev/null
+++ b/spec/kdumpctl_reset_crashkernel_spec.sh
@@ -0,0 +1,224 @@
+#!/bin/bash
+Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
+ Include ./kdumpctl
+ kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64
+ kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64
+ ck=222M
+ KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -d /tmp/spec_test.XXXXXXXXXX)
+ current_kernel=5.15.6-100.fc34.x86_64
+
+ setup() {
+ cp -r spec/support/boot_load_entries "$KDUMP_SPEC_TEST_RUN_DIR"
+ cp spec/support/grub_env "$KDUMP_SPEC_TEST_RUN_DIR"/env_temp
+ }
+
+ cleanup() {
+ rm -rf "$KDUMP_SPEC_TEST_RUN_DIR"
+ }
+
+ BeforeAll 'setup'
+ AfterAll 'cleanup'
+
+ grubby() {
+ # - --no-etc-grub-update, not update /etc/default/grub
+ # - --bad-image-okay, don't check the validity of the image
+ # - --env, specify custom grub2 environment block file to avoid modifying
+ # the default /boot/grub2/grubenv
+ # - --bls-directory, specify custom BootLoaderSpec config files to avoid
+ # modifying the default /boot/loader/entries
+ @grubby --no-etc-grub-update --grub2 --bad-image-okay
--env="$KDUMP_SPEC_TEST_RUN_DIR"/env_temp -b
"$KDUMP_SPEC_TEST_RUN_DIR"/boot_load_entries "$@"
+ }
+
+ Describe "Test the kdump dump mode "
+ uname() {
+ if [[ $1 == '-m' ]]; then
+ echo -n x86_64
+ elif [[ $1 == '-r' ]]; then
+ echo -n $current_kernel
+ fi
+ }
+ kdump_crashkernel=$(get_default_crashkernel kdump)
+ Context "when --kernel not specified"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ Specify 'kdumpctl should warn the user that crashkernel has been udpated'
+ When call reset_crashkernel
+ The error should include "Updated crashkernel=$kdump_crashkernel"
+ End
+
+ Specify 'Current running kernel should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$kdump_crashkernel"
+ The line 3 of output should not include crashkernel=$ck
+ End
+
+ Specify 'Other kernel still use the old crashkernel value'
+ When call grubby --info $kernel2
+ The line 3 of output should include crashkernel=$ck
+ End
+ End
+
+ Context "--kernel=ALL"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ Specify 'kdumpctl should warn the user that crashkernel has been udpated'
+ When call reset_crashkernel --kernel=ALL
+ The error should include "Updated crashkernel=$kdump_crashkernel for
kernel=$kernel1"
+ The error should include "Updated crashkernel=$kdump_crashkernel for
kernel=$kernel2"
+ End
+
+ Specify 'kernel1 should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$kdump_crashkernel"
+ End
+
+ Specify 'kernel2 should have crashkernel updated'
+ When call grubby --info $kernel2
+ The line 3 of output should include crashkernel="$kdump_crashkernel"
+ End
+ End
+
+ Context "--kernel=/boot/one-kernel to update one specified kernel"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ Specify 'kdumpctl should warn the user that crashkernel has been updated'
+ When call reset_crashkernel --kernel=$kernel1
+ The error should include "Updated crashkernel=$kdump_crashkernel for
kernel=$kernel1"
+ End
+
+ Specify 'kernel1 should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$kdump_crashkernel"
+ End
+
+ Specify 'kernel2 should have the old crashkernel'
+ When call grubby --info $kernel2
+ The line 3 of output should include crashkernel=$ck
+ End
+
+ End
+
+ End
+
+ Describe "FADump" fadump
+ uname() {
+ if [[ $1 == '-m' ]]; then
+ echo -n ppc64le
+ elif [[ $1 == '-r' ]]; then
+ echo -n $current_kernel
+ fi
+ }
+
+ _update_kernel_arg_in_grub_etc_default() {
+ # don't modify /etc/default/grub during the test
+ echo _update_kernel_arg_in_grub_etc_default "$@"
+ }
+
+ kdump_crashkernel=$(get_default_crashkernel kdump)
+ fadump_crashkernel=$(get_default_crashkernel fadump)
+ Context "when no --kernel specified"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ grubby --remove-args=fadump --update-kernel ALL
+ Specify 'kdumpctl should warn the user that crashkernel has been udpated'
+ When call reset_crashkernel
+ The error should include "Updated crashkernel=$kdump_crashkernel"
+ End
+
+ Specify 'Current running kernel should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$kdump_crashkernel"
+ End
+
+ Specify 'Other kernel still use the old crashkernel value'
+ When call grubby --info $kernel2
+ The line 3 of output should include crashkernel=$ck
+ End
+ End
+
+ Context "--kernel=ALL --fadump=on"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ Specify 'kdumpctl should warn the user that crashkernel has been udpated'
+ When call reset_crashkernel --kernel=ALL --fadump=on
+ The line 1 of output should include "_update_kernel_arg_in_grub_etc_default
crashkernel $fadump_crashkernel"
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel1"
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel2"
+ End
+
+ Specify 'kernel1 should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$fadump_crashkernel"
+ End
+
+ Specify 'kernel2 should have crashkernel updated'
+ When call get_grub_kernel_boot_parameter $kernel2 crashkernel
+ The output should equal "$fadump_crashkernel"
+ End
+ End
+
+ Context "--kernel=/boot/one-kernel to update one specified kernel"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ grubby --args fadump=on --update-kernel $kernel1
+ Specify 'kdumpctl should warn the user that crashkernel has been updated'
+ When call reset_crashkernel --kernel=$kernel1
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel1"
+ End
+
+ Specify 'kernel1 should have crashkernel updated'
+ When call grubby --info $kernel1
+ The line 3 of output should include crashkernel="$fadump_crashkernel"
+ End
+
+ Specify 'kernel2 should have the old crashkernel'
+ When call get_grub_kernel_boot_parameter $kernel2 crashkernel
+ The output should equal $ck
+ End
+ End
+
+ Context "Update all kernels but without --fadump specified"
+ grubby --args crashkernel=$ck --update-kernel ALL
+ grubby --args fadump=on --update-kernel $kernel1
+ Specify 'kdumpctl should warn the user that crashkernel has been updated'
+ When call reset_crashkernel --kernel=$kernel1
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel1"
+ End
+
+ Specify 'kernel1 should have crashkernel updated'
+ When call get_grub_kernel_boot_parameter $kernel1 crashkernel
+ The output should equal "$fadump_crashkernel"
+ End
+
+ Specify 'kernel2 should have the old crashkernel'
+ When call get_grub_kernel_boot_parameter $kernel2 crashkernel
+ The output should equal $ck
+ End
+ End
+
+ Context 'Switch between fadump=on and fadump=nocma'
+ grubby --args crashkernel=$ck --update-kernel ALL
+ grubby --args fadump=on --update-kernel ALL
+ Specify 'fadump=on to fadump=nocma'
+ When call reset_crashkernel --kernel=ALL --fadump=nocma
+ The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default
crashkernel $fadump_crashkernel"
+ The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump
nocma"
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel1"
+ The error should include "Updated crashkernel=$fadump_crashkernel for
kernel=$kernel2"
+ End
+
+ Specify 'kernel1 should have fadump=nocma in cmdline'
+ When call get_grub_kernel_boot_parameter $kernel1 fadump
+ The output should equal nocma
+ End
+
+ Specify 'fadump=nocma to fadump=on'
+ When call reset_crashkernel --kernel=ALL --fadump=on
+ The line 1 of output should equal "_update_kernel_arg_in_grub_etc_default
crashkernel $fadump_crashkernel"
+ The line 2 of output should equal "_update_kernel_arg_in_grub_etc_default fadump
on"
+ The error should include "Updated fadump=on for kernel=$kernel1"
+ End
+
+ Specify 'kernel2 should have fadump=on in cmdline'
+ When call get_grub_kernel_boot_parameter $kernel1 fadump
+ The output should equal on
+ End
+
+ End
+
+ End
+End
diff --git a/spec/support/bin/@grubby b/spec/support/bin/@grubby
new file mode 100755
index 0000000..2a9b33f
--- /dev/null
+++ b/spec/support/bin/@grubby
@@ -0,0 +1,3 @@
+#!/bin/sh -e
+. "$SHELLSPEC_SUPPORT_BIN"
+invoke grubby "$@"
diff --git a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
new file mode 100644
index 0000000..b821952
--- /dev/null
+++ b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-0-rescue.conf
@@ -0,0 +1,8 @@
+title Fedora (0-rescue-e986846f63134c7295458cf36300ba5b) 33 (Workstation Edition)
+version 0-rescue-e986846f63134c7295458cf36300ba5b
+linux /boot/vmlinuz-0-rescue-e986846f63134c7295458cf36300ba5b
+initrd /boot/initramfs-0-rescue-e986846f63134c7295458cf36300ba5b.img
+options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1
crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G
fadump=on
+grub_users $grub_users
+grub_arg --unrestricted
+grub_class kernel
diff --git
a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
new file mode 100644
index 0000000..08bd411
--- /dev/null
+++
b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.14.14-200.fc34.x86_64.conf
@@ -0,0 +1,8 @@
+title Fedora (5.14.14-200.fc34.x86_64) 34 (Workstation Edition)
+version 5.14.14-200.fc34.x86_64
+linux /boot/vmlinuz-5.14.14-200.fc34.x86_64
+initrd /boot/initramfs-5.14.14-200.fc34.x86_64.img
+options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1
crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G
fadump=on
+grub_users $grub_users
+grub_arg --unrestricted
+grub_class kernel
diff --git
a/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
new file mode 100644
index 0000000..9259b99
--- /dev/null
+++
b/spec/support/boot_load_entries/e986846f63134c7295458cf36300ba5b-5.15.6-100.fc34.x86_64.conf
@@ -0,0 +1,8 @@
+title Fedora (5.15.6-100.fc34.x86_64) 34 (Workstation Edition)
+version 5.15.6-100.fc34.x86_64
+linux /boot/vmlinuz-5.15.6-100.fc34.x86_64
+initrd /boot/initramfs-5.15.6-100.fc34.x86_64.img
+options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau
modprobe.blacklist=nouveau nvidia-drm.modeset=1
crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G
fadump=on
+grub_users $grub_users
+grub_arg --unrestricted
+grub_class fedora
diff --git a/spec/support/grub_env b/spec/support/grub_env
new file mode 100644
index 0000000..a77303c
--- /dev/null
+++ b/spec/support/grub_env
@@ -0,0 +1,3 @@
+# GRUB Environment Block
+# WARNING: Do not edit this file by tools other than grub-editenv!!!
+##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
\ No newline at end of file
commit ea8b06df8392d71bdb694646a4e24fd29a947977
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Jan 4 20:57:55 2022 +0800
unit tests: add tests for _{update,read}_kernel_arg_in_grub_etc_default in kdumpctl
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index 9fbc1a0..e72bf1d 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -107,4 +107,71 @@ Describe 'kdumpctl'
End
End
+ Describe '_update_kernel_arg_in_grub_etc_default()'
+ GRUB_ETC_DEFAULT=/tmp/default_grub
+
+ cleanup() {
+ rm -rf "$GRUB_ETC_DEFAULT"
+ }
+ AfterAll 'cleanup'
+
+ Context 'when the given parameter is in different positions'
+ Parameters
+ "crashkernel=222M fadump=on rhgb quiet" crashkernel 333M
+ " fadump=on crashkernel=222M rhgb quiet" crashkernel 333M
+ "fadump=on rhgb quiet crashkernel=222M" crashkernel 333M
+ "fadump=on rhgb quiet" crashkernel 333M
+ "fadump=on foo=bar1 rhgb quiet" foo bar2
+ End
+
+ It 'should update the kernel parameter correctly'
+ echo 'GRUB_CMDLINE_LINUX="'"$1"'"'
>$GRUB_ETC_DEFAULT
+ When call _update_kernel_arg_in_grub_etc_default "$2" "$3"
+ # the updated kernel parameter should appear in the end
+ The contents of file $GRUB_ETC_DEFAULT should include "$2=$3\""
+ End
+ End
+
+ It 'should only update the given parameter and not update the parameter that has
the given parameter as suffix'
+ echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet ckcrashkernel=222M"'
>$GRUB_ETC_DEFAULT
+ _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M
+ When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val"
+ The contents of file $GRUB_ETC_DEFAULT should include
"crashkernel=$_ck_val\""
+ The contents of file $GRUB_ETC_DEFAULT should include "ckcrashkernel=222M"
+ End
+
+ It 'should be able to handle the cases of there are multiple crashkernel
entries'
+ echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet crashkernel=101M
crashkernel=222M"' >$GRUB_ETC_DEFAULT
+ _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M
+ When call _update_kernel_arg_in_grub_etc_default crashkernel "$_ck_val"
+ The contents of file $GRUB_ETC_DEFAULT should include
"crashkernel=$_ck_val\""
+ The contents of file $GRUB_ETC_DEFAULT should not include
"crashkernel=222M"
+ End
+
+ Context 'when it removes a kernel parameter'
+
+ It 'should remove all values for given arg'
+ echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M fadump=on
crashkernel=222M"' >$GRUB_ETC_DEFAULT
+ When call _update_kernel_arg_in_grub_etc_default crashkernel
+ The contents of file $GRUB_ETC_DEFAULT should equal
'GRUB_CMDLINE_LINUX="fadump=on"'
+ End
+
+ It 'should not remove args that have the given arg as suffix'
+ echo 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M crashkernel=11M
ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT
+ When call _update_kernel_arg_in_grub_etc_default crashkernel
+ The contents of file $GRUB_ETC_DEFAULT should equal
'GRUB_CMDLINE_LINUX="ckcrashkernel=33M ckcrashkernel=222M"'
+ End
+ End
+
+ End
+
+ Describe '_read_kernel_arg_in_grub_etc_default()'
+ GRUB_ETC_DEFAULT=/tmp/default_grub
+ It 'should read the value for given arg'
+ echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M
ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT
+ When call _read_kernel_arg_in_grub_etc_default crashkernel
+ The output should equal '11M'
+ End
+ End
+
End
commit 6506bd9b1bcd4117676aaef513c144c4d81bec21
Author: Coiby Xu <coxu(a)redhat.com>
Date: Fri Jan 21 15:46:40 2022 +0800
unit tests: add tests for kdumpctl read_proc_environ_var and _is_osbuild
AfterAll is an example group hook [1] which would be run after the group
tests are executed. Use this hook to clean up the files created by mktemp.
[1]
https://github.com/shellspec/shellspec#beforeall-afterall---example-group...
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index b968f74..9fbc1a0 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -70,5 +70,41 @@ Describe 'kdumpctl'
End
+ Describe "read_proc_environ_var()"
+ environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX)
+ cleanup() {
+ rm -rf "$environ_test_file"
+ }
+ AfterAll 'cleanup'
+ echo -ne
"container=bwrap-osbuild\x00SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEbw33A/agent.1794\x00SSH_AGENT_PID=1929\x00env=test_env"
>"$environ_test_file"
+ Parameters
+ container bwrap-osbuild
+ SSH_AUTH_SOCK /tmp/ssh-XXXXXXEbw33A/agent.1794
+ env test_env
+ not_exist ""
+ End
+ It 'should read the environ variable value as expected'
+ When call read_proc_environ_var "$1" "$environ_test_file"
+ The output should equal "$2"
+ The status should be success
+ End
+ End
+
+ Describe "_is_osbuild()"
+ environ_test_file=$(mktemp -t spec_test_environ_test_file.XXXXXXXXXX)
+ # shellcheck disable=SC2034
+ # override the _OSBUILD_ENVIRON_PATH variable
+ _OSBUILD_ENVIRON_PATH="$environ_test_file"
+ Parameters
+ 'container=bwrap-osbuild' success
+ '' failure
+ End
+ It 'should be able to tell if it is the osbuild environment'
+ echo -ne "$1" >"$environ_test_file"
+ When call _is_osbuild
+ The status should be "$2"
+ The stderr should equal ""
+ End
+ End
End
commit 59386d5a8b1d2c2c2f9e8cdeb2a9e17565316033
Author: Coiby Xu <coxu(a)redhat.com>
Date: Wed Jan 5 15:24:02 2022 +0800
unit tests: add tests for get_dump_mode_by_fadump_val
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index e1d8698..b968f74 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -45,4 +45,30 @@ Describe 'kdumpctl'
The error should include "kernel_path=ALL invalid"
End
End
+
+ Describe 'get_dump_mode_by_fadump_val()'
+
+ Context 'when given valid fadump values'
+ Parameters
+ "#1" on fadump
+ "#2" nocma fadump
+ "#3" "" kdump
+ "#4" off kdump
+ End
+ It "should return the dump mode correctly"
+ When call get_dump_mode_by_fadump_val "$2"
+ The output should equal "$3"
+ The status should be success
+ End
+ End
+
+ It 'should complain given invalid fadump value'
+ When call get_dump_mode_by_fadump_val /boot/vmlinuz
+ The status should be failure
+ The error should include 'invalid fadump'
+ End
+
+ End
+
+
End
commit 93373c040627f31826d864110413c4e1f72e9b4b
Author: Coiby Xu <coxu(a)redhat.com>
Date: Wed Jan 5 13:48:58 2022 +0800
unit tests: add tests for get_grub_kernel_boot_parameter
This test suite makes use of three features provided by ShellSpec
- funcion-based mock [2]: mock a function by re-defining and exporting it
- parameterized tests [3]: run multiple sets of input against the same
test
- %text directive [4]: similar to heredoc but free of
the indentation issue
Note
1. Describe and Context are aliases for ExampleGroup which a block for
grouping example groups or examples [5]. Describe and Context are used to
improve readability.
2. ShellSpec requires .shellspec file.
[1]
https://github.com/dodie/testing-in-bash#detailed-comparision
[2]
https://github.com/shellspec/shellspec#function-based-mock
[3]
https://github.com/shellspec/shellspec#parameters---parameterized-example
[4]
https://github.com/shellspec/shellspec#text---embedded-text
[5]
https://github.com/shellspec/shellspec#dsl-syntax
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/.shellspec b/.shellspec
new file mode 100644
index 0000000..e69de29
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
new file mode 100644
index 0000000..e1d8698
--- /dev/null
+++ b/spec/kdumpctl_general_spec.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+Describe 'kdumpctl'
+ Include ./kdumpctl
+
+ Describe 'get_grub_kernel_boot_parameter()'
+ grubby() {
+ %text
+ #|index=1
+ #|kernel="/boot/vmlinuz-5.14.14-200.fc34.x86_64"
+ #|args="crashkernel=11M nvidia-drm.modeset=1 crashkernel=100M ro rhgb quiet
crcrashkernel=200M crashkernel=32T-64T:128G,64T-102400T:180G fadump=on"
+ #|root="UUID=45fdf703-3966-401b-b8f7-cf056affd2b0"
+ }
+ DUMMY_PARAM=/boot/vmlinuz
+
+ Context "when given a kernel parameter in different positions"
+ # Test the following cases:
+ # - the kernel parameter in the end
+ # - the kernel parameter in the first
+ # - the kernel parameter is crashkernel (suffix of crcrashkernel)
+ # - the kernel parameter that does not exist
+ # - the kernel parameter doesn't have a value
+ Parameters
+ # parameter answer
+ fadump on
+ nvidia-drm.modeset 1
+ crashkernel 32T-64T:128G,64T-102400T:180G
+ aaaa ""
+ ro ""
+ End
+
+ It 'should retrieve the value succesfully'
+ When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" "$2"
+ The output should equal "$3"
+ End
+ End
+
+ It 'should retrive the last value if multiple <parameter=value> entries
exist'
+ When call get_grub_kernel_boot_parameter "$DUMMY_PARAM" crashkernel
+ The output should equal '32T-64T:128G,64T-102400T:180G'
+ End
+
+ It 'should fail when called with kernel_path=ALL'
+ When call get_grub_kernel_boot_parameter ALL ro
+ The status should be failure
+ The error should include "kernel_path=ALL invalid"
+ End
+ End
+End
commit b97310428f336d58028d34f3f3c7a551e47b5c32
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Jan 4 14:04:38 2022 +0800
unit tests: prepare for kdumpctl and kdump-lib.sh to be unit-tested
Currently there are two issues with unit-testing the functions defined
in kdumpctl and other shell scripts after sourcing them,
- kdumpctl would call main which requires root permission and would
create single instance lock (/var/lock/kdump)
- kdumpctl and other shell scripts directly source files under /usr/lib/kdump/
When ShellSpec load a script via "Include", it defines the__SOURCED__
variable. By making use of __SOURCED__, we can
1. let kdumpctl not call main when kdumpctl is "Include"d by ShellSpec
2. instruct kdumpctl and kdump-lib.sh to source the files in the repo
when running ShelSpec tests
Note coverage/ is added to .gitignore because ShellSpec generates code
coverage results in this folder.
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/.gitignore b/.gitignore
index 7a38a39..e9c2dd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@
/kexec-tools-2.0.11.tar.xz
/makedumpfile-1.5.9.tar.gz
/kexec-tools-2.0.12.tar.xz
+coverage/
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 5b1656e..557eff6 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -2,8 +2,11 @@
#
# Kdump common variables and functions
#
-
-. /usr/lib/kdump/kdump-lib-initramfs.sh
+if [[ ${__SOURCED__:+x} ]]; then
+ . ./kdump-lib-initramfs.sh
+else
+ . /lib/kdump/kdump-lib-initramfs.sh
+fi
FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled"
diff --git a/kdumpctl b/kdumpctl
index 4d819c2..6188d47 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -32,8 +32,14 @@ fi
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
. $dracutbasedir/dracut-functions.sh
-. /lib/kdump/kdump-lib.sh
-. /lib/kdump/kdump-logger.sh
+
+if [[ ${__SOURCED__:+x} ]]; then
+ KDUMP_LIB_PATH=.
+else
+ KDUMP_LIB_PATH=/lib/kdump
+fi
+. $KDUMP_LIB_PATH/kdump-lib.sh
+. $KDUMP_LIB_PATH/kdump-logger.sh
#initiate the kdump logger
if ! dlog_init; then
@@ -1676,11 +1682,6 @@ reset_crashkernel_for_installed_kernel()
fi
}
-if [[ ! -f $KDUMP_CONFIG_FILE ]]; then
- derror "Error: No kdump config file found!"
- exit 1
-fi
-
main()
{
# Determine if the dump mode is kdump or fadump
@@ -1753,6 +1754,15 @@ main()
esac
}
+if [[ ${__SOURCED__:+x} ]]; then
+ return
+fi
+
+if [[ ! -f $KDUMP_CONFIG_FILE ]]; then
+ derror "Error: No kdump config file found!"
+ exit 1
+fi
+
# Other kdumpctl instances will block in queue, until this one exits
single_instance_lock
commit 11140c28a25169837333c5bf7d51cbe17c897025
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon Apr 11 10:56:46 2022 +0800
Release 2.0.24-1
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 6b7ef14..db6374c 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -4,8 +4,8 @@
%global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7})
Name: kexec-tools
-Version: 2.0.23
-Release: 5%{?dist}
+Version: 2.0.24
+Release: 1%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
@@ -103,7 +103,6 @@ Requires: systemd-udev%{?_isa}
#
# Patches 401 through 500 are meant for s390 kexec-tools enablement
#
-Patch401:
./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
#
# Patches 501 through 600 are meant for ARM kexec-tools enablement
@@ -127,7 +126,6 @@ mkdir -p -m755 kcp
tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19}
-%patch401 -p1
%ifarch ppc
%define archdef ARCH=ppc
@@ -407,6 +405,28 @@ fi
%endif
%changelog
+* Mon Apr 11 2022 Coiby <coxu(a)redhat.com> - 2.0.24-1
+- Update kexec-tools to 2.0.24
+- kdumpctl: remove kdump_get_conf_val in save_raw
+- kdumpctl: drop DUMP_TARGET variable
+- kdumpctl: drop SSH_KEY_LOCATION variable
+- kdumpctl: drop SAVE_PATH variable
+- kdumpctl: reduce file operations on kdump.conf
+- kdumpctl: merge check_ssh_config into check_config
+- kdumpctl: simplify propagate_ssh_key
+- kdumpctl: forbid aliases from ssh config
+- kdumpctl: fix comment in check_and_wait_network_ready
+- kdump-lib-initramfs: merge definitions for default ssh key
+- kdumpctl: remove unnecessary uses of $?
+- kdump-lib: fix typo in variable name
+- kdump-capture.service: switch to journal for stdout
+- kdumpctl/estimate: Fix unnecessary warning
+- kdumpctl: sync the $TARGET_INITRD after rebuild
+- try to update the crashkernel in GRUB_ETC_DEFAULT after kexec-tools updates the default
crashkernel value
+- address the case where there are multiple values for the same kernel arg
+- update kernel crashkernel in posttrans RPM scriptlet when updating kexec-tools
+- kdump-lib.sh: Check the output of blkid with sed instead of eval
+
* Mon Feb 14 2022 Coiby <coxu(a)redhat.com> - 2.0.23-5
- fix incorrect usage of _get_all_kernels_from_grubby
- fix the mistake of swapping function parameters of read_proc_environ_var
diff --git a/sources b/sources
index 5069108..95c0fc6 100644
--- a/sources
+++ b/sources
@@ -1,3 +1,3 @@
SHA512 (eppic-e8844d3.tar.gz) =
d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763
-SHA512 (kexec-tools-2.0.23.tar.xz) =
b6e3b967cacc31c434b185d25da4d53c822ae4bbcec26ef9d6cb171f294fdcc80913d381e686a0a41e025187835f4dc088052ff88efe75a021d7624c8b1a1ed8
+SHA512 (kexec-tools-2.0.24.tar.xz) =
ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822
SHA512 (makedumpfile-1.7.0.tar.gz) =
579a1fb79d023a1419fc8612a02a04dda3e3b3d72455566433ab6bec08627aa9a176c55566393a081a7aae3fd0543800196596b25445b21b16346556723e9cf7
commit 55b5c4e2b0105ae5b64ab3a5ea1c1879dc818a03
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:11 2022 +0100
kdumpctl: simplify local_fs_dump_target
Make use of the new ${OPT[]} array and simplify local_fs_dump_target to
remove one more file operations.
While at it rename the local_fs_dump_target to is_local_target
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 82e8574..4d819c2 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -850,27 +850,22 @@ save_raw()
return 0
}
-local_fs_dump_target()
+is_local_target()
{
- local _target
-
- if _target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf); then
- echo "$_target" | awk '{print $2}'
- fi
+ [[ ${OPT[_fstype]} =~ ^ext[234]|^xfs|^btrfs|^minix ]]
}
path_to_be_relabeled()
{
- local _path _target _mnt="/" _rmnt
+ local _path _mnt="/" _rmnt
if is_user_configured_dump_target; then
if is_mount_in_dracut_args; then
return
fi
- _target=$(local_fs_dump_target)
- if [[ -n $_target ]]; then
- _mnt=$(get_mntpoint_from_target "$_target")
+ if is_local_target; then
+ _mnt=$(get_mntpoint_from_target "${OPT[_target]}")
if ! is_mounted "$_mnt"; then
return
fi
commit ac5968218f4d4d86d5ad217c0912a81e985c5893
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:10 2022 +0100
kdumpctl: remove kdump_get_conf_val in save_raw
With the introduction of ${OPT[fstype]} this call to kdump_get_conf_val
can be removed now as well.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index bfba442..82e8574 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -819,8 +819,9 @@ save_raw()
{
local raw_target
- raw_target=$(kdump_get_conf_val raw)
- [[ -z $raw_target ]] && return 0
+ [[ ${OPT[_fstype]} == raw ]] || return 0
+
+ raw_target=${OPT[_target]}
[[ -b $raw_target ]] || {
derror "raw partition $raw_target not found"
return 1
commit 5118daf2ff9f2283782ea38e4b99cf9c307c2324
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:09 2022 +0100
kdumpctl: drop DUMP_TARGET variable
The variable is only used for ssh dump targets. Furthermore it is
identical to the value stored in ${OPT[_target]}. Thus drop DUMP_TARGET and
use ${OPT[_target]} instead.
In order to be able to distinguish between the different target types
introduce the internal ${OPT[_fstype]}.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index c5afedb..bfba442 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -10,7 +10,6 @@ MKDUMPRD="/sbin/mkdumprd -f"
MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
-DUMP_TARGET=""
DEFAULT_INITRD=""
DEFAULT_INITRD_BAK=""
KDUMP_INITRD=""
@@ -196,7 +195,7 @@ _set_config()
fi
if [[ -n ${OPT[$opt]} ]]; then
- if [[ $opt == _target ]]; then
+ if [[ $opt == _target ]] || [[ $opt == _fstype ]]; then
derror "More than one dump targets specified"
else
derror "Duplicated kdump config value of option $opt"
@@ -216,6 +215,7 @@ parse_config()
derror 'Multiple mount targets specified in one "dracut_args".'
return 1
fi
+ _set_config _fstype "$(get_dracut_args_fstype "$config_val")" ||
return 1
_set_config _target "$(get_dracut_args_target "$config_val")" ||
return 1
fi
;;
@@ -223,15 +223,13 @@ parse_config()
if [[ -d "/proc/device-tree/ibm,opal/dump" ]]; then
dwarn "WARNING: Won't capture opalcore when 'raw' dump target is
used."
fi
+ _set_config _fstype "$config_opt" || return 1
config_opt=_target
;;
- ext[234] | minix | btrfs | xfs | nfs )
+ ext[234] | minix | btrfs | xfs | nfs | ssh)
+ _set_config _fstype "$config_opt" || return 1
config_opt=_target
;;
- ssh)
- config_opt=_target
- DUMP_TARGET=$config_val
- ;;
sshkey)
if [[ -z $config_val ]]; then
derror "Invalid kdump config value for option '$config_opt'"
@@ -691,12 +689,12 @@ check_ssh_config()
{
local target
- [[ -n $DUMP_TARGET ]] || return 0
+ [[ "${OPT[_fstype]}" == ssh ]] || return 0
- [[ $DUMP_TARGET =~ .*@.* ]] || return 1
- target=$(ssh -G "$DUMP_TARGET" | sed -n -e
"s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
- if [[ ${DUMP_TARGET#*@} != "$target" ]]; then
- derror "Invalid ssh destination $DUMP_TARGET provided."
+ target=$(ssh -G "${OPT[_target]}" | sed -n -e
"s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
+ [[ ${OPT[_target]} =~ .*@.* ]] || return 1
+ if [[ ${OPT[_target]#*@} != "$target" ]]; then
+ derror "Invalid ssh destination ${OPT[_target]} provided."
return 1
fi
@@ -715,25 +713,25 @@ check_and_wait_network_ready()
local retval
local errmsg
- [[ -n $DUMP_TARGET ]] || return 0
+ [[ "${OPT[_fstype]}" == ssh ]] || return 0
start_time=$(date +%s)
while true; do
- errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "${OPT[path]}" 2>&1)
+ errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "${OPT[_target]}"
mkdir -p "${OPT[path]}" 2>&1)
retval=$?
# ssh exits with the exit status of the remote command or with 255 if an error
occurred
if [[ $retval -eq 0 ]]; then
return 0
elif [[ $retval -ne 255 ]]; then
- derror "Could not create $DUMP_TARGET:${OPT[path]}, you should check the
privilege on server side"
+ derror "Could not create ${OPT[_target]}:${OPT[path]}, you should check the
privilege on server side"
return 1
fi
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
ddebug "$errmsg"
if echo "$errmsg" | grep -q "Permission denied\|No such file or
directory\|Host key verification failed"; then
- derror "Could not create $DUMP_TARGET:${OPT[path]}, you probably need to run
\"kdumpctl propagate\""
+ derror "Could not create ${OPT[_target]}:${OPT[path]}, you probably need to run
\"kdumpctl propagate\""
return 1
fi
@@ -751,7 +749,7 @@ check_and_wait_network_ready()
sleep 1
done
- dinfo "Could not create $DUMP_TARGET:${OPT[path]}, ipaddr is not ready yet. You
should check network connection"
+ dinfo "Could not create ${OPT[_target]}:${OPT[path]}, ipaddr is not ready yet. You
should check network connection"
return 1
}
@@ -761,7 +759,7 @@ propagate_ssh_key()
parse_config || return 1
- if [[ -z $DUMP_TARGET ]] ; then
+ if [[ ${OPT[_fstype]} != ssh ]] ; then
derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh
<user>@<host>' and that it is properly formatted."
exit 1
@@ -778,9 +776,9 @@ propagate_ssh_key()
dinfo "done."
fi
- SSH_USER=${DUMP_TARGET%@*}
- SSH_SERVER=${DUMP_TARGET#*@}
- if ssh-copy-id -i "$KEYFILE" "$DUMP_TARGET"; then
+ SSH_USER=${OPT[_target]%@*}
+ SSH_SERVER=${OPT[_target]#*@}
+ if ssh-copy-id -i "$KEYFILE" "${OPT[_target]}"; then
dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on
$SSH_SERVER"
return 0
else
commit a859abe3652c1eea75b847e6f6f93033b478a4d3
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:08 2022 +0100
kdumpctl: drop SSH_KEY_LOCATION variable
The variable is only used for ssh dump targets. Furthermore it is
identical to the value stored in ${OPT[sshkey]}. Thus drop
SSH_KEY_LOCATION and use ${OPT[sshkey]} instead.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 876561e..c5afedb 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -9,7 +9,6 @@ KDUMP_LOG_PATH="/var/log"
MKDUMPRD="/sbin/mkdumprd -f"
MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
-SSH_KEY_LOCATION=$DEFAULT_SSHKEY
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
DUMP_TARGET=""
DEFAULT_INITRD=""
@@ -238,9 +237,10 @@ parse_config()
derror "Invalid kdump config value for option '$config_opt'"
return 1
elif [[ -f $config_val ]]; then
- SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val")
+ config_val=$(/usr/bin/readlink -m "$config_val")
else
- dwarn "WARNING: '$config_val' doesn't exist, using default value
'$SSH_KEY_LOCATION'"
+ dwarn "WARNING: '$config_val' doesn't exist, using default value
'$DEFAULT_SSHKEY'"
+ config_val=$DEFAULT_SSHKEY
fi
;;
path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules |
failure_action | default | final_action | force_rebuild | force_no_rebuild |
fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;;
@@ -262,6 +262,7 @@ parse_config()
done <<< "$(kdump_read_conf)"
OPT[path]=${OPT[path]:-$DEFAULT_PATH}
+ OPT[sshkey]=${OPT[sshkey]:-$DEFAULT_SSHKEY}
check_failure_action_config || return 1
check_final_action_config || return 1
@@ -718,7 +719,7 @@ check_and_wait_network_ready()
start_time=$(date +%s)
while true; do
- errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "${OPT[path]}" 2>&1)
+ errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "${OPT[path]}" 2>&1)
retval=$?
# ssh exits with the exit status of the remote command or with 255 if an error
occurred
@@ -766,7 +767,7 @@ propagate_ssh_key()
exit 1
fi
- local KEYFILE=$SSH_KEY_LOCATION
+ local KEYFILE=${OPT[sshkey]}
#Check to see if we already created key, if not, create it.
if [[ -f $KEYFILE ]]; then
commit 0460f0a7686334a14c5b17ef00721ad25c54324b
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:07 2022 +0100
kdumpctl: drop SAVE_PATH variable
The variable is only used for ssh dump targets. Furthermore it is
identical to the value stored in ${OPT[path]}. Thus drop SAVE_PATH and
use ${OPT[path]} instead.
Also make sure that ${OPT[path]} is always set to the default value when
no entry in kdump.conf is found.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 0b57384..876561e 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -9,7 +9,6 @@ KDUMP_LOG_PATH="/var/log"
MKDUMPRD="/sbin/mkdumprd -f"
MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
-SAVE_PATH=/var/crash
SSH_KEY_LOCATION=$DEFAULT_SSHKEY
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
DUMP_TARGET=""
@@ -244,10 +243,7 @@ parse_config()
dwarn "WARNING: '$config_val' doesn't exist, using default value
'$SSH_KEY_LOCATION'"
fi
;;
- path)
- SAVE_PATH=$config_val
- ;;
- core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action |
default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args |
fence_kdump_nodes | auto_reset_crashkernel) ;;
+ path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules |
failure_action | default | final_action | force_rebuild | force_no_rebuild |
fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;;
net | options | link_delay | disk_timeout | debug_mem_level | blacklist)
derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage
for alternatives."
@@ -265,6 +261,8 @@ parse_config()
_set_config "$config_opt" "$config_val" || return 1
done <<< "$(kdump_read_conf)"
+ OPT[path]=${OPT[path]:-$DEFAULT_PATH}
+
check_failure_action_config || return 1
check_final_action_config || return 1
check_fence_kdump_config || return 1
@@ -720,21 +718,21 @@ check_and_wait_network_ready()
start_time=$(date +%s)
while true; do
- errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "$SAVE_PATH" 2>&1)
+ errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "${OPT[path]}" 2>&1)
retval=$?
# ssh exits with the exit status of the remote command or with 255 if an error
occurred
if [[ $retval -eq 0 ]]; then
return 0
elif [[ $retval -ne 255 ]]; then
- derror "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege
on server side"
+ derror "Could not create $DUMP_TARGET:${OPT[path]}, you should check the
privilege on server side"
return 1
fi
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
ddebug "$errmsg"
if echo "$errmsg" | grep -q "Permission denied\|No such file or
directory\|Host key verification failed"; then
- derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run
\"kdumpctl propagate\""
+ derror "Could not create $DUMP_TARGET:${OPT[path]}, you probably need to run
\"kdumpctl propagate\""
return 1
fi
@@ -752,7 +750,7 @@ check_and_wait_network_ready()
sleep 1
done
- dinfo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You
should check network connection"
+ dinfo "Could not create $DUMP_TARGET:${OPT[path]}, ipaddr is not ready yet. You
should check network connection"
return 1
}
@@ -820,7 +818,6 @@ check_current_status()
save_raw()
{
- local kdump_dir
local raw_target
raw_target=$(kdump_get_conf_val raw)
@@ -834,13 +831,8 @@ save_raw()
dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss
is expected."
return 0
fi
- kdump_dir=${OPT[path]}
- if [[ -z ${kdump_dir} ]]; then
- coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")"
- else
- coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")"
- fi
+ coredir="${OPT[path]}/$(date +"%Y-%m-%d-%H:%M")"
mkdir -p "$coredir"
[[ -d $coredir ]] || {
derror "failed to create $coredir"
commit edb1d04425605db53637f698422017b609efe2b4
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:06 2022 +0100
kdumpctl: reduce file operations on kdump.conf
Every call to kdump_get_conf_val parses kdump.conf although the file has
already been parsed in check_config. Thus store the values parsed in
check_config in an array and use them later instead of re-parsing the
file over and over again.
While at it rename check_config to parse_config.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 85ea7aa..0b57384 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -27,6 +27,8 @@ standard_kexec_args="-d -p"
# Some default values in case /etc/sysconfig/kdump doesn't include
KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
+declare -A OPT
+
if [[ -f /etc/sysconfig/kdump ]]; then
. /etc/sysconfig/kdump
fi
@@ -185,9 +187,29 @@ restore_default_initrd()
fi
}
-check_config()
+_set_config()
+{
+ local opt=$1
+ local val=$2
+
+ if [[ -z $val ]]; then
+ derror "Invalid kdump config value for option '$opt'"
+ return 1
+ fi
+
+ if [[ -n ${OPT[$opt]} ]]; then
+ if [[ $opt == _target ]]; then
+ derror "More than one dump targets specified"
+ else
+ derror "Duplicated kdump config value of option $opt"
+ fi
+ return 1
+ fi
+ OPT[$opt]="$val"
+}
+
+parse_config()
{
- local -A _opt_rec
while read -r config_opt config_val; do
case "$config_opt" in
dracut_args)
@@ -196,7 +218,7 @@ check_config()
derror 'Multiple mount targets specified in one "dracut_args".'
return 1
fi
- config_opt=_target
+ _set_config _target "$(get_dracut_args_target "$config_val")" ||
return 1
fi
;;
raw)
@@ -240,20 +262,7 @@ check_config()
;;
esac
- if [[ -z $config_val ]]; then
- derror "Invalid kdump config value for option '$config_opt'"
- return 1
- fi
-
- if [[ -n ${_opt_rec[$config_opt]} ]]; then
- if [[ $config_opt == _target ]]; then
- derror "More than one dump targets specified"
- else
- derror "Duplicated kdump config value of option $config_opt"
- fi
- return 1
- fi
- _opt_rec[$config_opt]="$config_val"
+ _set_config "$config_opt" "$config_val" || return 1
done <<< "$(kdump_read_conf)"
check_failure_action_config || return 1
@@ -321,8 +330,8 @@ check_files_modified()
#also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled.
modified_files=$(get_pcs_cluster_modified_files)
- EXTRA_BINS=$(kdump_get_conf_val kdump_post)
- CHECK_FILES=$(kdump_get_conf_val kdump_pre)
+ EXTRA_BINS=${OPT[kdump_post]}
+ CHECK_FILES=${OPT[kdump_pre]}
HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/"
if [[ -d /etc/kdump/post.d ]]; then
for file in /etc/kdump/post.d/*; do
@@ -339,17 +348,17 @@ check_files_modified()
done
fi
HOOKS="$HOOKS $POST_FILES $PRE_FILES"
- CORE_COLLECTOR=$(kdump_get_conf_val core_collector | awk '{print $1}')
+ CORE_COLLECTOR=$(echo "${OPT[core_collector]}" | awk '{print $1}')
CORE_COLLECTOR=$(type -P "$CORE_COLLECTOR")
# POST_FILES and PRE_FILES are already checked against executable, need not to check
again.
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
- CHECK_FILES=$(kdump_get_conf_val extra_bins)
+ CHECK_FILES=${OPT[extra_bins]}
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
files="$KDUMP_CONFIG_FILE $KDUMP_KERNEL $EXTRA_BINS $CORE_COLLECTOR"
[[ -e /etc/fstab ]] && files="$files /etc/fstab"
# Check for any updated extra module
- EXTRA_MODULES="$(kdump_get_conf_val extra_modules)"
+ EXTRA_MODULES="${OPT[extra_modules]}"
if [[ -n $EXTRA_MODULES ]]; then
if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then
files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep"
@@ -541,14 +550,14 @@ check_rebuild()
setup_initrd || return 1
- force_no_rebuild=$(kdump_get_conf_val force_no_rebuild)
+ force_no_rebuild=${OPT[force_no_rebuild]}
force_no_rebuild=${force_no_rebuild:-0}
if [[ $force_no_rebuild != "0" ]] && [[ $force_no_rebuild !=
"1" ]]; then
derror "Error: force_no_rebuild value is invalid"
return 1
fi
- force_rebuild=$(kdump_get_conf_val force_rebuild)
+ force_rebuild=${OPT[force_rebuild]}
force_rebuild=${force_rebuild:-0}
if [[ $force_rebuild != "0" ]] && [[ $force_rebuild != "1"
]]; then
derror "Error: force_rebuild value is invalid"
@@ -751,7 +760,7 @@ propagate_ssh_key()
{
local SSH_USER SSH_SERVER
- check_config || return 1
+ parse_config || return 1
if [[ -z $DUMP_TARGET ]] ; then
derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
@@ -825,7 +834,7 @@ save_raw()
dwarn "Warning: Detected '$check_fs' signature on $raw_target, data loss
is expected."
return 0
fi
- kdump_dir=$(kdump_get_conf_val path)
+ kdump_dir=${OPT[path]}
if [[ -z ${kdump_dir} ]]; then
coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")"
else
@@ -911,7 +920,7 @@ check_fence_kdump_config()
hostname=$(hostname)
ipaddrs=$(hostname -I)
- nodes=$(kdump_get_conf_val "fence_kdump_nodes")
+ nodes=${OPT[fence_kdump_nodes]}
for node in $nodes; do
if [[ $node == "$hostname" ]]; then
@@ -964,8 +973,8 @@ check_failure_action_config()
local failure_action
local option="failure_action"
- default_option=$(kdump_get_conf_val default)
- failure_action=$(kdump_get_conf_val failure_action)
+ default_option=${OPT[default]}
+ failure_action=${OPT[failure_action]}
if [[ -z $failure_action ]] && [[ -z $default_option ]]; then
return 0
@@ -994,7 +1003,7 @@ check_final_action_config()
{
local final_action
- final_action=$(kdump_get_conf_val final_action)
+ final_action=${OPT[final_action]}
if [[ -z $final_action ]]; then
return 0
else
@@ -1017,7 +1026,7 @@ start()
return 1
fi
- if ! check_config; then
+ if ! parse_config; then
derror "Starting kdump: [FAILED]"
return 1
fi
@@ -1153,7 +1162,7 @@ stop()
rebuild()
{
- check_config || return 1
+ parse_config || return 1
check_and_wait_network_ready || return 1
setup_initrd || return 1
commit 4adf6d3cc85811d47ddc90c89a6f47b699350410
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:05 2022 +0100
kdumpctl: merge check_ssh_config into check_config
check_config and check_ssh_config both parse /etc/kdump.conf and are
usually used together. The difference between both is that
check_ssh_config does some extra checks on the format of the provided
ssh destination but ignores invalid or deprecated options in the config.
Thus merge check_ssh_config into check_config. Leave the additional
checks on the ssh destination in check_ssh_config but treat it like the
checks done for e.g. the failure_action.
This slightly changes the behavior of 'kdumpctl propagate', which now
fails if kdump.conf contains an invalid value unrelated to ssh. This
change in behavior isn't problematic because 'kdumpctl propagate' always
needs to be followed by a 'kdumpctl start' to have a working kdump
environment. For the situations where 'propagate' fails now the
'start'
would have failed in the past. So the failure only moved one step ahead
in the sequence.
While at it drop check_ssh_target and call check_and_wait_network_ready
directly.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index e6d5066..85ea7aa 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -205,10 +205,27 @@ check_config()
fi
config_opt=_target
;;
- ext[234] | minix | btrfs | xfs | nfs | ssh)
+ ext[234] | minix | btrfs | xfs | nfs )
config_opt=_target
;;
- sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules |
failure_action | default | final_action | force_rebuild | force_no_rebuild |
fence_kdump_args | fence_kdump_nodes | auto_reset_crashkernel) ;;
+ ssh)
+ config_opt=_target
+ DUMP_TARGET=$config_val
+ ;;
+ sshkey)
+ if [[ -z $config_val ]]; then
+ derror "Invalid kdump config value for option '$config_opt'"
+ return 1
+ elif [[ -f $config_val ]]; then
+ SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val")
+ else
+ dwarn "WARNING: '$config_val' doesn't exist, using default value
'$SSH_KEY_LOCATION'"
+ fi
+ ;;
+ path)
+ SAVE_PATH=$config_val
+ ;;
+ core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action |
default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args |
fence_kdump_nodes | auto_reset_crashkernel) ;;
net | options | link_delay | disk_timeout | debug_mem_level | blacklist)
derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage
for alternatives."
@@ -242,6 +259,7 @@ check_config()
check_failure_action_config || return 1
check_final_action_config || return 1
check_fence_kdump_config || return 1
+ check_ssh_config || return 1
return 0
}
@@ -665,29 +683,8 @@ check_ssh_config()
{
local target
- while read -r config_opt config_val; do
- case "$config_opt" in
- sshkey)
- # remove inline comments after the end of a directive.
- if [[ -f $config_val ]]; then
- # canonicalize the path
- SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val")
- else
- dwarn "WARNING: '$config_val' doesn't exist, using default value
'$SSH_KEY_LOCATION'"
- fi
- ;;
- path)
- SAVE_PATH=$config_val
- ;;
- ssh)
- DUMP_TARGET=$config_val
- ;;
- *) ;;
-
- esac
- done <<< "$(kdump_read_conf)"
+ [[ -n $DUMP_TARGET ]] || return 0
- [[ -n $DUMP_TARGET ]] || return 1
[[ $DUMP_TARGET =~ .*@.* ]] || return 1
target=$(ssh -G "$DUMP_TARGET" | sed -n -e
"s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
if [[ ${DUMP_TARGET#*@} != "$target" ]]; then
@@ -710,6 +707,8 @@ check_and_wait_network_ready()
local retval
local errmsg
+ [[ -n $DUMP_TARGET ]] || return 0
+
start_time=$(date +%s)
while true; do
errmsg=$(ssh -i "$SSH_KEY_LOCATION" -o BatchMode=yes "$DUMP_TARGET"
mkdir -p "$SAVE_PATH" 2>&1)
@@ -748,16 +747,13 @@ check_and_wait_network_ready()
return 1
}
-check_ssh_target()
-{
- check_and_wait_network_ready
-}
-
propagate_ssh_key()
{
local SSH_USER SSH_SERVER
- if ! check_ssh_config; then
+ check_config || return 1
+
+ if [[ -z $DUMP_TARGET ]] ; then
derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh
<user>@<host>' and that it is properly formatted."
exit 1
@@ -1040,11 +1036,9 @@ start()
return 0
fi
- if check_ssh_config; then
- if ! check_ssh_target; then
- derror "Starting kdump: [FAILED]"
- return 1
- fi
+ if ! check_and_wait_network_ready; then
+ derror "Starting kdump: [FAILED]"
+ return 1
fi
if ! check_rebuild; then
@@ -1160,12 +1154,7 @@ stop()
rebuild()
{
check_config || return 1
-
- if check_ssh_config; then
- if ! check_ssh_target; then
- return 1
- fi
- fi
+ check_and_wait_network_ready || return 1
setup_initrd || return 1
commit e3fa3678404e161be27914b91c69693613b1fcfe
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:04 2022 +0100
kdumpctl: simplify propagate_ssh_key
The function has multiple problems:
1) SSH_{USER,SERVER} aren't defined local
2) Weird use of cut and sed to parse the DUMP_TARGET for the user and
host although check_ssh_config guarantees that it has the format
<user>@<host>.
3) Unnecessary use of a variable for the return value
4) Weird behavior to first unpack the DUMP_TARGET to SSH_USER and
SSH_SERVER and then putting it back together again
5) Definition of variable errmsg that is only used once but breaks
grep-ability of error message.
6) Wrong order when redirecting output of ssh-keygen, see SC2069 [1]
Fix them now.
While at it also improve the error messages in the function.
[1]
https://www.shellcheck.net/wiki/SC2069
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 8ad6e4c..e6d5066 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -755,35 +755,32 @@ check_ssh_target()
propagate_ssh_key()
{
+ local SSH_USER SSH_SERVER
+
if ! check_ssh_config; then
- derror "No ssh config specified in $KDUMP_CONFIG_FILE. Can't propagate"
+ derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
+ derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh
<user>@<host>' and that it is properly formatted."
exit 1
fi
local KEYFILE=$SSH_KEY_LOCATION
- local errmsg="Failed to propagate ssh key"
#Check to see if we already created key, if not, create it.
if [[ -f $KEYFILE ]]; then
dinfo "Using existing keys..."
else
dinfo "Generating new ssh keys... "
- /usr/bin/ssh-keygen -t rsa -f "$KEYFILE" -N "" 2>&1 >
/dev/null
+ /usr/bin/ssh-keygen -t rsa -f "$KEYFILE" -N "" &> /dev/null
dinfo "done."
fi
- #now find the target ssh user and server to contact.
- SSH_USER=$(echo "$DUMP_TARGET" | cut -d@ -f1)
- SSH_SERVER=$(echo "$DUMP_TARGET" | sed -e's/\(.*(a)\)\(.*$\)/\2/')
-
- #now send the found key to the found server
- ssh-copy-id -i "$KEYFILE" "$SSH_USER@$SSH_SERVER"
- RET=$?
- if [[ $RET == 0 ]]; then
+ SSH_USER=${DUMP_TARGET%@*}
+ SSH_SERVER=${DUMP_TARGET#*@}
+ if ssh-copy-id -i "$KEYFILE" "$DUMP_TARGET"; then
dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on
$SSH_SERVER"
return 0
else
- derror "$errmsg, $KEYFILE failed in transfer to $SSH_SERVER"
+ derror "Failed to propagate ssh key, could not transfer $KEYFILE to
$SSH_SERVER"
exit 1
fi
}
commit b802dbff9f0da8b5cd6eebf28dd3e7fd207cc45c
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:03 2022 +0100
kdumpctl: forbid aliases from ssh config
For ssh targets kdumpctl only verifies that the config value has the
correct <user>@<host> format itself. For all other tests, e.g. if the
destination can be reached, it relies on ssh. This allows users to
provide a <host> that isn't the proper hostname but an alias defined in
the ssh_config without failing the tests. If this is done
dracut-module-setup.sh:kdump_get_remote_ip will fail to obtain the
targets ip address. This failure is not detected and thus will not fail
the initramfs creation. The resulting initramfs however doesn't have the
necessary information for setting up the network and thus will fail to
boot.
Prevent the use of alias hostnames by verifying that the given hostname
is the same one ssh would use after parsing the ssh_config.
Note: Don't use getent ahosts to verify that the given host can be
resolved as this requires the network to be up which cannot be
guaranteed when the kdump.conf is parsed.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 7d40f76..8ad6e4c 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -663,7 +663,7 @@ load_kdump()
check_ssh_config()
{
- local SSH_TARGET
+ local target
while read -r config_opt config_val; do
case "$config_opt" in
@@ -687,11 +687,14 @@ check_ssh_config()
esac
done <<< "$(kdump_read_conf)"
- #make sure they've configured kdump.conf for ssh dumps
- SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p')
- if [[ -z $SSH_TARGET ]]; then
+ [[ -n $DUMP_TARGET ]] || return 1
+ [[ $DUMP_TARGET =~ .*@.* ]] || return 1
+ target=$(ssh -G "$DUMP_TARGET" | sed -n -e
"s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
+ if [[ ${DUMP_TARGET#*@} != "$target" ]]; then
+ derror "Invalid ssh destination $DUMP_TARGET provided."
return 1
fi
+
return 0
}
commit 247b3dd297f1ee2224af2d3b838019af428c387e
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:02 2022 +0100
kdumpctl: fix comment in check_and_wait_network_ready
The time out was increased to 180 seconds in 680c0d3 ("kdumpctl:
distinguish the failed reason of ssh"). Update the comment to reflect
that change.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 7b01cd3..7d40f76 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -734,7 +734,7 @@ check_and_wait_network_ready()
cur=$(date +%s)
diff=$((cur - start_time))
- # 60s time out
+ # time out after 180s
if [[ $diff -gt 180 ]]; then
break
fi
commit 7cd3f232d50c76bb5c6bf0b3175cc2c36c2f3351
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:01 2022 +0100
kdump-lib-initramfs: merge definitions for default ssh key
There are currently three identical definitions for the default ssh key.
Combine them into one in kdump-lib-initramfs.sh.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b69bc98..b17455a 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -22,7 +22,7 @@ FAILURE_ACTION="systemctl reboot -f"
DATEDIR=$(date +%Y-%m-%d-%T)
HOST_IP='127.0.0.1'
DUMP_INSTRUCTION=""
-SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
+SSH_KEY_LOCATION=$DEFAULT_SSHKEY
DD_BLKSIZE=512
FINAL_ACTION="systemctl reboot -f"
KDUMP_PRE=""
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 9be0fe9..84e6bf7 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -4,6 +4,7 @@
# not be the default shell. Any code added must be POSIX compliant.
DEFAULT_PATH="/var/crash/"
+DEFAULT_SSHKEY="/root/.ssh/kdump_id_rsa"
KDUMP_CONFIG_FILE="/etc/kdump.conf"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
diff --git a/kdumpctl b/kdumpctl
index 35fd6e0..7b01cd3 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -10,7 +10,7 @@ MKDUMPRD="/sbin/mkdumprd -f"
MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
SAVE_PATH=/var/crash
-SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
+SSH_KEY_LOCATION=$DEFAULT_SSHKEY
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
DUMP_TARGET=""
DEFAULT_INITRD=""
diff --git a/mkdumprd b/mkdumprd
index 5996d50..3e250e0 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -22,7 +22,7 @@ if ! dlog_init; then
exit 1
fi
-SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
+SSH_KEY_LOCATION=$DEFAULT_SSHKEY
SAVE_PATH=$(get_save_path)
OVERRIDE_RESETTABLE=0
commit b49083126fcdd5be8cb7d84e0048ac2adddb6aed
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:47:00 2022 +0100
kdumpctl: remove unnecessary uses of $?
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index b7922a6..35fd6e0 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -86,7 +86,6 @@ rebuild_fadump_initrd()
check_earlykdump_is_enabled()
{
grep -q -w "rd.earlykdump" /proc/cmdline
- return $?
}
rebuild_kdump_initrd()
@@ -117,8 +116,6 @@ rebuild_initrd()
else
rebuild_kdump_initrd
fi
-
- return $?
}
#$1: the files to be checked with IFS=' '
@@ -584,7 +581,6 @@ check_rebuild()
dinfo "Rebuilding $TARGET_INITRD"
rebuild_initrd
- return $?
}
# On ppc64le LPARs, the keys trusted by firmware do not end up in
@@ -815,8 +811,6 @@ check_current_status()
else
check_current_kdump_status
fi
-
- return $?
}
save_raw()
@@ -945,7 +939,6 @@ check_dump_feasibility()
fi
check_kdump_feasibility
- return $?
}
start_fadump()
@@ -967,8 +960,6 @@ start_dump()
else
load_kdump
fi
-
- return $?
}
check_failure_action_config()
@@ -1077,7 +1068,7 @@ reload()
if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then
reload_fadump
- return $?
+ return
else
if ! stop_kdump; then
derror "Stopping kdump: [FAILED]"
@@ -1141,7 +1132,7 @@ reload_fadump()
# to handle such scenario.
if stop_fadump; then
start_fadump
- return $?
+ return
fi
fi
@@ -1180,7 +1171,6 @@ rebuild()
dinfo "Rebuilding $TARGET_INITRD"
rebuild_initrd
- return $?
}
do_estimate()
@@ -1787,5 +1777,3 @@ single_instance_lock
exec 9<&-
main "$@"
)
-
-exit $?
commit aa9bb8f8cef734fb1f6ab36ccaaa8936edb4f467
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:46:59 2022 +0100
kdump-lib: fix typo in variable name
in prepare_kdump_bootinfo s/defaut/default/.
While at it declare it with the other local variables as local.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 4ed5035..5b1656e 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -640,7 +640,7 @@ prepare_kexec_args()
prepare_kdump_bootinfo()
{
local boot_img boot_imglist boot_dirlist boot_initrdlist
- local machine_id
+ local machine_id dir img default_initrd_base var_target_initrd_dir
if [[ -z $KDUMP_KERNELVER ]]; then
KDUMP_KERNELVER="$(uname -r)"
@@ -677,8 +677,8 @@ prepare_kdump_bootinfo()
boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd"
for initrd in $boot_initrdlist; do
if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then
- defaut_initrd_base="$initrd"
- DEFAULT_INITRD="$KDUMP_BOOTDIR/$defaut_initrd_base"
+ default_initrd_base="$initrd"
+ DEFAULT_INITRD="$KDUMP_BOOTDIR/$default_initrd_base"
break
fi
done
@@ -686,12 +686,12 @@ prepare_kdump_bootinfo()
# Create kdump initrd basename from default initrd basename
# initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img
# initrd => initrdkdump
- if [[ -z $defaut_initrd_base ]]; then
+ if [[ -z $default_initrd_base ]]; then
kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img
- elif [[ $defaut_initrd_base == *.* ]]; then
- kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.}
+ elif [[ $default_initrd_base == *.* ]]; then
+ kdump_initrd_base=${default_initrd_base%.*}kdump.${DEFAULT_INITRD##*.}
else
- kdump_initrd_base=${defaut_initrd_base}kdump
+ kdump_initrd_base=${default_initrd_base}kdump
fi
# Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable
commit 5947707682e7de478aa1e1b41006ce50f84699cc
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 15:46:58 2022 +0100
kdump-capture.service: switch to journal for stdout
Using syslog for StandardOutput in a service file was deprecated in
systemd v246 with commit f3dc6af20f ("core: automatically update
StandardOuput=syslog to =journal (and similar for StandardError=)").
Thus the following warnings are printed in the crash kernel when
creating a dump.
systemd[1]: /usr/lib/systemd/system/kdump-capture.service:23: Standard output type
syslog is obsolete, automatically updating to journal. Please update your unit file, and
consider removing the setting altogether.
systemd[1]: /usr/lib/systemd/system/kdump-capture.service:24: Standard output type
syslog+console is obsolete, automatically updating to journal+console. Please update your
unit file, and consider removing the setting altogether.
Fix this by redirecting the stdout and stderr to the journal.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
Reviewed-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/dracut-kdump-capture.service b/dracut-kdump-capture.service
index 3f20aba..7109169 100644
--- a/dracut-kdump-capture.service
+++ b/dracut-kdump-capture.service
@@ -20,8 +20,8 @@ Environment=NEWROOT=/sysroot
Type=oneshot
ExecStart=/bin/kdump.sh
StandardInput=null
-StandardOutput=syslog
-StandardError=syslog+console
+StandardOutput=journal
+StandardError=journal+console
KillMode=process
RemainAfterExit=yes
commit 8736aa5bb359e0fccbb07919e49f68c22299c55a
Author: Philipp Rudo <prudo(a)redhat.com>
Date: Fri Mar 25 16:19:40 2022 +0100
kdumpctl/estimate: Fix unnecessary warning
do_estimate prints the warning that the reserved crashkernel is lower
than the recommended one even then when both values are identical. This
might cause confusion. So omit printing the warning when both values are
equal.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
Acked-by: Coiby Xu <coxu(a)redhat.com>
diff --git a/kdumpctl b/kdumpctl
index 1869753..b7922a6 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1270,7 +1270,7 @@ do_estimate()
done
fi
- if [[ $reserved_size -le $recommended_size ]]; then
+ if [[ $reserved_size -lt $recommended_size ]]; then
echo "WARNING: Current crashkernel size is lower than recommended size
$((recommended_size / size_mb))M."
fi
}
commit 7141d044c8880815f308e61f612b710b7bc8a9a3
Author: Lichen Liu <lichliu(a)redhat.com>
Date: Tue Mar 1 13:09:00 2022 +0800
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 <lichliu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
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
commit 6d4062a936694b7cab7e0c536414b4d5b6ab8668
Author: Coiby Xu <coxu(a)redhat.com>
Date: Wed Feb 16 09:42:54 2022 +0800
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 <prudo(a)redhat.com>
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
commit 37f4f2c1f6f1304e1b58604a788c57c51508eead
Author: Coiby Xu <coxu(a)redhat.com>
Date: Tue Feb 15 13:24:19 2022 +0800
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 <prudo(a)redhat.com>
Suggested-by: Philipp Rudo <prudo(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
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
commit 311b5b100b512134cddb189f46c8bb85d74f9275
Author: Coiby Xu <coxu(a)redhat.com>
Date: Fri Feb 11 13:11:17 2022 +0800
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 <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
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
commit 2bbc7512a2f2cf953ea047f54bd590d4d285b658
Author: Tao Liu <ltao(a)redhat.com>
Date: Wed Feb 16 14:26:38 2022 +0800
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 <ltao(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
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
commit 59fcb8ae5b13d776f5a1966173b57d6404699aae
Author: Coiby Xu <coxu(a)redhat.com>
Date: Mon Feb 14 12:07:08 2022 +0800
Release 2.0.23-5
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
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 <coxu(a)redhat.com> - 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 <coxu(a)redhat.com> - 2.0.23-4
- fix broken kdump_get_arch_recommend_size
- remove the upper bound of 102400T for the range in default crashkernel
commit 41b8f9528c8ed89c68ad59750c18f032b5675a06
Author: Coiby Xu <coxu(a)redhat.com>
Date: Wed Feb 9 08:04:39 2022 +0800
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 <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
Reviewed-by: Tao Liu <ltao(a)redhat.com>
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"