[RFC PATCH 00/26] kdumpctl: Introduce new CLI
by Philipp Rudo
Hi everybody,
The series far from being complete. But it finally passes the first simple
tests so I think it's time to get the first feedback.
The series started out with the request to be able to rebuild the initramfs for
all installed kernels. As 'reset-crashkernel' already had a --kernel=ALL option
I didn't want to introduce a second way to do the same thing. My problem was
the way --kernel=ALL was implemented, especially its hard dependency on grubby
which might not be installed on all systems. This lead to basically a rewrite
of the crashkernel handling with now (hopefully) simpler, better to understand
code.
An other problem I had with the former implementation of --kernel=ALL was that
the command line parser was self-written. This made the UI much more rigid than
it had to be. So I changed it to use getopt instead. In order to prevent
unnecessary duplicate code I also wrote a framework around it (which might be a
little bit over engineered for what we need but once I started I refused to
give up plus it gives bash-completion almost for free, which is nice ;-)).
While at it I also added some basic options most users expect, like --help.
Finally I've merged multiple commands to make the UI (hopefully) a little bit
cleaner and more intuitive. For example I've never understood why 'status' only
retuned a simple yes/no but not other important information about the current
state like 'git status' does.
As stated in the beginning there is still a lot to do. In particular:
* Test cases still need to be adjusted (and new ones added).
* The documentation needs to be reviewed and adjusted.
* The patches don't consider Pingfans 64k work, yet. So they will need some
adjustments (they are currently based on
29fe563 ("kdump.conf: redirect unknown architecture warning to stderr"))
* I've noticed a bug in the bash completion where subsubcommands aren't
completed correctly.
* And of course the series need a lot more testing. For the moment I've only
made some very simple sanity checks. So I would be surprised if the code
isn't still riddled with bugs...
Anyway, this is quite a big change and opinions on what a good UI is are very
subjective. That's why I want to get feedback early before I waste too much
time on something which isn't wanted.
Happy to hear your opinion (good and bad).
Thanks
Philipp
Philipp Rudo (26):
kdumpctl: Fix various shellcheck findings
kdump-lib: make is_zstd_command_available more generic
kdump-lib: simplify _get_kdump_kernel_version
kdumpctl: drop _get_current_running_kernel_path
kdumpctl: drop condrestart subcommand
kdumpctl: make all subcommands execute exactly one function
kdumpctl: Restructure subcommand handling and and usage
kdumpctl: simplify _update_kernel_cmdline
kdumpctl: Prevent option --fadump on non-PPC in reset_crashkernel
kdumpctl: Stop updating grub config in reset_crashkernel
kdumpctl: Simplify fadump handling in reset_crashkernel
kdumpctl: Use getopt for option parsing in reset_crashkernel
kdumpctl: Add simple bash-completion for kdumpctl
kdumpctl: Make --kernel a global option
kdumpctl: Add global -h/--help option
kdumpctl: Add --kver option
kdumpctl: Reduce dependencies from grubby for --kernel
kdumpctl: merge reset_crashkernel_{after_update,for_installed_kernel}
kdumpctl: Allow --kernel with 'start' and 'rebuild'
kdumpctl: Add --quiet/--verbose option
kdumpctl: Rework the 'status' subcommand
kdumpctl: Merge _upgrade_crashkernel into the upgrade hook
kdumpctl: Drop special handling for CoreOS in reset_crashkernel
kdumpctl: Determine "old" value within _update_kernel_cmdline
kdumpctl: Introduce new crashkernel subcommand
REMOVEME: add test subsubcommands
92-crashkernel.install | 2 +-
kdump-lib.sh | 27 +-
kdumpctl | 1094 ++++++++++++++++++++++++--------------
kdumpctl.bash-completion | 125 +++++
kexec-tools.spec | 16 +-
mkdumprd | 2 +-
mkfadumprd | 2 +-
7 files changed, 865 insertions(+), 403 deletions(-)
create mode 100755 kdumpctl.bash-completion
--
2.40.1
2 months, 2 weeks
[RFC] Split kexec-tools into two sub-packages kexec-tools and kdump-tools
by Coiby Xu
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2121912
Now there is a growing user base to use the kexec reboot and it's
desirable to make the kexec-tools package more modular.
This patch splits current kexec-tools into two sub-packages kexec-tools
and kdump-tools. Now kexec-tools merely provides /usr/sbin/kexec and the
remaining features go into kdump-tools.
"dnf repoquery --whatrequires kexec-tools" shows the following packages
requires kexec-tools,
- abrt-addon-vmcore
- anaconda-install-env-deps
- cockpit-kdump
- dracut-kiwi-oem-dump
- realtime-setup
- retrace-server
For those packages that need kdump, the dependency needs to point to
the new kdump-tools package instead.
Cc: fedora-devel(a)lists.fedorahosted.org
Cc: Dusty Mabe <dustymabe(a)redhat.com>
Cc: crash-catcher-owner(a)lists.fedorahosted.org
CC: anaconda-devel(a)lists.fedoraproject.org
Cc: Martin Pitt <mpitt(a)redhat.com>
Cc: kiwi-images(a)googlegroups.com
Cc: Clark Williams <williams(a)redhat.com>
Cc: Matěj Grabovský <mgrabovs(a)redhat.com>
Suggested-by: Zbigniew Jędrzejewski-Szmek <zbyszek(a)in.waw.pl>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kexec-tools.spec | 80 +++++++++++++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 32 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 360b6c5d..6e78f6d3 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -5,9 +5,10 @@
Name: kexec-tools
Version: 2.0.26
-Release: 7%{?dist}
+Release: 8%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
+Obsoletes: kexec-tools < 2.0.26-8
Source0: http://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz
Source1: kdumpctl
@@ -56,33 +57,6 @@ Source109: dracut-early-kdump-module-setup.sh
Source200: dracut-fadump-init-fadump.sh
Source201: dracut-fadump-module-setup.sh
-%ifarch ppc64 ppc64le
-Requires(post): servicelog
-Recommends: keyutils
-%endif
-Requires(pre): coreutils sed zlib
-Requires: dracut >= 058
-Requires: dracut-network >= 058
-Requires: dracut-squash >= 058
-Requires: ethtool
-Requires: util-linux
-# Needed for UKI support
-Recommends: binutils
-Recommends: grubby
-Recommends: hostname
-BuildRequires: make
-BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel
-BuildRequires: pkgconfig intltool gettext
-BuildRequires: systemd-rpm-macros
-BuildRequires: automake autoconf libtool
-%ifarch %{ix86} x86_64 ppc64 ppc s390x ppc64le
-Obsoletes: diskdumputils netdump kexec-tools-eppic
-%endif
-
-%ifnarch s390x
-Requires: systemd-udev%{?_isa}
-%endif
-
#START INSERT
#
@@ -117,6 +91,42 @@ normal or a panic reboot. This package contains the /sbin/kexec
binary and ancillary utilities that together form the userspace
component of the kernel's kexec feature.
+%package -n kdump-tools
+Summary: Kernel crash dump collection tools
+Obsoletes: kexec-tools < 2.0.26-8
+%ifarch ppc64 ppc64le
+Requires(post): servicelog
+Recommends: keyutils
+%endif
+Requires(pre): coreutils sed zlib
+Requires: kexec-tools >= 2.0.26-8
+Requires: dracut >= 058
+Requires: dracut-network >= 058
+Requires: dracut-squash >= 058
+Requires: ethtool
+Requires: util-linux
+Requires: binutils
+Obsoletes: kexec-tools = 2.0.26-8
+Recommends: grubby
+Recommends: hostname
+BuildRequires: make
+BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel
+BuildRequires: pkgconfig intltool gettext
+BuildRequires: systemd-rpm-macros
+BuildRequires: automake autoconf libtool
+%ifarch %{ix86} x86_64 ppc64 ppc s390x ppc64le
+Obsoletes: diskdumputils netdump kexec-tools-eppic
+%endif
+
+%ifnarch s390x
+Requires: systemd-udev%{?_isa}
+%endif
+%description -n kdump-tools
+kdump-tools is reponsible for collecting the crash kernel dump. It builds and
+load the kdump initramfs so when a kernel crashes, the system will boot the
+kdump kernel and initramfs to save the colletecd crash kernel dump to specified
+target.
+
%prep
%setup -q
@@ -261,7 +271,7 @@ chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpini
mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
-%post
+%post -n kdump-tools
# Initial installation
%systemd_post kdump.service
@@ -295,10 +305,10 @@ then
fi
-%postun
+%postun -n kdump-tools
%systemd_postun_with_restart kdump.service
-%preun
+%preun -n kdump-tools
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh
%endif
@@ -326,7 +336,7 @@ do
fi
done
-%posttrans
+%posttrans -n kdump-tools
# Try to reset kernel crashkernel value to new default value or set up
# crasherkernel value for new install
#
@@ -342,6 +352,9 @@ fi
%files
/usr/sbin/kexec
+%{_mandir}/man8/kexec.8.gz
+
+%files -n kdump-tools
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
/usr/sbin/makedumpfile
%endif
@@ -396,6 +409,9 @@ fi
%endif
%changelog
+* Wed Jun 14 2023 Coiby <coxu(a)redhat.com> - 2.0.26-8
+- split kexec-tools into kexec-tools and kdump-tools
+
* Wed Jun 14 2023 Coiby <coxu(a)redhat.com> - 2.0.26-7
- kdumpctl: Fix the matching of plus symbol by grep's EREs
- kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately
--
2.41.0
2 months, 4 weeks
[PATCH] Exclude the extra memory requirement when comparing the estimated value with the baseline value
by Coiby Xu
The current estimated crashkernel is too small and leads to OOM for the
LUKS case forboth aarch64 4k and 64k kernels. Since the baseline value
doesn't take special cases like LUKS into consideration, the extra
memory requirement should be included when comparing the estimated value
with the baseline value.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 58c18d21..12401042 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1314,13 +1314,15 @@ do_estimate()
echo -e "Encrypted kdump target requires extra memory, assuming using the keyslot with maximum memory requirement\n"
fi
- estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size + crypt_size))
+ estimated_size=$((kernel_size + mod_size + initrd_size + runtime_size))
if [[ $baseline_size -gt $estimated_size ]]; then
recommended_size=$baseline_size
else
recommended_size=$estimated_size
fi
+ recommended_size=$((recommended_size + crypt_size))
+
echo "Reserved crashkernel: $((reserved_size / size_mb))M"
echo "Recommended crashkernel: $((recommended_size / size_mb))M"
echo
--
2.40.1
2 months, 4 weeks
[PATCH] spec: kdump/ppc64: make servicelog_notify silent when there are no errors
by Lichen Liu
There is confusing message in /var/log/anaconda/packaging.log when installing
kexec-tools during the system installation on ppc64le:
Event Notification Registration successful (id: 1)
Make servicelog_notify slient when there are no erros.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
kexec-tools.spec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec
index d7d2947..51a16ba 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -268,7 +268,7 @@ touch /etc/kdump.conf
%ifarch ppc64 ppc64le
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null
-servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin
+servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null
%endif
# This portion of the script is temporary. Its only here
@@ -299,7 +299,7 @@ fi
%preun
%ifarch ppc64 ppc64le
-servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh
+servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/dev/null
%endif
%systemd_preun kdump.service
--
2.40.1
3 months, 1 week
[PATCH 1/3] tests: generate correct RPM name
by Coiby Xu
Tests failed to run against Fedora 37 or newer cloud images because of
the following error,
It's a image with multiple partitions, using last partition as main partition
'xxx/tests/build/x86_64/kexec-tools-2.0.26-5.fc37.src.rpm' not found
/dev/nbd0 disconnected
make: *** [Makefile:73: xxx/tests/output/test-base-image] Error 1
This is because starting with Fedora 37, rpm changes its API,
# Fedora >= 37
$ rpm -q --specfile kexec-tools.spec
kexec-tools-2.0.26-5.fc37.src
# Fedora 36
$ rpm -q --specfile kexec-tools.spec
kexec-tools-2.0.26-5.fc36
The tests depends on rpm to generate correct RPM name. Fix this issue by
removing the trailing .src from the output of "rpm -q --specfile".
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
tests/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile b/tests/Makefile
index 05fda1da..45688caf 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -30,7 +30,7 @@ RPMDEFINE = --define '_sourcedir $(REPO)'\
KEXEC_TOOLS_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*))
KEXEC_TOOLS_TEST_SRC = $(wildcard $(REPO)/tests/scripts/**/*)
-KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 .)
+KEXEC_TOOLS_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 . | sed -e 's#.src#.$(ARCH)#')
KEXEC_TOOLS_RPM = $(BUILD_ROOT)/$(ARCH)/$(KEXEC_TOOLS_NVR).rpm
all: $(TEST_ROOT)/output/test-base-image
--
2.40.1
3 months, 1 week
[PATCH] kdump-lib: Match 64k debug kernel in prepare_kdump_bootinfo()
by Pingfan Liu
For kernel 64k variant, it terminates with substring 64k-debug, e.g.
vmlinuz-5.14.0-327.el9.aarch64+64k-debug.
Providing an extra matching pattern to filter out it.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
---
kdump-lib.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 9e818d3..4290be3 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -614,7 +614,8 @@ prepare_kdump_bootinfo()
return 1
fi
- if [[ "$KDUMP_KERNEL" == *"+debug" ]]; then
+ # For 64k variant, e.g. vmlinuz-5.14.0-327.el9.aarch64+64k-debug
+ if [[ "$KDUMP_KERNEL" == *"+debug" || "$KDUMP_KERNEL" == *"64k-debug" ]]; then
dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value."
fi
--
2.31.1
3 months, 1 week
[PATCH] kdumpctl: Fix temporary directory location
by Philipp Rudo
The temporary directory is currently created under the current working
directory. That alone isn't ideal but works most of the time. However,
it will fail when the current working directory is not writable. So make
sure the directory is created within TMPDIR.
Fixes: ea00b7d ("kdumpctl: Move temp file in get_kernel_size to global temp dir")
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
---
kdumpctl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 58c18d2..7e561fd 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -45,7 +45,7 @@ if ! dlog_init; then
exit 1
fi
-KDUMP_TMPDIR=$(mktemp -d kdump.XXXX)
+KDUMP_TMPDIR=$(mktemp --tmpdir -d kdump.XXXX)
trap '
ret=$?;
rm -rf "$KDUMP_TMPDIR"
--
2.41.0
3 months, 1 week
[PATCHv3] kdumpctl: Fix the matching of plus symbol by grep's EREs
by Pingfan Liu
After introducing 64k variant kernel on aarch64, an example kernel name
looks like "vmlinuz-5.14.0-316.el9.aarch64+64k". To match the plus
symbol, it demands an escape charater.
Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
---
v2 -> v3:
using bash builtin string replacement
kdumpctl | 3 +++
spec/kdumpctl_general_spec.sh | 17 +++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 48cd33d..0a0bab2 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1406,6 +1406,9 @@ _filter_grubby_kernel_str()
_find_kernel_path_by_release()
{
local _release="$1" _grubby_kernel_str _kernel_path
+
+ # Insert '/' before '+' to cope with grep's EREs
+ _release=${_release//+/\\+}
_grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(\/\w+)?\"$")
_kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str")
if [[ -z $_kernel_path ]]; then
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index bb5755c..7304cd4 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -222,6 +222,23 @@ Describe 'kdumpctl'
End
End
+ Describe '_find_kernel_path_by_release()'
+ grubby() {
+ echo -e 'kernel="/boot/vmlinuz-6.2.11-200.fc37.x86_64"\nkernel="/boot/vmlinuz-5.14.0-322.el9.aarch64"\nkernel="/boot/vmlinuz-5.14.0-316.el9.aarch64+64k"'
+ }
+
+ Parameters
+ # parameter answer
+ vmlinuz-6.2.11-200.fc37.x86_64 /boot/vmlinuz-6.2.11-200.fc37.x86_64
+ vmlinuz-5.14.0-322.el9.aarch64 /boot/vmlinuz-5.14.0-322.el9.aarch64
+ vmlinuz-5.14.0-316.el9.aarch64+64k /boot/vmlinuz-5.14.0-316.el9.aarch64+64k
+ End
+ It 'returns the kernel path for the given release'
+ When call _find_kernel_path_by_release "$1"
+ The output should equal "$2"
+ End
+ End
+
Describe 'parse_config()'
bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX)
cleanup() {
--
2.31.1
3 months, 2 weeks
[PATCHv5 0/4] add support for 64k variant
by Pingfan Liu
6k aarch64 has significant memory consumption more than 4k variant, and
requires an separated crashkernel formula.
This series generates the formula dynamiclly based on the system
environment.
v4 -> v5:
fix complain by shellcheck on [2/4]
rebase to latest rawhide (commit 29fe563 kdump.conf: redirect unknown architecture warning to stderr)
Pingfan Liu (4):
kdump-lib: Introduce a help function _crashkernel_add()
kdump-lib: Introduce parse_kver_from_path() to get kernel version from
its path name
kdump-lib: add support for 64K aarch64
kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately
kdump-lib.sh | 138 ++++++++++++++++++++++++++++++++++++++++-
kdumpctl | 6 +-
spec/kdump-lib_spec.sh | 20 ++++++
3 files changed, 161 insertions(+), 3 deletions(-)
--
2.31.1
3 months, 2 weeks
[PATCHv4 0/4] add support for 64k variant
by Pingfan Liu
6k aarch64 has significant memory consumption more than 4k variant, and
requires an separated crashkernel formula.
This series generates the formula dynamiclly based on the system
environment.
---
v3 -> v4
Introduce parse_kver_from_path() to extract kernel version info
Simplify bash return statement
Pingfan Liu (4):
kdump-lib: Introduce a help function _crashkernel_add()
kdump-lib: Introduce parse_kver_from_path() to get kernel version from
its path name
kdump-lib: add support for 64K aarch64
kdump-lib: Evaluate the memory consumption by smmu and mlx5 separately
kdump-lib.sh | 138 ++++++++++++++++++++++++++++++++++++++++-
kdumpctl | 6 +-
spec/kdump-lib_spec.sh | 20 ++++++
3 files changed, 161 insertions(+), 3 deletions(-)
--
2.31.1
3 months, 2 weeks