Enable erofs support for the kdump initrd

Resolves: RHEL-50942
Upstream: https://github.com/rhkdump/kdump-utils.git
Conflict: Dropped hunks concerning OVS bridge support in patch 3 and 5
	   due to missing 224d310 ("Support setting up Open vSwitch
	   (Ovs) Bridge network")

Also contains upstream commit

commit 2970176d9e9b7b6a1191a9ee54423d2f1c56fbaf
Author: Philipp Rudo <prudo@redhat.com>
Date:   Tue Sep 24 10:39:32 2024 +0200

    spec: fix patching of files in subdirectories

    With 23df04b ("dracut: create sub-directories for dracut modules") the
    dracut modules were moved to subdirectories. This causes problems when
    someone wants to include a patch to the spec file to change one of the
    files in those subdirectories. Reason is that '%autosetup' in the spec
    file calls 'patch' per default. 'patch' however, will strip all
    directories when it is called without option -p. Which means that it
    will search the file in the root directory and then fail because it
    cannot find it. Thus add option -p1 to '%autosetup' which will be passed
    on to 'patch'. Choose -p1 as that will work with the most common patch
    creation tools like git and packit.

    Signed-off-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Philipp Rudo 2024-09-27 15:24:24 +02:00
parent c53ac4eb20
commit d38412baaf
17 changed files with 2646 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From 628387661812c74ddd613fcb3ac2203bbd6f1204 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 13:59:41 +0200
Subject: [PATCH 01/16] editorconfig: set indent_size=8
The indent_size gives the number of spaces an indentation should have.
When combined with indent_style=tab and tab_width=X the leading X spaces
are replaced by a tab. If tab_width is omitted it is set to the value of
indent_size. For the current settings this means that every level of
indentation is indented by a single space which gets replaced by a tab.
The tab again is displayed by a single space, if you set your editor to
follow the editconfig. This is not only barely readable but also impacts
line breaks for over long lines. Thus set indent_size=8 to better match
the way over long lines are broken at the moment.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
.editorconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.editorconfig b/.editorconfig
index b343f27..98bc39a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -11,7 +11,7 @@ shell_variant = posix
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
-indent_size = 1
+indent_size = 8
switch_case_indent = false
function_next_line = true
binary_next_line = false
--
2.46.1

View File

@ -0,0 +1,187 @@
From c986a97b64060fdc0f5ae67fb822163a7fd5a884 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Mon, 1 Jul 2024 15:06:15 +0200
Subject: [PATCH 02/16] dracut: create sub-directories for dracut modules
With the introduction of the Makefile it is now easy to move files into
different sub-directories. Thus create a sub-directory for each of the
dracut modules and move their files there. This not only cleans up the
main directory but also simplifies the Makefile and prevents bugs like
the one fixed in 5109f11 ("Makefile: Fix early-kdump file names").
One nice site effect by using 'cp' instead of 'install' is that file
permissions from the repo are preserved. So instead of manually setting
the file permissions for each call to 'install' we can now simply change
(and commit) the file permissions in the repo. Like it is done for
99kdumpbase/monitor_dd_progress.sh and 99zz-fadumpinit/module-setup.sh
in this commit.
Also adjust the .editorconfig to the new structure.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
.editorconfig | 10 ----------
Makefile | 19 +++----------------
dracut/.editorconfig | 9 +++++++++
.../99earlykdump/early-kdump.sh | 0
.../99earlykdump/module-setup.sh | 0
dracut/99kdumpbase/.editorconfig | 3 +++
.../99kdumpbase/kdump-capture.service | 0
.../99kdumpbase/kdump-emergency.service | 0
.../99kdumpbase/kdump-emergency.target | 0
.../99kdumpbase/kdump.sh | 0
.../99kdumpbase/module-setup.sh | 0
.../99kdumpbase/monitor_dd_progress.sh | 0
dracut/99zz-fadumpinit/.editorconfig | 3 +++
.../99zz-fadumpinit/init-fadump.sh | 0
.../99zz-fadumpinit/module-setup.sh | 0
15 files changed, 18 insertions(+), 26 deletions(-)
create mode 100644 dracut/.editorconfig
rename dracut-early-kdump.sh => dracut/99earlykdump/early-kdump.sh (100%)
rename dracut-early-kdump-module-setup.sh => dracut/99earlykdump/module-setup.sh (100%)
create mode 100644 dracut/99kdumpbase/.editorconfig
rename dracut-kdump-capture.service => dracut/99kdumpbase/kdump-capture.service (100%)
rename dracut-kdump-emergency.service => dracut/99kdumpbase/kdump-emergency.service (100%)
rename dracut-kdump-emergency.target => dracut/99kdumpbase/kdump-emergency.target (100%)
rename dracut-kdump.sh => dracut/99kdumpbase/kdump.sh (100%)
rename dracut-module-setup.sh => dracut/99kdumpbase/module-setup.sh (100%)
rename dracut-monitor_dd_progress.sh => dracut/99kdumpbase/monitor_dd_progress.sh (100%)
mode change 100644 => 100755
create mode 100644 dracut/99zz-fadumpinit/.editorconfig
rename dracut-fadump-init-fadump.sh => dracut/99zz-fadumpinit/init-fadump.sh (100%)
rename dracut-fadump-module-setup.sh => dracut/99zz-fadumpinit/module-setup.sh (100%)
mode change 100644 => 100755
diff --git a/.editorconfig b/.editorconfig
index 98bc39a..dd58ec8 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -20,13 +20,3 @@ space_redirects = true
# Some scripts will only run with bash
[{mkfadumprd,mkdumprd,kdumpctl,kdump-lib.sh}]
shell_variant = bash
-
-# Use dracut code style for *-module-setup.sh
-[*-module-setup.sh,dracut-early-kdump.sh]
-shell_variant = bash
-indent_style = space
-indent_size = 4
-switch_case_indent = true
-function_next_line = false
-binary_next_line = true
-space_redirects = true
diff --git a/Makefile b/Makefile
index 538e4f4..5029a59 100644
--- a/Makefile
+++ b/Makefile
@@ -12,27 +12,14 @@ udevrulesdir ?= ${libdir}/udev/rules.d
systemdsystemunitdir ?= ${libdir}/systemd/system/
ARCH ?= $(shell uname -m)
dracutmoddir = $(DESTDIR)${libdir}/dracut/modules.d
-kdumpbasemoddir = $(dracutmoddir)/99kdumpbase
dracut-modules:
mkdir -p $(dracutmoddir)
- mkdir -p -m755 $(kdumpbasemoddir)
-
- install -m 755 dracut-kdump.sh $(kdumpbasemoddir)/kdump.sh
- install -m 755 dracut-module-setup.sh $(kdumpbasemoddir)/module-setup.sh
- install -m 755 dracut-monitor_dd_progress.sh $(kdumpbasemoddir)/monitor_dd_progress.sh
- install -m 644 dracut-kdump-emergency.service $(kdumpbasemoddir)/kdump-emergency.service
- install -m 644 dracut-kdump-capture.service $(kdumpbasemoddir)/kdump-capture.service
- install -m 644 dracut-kdump-emergency.target $(kdumpbasemoddir)/kdump-emergency.target
-
- mkdir -p -m755 $(dracutmoddir)/99earlykdump
- install -m 755 dracut-early-kdump.sh $(dracutmoddir)/99earlykdump/early-kdump.sh
- install -m 755 dracut-early-kdump-module-setup.sh $(dracutmoddir)/99earlykdump/module-setup.sh
+ cp -r dracut/99kdumpbase $(dracutmoddir)
+ cp -r dracut/99earlykdump $(dracutmoddir)
ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH)))
- mkdir -p -m755 $(dracutmoddir)/99zz-fadumpinit
- install -m 755 dracut-fadump-init-fadump.sh $(dracutmoddir)/99zz-fadumpinit/init-fadump.sh
- install -m 755 dracut-fadump-module-setup.sh $(dracutmoddir)/99zz-fadumpinit/module-setup.sh
+ cp -r dracut/99zz-fadumpinit $(dracutmoddir)
endif
kdump-conf: gen-kdump-conf.sh
diff --git a/dracut/.editorconfig b/dracut/.editorconfig
new file mode 100644
index 0000000..254f870
--- /dev/null
+++ b/dracut/.editorconfig
@@ -0,0 +1,9 @@
+# Use dracut code style for dracut modules
+[*]
+shell_variant = bash
+indent_style = space
+indent_size = 4
+switch_case_indent = true
+function_next_line = false
+binary_next_line = true
+space_redirects = true
diff --git a/dracut-early-kdump.sh b/dracut/99earlykdump/early-kdump.sh
similarity index 100%
rename from dracut-early-kdump.sh
rename to dracut/99earlykdump/early-kdump.sh
diff --git a/dracut-early-kdump-module-setup.sh b/dracut/99earlykdump/module-setup.sh
similarity index 100%
rename from dracut-early-kdump-module-setup.sh
rename to dracut/99earlykdump/module-setup.sh
diff --git a/dracut/99kdumpbase/.editorconfig b/dracut/99kdumpbase/.editorconfig
new file mode 100644
index 0000000..feb7df2
--- /dev/null
+++ b/dracut/99kdumpbase/.editorconfig
@@ -0,0 +1,3 @@
+# These files run in the initrd and need to be posix compliant
+[{monitor_dd_progress.sh,kdump.sh}]
+shell_variant = posix
diff --git a/dracut-kdump-capture.service b/dracut/99kdumpbase/kdump-capture.service
similarity index 100%
rename from dracut-kdump-capture.service
rename to dracut/99kdumpbase/kdump-capture.service
diff --git a/dracut-kdump-emergency.service b/dracut/99kdumpbase/kdump-emergency.service
similarity index 100%
rename from dracut-kdump-emergency.service
rename to dracut/99kdumpbase/kdump-emergency.service
diff --git a/dracut-kdump-emergency.target b/dracut/99kdumpbase/kdump-emergency.target
similarity index 100%
rename from dracut-kdump-emergency.target
rename to dracut/99kdumpbase/kdump-emergency.target
diff --git a/dracut-kdump.sh b/dracut/99kdumpbase/kdump.sh
similarity index 100%
rename from dracut-kdump.sh
rename to dracut/99kdumpbase/kdump.sh
diff --git a/dracut-module-setup.sh b/dracut/99kdumpbase/module-setup.sh
similarity index 100%
rename from dracut-module-setup.sh
rename to dracut/99kdumpbase/module-setup.sh
diff --git a/dracut-monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh
old mode 100644
new mode 100755
similarity index 100%
rename from dracut-monitor_dd_progress.sh
rename to dracut/99kdumpbase/monitor_dd_progress.sh
diff --git a/dracut/99zz-fadumpinit/.editorconfig b/dracut/99zz-fadumpinit/.editorconfig
new file mode 100644
index 0000000..fdcbad4
--- /dev/null
+++ b/dracut/99zz-fadumpinit/.editorconfig
@@ -0,0 +1,3 @@
+# These files run in the initrd and need to be posix compliant
+[{init-fadump.sh}]
+shell_variant = posix
diff --git a/dracut-fadump-init-fadump.sh b/dracut/99zz-fadumpinit/init-fadump.sh
similarity index 100%
rename from dracut-fadump-init-fadump.sh
rename to dracut/99zz-fadumpinit/init-fadump.sh
diff --git a/dracut-fadump-module-setup.sh b/dracut/99zz-fadumpinit/module-setup.sh
old mode 100644
new mode 100755
similarity index 100%
rename from dracut-fadump-module-setup.sh
rename to dracut/99zz-fadumpinit/module-setup.sh
--
2.46.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
From 3487bc2c6b24331eca01f2d0c2d30016e8686eaf Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 14:49:44 +0200
Subject: [PATCH 04/16] 99kdumpbase: drop unnecessary 2>&1
Bash allows to redirect/pipe the stdout and stderr together using
'&>' and '|&'. Make use of this to simplify the code a little bit.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/module-setup.sh | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 8e0bccc..56215e4 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -488,14 +488,13 @@ kdump_setup_znet() {
fi
for _netif in $1; do
- chzdev --export "$_tempfile" --active --by-interface "$_netif" \
- 2>&1 | ddebug
+ chzdev --export "$_tempfile" --active --by-interface "$_netif" |& ddebug
sed -i -e 's/^\[active /\[persistent /' "$_tempfile"
ddebug < "$_tempfile"
chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \
- --yes --no-root-update --force 2>&1 | ddebug
+ --yes --no-root-update --force |& ddebug
lszdev --configured --persistent --info --by-interface "$_netif" \
- --base "/etc=$initdir/etc" 2>&1 | ddebug
+ --base "/etc=$initdir/etc" |& ddebug
done
rm -f "$_tempfile"
}
@@ -888,7 +887,7 @@ is_localhost() {
get_pcs_fence_kdump_nodes() {
local nodes
- pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1
+ pcs cluster sync &> /dev/null && pcs cluster cib-upgrade &> /dev/null
# get cluster nodes from cluster cib, get interface and ip address
nodelist=$(pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -)
--
2.46.1

View File

@ -0,0 +1,247 @@
From 441843d66d25c8c144caeb5d4aa78b38453295e9 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:01:30 +0200
Subject: [PATCH 05/16] 99kdumpbase: fix shellcheck warnings
Fix the shellcheck warnings for 99kdumpbase. With this
$ shellcheck -x dracut/99kdumpbase/*.sh
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/kdump.sh | 32 +++++++++++-------
dracut/99kdumpbase/module-setup.sh | 40 +++++++++++++++++++++--
dracut/99kdumpbase/monitor_dd_progress.sh | 6 ++--
3 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/dracut/99kdumpbase/kdump.sh b/dracut/99kdumpbase/kdump.sh
index 22586b1..dea83ee 100755
--- a/dracut/99kdumpbase/kdump.sh
+++ b/dracut/99kdumpbase/kdump.sh
@@ -3,8 +3,11 @@
# The main kdump routine in capture kernel, bash may not be the
# default shell. Any code added must be POSIX compliant.
+# shellcheck source=/dev/null
. /lib/dracut-lib.sh
+# shellcheck source=SCRIPTDIR/../../kdump-logger.sh
. /lib/kdump-logger.sh
+# shellcheck source=SCRIPTDIR/../../kdump-lib-initramfs.sh
. /lib/kdump-lib-initramfs.sh
#initiate the kdump logger
@@ -262,11 +265,14 @@ dump_to_rootfs() {
kdump_emergency_shell() {
ddebug "Switching to kdump emergency shell..."
+ # shellcheck source=/dev/null
[ -f /etc/profile ] && . /etc/profile
export PS1='kdump:${PWD}# '
+ # shellcheck source=/dev/null
. /lib/dracut-lib.sh
if [ -f /dracut-state.sh ]; then
+ # shellcheck source=/dev/null
. /dracut-state.sh 2> /dev/null
fi
@@ -293,16 +299,16 @@ kdump_emergency_shell() {
do_failure_action() {
dinfo "Executing failure action $FAILURE_ACTION"
- eval $FAILURE_ACTION
+ eval "$FAILURE_ACTION"
}
do_final_action() {
dinfo "Executing final action $FINAL_ACTION"
- eval $FINAL_ACTION
+ eval "$FINAL_ACTION"
}
do_dump() {
- eval $DUMP_INSTRUCTION
+ eval "$DUMP_INSTRUCTION"
_ret=$?
if [ $_ret -ne 0 ]; then
@@ -390,7 +396,7 @@ dump_ssh() {
dinfo "saving to $2:$_ssh_dir"
cat /var/lib/random-seed > /dev/urandom
- ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1
+ ssh -q "$_ssh_opt" "$2" mkdir -p "$_ssh_dir" || return 1
save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2"
@@ -402,17 +408,19 @@ dump_ssh() {
save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
- scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete"
+ scp -q "$_ssh_opt" /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete"
_ret=$?
_vmcore="vmcore"
else
- $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'"
+ # shellcheck disable=SC2029
+ $CORE_COLLECTOR /proc/vmcore | ssh "$_ssh_opt" "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'"
_ret=$?
_vmcore="vmcore.flat"
fi
if [ $_ret -eq 0 ]; then
- ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'"
+ # shellcheck disable=SC2029
+ ssh "$_ssh_opt" "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'"
_ret=$?
if [ $_ret -ne 0 ]; then
derror "moving vmcore failed, exitcode:$_ret"
@@ -442,12 +450,13 @@ save_opalcore_ssh() {
dinfo "saving opalcore:$OPALCORE to $3:$1"
- if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then
+ if ! scp "$2" "$OPALCORE" "$4:$1/opalcore-incomplete"; then
derror "saving opalcore failed"
return 1
fi
- ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore"
+ # shellcheck disable=SC2029
+ ssh "$2" "$3" mv "$1/opalcore-incomplete" "$1/opalcore"
dinfo "saving opalcore complete"
return 0
}
@@ -458,8 +467,9 @@ save_opalcore_ssh() {
# $4: ssh address in <user>@<host> format
save_vmcore_dmesg_ssh() {
dinfo "saving vmcore-dmesg.txt to $4:$2"
- if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then
- ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt"
+ # shellcheck disable=SC2029
+ if "$1" /proc/vmcore | ssh "$3" "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then
+ ssh -q "$3" "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt"
dinfo "saving vmcore-dmesg.txt complete"
else
derror "saving vmcore-dmesg.txt failed"
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 56215e4..70dc8ca 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -11,12 +11,14 @@ _get_kdump_netifs() {
}
kdump_module_init() {
+ # shellcheck disable=SC2154
if ! [[ -d "${initdir}/tmp" ]]; then
mkdir -p "${initdir}/tmp"
fi
mkdir -p "$_DRACUT_KDUMP_NM_TMP_DIR"
+ # shellcheck source=SCRIPTDIR/../../kdump-lib.sh
. /lib/kdump/kdump-lib.sh
}
@@ -38,6 +40,7 @@ depends() {
kdump_module_init
add_opt_module() {
+ # shellcheck disable=SC2154
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
@@ -56,7 +59,7 @@ depends() {
fi
if is_lvm2_thinp_dump_target; then
- if grep -q lvmthinpool-monitor <<< $(dracut --list-modules); then
+ if grep -q lvmthinpool-monitor <<< "$(dracut --list-modules)"; then
add_opt_module lvmthinpool-monitor
else
dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057."
@@ -481,12 +484,14 @@ kdump_setup_vlan() {
# setup s390 znet
kdump_setup_znet() {
local _netif
- local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX)
+ local _tempfile
if [[ "$(uname -m)" != "s390x" ]]; then
return
fi
+ _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX)
+
for _netif in $1; do
chzdev --export "$_tempfile" --active --by-interface "$_netif" |& ddebug
sed -i -e 's/^\[active /\[persistent /' "$_tempfile"
@@ -830,6 +861,7 @@ kdump_check_iscsi_targets() {
# If our prerequisites are not met, fail anyways.
type -P iscsistart > /dev/null || return 1
+ # shellcheck disable=SC2317
kdump_check_setup_iscsi() {
local _dev
_dev=$1
@@ -896,6 +928,7 @@ get_pcs_fence_kdump_nodes() {
for node in ${nodelist}; do
# convert $node from 'uname="nodeX"' to 'nodeX'
eval "$node"
+ # shellcheck disable=SC2154
nodename="$uname"
# Skip its own node name
if is_localhost "$nodename"; then
@@ -910,6 +943,7 @@ get_pcs_fence_kdump_nodes() {
# retrieves fence_kdump args from config file
get_pcs_fence_kdump_args() {
if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then
+ # shellcheck disable=SC1090
. "$FENCE_KDUMP_CONFIG_FILE"
echo "$FENCE_KDUMP_OPTS"
fi
@@ -1013,6 +1047,7 @@ install() {
kdump_install_random_seed
fi
dracut_install -o /etc/adjtime /etc/localtime
+ # shellcheck disable=SC2154
inst "$moddir/monitor_dd_progress.sh" "/kdumpscripts/monitor_dd_progress.sh"
inst "/bin/dd" "/bin/dd"
inst "/bin/tail" "/bin/tail"
@@ -1031,6 +1066,7 @@ install() {
inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
+ # shellcheck disable=SC2154
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
# Replace existing emergency service and emergency target
diff --git a/dracut/99kdumpbase/monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh
index f9b03d5..f6ed409 100755
--- a/dracut/99kdumpbase/monitor_dd_progress.sh
+++ b/dracut/99kdumpbase/monitor_dd_progress.sh
@@ -11,15 +11,15 @@ done
while true; do
sleep 5
- if [ ! -d /proc/$DD_PID ]; then
+ if [ ! -d /proc/"$DD_PID" ]; then
break
fi
- kill -s USR1 $DD_PID
+ kill -s USR1 "$DD_PID"
CURRENT_SIZE=$(tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g")
[ -n "$CURRENT_SIZE" ] && {
CURRENT_MB=$((CURRENT_SIZE / 1048576))
- echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r"
+ printf "Copied %s MB / %s MB\r" "$CURRENT_MB" "$SRC_FILE_MB"
}
done
--
2.46.1

View File

@ -0,0 +1,86 @@
From 1b262cde62fed38f124ed2cdf408ae01de508efc Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:12:35 +0200
Subject: [PATCH 06/16] 99earlykdump: fix shellcheck warnings
Fix the shellcheck warnings for 99earlykdump. With this
$ shellcheck -x dracut/99earlykdump/*.sh
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99earlykdump/early-kdump.sh | 5 +++++
dracut/99earlykdump/module-setup.sh | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/dracut/99earlykdump/early-kdump.sh b/dracut/99earlykdump/early-kdump.sh
index a355010..c56ed82 100755
--- a/dracut/99earlykdump/early-kdump.sh
+++ b/dracut/99earlykdump/early-kdump.sh
@@ -8,9 +8,13 @@ EARLY_KDUMP_KERNEL=""
EARLY_KDUMP_CMDLINE=""
EARLY_KEXEC_ARGS=""
+# shellcheck source=/dev/null
. /etc/sysconfig/kdump
+# shellcheck source=/dev/null
. /lib/dracut-lib.sh
+# shellcheck source=SCRIPTDIR/../../kdump-lib.sh
. /lib/kdump-lib.sh
+# shellcheck source=SCRIPTDIR/../../kdump-logger.sh
. /lib/kdump-logger.sh
# initiate the kdump logger
@@ -41,6 +45,7 @@ early_kdump_load() {
prepare_parameters
+ # shellcheck disable=SC2153
EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
# Here, only output the messages, but do not save these messages
diff --git a/dracut/99earlykdump/module-setup.sh b/dracut/99earlykdump/module-setup.sh
index 0451118..98486c5 100755
--- a/dracut/99earlykdump/module-setup.sh
+++ b/dracut/99earlykdump/module-setup.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+# shellcheck source=/dev/null
. /etc/sysconfig/kdump
KDUMP_KERNEL=""
@@ -19,11 +20,13 @@ depends() {
}
prepare_kernel_initrd() {
+ # shellcheck source=SCRIPTDIR/../../kdump-lib.sh
. /lib/kdump/kdump-lib.sh
prepare_kdump_bootinfo
# $kernel is a variable from dracut
+ # shellcheck disable=SC2154
if [[ $KDUMP_KERNELVER != "$kernel" ]]; then
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
"but the initramfs is generated for kernel version '$kernel'"
@@ -54,6 +57,7 @@ install() {
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst_script "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump/kdump-lib-initramfs.sh"
inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
+ # shellcheck disable=SC2154
inst_hook cmdline 00 "$moddir/early-kdump.sh"
inst_binary "$KDUMP_KERNEL"
inst_binary "$KDUMP_INITRD"
@@ -61,5 +65,6 @@ install() {
ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump"
ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump"
+ # shellcheck disable=SC2154
chmod -x "${initdir}/$KDUMP_KERNEL"
}
--
2.46.1

View File

@ -0,0 +1,51 @@
From 3cb964855f508e8aabc91c297d9efc0cab766b0c Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:23:26 +0200
Subject: [PATCH 07/16] 99zz-fadumpinit: fix shellcheck warnings
Fix the shellcheck warnings for 99zz-fadumpinit. With this
$ shellcheck -x dracut/99zz-fadumpinit/*.sh
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99zz-fadumpinit/init-fadump.sh | 6 ++----
dracut/99zz-fadumpinit/module-setup.sh | 2 ++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dracut/99zz-fadumpinit/init-fadump.sh b/dracut/99zz-fadumpinit/init-fadump.sh
index 933afc0..911cf9e 100755
--- a/dracut/99zz-fadumpinit/init-fadump.sh
+++ b/dracut/99zz-fadumpinit/init-fadump.sh
@@ -14,10 +14,8 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o
mkdir /newroot
mount -t ramfs ramfs /newroot
- if [ $ROOTFS_IS_RAMFS ]; then
- for FILE in $(ls -A /fadumproot/); do
- mv /fadumproot/$FILE /newroot/
- done
+ if [ "$ROOTFS_IS_RAMFS" ]; then
+ mv /fadumproot/* /newroot/
exec switch_root /newroot /init
else
mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot
diff --git a/dracut/99zz-fadumpinit/module-setup.sh b/dracut/99zz-fadumpinit/module-setup.sh
index f062486..8fa5e16 100755
--- a/dracut/99zz-fadumpinit/module-setup.sh
+++ b/dracut/99zz-fadumpinit/module-setup.sh
@@ -9,7 +9,9 @@ depends() {
}
install() {
+ # shellcheck disable=SC2154
mv -f "$initdir/init" "$initdir/init.dracut"
+ # shellcheck disable=SC2154
inst_script "$moddir/init-fadump.sh" /init
chmod a+x "$initdir/init"
--
2.46.1

View File

@ -0,0 +1,75 @@
From e7813e45234e615bf5c937b30294c63c4885c5f9 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Wed, 14 Aug 2024 12:58:17 +0200
Subject: [PATCH 08/16] kdumpctl: fix shellcheck warnings
Fix the shellcheck warnings for kdumpctl. With this
$ $ shellcheck -x kdumpctl
now returns without finding.
While at it make use of the special SCRIPTDIR value for source-path.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
kdumpctl | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 1b6f7b9..612a159 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -33,9 +33,9 @@ if [[ ${__SOURCED__:+x} ]]; then
else
KDUMP_LIB_PATH=/lib/kdump
fi
-# shellcheck source=./kdump-lib.sh
+# shellcheck source=SCRIPTDIR/kdump-lib.sh
. $KDUMP_LIB_PATH/kdump-lib.sh
-# shellcheck source=./kdump-logger.sh
+# shellcheck source=SCRIPTDIR/kdump-logger.sh
. $KDUMP_LIB_PATH/kdump-logger.sh
#initiate the kdump logger
@@ -1199,16 +1199,15 @@ get_kernel_size()
check_vmlinux "$img" && get_vmlinux_size "$img" && return 0
# That didn't work, so retry after decompression.
- try_decompress '\037\213\010' xy gunzip "$img" "$tmp" ||
+ if try_decompress '\037\213\010' xy gunzip "$img" "$tmp" ||
try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" ||
try_decompress 'BZh' xy bunzip2 "$img" "$tmp" ||
try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" ||
try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" ||
try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" ||
- try_decompress '(\265/\375' xxx unzstd "$img" "$tmp"
-
- # Finally check for uncompressed images or objects:
- [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0
+ try_decompress '(\265/\375' xxx unzstd "$img" "$tmp"; then
+ get_vmlinux_size "$tmp" && return 0
+ fi
# Fallback to use iomem
local _size=0 _seg
@@ -1475,14 +1474,14 @@ reset_crashkernel()
exit 1
fi
_opt_fadump=${_opt#*=}
- if ! _dump_mode=$(get_dump_mode_by_fadump_val $_opt_fadump); then
+ if ! _dump_mode=$(get_dump_mode_by_fadump_val "$_opt_fadump"); then
derror "failed to determine dump mode"
exit
fi
;;
--kernel=*)
_val=${_opt#*=}
- if ! _valid_grubby_kernel_path $_val; then
+ if ! _valid_grubby_kernel_path "$_val"; then
derror "Invalid $_opt, please specify a valid kernel path, ALL or DEFAULT"
exit
fi
--
2.46.1

View File

@ -0,0 +1,53 @@
From 6fca9109dadc087265ccd785fbd60003ea69318c Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:29:39 +0200
Subject: [PATCH 09/16] mkdumprd: fix shellcheck warnings
Fix the shellcheck warnings for mkdumprd. With this
$ shellcheck -x mkdumprd
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
mkdumprd | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 27eed5e..7a35217 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -11,8 +11,11 @@ if [[ -f /etc/sysconfig/kdump ]]; then
fi
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
-. $dracutbasedir/dracut-functions.sh
+# shellcheck source=/dev/null
+. "$dracutbasedir"/dracut-functions.sh
+# shellcheck source=SCRIPTDIR/kdump-lib.sh
. /lib/kdump/kdump-lib.sh
+# shellcheck source=SCRIPTDIR/kdump-logger.sh
. /lib/kdump/kdump-logger.sh
export IN_KDUMP=1
@@ -32,6 +35,7 @@ MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
+# shellcheck disable=SC2154
trap '
ret=$?;
is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
@@ -256,7 +260,7 @@ check_user_configured_target()
verify_core_collector()
{
local _cmd="${1%% *}"
- local _params="${1#${_cmd}}"
+ local _params="${1#"${_cmd}"}"
if [[ $_cmd != "makedumpfile" ]]; then
if is_raw_dump_target; then
--
2.46.1

View File

@ -0,0 +1,44 @@
From f2e4123828e8b0fd02c87fcc62089ee68891bf7d Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Wed, 14 Aug 2024 12:39:28 +0200
Subject: [PATCH 10/16] mkfadumprd: fix shellcheck warnings
Fix the shellcheck warnings for mkfadumprd. With this
$ shellcheck -x mkfadumprd
now returns without finding.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
mkfadumprd | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mkfadumprd b/mkfadumprd
index dd6840f..2fd09ad 100755
--- a/mkfadumprd
+++ b/mkfadumprd
@@ -7,8 +7,11 @@ if [[ -f /etc/sysconfig/kdump ]]; then
fi
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
-. $dracutbasedir/dracut-functions.sh
+# shellcheck source=/dev/null
+. "$dracutbasedir"/dracut-functions.sh
+# shellcheck source=SCRIPTDIR/kdump-lib.sh
. /lib/kdump/kdump-lib.sh
+# shellcheck source=SCRIPTDIR/kdump-logger.sh
. /lib/kdump/kdump-logger.sh
#initiate the kdump logger
@@ -19,6 +22,7 @@ fi
MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
+# shellcheck disable=SC2154
trap '
ret=$?;
[[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
--
2.46.1

View File

@ -0,0 +1,136 @@
From f3c33d3d9fdea2ff17e8435306d62c4d3973098a Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 15:11:41 +0200
Subject: [PATCH 11/16] mkdumprd: simplify handling of dracut arguments
There are currently three functions to add arguments to dracut. None of
these improve readability or add any other benefit. So remove the
functions and clean up the code a little bit.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
mkdumprd | 50 ++++++++++++++++++++------------------------------
1 file changed, 20 insertions(+), 30 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 7a35217..196f3f8 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -29,7 +29,16 @@ SSH_KEY_LOCATION=$DEFAULT_SSHKEY
SAVE_PATH=$(get_save_path)
extra_modules=""
-dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' --aggressive-strip -o "plymouth resume ifcfg earlykdump")
+declare -a dracut_args
+dracut_args+=(--add kdumpbase)
+dracut_args+=(--quiet)
+dracut_args+=(--hostonly)
+dracut_args+=(--hostonly-cmdline)
+dracut_args+=(--hostonly-i18n)
+dracut_args+=(--hostonly-mode strict)
+dracut_args+=(--hostonly-nics '')
+dracut_args+=(--aggressive-strip)
+dracut_args+=(--omit "plymouth resume ifcfg earlykdump")
MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
@@ -46,21 +55,6 @@ trap '
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
-add_dracut_arg()
-{
- dracut_args+=("$@")
-}
-
-add_dracut_mount()
-{
- add_dracut_arg "--mount" "$1"
-}
-
-add_dracut_sshkey()
-{
- add_dracut_arg "--sshkey" "$1"
-}
-
# caller should ensure $1 is valid and mounted in 1st kernel
to_mount()
{
@@ -286,11 +280,7 @@ verify_core_collector()
add_mount()
{
- local _mnt
-
- _mnt=$(to_mount "$@") || exit 1
-
- add_dracut_mount "$_mnt"
+ dracut_args+=(--mount "$(to_mount "$@")") || exit 1
}
#handle the case user does not specify the dump target explicitly
@@ -353,14 +343,14 @@ while read -r config_opt config_val; do
if [[ -z $_praw ]]; then
exit 1
fi
- add_dracut_arg "--device" "$_praw"
+ dracut_args+=(--device "$_praw")
check_size raw "$config_val"
;;
ssh)
if strstr "$config_val" "@"; then
mkdir_save_path_ssh "$config_val"
check_size ssh "$config_val"
- add_dracut_sshkey "$SSH_KEY_LOCATION"
+ dracut_args+=(--sshkey "$SSH_KEY_LOCATION")
else
perror_exit "Bad ssh dump target $config_val"
fi
@@ -375,11 +365,11 @@ while read -r config_opt config_val; do
# because we call dracut with --hostonly-mode strict. So manually install
# nfsv4-related drivers.
if [[ $(get_dracut_args_fstype "$config_val") == nfs* ]]; then
- add_dracut_arg "--add-drivers" nfs_layout_nfsv41_files
+ dracut_args+=(--add-drivers "nfs_layout_nfsv41_files")
fi
while read -r dracut_arg; do
- add_dracut_arg "$dracut_arg"
+ dracut_args+=("$dracut_arg")
done <<< "$(echo "$config_val" | xargs -n 1 echo)"
;;
*) ;;
@@ -391,14 +381,14 @@ handle_default_dump_target
if ! have_compression_in_dracut_args; then
if is_squash_available && dracut_have_option "--squash-compressor"; then
- add_dracut_arg "--squash-compressor" "zstd"
+ dracut_args+=("--squash-compressor" "zstd")
elif has_command zstd; then
- add_dracut_arg "--compress" "zstd"
+ dracut_args+=("--compress" "zstd")
fi
fi
if [[ -n $extra_modules ]]; then
- add_dracut_arg "--add-drivers" "$extra_modules"
+ dracut_args+=("--add-drivers" "$extra_modules")
fi
# TODO: The below check is not needed anymore with the introduction of
@@ -411,10 +401,10 @@ if ! is_fadump_capable; then
# so it doesn't affect the logic of check_dump_fs_modified().
is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")"
- add_dracut_arg "--no-hostonly-default-device"
+ dracut_args+=(--no-hostonly-default-device)
if fips-mode-setup --is-enabled 2> /dev/null; then
- add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)"
+ dracut_args+=(--add-device "$(findmnt -n -o SOURCE --target /boot)")
fi
fi
--
2.46.1

View File

@ -0,0 +1,47 @@
From 5f1d411c6c6a2118e368e649f3212a0a6e3b9680 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 16:38:40 +0200
Subject: [PATCH 12/16] mkdumprd: drop extra_modules variable
Add the drivers directly and drop the extra_modules variable.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
mkdumprd | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 196f3f8..e01682d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -28,7 +28,6 @@ fi
SSH_KEY_LOCATION=$DEFAULT_SSHKEY
SAVE_PATH=$(get_save_path)
-extra_modules=""
declare -a dracut_args
dracut_args+=(--add kdumpbase)
dracut_args+=(--quiet)
@@ -328,7 +327,7 @@ while read -r config_opt config_val; do
# remove inline comments after the end of a directive.
case "$config_opt" in
extra_modules)
- extra_modules="$extra_modules $config_val"
+ dracut_args+=(--add-drivers "$config_val")
;;
ext[234] | xfs | btrfs | minix | nfs | virtiofs)
check_user_configured_target "$config_val" "$config_opt"
@@ -387,10 +386,6 @@ if ! have_compression_in_dracut_args; then
fi
fi
-if [[ -n $extra_modules ]]; then
- dracut_args+=("--add-drivers" "$extra_modules")
-fi
-
# TODO: The below check is not needed anymore with the introduction of
# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
# but still sysroot.mount unit gets generated based on 'root=' kernel
--
2.46.1

View File

@ -0,0 +1,34 @@
From 7fb90ad5fa3de5248f2fe9cd37a6af839788ef4d Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 18:52:51 +0200
Subject: [PATCH 13/16] 99kdumpbase: drop check for lvmthinpool-monitor module
The lvmthinpool-moitor module was added with dracut 057 but the minimal
required dracut version in the Fedora spec file is dracut >=058. So we
can safely assume that the module is always present.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/module-setup.sh | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 70dc8ca..7508851 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -59,11 +59,7 @@ depends() {
fi
if is_lvm2_thinp_dump_target; then
- if grep -q lvmthinpool-monitor <<< "$(dracut --list-modules)"; then
- add_opt_module lvmthinpool-monitor
- else
- dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057."
- fi
+ add_opt_module lvmthinpool-monitor
fi
if [[ "$(uname -m)" == "s390x" ]]; then
--
2.46.1

View File

@ -0,0 +1,49 @@
From 13fc0a77b1b676b172f2bf85f44901b8fd832ab8 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 17:01:55 +0200
Subject: [PATCH 14/16] mkdumprd: drop check for dracut option
--squash-compressor
The option --squash-compressor was introduced with dracut 057 but the
minimal required dracut version in the Fedora spec file is dracut >=058.
So we can safely assume that the option is always present.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
kdump-lib.sh | 6 ------
mkdumprd | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index f46c2e9..ba853d9 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -58,12 +58,6 @@ has_command()
[[ -x $(command -v "$1") ]]
}
-dracut_have_option()
-{
- local _option=$1
- ! dracut "$_option" 2>&1 | grep -q "unrecognized option"
-}
-
perror_exit()
{
derror "$@"
diff --git a/mkdumprd b/mkdumprd
index e01682d..517ce19 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -379,7 +379,7 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- if is_squash_available && dracut_have_option "--squash-compressor"; then
+ if is_squash_available; then
dracut_args+=("--squash-compressor" "zstd")
elif has_command zstd; then
dracut_args+=("--compress" "zstd")
--
2.46.1

View File

@ -0,0 +1,111 @@
From 70212dd7796cfe0df6a9fe9e3cb9c7b62231ba33 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 17:09:32 +0200
Subject: [PATCH 15/16] mkdumprd: explicitly add dracut 99squash module
The handling of compression in the initrd currently is a total mess.
There are multiple problems:
1) It is handled in two different locations, mkdumprd and
99kdumpbase, making the code unnecessarily complex.
2) While mkdumprd only adds the --squash-compressor option when there is
no compression requested in kdump.conf:dracut_args, 99kdumpbase
unconditionally adds the 99squash module. But once 99squash is added
dracut ignores all compression options passed on the command line and
produces an uncompressed initrd (assuming the compression is done in
the squashfs image). So adding a compression option to dracut_args
will neither compress the initrd nor the squashfs image.
3) To depend on 99squash, 99kdumpbase only checks whether the required
kernel modules are present but doesn't check whether the
squashfs-tools are installed. This can lead to failures when building
the initrd as 99squash fails to install. At the moment this only
works as the dracut-squash rpm depends on the squashfs-tools. But
once support for erofs is added this might no longer be the case.
4) In case 99squash cannot be used mkdumprd compresses the initrd with
zstd. But that doesn't really makes sense. For one compressing the
initrd only reduces the on-disk size but not the memory usage during
runtime of the initrd. Plus in case no compression is specified
dracut will automatically compress the initrd. For that it checks for
the 'best' available compression algorithm with zstd being the
default.
Clean this mess up be moving everything to mkdumprd, only addding
99squash when there is no compression given in the dracut_args, drop
setting the --compress option and, only include 99squash when the
squashfs-tools are installed.
Note: Only checking the squashfs-tools is sufficient as it doesn't make
sense to have them installed, when the kernel doesn't support squashfs.
There might be a use case to build images that then get used on an other
machine where the kernel supports it. But as the initrd is build with
--hostonly that is no use case we need to consider for kdump.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/module-setup.sh | 6 ------
kdump-lib.sh | 10 ----------
mkdumprd | 7 +++----
3 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 7508851..34593e4 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -44,12 +44,6 @@ depends() {
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
- if is_squash_available; then
- add_opt_module squash
- else
- dwarning "Required modules to build a squashed kdump image is missing!"
- fi
-
if is_wdt_active; then
add_opt_module watchdog
fi
diff --git a/kdump-lib.sh b/kdump-lib.sh
index ba853d9..c14e75e 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -43,16 +43,6 @@ is_sme_or_sev_active()
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1
}
-is_squash_available()
-{
- local _version kmodule
-
- _version=$(_get_kdump_kernel_version)
- for kmodule in squashfs overlay loop; do
- modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1
- done
-}
-
has_command()
{
[[ -x $(command -v "$1") ]]
diff --git a/mkdumprd b/mkdumprd
index 517ce19..366bcdb 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -379,10 +379,9 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- if is_squash_available; then
- dracut_args+=("--squash-compressor" "zstd")
- elif has_command zstd; then
- dracut_args+=("--compress" "zstd")
+ if has_command mksquashfs; then
+ dracut_args+=(--add squash)
+ dracut_args+=(--squash-compressor zstd)
fi
fi
--
2.46.1

View File

@ -0,0 +1,88 @@
From eaf2c3678e20b81134a4411d93aa6699867c079f Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 18:31:25 +0200
Subject: [PATCH 16/16] mkdumprd: add support for 95squash-erofs
With dracut 104 support for erofs in 99squash was added. For that the
squashfs specific code was split from 99squash module into
95squash-squashfs and a new 95squash-erofs was added. The modules are
structured the way, that you can either add 99squash, which then picks
the 'best' back end, or one of the 95squash-{squashfs,erofs} if you want
to make sure which back end is used.
Unfortunately erofs doesn't support the same compression algorithms
squashfs supports. So explicitly set which image type we want so we can
set the correct --squash-compressor option.
Keep support for the old 99squash for the time being so newer versions
of kdump-utils can work with dracut <= 103.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
mkdumprd | 29 ++++++++++++++++++++++++++++-
mkfadumprd | 2 +-
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 366bcdb..8c1b191 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -54,6 +54,22 @@ trap '
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
+# check whether the given dracut module is installed. If multiple modules are
+# provided return true if any of them is installed.
+has_dracut_module()
+{
+ local -a _args
+ local _e
+
+ [[ $# -ge 1 ]] || return 1
+
+ for _e in "$@"; do
+ _args+=(-e "$_e")
+ done
+
+ grep -x -q "${_args[@]}" <<< "$(dracut --list-modules)"
+}
+
# caller should ensure $1 is valid and mounted in 1st kernel
to_mount()
{
@@ -379,7 +395,18 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- if has_command mksquashfs; then
+ # With dracut 104 the 99squash module got split up into 99squash and
+ # 95squash-squashfs as well as the new 95squash-erofs. Explicitly set
+ # which image type is required otherwise the requested compression
+ # algorithm might not be supported.
+ if has_dracut_module squash-squashfs && has_command mksquashfs; then
+ dracut_args+=(--add squash-squashfs)
+ dracut_args+=(--squash-compressor zstd)
+ elif has_dracut_module squash-erofs && has_command mkfs.erofs; then
+ dracut_args+=(--add squash-erofs)
+ dracut_args+=(--squash-compressor lz4hc)
+ elif has_command mksquashfs; then
+ # only true for dracut <= 103
dracut_args+=(--add squash)
dracut_args+=(--squash-compressor zstd)
fi
diff --git a/mkfadumprd b/mkfadumprd
index 2fd09ad..37dc05d 100755
--- a/mkfadumprd
+++ b/mkfadumprd
@@ -46,7 +46,7 @@ ddebug "rebuild fadump initrd: $FADUMP_INITRD"
# compression ratio and increases the size of the initramfs image.
# Don't compress the capture image as uncompressed image is needed immediately.
# Also, early microcode would not be needed here.
-if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --no-compress --no-early-microcode; then
+if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --omit squash-squashfs --omit squash-erofs --no-compress --no-early-microcode; then
perror_exit "mkfadumprd: failed to build image with dump capture support"
fi
--
2.46.1

View File

@ -8,6 +8,54 @@ Summary: Kernel crash dump collection utilities
License: GPL-2.0-only
URL: https://github.com/rhkdump/kdump-utils
Source0: https://github.com/rhkdump/kdump-utils/archive/v%{version}/%{name}-%{version}.tar.gz
# editorconfig: set indent_size=8
# Author: Philipp Rudo <prudo@redhat.com>
Patch1: 0001-editorconfig-set-indent_size-8.patch
# dracut: create sub-directories for dracut modules
# Author: Philipp Rudo <prudo@redhat.com>
Patch2: 0002-dracut-create-sub-directories-for-dracut-modules.patch
# dracut/*: fix coding style using shfmt
# Author: Philipp Rudo <prudo@redhat.com>
Patch3: 0003-dracut-fix-coding-style-using-shfmt.patch
# 99kdumpbase: drop unnecessary 2>&1
# Author: Philipp Rudo <prudo@redhat.com>
Patch4: 0004-99kdumpbase-drop-unnecessary-2-1.patch
# 99kdumpbase: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch5: 0005-99kdumpbase-fix-shellcheck-warnings.patch
# 99earlykdump: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch6: 0006-99earlykdump-fix-shellcheck-warnings.patch
# 99zz-fadumpinit: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch7: 0007-99zz-fadumpinit-fix-shellcheck-warnings.patch
# kdumpctl: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch8: 0008-kdumpctl-fix-shellcheck-warnings.patch
# mkdumprd: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch9: 0009-mkdumprd-fix-shellcheck-warnings.patch
# mkfadumprd: fix shellcheck warnings
# Author: Philipp Rudo <prudo@redhat.com>
Patch10: 0010-mkfadumprd-fix-shellcheck-warnings.patch
# mkdumprd: simplify handling of dracut arguments
# Author: Philipp Rudo <prudo@redhat.com>
Patch11: 0011-mkdumprd-simplify-handling-of-dracut-arguments.patch
# mkdumprd: drop extra_modules variable
# Author: Philipp Rudo <prudo@redhat.com>
Patch12: 0012-mkdumprd-drop-extra_modules-variable.patch
# 99kdumpbase: drop check for lvmthinpool-monitor module
# Author: Philipp Rudo <prudo@redhat.com>
Patch13: 0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch
# mkdumprd: drop check for dracut option --squash-compressor
# Author: Philipp Rudo <prudo@redhat.com>
Patch14: 0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch
# mkdumprd: explicitly add dracut 99squash module
# Author: Philipp Rudo <prudo@redhat.com>
Patch15: 0015-mkdumprd-explicitly-add-dracut-99squash-module.patch
# mkdumprd: add support for 95squash-erofs
# Author: Philipp Rudo <prudo@redhat.com>
Patch16: 0016-mkdumprd-add-support-for-95squash-erofs.patch
%ifarch ppc64 ppc64le
Requires(post): servicelog
@ -39,7 +87,7 @@ kdump kernel and initramfs to save the collected crash kernel dump to specified
target.
%prep
%autosetup
%autosetup -p1
%install
%make_install sbindir=%_sbindir