diff --git a/SOURCES/60-kdump.install b/SOURCES/60-kdump.install index 0a3b40e..5b0e021 100755 --- a/SOURCES/60-kdump.install +++ b/SOURCES/60-kdump.install @@ -2,17 +2,23 @@ COMMAND="$1" KERNEL_VERSION="$2" -BOOT_DIR_ABS="$3" +KDUMP_INITRD_DIR_ABS="$3" KERNEL_IMAGE="$4" if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then exit 0 fi -if [[ -d "$BOOT_DIR_ABS" ]]; then +if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then KDUMP_INITRD="initrdkdump" else - BOOT_DIR_ABS="/boot" + # If `KDUMP_BOOTDIR` is not writable, then the kdump + # initrd must have been placed at `/var/lib/kdump` + if [[ ! -w "/boot" ]]; then + KDUMP_INITRD_DIR_ABS="/var/lib/kdump" + else + KDUMP_INITRD_DIR_ABS="/boot" + fi KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img" fi @@ -23,7 +29,7 @@ case "$COMMAND" in # and managed by kdump service ;; remove) - rm -f -- "$BOOT_DIR_ABS/$KDUMP_INITRD" + rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD" ret=$? ;; esac diff --git a/SOURCES/dracut-module-setup.sh b/SOURCES/dracut-module-setup.sh index 8c02006..df08fd7 100755 --- a/SOURCES/dracut-module-setup.sh +++ b/SOURCES/dracut-module-setup.sh @@ -391,6 +391,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 name kdump_setup_znet() { @@ -410,11 +438,17 @@ kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2 local _static _proto _ip_conf _ip_opts _ifname_opts kdumpnic local _netmac=$(kdump_get_mac_addr $_netdev) + local _znet_netdev kdumpnic=$(kdump_setup_ifname $_netdev) - if [ "$(uname -m)" = "s390x" ]; then - kdump_setup_znet $_netdev + _znet_netdev=$(find_online_znet_device) + if [[ -n "$_znet_netdev" ]]; then + $(kdump_setup_znet "$_znet_netdev") + if [[ $? != 0 ]]; then + derror "Failed to set up znet" + exit 1 + fi fi _static=$(kdump_static_ip $_netdev $_srcaddr $kdumpnic) diff --git a/SOURCES/kdump-lib.sh b/SOURCES/kdump-lib.sh index 0279904..97b91c6 100755 --- a/SOURCES/kdump-lib.sh +++ b/SOURCES/kdump-lib.sh @@ -724,20 +724,30 @@ prepare_kdump_bootinfo() boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd" for initrd in $boot_initrdlist; do if [ -f "$KDUMP_BOOTDIR/$initrd" ]; then - DEFAULT_INITRD="$KDUMP_BOOTDIR/$initrd" + defaut_initrd_base="$initrd" + DEFAULT_INITRD="$KDUMP_BOOTDIR/$defaut_initrd_base" break fi done - # Get kdump initrd from default initrd filename + # Create kdump initrd basename from default initrd basename # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img # initrd => initrdkdump - if [[ -z "$DEFAULT_INITRD" ]]; then - KDUMP_INITRD=${KDUMP_BOOTDIR}/initramfs-${KDUMP_KERNELVER}kdump.img - elif [[ $(basename $DEFAULT_INITRD) == *.* ]]; then - KDUMP_INITRD=${DEFAULT_INITRD%.*}kdump.${DEFAULT_INITRD##*.} + if [[ -z "$defaut_initrd_base" ]]; then + kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img + elif [[ $defaut_initrd_base == *.* ]]; then + kdump_initrd_base=${defaut_initrd_base%.*}kdump.${DEFAULT_INITRD##*.} else - KDUMP_INITRD=${DEFAULT_INITRD}kdump + kdump_initrd_base=${defaut_initrd_base}kdump + fi + + # Place kdump initrd in `/var/lib/kdump` if `KDUMP_BOOTDIR` not writable + if [[ ! -w "$KDUMP_BOOTDIR" ]];then + var_target_initrd_dir="/var/lib/kdump" + mkdir -p "$var_target_initrd_dir" + KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base" + else + KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base" fi } diff --git a/SOURCES/kdumpctl b/SOURCES/kdumpctl index 7bdbf6f..4571e3a 100755 --- a/SOURCES/kdumpctl +++ b/SOURCES/kdumpctl @@ -151,8 +151,8 @@ rebuild_kdump_initrd() rebuild_initrd() { - if [[ ! -w "$KDUMP_BOOTDIR" ]];then - derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD" + if [[ ! -w $(dirname $TARGET_INITRD) ]];then + derror "$(dirname $TARGET_INITRD) does not have write permission. Cannot rebuild $TARGET_INITRD" return 1 fi diff --git a/SOURCES/mkdumprd b/SOURCES/mkdumprd index 13945ab..3c2fb5d 100644 --- a/SOURCES/mkdumprd +++ b/SOURCES/mkdumprd @@ -226,7 +226,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" diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index 72c8207..48fc9dd 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.20 -Release: 51%{?dist} +Release: 52%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -195,6 +195,7 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_bindir} mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir} mkdir -p -m755 $RPM_BUILD_ROOT%{_prefix}/lib/kdump +mkdir -p -m755 $RPM_BUILD_ROOT%{_sharedstatedir}/kdump install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl install -m 755 build/sbin/kexec $RPM_BUILD_ROOT/usr/sbin/kexec @@ -359,6 +360,7 @@ done %dir %{_sysconfdir}/kdump %dir %{_sysconfdir}/kdump/pre.d %dir %{_sysconfdir}/kdump/post.d +%dir %{_sharedstatedir}/kdump %{_mandir}/man8/kdumpctl.8.gz %{_mandir}/man8/kexec.8.gz %{_mandir}/man8/makedumpfile.8.gz @@ -383,6 +385,11 @@ done %endif %changelog +* Thu Jun 17 2021 Pingfan Liu - 2.0.20-52 +- Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable +- Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet +- mkdumprd: display the absolute path of dump location in the check_user_configured_target() + * Wed Jun 2 2021 Pingfan Liu - 2.0.20-51 - Stop reloading kdump service on CPU hotplug event for FADump - fadump: improve fadump-howto.txt about remote dump target setup