[PATCH V4] fadump: isolate fadump initramfs image within the default
one
by Hari Bathini
In case of fadump, the initramfs image has to be built to boot into
the production environment as well as to offload the active crash dump
to the specified dump target (for boot after crash). As the same image
would be used for both boot scenarios, it could not be built optimally
while accommodating both cases.
Use --include to include the initramfs image built for offloading
active crash dump to the specified dump target. Also, introduce a new
out-of-tree dracut module (99zz-fadumpinit) that installs a customized
init program while moving the default /init to /init.dracut. This
customized init program is leveraged to isolate fadump image within
the default initramfs image by kicking off default boot process
(exec /init.dracut) for regular boot scenario and activating fadump
initramfs image, if the system is booting after a crash.
If squash is available, ensure default initramfs image is also built
with squash module to reduce memory consumption in capture kernel.
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
* This patch depends on the below 3 dracut PRs:
- https://github.com/dracutdevs/dracut/pull/1532
- https://github.com/dracutdevs/dracut/pull/1535
- https://github.com/dracutdevs/dracut/pull/1545
Changes in V4:
* Moved is_squash_available() into kdump-lib.sh to reuse in mkfadumprd.
* Added a condition in mkfadumprd to build default initramfs with squash
module, if squash is available.
* pivot_root util used to change '/' when squash is used while building
default initramfs (Kairui).
* Changed mv, switch_root utils installations to be conditional on squash
module availability.
* Changed moving files from /fadumproot to use "$(ls -A /fadumproot)" to
ensure file names beginning with "." are also moved.
* Added a TODO at is_fadump_capable() check in mkdumprd for removing it
eventually.
Changes in V3:
* Removed dependency with squash module by extracting fadump
initramfs to /fadumproot directory.
* Moved code that builds initramfs for fadump to mkfadumprd and
added cleanup support based on inputs from Kairui.
Changes in V2:
* Moved kernel modules installation from install() to installkernel()
for zz-fadumpinit dracut module.
* Updated kexec-tools.spec to install zz-fadumpinit module files
appropriately.
* Fixed error check for capture initramfs image isolation with dracut.
dracut-fadump-init-fadump.sh | 44 ++++++++++++++++++++++++++++++
dracut-fadump-module-setup.sh | 23 ++++++++++++++++
dracut-module-setup.sh | 16 +----------
kdump-lib.sh | 10 +++++++
kdumpctl | 22 +++------------
kexec-tools.spec | 14 ++++++++++
mkdumprd | 5 +++
mkfadumprd | 60 +++++++++++++++++++++++++++++++++++++++++
8 files changed, 162 insertions(+), 32 deletions(-)
create mode 100755 dracut-fadump-init-fadump.sh
create mode 100644 dracut-fadump-module-setup.sh
create mode 100644 mkfadumprd
diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh
new file mode 100755
index 0000000..5468d99
--- /dev/null
+++ b/dracut-fadump-init-fadump.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+export PATH=/usr/bin:/usr/sbin
+export SYSTEMD_IN_INITRD=lenient
+
+[ -e /proc/mounts ] ||
+ (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
+
+grep -q '^sysfs /sys sysfs' /proc/mounts ||
+ (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
+
+grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1
+
+if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
+ mkdir /newroot
+ mount -t ramfs ramfs /newroot
+
+ if [ $ROOTFS_IS_RAMFS ]; then
+ for FILE in $(ls -A /fadumproot/); do
+ mv /fadumproot/$FILE /newroot/
+ done
+ exec switch_root /newroot /init
+ else
+ mkdir /newroot/sys /newroot/proc /newroot/oldroot
+ mount --move /proc /newroot/proc
+ mount --move /sys /newroot/sys
+ cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
+ cd /newroot && pivot_root . oldroot
+
+ loop=1
+ while [ $loop ]; do
+ unset loop
+ while read -r _ mp _; do
+ case $mp in
+ /oldroot/*) umount "$mp" && loop=1 ;;
+ esac
+ done </proc/mounts
+ done
+ umount -l oldroot
+
+ exec /init
+ fi
+else
+ exec /init.dracut
+fi
diff --git a/dracut-fadump-module-setup.sh b/dracut-fadump-module-setup.sh
new file mode 100644
index 0000000..f062486
--- /dev/null
+++ b/dracut-fadump-module-setup.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+check() {
+ return 255
+}
+
+depends() {
+ return 0
+}
+
+install() {
+ mv -f "$initdir/init" "$initdir/init.dracut"
+ inst_script "$moddir/init-fadump.sh" /init
+ chmod a+x "$initdir/init"
+
+ # Install required binaries for the init script (init-fadump.sh)
+ inst_multiple sh modprobe grep mkdir mount
+ if dracut_module_included "squash"; then
+ inst_multiple cp pivot_root umount
+ else
+ inst_multiple ls mv switch_root
+ fi
+}
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 35a961a..c8d7f08 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -27,17 +27,7 @@ depends() {
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
- is_squash_available() {
- for kmodule in squashfs overlay loop; do
- if [ -z "$KDUMP_KERNELVER" ]; then
- modprobe --dry-run $kmodule &>/dev/null || return 1
- else
- modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
- fi
- done
- }
-
- if is_squash_available && ! is_fadump_capable; then
+ if is_squash_available; then
add_opt_module squash
else
dwarning "Required modules to build a squashed kdump image is missing!"
@@ -1085,7 +1075,5 @@ install() {
${initdir}/etc/lvm/lvm.conf &>/dev/null
# Save more memory by dropping switch root capability
- if ! is_fadump_capable; then
- dracut_no_switch_root
- fi
+ dracut_no_switch_root
}
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 27741fb..8e618f8 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -19,6 +19,16 @@ is_fadump_capable()
return 1
}
+is_squash_available() {
+ for kmodule in squashfs overlay loop; do
+ if [ -z "$KDUMP_KERNELVER" ]; then
+ modprobe --dry-run $kmodule &>/dev/null || return 1
+ else
+ modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
+ fi
+ done
+}
+
perror_exit() {
derror "$@"
exit 1
diff --git a/kdumpctl b/kdumpctl
index 978dae5..26247d1 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -8,6 +8,7 @@ KEXEC_ARGS=""
KDUMP_CONFIG_FILE="/etc/kdump.conf"
KDUMP_LOG_PATH="/var/log"
MKDUMPRD="/sbin/mkdumprd -f"
+MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
@@ -104,25 +105,10 @@ save_core()
rebuild_fadump_initrd()
{
- local target_initrd_tmp
-
- # this file tells the initrd is fadump enabled
- touch /tmp/fadump.initramfs
- target_initrd_tmp="$TARGET_INITRD.tmp"
- ddebug "rebuild fadump initrd: $target_initrd_tmp $DEFAULT_INITRD_BAK $KDUMP_KERNELVER"
- $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \
- -i /tmp/fadump.initramfs /etc/fadump.initramfs
- if [ $? != 0 ]; then
- derror "mkdumprd: failed to rebuild initrd with fadump support"
- rm -f /tmp/fadump.initramfs
+ if ! $MKFADUMPRD "$DEFAULT_INITRD_BAK" "$TARGET_INITRD" --kver "$KDUMP_KERNELVER"; then
+ derror "mkfadumprd: failed to make fadump initrd"
return 1
fi
- rm -f /tmp/fadump.initramfs
-
- # updating fadump initrd
- ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD"
- mv $target_initrd_tmp $TARGET_INITRD
- sync
return 0
}
@@ -612,7 +598,7 @@ check_rebuild()
#in case of fadump mode, check whether the default/target
#initrd is already built with dump capture capability
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
- capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l)
+ capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l)
fi
fi
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 7b29b0e..f43c186 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -39,6 +39,7 @@ Source28: kdump-udev-throttler
Source29: kdump.sysconfig.aarch64
Source30: 60-kdump.install
Source31: kdump-logger.sh
+Source32: mkfadumprd
#######################################
# These are sources for mkdumpramfs
@@ -54,6 +55,9 @@ Source107: dracut-kdump-emergency.target
Source108: dracut-early-kdump.sh
Source109: dracut-early-kdump-module-setup.sh
+Source200: dracut-fadump-init-fadump.sh
+Source201: dracut-fadump-module-setup.sh
+
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
@@ -176,6 +180,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
+install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
@@ -211,6 +216,7 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
+%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
# deal with dracut modules
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
@@ -228,6 +234,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
+%ifarch ppc64 ppc64le
+mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit
+cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+%endif
%define dracutlibdir %{_prefix}/lib/dracut
@@ -309,6 +322,7 @@ done
/usr/sbin/makedumpfile
%endif
/usr/sbin/mkdumprd
+/usr/sbin/mkfadumprd
/usr/sbin/vmcore-dmesg
%{_bindir}/*
%{_datadir}/kdump
diff --git a/mkdumprd b/mkdumprd
index 6d699c3..89a160d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -452,6 +452,11 @@ then
add_dracut_arg "--add-drivers" \"$extra_modules\"
fi
+# TODO: The below check is not needed anymore with the introduction of
+# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
+# but still sysroot.mount unit gets generated based on 'root=' kernel
+# parameter available in fadump case. So, find a way to fix that first
+# before removing this check.
if ! is_fadump_capable; then
# The 2nd rootfs mount stays behind the normal dump target mount,
# so it doesn't affect the logic of check_dump_fs_modified().
diff --git a/mkfadumprd b/mkfadumprd
new file mode 100644
index 0000000..4af4ae6
--- /dev/null
+++ b/mkfadumprd
@@ -0,0 +1,60 @@
+#!/bin/bash --norc
+# Generate an initramfs image that isolates dump capture capability within
+# the default initramfs using zz-fadumpinit dracut module.
+
+if [ -f /etc/sysconfig/kdump ]; then
+ . /etc/sysconfig/kdump
+fi
+
+[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
+. $dracutbasedir/dracut-functions.sh
+. /lib/kdump/kdump-lib.sh
+. /lib/kdump/kdump-logger.sh
+
+#initiate the kdump logger
+if ! dlog_init; then
+ echo "mkfadumprd: failed to initiate the kdump logger."
+ exit 1
+fi
+
+readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
+[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
+trap '
+ ret=$?;
+ [[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
+ exit $ret;
+ ' EXIT
+
+# clean up after ourselves no matter how we die.
+trap 'exit 1;' SIGINT
+
+MKDUMPRD="/sbin/mkdumprd -f"
+# Default boot initramfs to be rebuilt
+REBUILD_INITRD="$1" && shift
+TARGET_INITRD="$1" && shift
+FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
+
+### First build an initramfs with dump capture capability
+# this file tells the initrd is fadump enabled
+touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
+ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
+if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
+ perror_exit "mkfadumprd: failed to build image with dump capture support"
+fi
+
+### Unpack the initramfs having dump capture capability
+mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
+if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$MKFADUMPRD_TMPDIR/fadump.img" && \
+ popd > /dev/null); then
+ derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
+ exit 1
+fi
+
+### Pack it into the normal boot initramfs with zz-fadumpinit module
+_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot"
+if is_squash_available; then
+ _dracut_isolate_args="$_dracut_isolate_args --add squash"
+fi
+if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then
+ perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
+fi
2 years, 10 months
Re: [PATCH V3] fadump: isolate fadump initramfs image within the
default one
by Hari Bathini
On 10/06/21 8:29 pm, Hari Bathini wrote:
> In case of fadump, the initramfs image has to be built to boot into
> the production environment as well as to offload the active crash dump
> to the specified dump target (for boot after crash). As the same image
> would be used for both boot scenarios, it could not be built optimally
> while accommodating both cases.
>
> Use --include to include the initramfs image built for offloading
> active crash dump to the specified dump target. Also, introduce a new
> out-of-tree dracut module (99zz-fadumpinit) that installs a customized
> init program while moving the default /init to /init.dracut. This
> customized init program is leveraged to isolate fadump image within
> the default initramfs image by kicking off default boot process
> (exec /init.dracut) for regular boot scenario and activating fadump
> initramfs image, if the system is booting after a crash.
>
> Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
> ---
>
> * Applying this patch, the initramfs image built with fadump support
> can be too large, without https://github.com/dracutdevs/dracut/pull/1532
>
> TODO:
> * Fix missing ssh identify file /root/.ssh/kdump_id_rsa with
> squash not used and remote (ssh) dump target configured.
>
> Changes in V3:
> * Removed dependency with squash module by extracting fadump
> initramfs to /fadumproot directory.
> * Moved code that builds initramfs for fadump to mkfadumprd and
> added cleanup support based on inputs from Kairui.
>
> Changes in V2:
> * Moved kernel modules installation from install() to installkernel() for
> zz-fadumpinit dracut module.
> * Updated kexec-tools.spec to install zz-fadumpinit module files appropriately.
> * Fixed error check for capture initramfs image isolation with dracut.
>
>
> dracut-fadump-init-fadump.sh | 20 ++++++++++++++
> dracut-fadump-module-setup.sh | 17 ++++++++++++
> dracut-module-setup.sh | 6 +---
> kdumpctl | 22 +++-------------
> kexec-tools.spec | 14 ++++++++++
> mkfadumprd | 58 +++++++++++++++++++++++++++++++++++++++++
> 6 files changed, 115 insertions(+), 22 deletions(-)
> create mode 100644 dracut-fadump-init-fadump.sh
> create mode 100644 dracut-fadump-module-setup.sh
> create mode 100644 mkfadumprd
>
> diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh
> new file mode 100644
> index 0000000..736a7dd
> --- /dev/null
> +++ b/dracut-fadump-init-fadump.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +PATH=/bin:/sbin
> +
> +[ -e /proc/self/mounts ] \
> + || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
> +
> +grep -q '^sysfs /sys sysfs' /proc/self/mounts \
> + || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
> +
> +# If system is booting after a crash, switch to initramfs built for dump capture
> +if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
> + mkdir -p /newroot
> + mount -t ramfs ramfs /newroot
> + mv /fadumproot/* /newroot
Similar to the dracut --include issue, this would also leave behind
filenames beginning with '.'. As replacing '*' with '.' won't work,
probably need to use different wildcards...
Thanks
Hari
2 years, 10 months
[crash PATCH] Add basic selftest for crash
by Tao Liu
The purpose of crash selftest is to perform quick sanity testing of
new patches, and further more, to work with kexec-tools selftest, in
order to provide complete testing for kdump overall process.
This patch borrowed kexec-tools selftest. Now by running "make live-test"
and "make vmcore-test" in tests/, the selftest will build crash from source,
and execute it by feeding a group of commands to crash, then check the
outputs whether are as expected.
The commands are located in scripts/crash_test.sh, which will be enriched
continuously.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
tests/Makefile | 51 ++++++++++++++++++++
tests/README | 26 ++++++++++
tests/scripts/crash_test.sh | 94 +++++++++++++++++++++++++++++++++++++
3 files changed, 171 insertions(+)
create mode 100644 tests/Makefile
create mode 100644 tests/README
create mode 100755 tests/scripts/crash_test.sh
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..2a0b251
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,51 @@
+VMCORE ?=
+VMLINUX ?=
+
+TEST_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
+BUILD_ROOT := $(TEST_ROOT)/build
+REPO = $(shell realpath $(TEST_ROOT)/../)
+SPEC = crash.spec
+ARCH = $(shell arch)
+TEST_SCRIPT = $(TEST_ROOT)/scripts/crash_test.sh
+
+RPMDEFINE = --define '_sourcedir $(REPO)'\
+ --define '_specdir $(REPO)'\
+ --define '_builddir $(BUILD_ROOT)'\
+ --define '_srcrpmdir $(BUILD_ROOT)'\
+ --define '_rpmdir $(BUILD_ROOT)'
+
+CRASH_SRC = $(filter-out $(REPO)/tests,$(wildcard $(REPO)/*))
+CRASH_NVR = $(shell rpm $(RPMDEFINE) -q --specfile $(REPO)/$(SPEC) 2>/dev/null | grep -m 1 .)
+CRASH_RPM = $(BUILD_ROOT)/$(ARCH)/$(CRASH_NVR).rpm
+CRASH_BIN = $(BUILD_ROOT)/$(ARCH)/usr/bin/crash
+
+default:
+ @echo "make live-test"
+ @echo "make vmcore-test VMCORE=<file> VMLINUX=<file>"
+ @exit 0
+
+$(CRASH_RPM): $(CRASH_SRC)
+ sh -c "cd .. && fedpkg sources"
+ @echo Rebuilding RPM due to modification of sources: $?
+ rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC)
+
+crash_bin: $(CRASH_RPM)
+ cd $(BUILD_ROOT)/$(ARCH) && rpm2cpio $(CRASH_RPM) | cpio -div
+ touch crash_bin
+
+live-test: crash_bin
+ $(TEST_SCRIPT) $(CRASH_BIN)
+
+vmcore-test: crash_bin
+ifeq ($(strip $(VMCORE)),)
+ @echo "Must provide VMCORE!"
+ @exit 1
+endif
+ifeq ($(strip $(VMLINUX)),)
+ @echo "Must provide VMLINUX!"
+ @exit 1
+endif
+ $(TEST_SCRIPT) $(CRASH_BIN) $(VMCORE) $(VMLINUX)
+
+clean:
+ rm -rf $(TEST_ROOT)/build crash_bin
\ No newline at end of file
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..d286cef
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,26 @@
+===============
+Crash Self-test
+===============
+
+
+Introduction
+============
+The self-tests here are useful for quick sanity tests for new patches, and are also useful for overall kdump process testing when intergrated with kexec-tools.
+
+Basic usage
+===========
+If you want to perform vmcore-testing, you need to get vmcore and vmlinux ready first. Then you can start vmcore-testing by typing the following command:
+
+`make clean && make vmcore-test VMCORE=<path/to/vmcore> VMLINUX=<path/to/vmlinux>`
+
+If you want to perform live-testing, you need to install kernel-debuginfo first.
+
+`sudo debuginfo-install -y kernel-debuginfo-$(uname -r)`
+
+Then start live-testing by typing the following command:
+
+`make clean && make live-test`
+
+Test Cases
+==========
+Currently the testing commands are located in tests/scripts/crash_test.sh. A cmd_list array is piped to crash, then check the output of crash whether is expected.
\ No newline at end of file
diff --git a/tests/scripts/crash_test.sh b/tests/scripts/crash_test.sh
new file mode 100755
index 0000000..d09e0ea
--- /dev/null
+++ b/tests/scripts/crash_test.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+crash=$1
+vmcore=$2
+vmlinux=$3
+
+cmd_list=(
+ "p linux_banner"
+ "rd -a linux_banner | head -1"
+ "sym schedule"
+ "whatis linux_banner"
+ "eval 1+1 | grep hexadecimal"
+ "q"
+)
+
+log_filter() {
+ res=$(awk '
+ /^\s*$/ {
+ next;
+ }
+ /WARNING: kernel relocated .* patching .* gdb minimal_symbol values/ {
+ next;
+ }
+
+ ###################Check cmd_list###################
+ /^p linux_banner$/ {
+ allow_regex="^linux_banner = \\$1 = 0x[0-9a-f]+ (<linux_banner> )?\"Linux version";
+ next;
+ }
+ /^rd -a linux_banner | head -1$/ {
+ allow_regex="^[0-9a-f]+: Linux version";
+ next;
+ }
+ /^sym schedule$/ {
+ allow_regex="^[0-9a-f]+ \\(T\\) schedule ";
+ next;
+ }
+ /^whatis linux_banner$/ {
+ allow_regex="^const char linux_banner\\[\\];$";
+ next;
+ }
+ /^eval 1+1 | grep hexadecimal$/ {
+ allow_regex="^hexadecimal: 2 ";
+ next;
+ }
+ /^q$/ {
+ next;
+ }
+ ################End of cmd_list check################
+
+ $0 !~ allow_regex {
+ print $0;
+ }
+
+ ##################Crash error check##################
+ tolower($0) ~ /\<mismatch\>/ {print $0;next;}
+ tolower($0) ~ /cannot/ {print $0;next;}
+ tolower($0) ~ /\<fail\>/ {print $0;next;}
+ tolower($0) ~ /\<failed\>/ {print $0;next;}
+ tolower($0) ~ /\<error\>/ {print $0;next;}
+ tolower($0) ~ /\<invalid\>/ {print $0;next;}
+ tolower($0) ~ /unexpect/ {print $0;next;}
+ tolower($0) ~ /not supported/ {print $0;next;}
+ tolower($0) ~ /no such file or directory/ {print $0;next;}
+ ###############End of crash error check###############
+ ')
+
+ if [ -z "$res" ]; then
+ return 0
+ else
+ echo $res
+ return 1
+ fi
+}
+
+for ((i=0;i<${#cmd_list[@]};i++)); do
+ echo "echo '${cmd_list[$i]}'"
+ echo ${cmd_list[$i]}
+done | \
+$crash -s $vmcore $vmlinux 2>&1 | \
+log_filter
+
+exit_val=(${PIPESTATUS[@]})
+
+crash_exit_val=${exit_val[1]}
+filter_exit_val=${exit_val[2]}
+
+if [[ $crash_exit_val -eq 0 && $filter_exit_val -eq 0 ]]; then
+ echo "Crash test pass"
+ exit 0
+else
+ echo "Crash test fail"
+ exit 1
+fi
\ No newline at end of file
--
2.29.2
2 years, 10 months
[PATCH v3 0/4] Several improvements on selftest
by Coiby Xu
v3 -> v2:
1. selftest: kill VM reliably
- only kill if there are subjobs belonging to a pid
2. selftest: ignore all spaces when compare the dmesg files (new)
v1 -> v2:
1. selftest: kill VM reliably
- use $_jobs instead of `echo $_jobs` to iterate jobs
- fix format issue
2. selftest: Make test_base_image depends on EXTRA_RPMS (new)
Coiby Xu (4):
selftest: fix the error of misplacing double quotes
selftest: kill VM reliably
selftest: Make test_base_image depends on EXTRA_RPMS
selftest: ignore all spaces when compare the dmesg files
tests/Makefile | 2 +-
tests/scripts/kexec-kdump-test/init.sh | 2 +-
tests/scripts/run-test.sh | 17 +++++++++++++----
tests/scripts/test-lib.sh | 3 +--
tests/scripts/testcases/nfs-kdump/0-server.sh | 2 +-
5 files changed, 17 insertions(+), 9 deletions(-)
--
2.31.1
2 years, 10 months
Re: [PATCH V3] fadump: isolate fadump initramfs image within the
default one
by Kairui Song
Hi Hari,
On Thu, Jun 10, 2021 at 11:01 PM Hari Bathini <hbathini(a)linux.ibm.com> wrote:
>
> In case of fadump, the initramfs image has to be built to boot into
> the production environment as well as to offload the active crash dump
> to the specified dump target (for boot after crash). As the same image
> would be used for both boot scenarios, it could not be built optimally
> while accommodating both cases.
>
> Use --include to include the initramfs image built for offloading
> active crash dump to the specified dump target. Also, introduce a new
> out-of-tree dracut module (99zz-fadumpinit) that installs a customized
> init program while moving the default /init to /init.dracut. This
> customized init program is leveraged to isolate fadump image within
> the default initramfs image by kicking off default boot process
> (exec /init.dracut) for regular boot scenario and activating fadump
> initramfs image, if the system is booting after a crash.
>
> Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
> ---
>
> * Applying this patch, the initramfs image built with fadump support
> can be too large, without https://github.com/dracutdevs/dracut/pull/1532
>
> TODO:
> * Fix missing ssh identify file /root/.ssh/kdump_id_rsa with
> squash not used and remote (ssh) dump target configured.
Thank you very much for the update!
For this issue (missing ssh identify file when squash is not used), we
can actually force squash module to be enabled for fadump initramfs.
kdump have been forcing squash module enabled for a long time and I
think that's OK. And meanwhile better fix that in dracut, that's
definitely a dracut bug.
As we talked before, we did observe some strange error messages when
building the initramfs, I think most of them are caused by some hidden
dracut bugs.
Ideally, we can enable squash module for both the fadump initramfs,
and the normal initramfs, the strange scary error messages are still
unclear to me.
I'll try to figure out if it can be fixed in dracut/squash module
side, so hopefully nothing more special needs to be done from
kexec-tools side.
>
> Changes in V3:
> * Removed dependency with squash module by extracting fadump
> initramfs to /fadumproot directory.
> * Moved code that builds initramfs for fadump to mkfadumprd and
> added cleanup support based on inputs from Kairui.
>
> Changes in V2:
> * Moved kernel modules installation from install() to installkernel() for
> zz-fadumpinit dracut module.
> * Updated kexec-tools.spec to install zz-fadumpinit module files appropriately.
> * Fixed error check for capture initramfs image isolation with dracut.
>
>
> dracut-fadump-init-fadump.sh | 20 ++++++++++++++
> dracut-fadump-module-setup.sh | 17 ++++++++++++
> dracut-module-setup.sh | 6 +---
> kdumpctl | 22 +++-------------
> kexec-tools.spec | 14 ++++++++++
> mkfadumprd | 58 +++++++++++++++++++++++++++++++++++++++++
> 6 files changed, 115 insertions(+), 22 deletions(-)
> create mode 100644 dracut-fadump-init-fadump.sh
> create mode 100644 dracut-fadump-module-setup.sh
> create mode 100644 mkfadumprd
>
> diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh
> new file mode 100644
> index 0000000..736a7dd
> --- /dev/null
> +++ b/dracut-fadump-init-fadump.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +PATH=/bin:/sbin
> +
> +[ -e /proc/self/mounts ] \
> + || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
> +
> +grep -q '^sysfs /sys sysfs' /proc/self/mounts \
> + || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
> +
> +# If system is booting after a crash, switch to initramfs built for dump capture
> +if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
> + mkdir -p /newroot
> + mount -t ramfs ramfs /newroot
> + mv /fadumproot/* /newroot
> +
> + # Jump to initramfs built for dump capture
> + SYSTEMD_IN_INITRD=lenient exec switch_root /newroot /init
> +else
> + exec /init.dracut
> +fi
> diff --git a/dracut-fadump-module-setup.sh b/dracut-fadump-module-setup.sh
> new file mode 100644
> index 0000000..5ba4564
> --- /dev/null
> +++ b/dracut-fadump-module-setup.sh
> @@ -0,0 +1,17 @@
> +#!/bin/bash
> +
> +check() {
> + return 255
> +}
> +
> +depends() {
> + return 0
> +}
> +
> +install() {
> + mv -f "$initdir/init" "$initdir/init.dracut"
> + inst_script "$moddir/init-fadump.sh" /init
> +
> + # Install required binaries for the init script (init-fadump.sh)
> + inst_multiple sh modprobe grep mkdir mount mv switch_root
> +}
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 35a961a..ab369b3 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -37,7 +37,7 @@ depends() {
> done
> }
>
> - if is_squash_available && ! is_fadump_capable; then
> + if is_squash_available; then
> add_opt_module squash
> else
> dwarning "Required modules to build a squashed kdump image is missing!"
> @@ -1085,7 +1085,5 @@ install() {
> ${initdir}/etc/lvm/lvm.conf &>/dev/null
>
> # Save more memory by dropping switch root capability
> - if ! is_fadump_capable; then
> - dracut_no_switch_root
> - fi
> + dracut_no_switch_root
> }
> diff --git a/kdumpctl b/kdumpctl
> index 978dae5..26247d1 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -8,6 +8,7 @@ KEXEC_ARGS=""
> KDUMP_CONFIG_FILE="/etc/kdump.conf"
> KDUMP_LOG_PATH="/var/log"
> MKDUMPRD="/sbin/mkdumprd -f"
> +MKFADUMPRD="/sbin/mkfadumprd"
> DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
> SAVE_PATH=/var/crash
> SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
> @@ -104,25 +105,10 @@ save_core()
>
> rebuild_fadump_initrd()
> {
> - local target_initrd_tmp
> -
> - # this file tells the initrd is fadump enabled
> - touch /tmp/fadump.initramfs
> - target_initrd_tmp="$TARGET_INITRD.tmp"
> - ddebug "rebuild fadump initrd: $target_initrd_tmp $DEFAULT_INITRD_BAK $KDUMP_KERNELVER"
> - $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \
> - -i /tmp/fadump.initramfs /etc/fadump.initramfs
> - if [ $? != 0 ]; then
> - derror "mkdumprd: failed to rebuild initrd with fadump support"
> - rm -f /tmp/fadump.initramfs
> + if ! $MKFADUMPRD "$DEFAULT_INITRD_BAK" "$TARGET_INITRD" --kver "$KDUMP_KERNELVER"; then
> + derror "mkfadumprd: failed to make fadump initrd"
> return 1
> fi
> - rm -f /tmp/fadump.initramfs
> -
> - # updating fadump initrd
> - ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD"
> - mv $target_initrd_tmp $TARGET_INITRD
> - sync
>
> return 0
> }
> @@ -612,7 +598,7 @@ check_rebuild()
> #in case of fadump mode, check whether the default/target
> #initrd is already built with dump capture capability
> if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
> - capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l)
> + capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l)
> fi
> fi
>
> diff --git a/kexec-tools.spec b/kexec-tools.spec
> index e94ed02..8605a1f 100644
> --- a/kexec-tools.spec
> +++ b/kexec-tools.spec
> @@ -39,6 +39,7 @@ Source28: kdump-udev-throttler
> Source29: kdump.sysconfig.aarch64
> Source30: 60-kdump.install
> Source31: kdump-logger.sh
> +Source32: mkfadumprd
>
> #######################################
> # These are sources for mkdumpramfs
> @@ -54,6 +55,9 @@ Source107: dracut-kdump-emergency.target
> Source108: dracut-early-kdump.sh
> Source109: dracut-early-kdump-module-setup.sh
>
> +Source200: dracut-fadump-init-fadump.sh
> +Source201: dracut-fadump-module-setup.sh
> +
> Requires(post): systemd-units
> Requires(preun): systemd-units
> Requires(postun): systemd-units
> @@ -176,6 +180,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
> install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
>
> install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
> +install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd
> install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
> install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
> install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
> @@ -211,6 +216,7 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar
>
> %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
> %define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
> +%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
>
> # deal with dracut modules
> mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
> @@ -228,6 +234,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk
> cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
> chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
> chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
> +%ifarch ppc64 ppc64le
> +mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit
> +cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
> +cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
> +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
> +chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
> +%endif
>
>
> %define dracutlibdir %{_prefix}/lib/dracut
> @@ -309,6 +322,7 @@ done
> /usr/sbin/makedumpfile
> %endif
> /usr/sbin/mkdumprd
> +/usr/sbin/mkfadumprd
> /usr/sbin/vmcore-dmesg
> %{_bindir}/*
> %{_datadir}/kdump
> diff --git a/mkfadumprd b/mkfadumprd
> new file mode 100644
> index 0000000..c0ee455
> --- /dev/null
> +++ b/mkfadumprd
> @@ -0,0 +1,58 @@
> +#!/bin/bash --norc
> +# Generate an initramfs image that isolates dump capture capability within
> +# the default initramfs using zz-fadumpinit dracut module.
> +
> +if [ -f /etc/sysconfig/kdump ]; then
> + . /etc/sysconfig/kdump
> +fi
> +
> +[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
> +. $dracutbasedir/dracut-functions.sh
> +. /lib/kdump/kdump-lib.sh
> +. /lib/kdump/kdump-logger.sh
> +
> +#initiate the kdump logger
> +if ! dlog_init; then
> + echo "mkfadumprd: failed to initiate the kdump logger."
> + exit 1
> +fi
> +
> +readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
> +[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
> +trap '
> + ret=$?;
> + [[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
> + exit $ret;
> + ' EXIT
> +
> +# clean up after ourselves no matter how we die.
> +trap 'exit 1;' SIGINT
> +
> +MKDUMPRD="/sbin/mkdumprd -f"
> +# Default boot initramfs to be rebuilt
> +REBUILD_INITRD="$1" && shift
> +TARGET_INITRD="$1" && shift
> +FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
> +
> +### First build an initramfs with dump capture capability
> +# this file tells the initrd is fadump enabled
> +touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
> +ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
> +if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
> + perror_exit "mkfadumprd: failed to build image with dump capture support"
> +fi
> +
> +### Unpack the initramfs having dump capture capability
> +mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
> +if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$MKFADUMPRD_TMPDIR/fadump.img" && \
> + popd > /dev/null); then
> + ls "$MKFADUMPRD_TMPDIR/fadumproot"
> + derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
> + exit 1
> +fi
> +
> +### Pack it into the normal boot initramfs with zz-fadumpinit module
> +_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot"
> +if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then
> + perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
> +fi
>
>
--
Best Regards,
Kairui Song
2 years, 10 months
[PATCH V3] fadump: isolate fadump initramfs image within the default
one
by Hari Bathini
In case of fadump, the initramfs image has to be built to boot into
the production environment as well as to offload the active crash dump
to the specified dump target (for boot after crash). As the same image
would be used for both boot scenarios, it could not be built optimally
while accommodating both cases.
Use --include to include the initramfs image built for offloading
active crash dump to the specified dump target. Also, introduce a new
out-of-tree dracut module (99zz-fadumpinit) that installs a customized
init program while moving the default /init to /init.dracut. This
customized init program is leveraged to isolate fadump image within
the default initramfs image by kicking off default boot process
(exec /init.dracut) for regular boot scenario and activating fadump
initramfs image, if the system is booting after a crash.
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
---
* Applying this patch, the initramfs image built with fadump support
can be too large, without https://github.com/dracutdevs/dracut/pull/1532
TODO:
* Fix missing ssh identify file /root/.ssh/kdump_id_rsa with
squash not used and remote (ssh) dump target configured.
Changes in V3:
* Removed dependency with squash module by extracting fadump
initramfs to /fadumproot directory.
* Moved code that builds initramfs for fadump to mkfadumprd and
added cleanup support based on inputs from Kairui.
Changes in V2:
* Moved kernel modules installation from install() to installkernel() for
zz-fadumpinit dracut module.
* Updated kexec-tools.spec to install zz-fadumpinit module files appropriately.
* Fixed error check for capture initramfs image isolation with dracut.
dracut-fadump-init-fadump.sh | 20 ++++++++++++++
dracut-fadump-module-setup.sh | 17 ++++++++++++
dracut-module-setup.sh | 6 +---
kdumpctl | 22 +++-------------
kexec-tools.spec | 14 ++++++++++
mkfadumprd | 58 +++++++++++++++++++++++++++++++++++++++++
6 files changed, 115 insertions(+), 22 deletions(-)
create mode 100644 dracut-fadump-init-fadump.sh
create mode 100644 dracut-fadump-module-setup.sh
create mode 100644 mkfadumprd
diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh
new file mode 100644
index 0000000..736a7dd
--- /dev/null
+++ b/dracut-fadump-init-fadump.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+PATH=/bin:/sbin
+
+[ -e /proc/self/mounts ] \
+ || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
+
+grep -q '^sysfs /sys sysfs' /proc/self/mounts \
+ || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
+
+# If system is booting after a crash, switch to initramfs built for dump capture
+if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
+ mkdir -p /newroot
+ mount -t ramfs ramfs /newroot
+ mv /fadumproot/* /newroot
+
+ # Jump to initramfs built for dump capture
+ SYSTEMD_IN_INITRD=lenient exec switch_root /newroot /init
+else
+ exec /init.dracut
+fi
diff --git a/dracut-fadump-module-setup.sh b/dracut-fadump-module-setup.sh
new file mode 100644
index 0000000..5ba4564
--- /dev/null
+++ b/dracut-fadump-module-setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+check() {
+ return 255
+}
+
+depends() {
+ return 0
+}
+
+install() {
+ mv -f "$initdir/init" "$initdir/init.dracut"
+ inst_script "$moddir/init-fadump.sh" /init
+
+ # Install required binaries for the init script (init-fadump.sh)
+ inst_multiple sh modprobe grep mkdir mount mv switch_root
+}
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 35a961a..ab369b3 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -37,7 +37,7 @@ depends() {
done
}
- if is_squash_available && ! is_fadump_capable; then
+ if is_squash_available; then
add_opt_module squash
else
dwarning "Required modules to build a squashed kdump image is missing!"
@@ -1085,7 +1085,5 @@ install() {
${initdir}/etc/lvm/lvm.conf &>/dev/null
# Save more memory by dropping switch root capability
- if ! is_fadump_capable; then
- dracut_no_switch_root
- fi
+ dracut_no_switch_root
}
diff --git a/kdumpctl b/kdumpctl
index 978dae5..26247d1 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -8,6 +8,7 @@ KEXEC_ARGS=""
KDUMP_CONFIG_FILE="/etc/kdump.conf"
KDUMP_LOG_PATH="/var/log"
MKDUMPRD="/sbin/mkdumprd -f"
+MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
@@ -104,25 +105,10 @@ save_core()
rebuild_fadump_initrd()
{
- local target_initrd_tmp
-
- # this file tells the initrd is fadump enabled
- touch /tmp/fadump.initramfs
- target_initrd_tmp="$TARGET_INITRD.tmp"
- ddebug "rebuild fadump initrd: $target_initrd_tmp $DEFAULT_INITRD_BAK $KDUMP_KERNELVER"
- $MKDUMPRD $target_initrd_tmp --rebuild $DEFAULT_INITRD_BAK --kver $KDUMP_KERNELVER \
- -i /tmp/fadump.initramfs /etc/fadump.initramfs
- if [ $? != 0 ]; then
- derror "mkdumprd: failed to rebuild initrd with fadump support"
- rm -f /tmp/fadump.initramfs
+ if ! $MKFADUMPRD "$DEFAULT_INITRD_BAK" "$TARGET_INITRD" --kver "$KDUMP_KERNELVER"; then
+ derror "mkfadumprd: failed to make fadump initrd"
return 1
fi
- rm -f /tmp/fadump.initramfs
-
- # updating fadump initrd
- ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD"
- mv $target_initrd_tmp $TARGET_INITRD
- sync
return 0
}
@@ -612,7 +598,7 @@ check_rebuild()
#in case of fadump mode, check whether the default/target
#initrd is already built with dump capture capability
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
- capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l)
+ capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l)
fi
fi
diff --git a/kexec-tools.spec b/kexec-tools.spec
index e94ed02..8605a1f 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -39,6 +39,7 @@ Source28: kdump-udev-throttler
Source29: kdump.sysconfig.aarch64
Source30: 60-kdump.install
Source31: kdump-logger.sh
+Source32: mkfadumprd
#######################################
# These are sources for mkdumpramfs
@@ -54,6 +55,9 @@ Source107: dracut-kdump-emergency.target
Source108: dracut-early-kdump.sh
Source109: dracut-early-kdump-module-setup.sh
+Source200: dracut-fadump-init-fadump.sh
+Source201: dracut-fadump-module-setup.sh
+
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
@@ -176,6 +180,7 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd
+install -m 755 %{SOURCE32} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8
@@ -211,6 +216,7 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
+%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
# deal with dracut modules
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
@@ -228,6 +234,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
+%ifarch ppc64 ppc64le
+mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit
+cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+%endif
%define dracutlibdir %{_prefix}/lib/dracut
@@ -309,6 +322,7 @@ done
/usr/sbin/makedumpfile
%endif
/usr/sbin/mkdumprd
+/usr/sbin/mkfadumprd
/usr/sbin/vmcore-dmesg
%{_bindir}/*
%{_datadir}/kdump
diff --git a/mkfadumprd b/mkfadumprd
new file mode 100644
index 0000000..c0ee455
--- /dev/null
+++ b/mkfadumprd
@@ -0,0 +1,58 @@
+#!/bin/bash --norc
+# Generate an initramfs image that isolates dump capture capability within
+# the default initramfs using zz-fadumpinit dracut module.
+
+if [ -f /etc/sysconfig/kdump ]; then
+ . /etc/sysconfig/kdump
+fi
+
+[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
+. $dracutbasedir/dracut-functions.sh
+. /lib/kdump/kdump-lib.sh
+. /lib/kdump/kdump-logger.sh
+
+#initiate the kdump logger
+if ! dlog_init; then
+ echo "mkfadumprd: failed to initiate the kdump logger."
+ exit 1
+fi
+
+readonly MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)"
+[ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed."
+trap '
+ ret=$?;
+ [[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR";
+ exit $ret;
+ ' EXIT
+
+# clean up after ourselves no matter how we die.
+trap 'exit 1;' SIGINT
+
+MKDUMPRD="/sbin/mkdumprd -f"
+# Default boot initramfs to be rebuilt
+REBUILD_INITRD="$1" && shift
+TARGET_INITRD="$1" && shift
+FADUMP_INITRD="$MKFADUMPRD_TMPDIR/fadump.img"
+
+### First build an initramfs with dump capture capability
+# this file tells the initrd is fadump enabled
+touch "$MKFADUMPRD_TMPDIR/fadump.initramfs"
+ddebug "rebuild fadump initrd: $FADUMP_INITRD $DEFAULT_INITRD $KDUMP_KERNELVER"
+if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs; then
+ perror_exit "mkfadumprd: failed to build image with dump capture support"
+fi
+
+### Unpack the initramfs having dump capture capability
+mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
+if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$MKFADUMPRD_TMPDIR/fadump.img" && \
+ popd > /dev/null); then
+ ls "$MKFADUMPRD_TMPDIR/fadumproot"
+ derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
+ exit 1
+fi
+
+### Pack it into the normal boot initramfs with zz-fadumpinit module
+_dracut_isolate_args="--rebuild $REBUILD_INITRD --add zz-fadumpinit -i $MKFADUMPRD_TMPDIR/fadumproot /fadumproot"
+if ! dracut --force --quiet $_dracut_isolate_args $@ "$TARGET_INITRD"; then
+ perror_exit "mkfadumprd: failed to setup '$TARGET_INITRD' with dump capture capability"
+fi
2 years, 10 months
[PATCH 0/2] Add support for crashkernel.conf
by Kairui Song
In RHEL, kernel supports a `crashkernel=auto` param and when it's used,
kernel will use its built-in default value as the crashkernel value.
But upstream doesn't like this idea. [1]
`crashkernel=auto` was introduced to provide user a default value, and
make it possible to update the crashkernel value automatically as kernel
package updates if user is using the default `auto` value.
After more discussion, `crashkernel=auto` will be dropped. To track
the default crashkernel value, kernel package can include a
crashkernel.conf file with it, and kexec-tools can make use of that
file, update kernel's boot cmdline accordingly, and help user to
reset the crashkernel value to default value.
[1]: https://lore.kernel.org/linux-mm/20210507010432.IN24PudKT%25akpm@linux-fo...
Kairui Song (2):
kdumpctl: Add kdumpctl reset-crashkernel
Add a new hook: 92-crashkernel.install
92-crashkernel.install | 131 +++++++++++++++++++++++++++++++++++++++++
kdumpctl | 32 +++++++++-
kdumpctl.8 | 9 +++
kexec-tools.spec | 4 ++
4 files changed, 174 insertions(+), 2 deletions(-)
create mode 100755 92-crashkernel.install
--
2.31.1
2 years, 10 months
[RESEND PATCH V2] fadump: isolate fadump initramfs image within the
default one
by Hari Bathini
In case of fadump, the initramfs image has to be built to boot into
the production environment as well as to offload the active crash dump
to the specified dump target (for boot after crash). As the same image
would be used for both boot scenarios, it could not be built optimally
while accommodating both cases.
Since dracut commit 8f7c332e488f ("refactor(squash): structure in a
cleaner way"), the squash'ed image is a complete environment that can
be activated for a given boot scenario. Use --include to include the
squash'ed initramfs image built to offload active crash dump to the
specified dump target.
Also, introduce a new out-of-tree dracut module (99zz-fadumpinit) that
installs a customized init program while moving the default /init to
/init.dracut.
Thus, the customized init program is leveraged to isolate fadump image
within the default initramfs image by kicking off default boot process
(exec /init.dracut) for regular boot scenario and activating squash'ed
image only when an active crash dump would be available.
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
---
* Resending the patch with '--quiet' option added to dracut while building the
initramfs image with capture image isolated.
Changes in V2:
* Moved kernel modules installation from install() to installkernel() for
zz-fadumpinit dracut module.
* Updated kexec-tools.spec to install zz-fadumpinit module files appropriately.
* Fixed error check for capture initramfs image isolation with dracut.
dracut-fadump-init-fadump.sh | 40 ++++++++++++++++++++++++++++++++++++++++
dracut-fadump-module-setup.sh | 23 +++++++++++++++++++++++
dracut-module-setup.sh | 2 +-
kdumpctl | 12 +++++++++++-
kexec-tools.spec | 11 +++++++++++
5 files changed, 86 insertions(+), 2 deletions(-)
create mode 100644 dracut-fadump-init-fadump.sh
create mode 100644 dracut-fadump-module-setup.sh
diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh
new file mode 100644
index 0000000..5a81cbe
--- /dev/null
+++ b/dracut-fadump-init-fadump.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+PATH=/bin:/sbin
+
+[ -e /proc/self/mounts ] \
+ || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
+
+grep -q '^sysfs /sys sysfs' /proc/self/mounts \
+ || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
+
+grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
+ || (mkdir -p /dev && mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev)
+
+grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
+ || (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)
+
+if [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
+ exec /init.dracut
+ exit
+fi
+
+# Load required modules
+modprobe loop
+modprobe squashfs
+modprobe overlay
+
+# Mount the squash image
+mkdir -p /squash
+mount -t ramfs ramfs /squash
+mkdir -p /squash/root /squash/overlay/upper /squash/overlay/work
+mount -t squashfs -o ro,loop /fadump-squash.img /squash/root
+
+# Setup new root overlay
+mkdir -p /newroot
+mount -t overlay overlay -o lowerdir=/squash/root,upperdir=/squash/overlay/upper,workdir=/squash/overlay/work/ /newroot/
+
+# Move all mount points to new root to prepare chroot
+mount --move /squash /newroot/squash
+
+# Jump to new root and clean setup files
+SYSTEMD_IN_INITRD=lenient exec switch_root /newroot /init
diff --git a/dracut-fadump-module-setup.sh b/dracut-fadump-module-setup.sh
new file mode 100644
index 0000000..479154a
--- /dev/null
+++ b/dracut-fadump-module-setup.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+check() {
+ return 255
+}
+
+depends() {
+ return 0
+}
+
+installkernel() {
+ # Install required kernel modules for the init script (init-fadump.sh)
+ hostonly="" instmods "loop" "squashfs" "overlay"
+}
+
+install() {
+ mv -f "$initdir/init" "$initdir/init.dracut"
+ inst_simple "$moddir/init-fadump.sh" /init
+ chmod 0755 "$initdir/init"
+
+ # Install required binaries for the init script (init-fadump.sh)
+ inst_multiple sh mount modprobe mkdir switch_root grep
+}
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index a99a0ea..ab48e79 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -37,7 +37,7 @@ depends() {
done
}
- if is_squash_available && ! is_fadump_capable; then
+ if is_squash_available; then
add_opt_module squash
else
dwarning "Required modules to build a squashed kdump image is missing!"
diff --git a/kdumpctl b/kdumpctl
index 978dae5..7e617e8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -18,6 +18,7 @@ DEFAULT_INITRD_BAK=""
KDUMP_INITRD=""
TARGET_INITRD=""
FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered"
+FADUMP_SQUASH_IMG=fadump-squash.img
#kdump shall be the default dump mode
DEFAULT_DUMP_MODE="kdump"
image_time=0
@@ -105,6 +106,7 @@ save_core()
rebuild_fadump_initrd()
{
local target_initrd_tmp
+ local _dracut_isolate_args
# this file tells the initrd is fadump enabled
touch /tmp/fadump.initramfs
@@ -119,6 +121,14 @@ rebuild_fadump_initrd()
fi
rm -f /tmp/fadump.initramfs
+ lsinitrd $target_initrd_tmp /squash-root.img > /tmp/$FADUMP_SQUASH_IMG
+ _dracut_isolate_args=" --rebuild $DEFAULT_INITRD_BAK --add zz-fadumpinit -i /tmp/$FADUMP_SQUASH_IMG /$FADUMP_SQUASH_IMG"
+ if [ ! -s /tmp/$FADUMP_SQUASH_IMG ] \
+ || ! dracut --force --quiet $_dracut_isolate_args $target_initrd_tmp; then
+ dwarn "WARNING: Could not isolate the dump capture initramfs image."
+ fi
+ rm -f /tmp/$FADUMP_SQUASH_IMG
+
# updating fadump initrd
ddebug "updating fadump initrd: $target_initrd_tmp $TARGET_INITRD"
mv $target_initrd_tmp $TARGET_INITRD
@@ -612,7 +622,7 @@ check_rebuild()
#in case of fadump mode, check whether the default/target
#initrd is already built with dump capture capability
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
- capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep ^kdumpbase$ | wc -l)
+ capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l)
fi
fi
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 11c64cb..a7cbf93 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -55,6 +55,9 @@ Source107: dracut-kdump-emergency.target
Source108: dracut-early-kdump.sh
Source109: dracut-early-kdump-module-setup.sh
+Source200: dracut-fadump-init-fadump.sh
+Source201: dracut-fadump-module-setup.sh
+
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
@@ -212,6 +215,7 @@ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/shar
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
+%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
# deal with dracut modules
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
@@ -230,6 +234,13 @@ cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlyk
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
+%ifarch ppc64 ppc64le
+mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit
+cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
+chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
+%endif
%define dracutlibdir %{_prefix}/lib/dracut
2 years, 10 months
[PATCH] mkdumprd: display the absolute path of dump location in the check_user_configured_target()
by Lianbo Jiang
When kdump service fails, the current errors do not display the
absolute path of dump location(marked it as "^"), for example:
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: Detected change(s) in the following file(s): /etc/kdump.conf
kdump: Rebuilding /boot/initramfs-4.18.0-304.el8.x86_64kdump.img
kdump: Dump path "/var1/crash" does not exist in dump target "UUID=c202ef45-3ac3-4adb-85e7-307a916757f0"
^^^^^^^^^^^
kdump: mkdumprd: failed to make kdump initrd
kdump: Starting kdump: [FAILED]
Here, it should output the absolute path of dump location with this
format: "<mount path>/<path>". To fix it, let's extend the relative
pathname to the absolute pathname in check_user_configured_target().
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1915819
Scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=69068102
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index b51807871595..6d699c3de4d0 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -246,7 +246,7 @@ check_user_configured_target()
# For user configured target, use $SAVE_PATH as the dump path within the target
if [ ! -d "$_mnt/$SAVE_PATH" ]; then
- perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\""
+ perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\""
fi
check_size fs "$_target"
--
2.30.2
2 years, 10 months
[PATCH v2] Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet
by Coiby Xu
This patch fixes bz1941106 and bz1941905 which passed empty rd.znet to the
kernel command line in the following cases,
- The IBM (Z15) KVM guest uses virtio for all devices including network
device, so there is no znet device for IBM KVM guest. So we can't
assume a s390x machine always has a znet device.
- When a bridged network is used, kexec-tools tries to obtain the znet
configuration from the ifcfg script of the bridged network rather than
from the ifcfg script of znet device.
We can iterate /sys/bus/ccwgroup/devices to tell if there if there is
a znet network device. By getting an ifname from znet, we can also avoid
mistaking the slave netdev as a znet network device in a bridged network
or bonded network.
Note: This patch also assumes there is only one znet device as commit
7148c0a30dfc48221eadf255e8a89619f98a8752 ("add s390x netdev setup")
which greatly simplifies the code. According to IBM [1], there could be
more than znet devices for a z/VM system and a z/VM system may have a
non-znet network device like ConnectX. Since kdump_setup_znet was
introduced in 2012 and so far there is no known customer complaint that
invalidates this assumption I think it's safe to assume an IBM z/VM
system only has one znet device. Besides, there is no z/VM system found
on beaker to test the alternative scenarios.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1941905#c13
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
v1 -> v2:
- fix the error of passing $_netdev instead of $_znet_netdev to
kdump_setup_znet [Kairui]
---
dracut-module-setup.sh | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index a99a0ea..a8ea63b 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -460,6 +460,34 @@ kdump_setup_vlan() {
fi
}
+# find online znet device
+# return ifname (_netdev)
+# code reaped from the list_configured function of
+# https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf
+find_online_znet_device() {
+ local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices"
+ local NETWORK_DEVICES d ifname ONLINE
+ NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR -type l)
+ for d in $NETWORK_DEVICES
+ do
+ read ONLINE < $d/online
+ if [ $ONLINE -ne 1 ]; then
+ continue
+ fi
+ # determine interface name, if there (only for qeth and if
+ # device is online)
+ if [ -f $d/if_name ]
+ then
+ read ifname < $d/if_name
+ elif [ -d $d/net ]
+ then
+ ifname=$(ls $d/net/)
+ fi
+ [ -n "$ifname" ] && break
+ done
+ echo -n "$ifname"
+}
+
# setup s390 znet cmdline
# $1: netdev (ifname)
# $2: nmcli connection show output
@@ -526,6 +554,7 @@ kdump_get_remote_ip()
kdump_install_net() {
local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic
local _static _proto _ip_conf _ip_opts _ifname_opts
+ local _znet_netdev _nm_show_cmd_znet
_destaddr=$(kdump_get_remote_ip $1)
_route=$(kdump_get_ip_route $_destaddr)
@@ -535,8 +564,10 @@ kdump_install_net() {
_netmac=$(kdump_get_mac_addr $_netdev)
kdumpnic=$(kdump_setup_ifname $_netdev)
- if [ "$(uname -m)" = "s390x" ]; then
- $(kdump_setup_znet "$_netdev" "$_nm_show_cmd")
+ _znet_netdev=$(find_online_znet_device)
+ if [[ -n "$_znet_netdev" ]]; then
+ _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev")
+ $(kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet")
if [[ $? != 0 ]]; then
derror "Failed to set up znet"
exit 1
--
2.31.1
2 years, 10 months