From 0f257c03d2d45dd5387e622308b3115160382fd8 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Dec 13 2022 06:13:29 +0000 Subject: import kexec-tools-2.0.25-3.el8 --- diff --git a/SOURCES/dracut-module-setup.sh b/SOURCES/dracut-module-setup.sh index 7ad8507..3dfed90 100755 --- a/SOURCES/dracut-module-setup.sh +++ b/SOURCES/dracut-module-setup.sh @@ -1,5 +1,20 @@ #!/bin/bash +_save_kdump_netifs() { + local _name + + if [[ -n $2 ]]; then + _name=$2 + else + _name=$1 + fi + unique_netifs[$1]=$_name +} + +_get_kdump_netifs() { + echo -n "${!unique_netifs[@]}" +} + kdump_module_init() { if ! [[ -d "${initdir}/tmp" ]]; then mkdir -p "${initdir}/tmp" @@ -300,11 +315,35 @@ kdump_setup_ifname() { echo "$_ifname" } +kdump_install_nm_netif_allowlist() { + local _netif _except_netif _netif_allowlist _netif_allowlist_nm_conf + + for _netif in $1; do + _per_mac=$(kdump_get_perm_addr "$_netif") + if [[ "$_per_mac" != 'not set' ]]; then + _except_netif="mac:$_per_mac" + else + _except_netif="interface-name:${unique_netifs[${_netif}]}" + fi + _netif_allowlist="${_netif_allowlist}except:${_except_netif};" + done + + _netif_allowlist_nm_conf=${initdir}/tmp/netif_allowlist_nm_conf + cat << EOF > "$_netif_allowlist_nm_conf" +[device-others] +match-device=${_netif_allowlist} +managed=false +EOF + + inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf" + rm -f "$_netif_allowlist_nm_conf" +} + kdump_setup_bridge() { local _netdev=$1 local _brif _dev _mac _kdumpdev for _dev in `ls /sys/class/net/$_netdev/brif/`; do - _kdumpdev=$_dev + _kdumpdev="" if kdump_is_bond "$_dev"; then kdump_setup_bond "$_dev" elif kdump_is_team "$_dev"; then @@ -316,6 +355,8 @@ kdump_setup_bridge() { _kdumpdev=$(kdump_setup_ifname $_dev) echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf fi + _save_kdump_netifs "$_dev" "$_kdumpdev" + [[ -z $_kdumpdev ]] && _kdumpdev=$_dev _brif+="$_kdumpdev," done echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf @@ -327,6 +368,7 @@ kdump_setup_bond() { for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) + _save_kdump_netifs "$_dev" "$_kdumpdev" echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf _slaves+="$_kdumpdev," done @@ -345,6 +387,7 @@ kdump_setup_team() { for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) + _save_kdump_netifs "$_dev" "$_kdumpdev" echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf _slaves+="$_kdumpdev," done @@ -379,6 +422,7 @@ kdump_setup_vlan() { _kdumpdev="$(kdump_setup_ifname $_phydev)" echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf fi + _save_kdump_netifs "$_phydev" "$_kdumpdev" } # find online znet device @@ -477,6 +521,7 @@ kdump_setup_netdev() { _ifname_opts=" ifname=$kdumpnic:$_netmac" echo "$_ifname_opts" >> $_ip_conf fi + _save_kdump_netifs "$_netdev" "$_kdumpdev" kdump_setup_dns "$_netdev" @@ -765,7 +810,7 @@ kdump_check_iscsi_targets () { # If our prerequisites are not met, fail anyways. type -P iscsistart >/dev/null || return 1 - kdump_check_setup_iscsi() ( + kdump_check_setup_iscsi() { local _dev _dev=$1 @@ -775,7 +820,7 @@ kdump_check_iscsi_targets () { cd .. done [[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD" - ) + } [[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_and_slaves_all kdump_check_setup_iscsi @@ -941,7 +986,8 @@ kdump_install_systemd_conf() { } install() { - local arch + declare -A unique_netifs + local arch _netifs kdump_module_init kdump_install_conf @@ -993,6 +1039,11 @@ install() { # at some point of time. kdump_check_iscsi_targets + _netifs=$(_get_kdump_netifs) + if [[ -n "$_netifs" ]]; then + kdump_install_nm_netif_allowlist "$_netifs" + fi + kdump_install_systemd_conf # For the lvm type target under kdump, in /etc/lvm/lvm.conf we can diff --git a/SOURCES/gen-kdump-conf.sh b/SOURCES/gen-kdump-conf.sh new file mode 100755 index 0000000..4bda9e8 --- /dev/null +++ b/SOURCES/gen-kdump-conf.sh @@ -0,0 +1,223 @@ +#!/bin/bash +# $1: target arch + + +SED_EXP="" + +generate() +{ + sed "$SED_EXP" << EOF +# This file contains a series of commands to perform (in order) in the kdump +# kernel after a kernel crash in the crash kernel(1st kernel) has happened. +# +# Directives in this file are only applicable to the kdump initramfs, and have +# no effect once the root filesystem is mounted and the normal init scripts are +# processed. +# +# Currently, only one dump target and path can be specified. If the dumping to +# the configured target fails, the failure action which can be configured via +# the "failure_action" directive will be performed. +# +# Supported options: +# +# raw +# - Will dd /proc/vmcore into . +# Use persistent device names for partition devices, +# such as /dev/vg/. +# +# nfs +# - Will mount nfs to , and copy /proc/vmcore to +# //%HOST-%DATE/, supports DNS. +# +# ssh +# - Will save /proc/vmcore to :/%HOST-%DATE/, +# supports DNS. +# NOTE: make sure the user has write permissions on the server. +# +# sshkey +# - Will use the sshkey to do ssh dump. +# Specify the path of the ssh key to use when dumping +# via ssh. The default value is /root/.ssh/kdump_id_rsa. +# +# +# - Will mount -t , and copy +# /proc/vmcore to //%DATE/. +# NOTE: can be a device node, label or uuid. +# It's recommended to use persistent device names +# such as /dev/vg/. +# Otherwise it's suggested to use label or uuid. +# +# path +# - "path" represents the file system path in which vmcore +# will be saved. If a dump target is specified in +# kdump.conf, then "path" is relative to the specified +# dump target. +# +# Interpretation of "path" changes a bit if the user didn't +# specify any dump target explicitly in kdump.conf. In this +# case, "path" represents the absolute path from root. The +# dump target and adjusted path are arrived at automatically +# depending on what's mounted in the current system. +# +# Ignored for raw device dumps. If unset, will use the default +# "/var/crash". +# +# core_collector +# - This allows you to specify the command to copy +# the vmcore. The default is makedumpfile, which on +# some architectures can drastically reduce vmcore size. +# See /sbin/makedumpfile --help for a list of options. +# Note that the -i and -g options are not needed here, +# as the initrd will automatically be populated with a +# config file appropriate for the running kernel. +# The default core_collector for raw/ssh dump is: +# "makedumpfile -F -l --message-level 7 -d 31". +# The default core_collector for other targets is: +# "makedumpfile -l --message-level 7 -d 31". +# +# "makedumpfile -F" will create a flattened vmcore. +# You need to use "makedumpfile -R" to rearrange the dump data to +# a normal dumpfile readable with analysis tools. For example: +# "makedumpfile -R vmcore < vmcore.flat". +# +# For core_collector format details, you can refer to +# kexec-kdump-howto.txt or kdump.conf manpage. +# +# kdump_post +# - This directive allows you to run a executable binary +# or script after the vmcore dump process terminates. +# The exit status of the current dump process is fed to +# the executable binary or script as its first argument. +# All files under /etc/kdump/post.d are collectively sorted +# and executed in lexical order, before binary or script +# specified kdump_post parameter is executed. +# +# kdump_pre +# - Works like the "kdump_post" directive, but instead of running +# after the dump process, runs immediately before it. +# Exit status of this binary is interpreted as follows: +# 0 - continue with dump process as usual +# non 0 - run the final action (reboot/poweroff/halt) +# All files under /etc/kdump/pre.d are collectively sorted and +# executed in lexical order, after binary or script specified +# kdump_pre parameter is executed. +# Even if the binary or script in /etc/kdump/pre.d directory +# returns non 0 exit status, the processing is continued. +# +# extra_bins +# - This directive allows you to specify additional binaries or +# shell scripts to be included in the kdump initrd. +# Generally they are useful in conjunction with a kdump_post +# or kdump_pre binary or script which depends on these extra_bins. +# +# extra_modules +# - This directive allows you to specify extra kernel modules +# that you want to be loaded in the kdump initrd. +# Multiple modules can be listed, separated by spaces, and any +# dependent modules will automatically be included. +# +# failure_action +# - Action to perform in case dumping fails. +# reboot: Reboot the system. +# halt: Halt the system. +# poweroff: Power down the system. +# shell: Drop to a bash shell. +# Exiting the shell reboots the system by default, +# or perform "final_action". +# dump_to_rootfs: Dump vmcore to rootfs from initramfs context and +# reboot by default or perform "final_action". +# Useful when non-root dump target is specified. +# The default option is "reboot". +# +# default +# - Same as the "failure_action" directive above, but this directive +# is obsolete and will be removed in the future. +# +# final_action +# - Action to perform in case dumping succeeds. Also performed +# when "shell" or "dump_to_rootfs" failure action finishes. +# Each action is same as the "failure_action" directive above. +# The default is "reboot". +# +# force_rebuild <0 | 1> +# - By default, kdump initrd will only be rebuilt when necessary. +# Specify 1 to force rebuilding kdump initrd every time when kdump +# service starts. +# +# force_no_rebuild <0 | 1> +# - By default, kdump initrd will be rebuilt when necessary. +# Specify 1 to bypass rebuilding of kdump initrd. +# +# force_no_rebuild and force_rebuild options are mutually +# exclusive and they should not be set to 1 simultaneously. +# +# override_resettable <0 | 1> +# - Usually an unresettable block device can't be a dump target. +# Specifying 1 when you want to dump even though the block +# target is unresettable +# By default, it is 0, which will not try dumping destined to fail. +# +# dracut_args +# - Pass extra dracut options when rebuilding kdump initrd. +# +# fence_kdump_args +# - Command line arguments for fence_kdump_send (it can contain +# all valid arguments except hosts to send notification to). +# +# fence_kdump_nodes +# - List of cluster node(s) except localhost, separated by spaces, +# to send fence_kdump notifications to. +# (this option is mandatory to enable fence_kdump). +# + +#raw /dev/vg/lv_kdump +#ext4 /dev/vg/lv_kdump +#ext4 LABEL=/boot +#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 +#nfs my.server.com:/export/tmp +#nfs [2001:db8::1:2:3:4]:/export/tmp +#ssh user@my.server.com +#ssh user@2001:db8::1:2:3:4 +#sshkey /root/.ssh/kdump_id_rsa +path /var/crash +core_collector makedumpfile -l --message-level 7 -d 31 +#core_collector scp +#kdump_post /var/crash/scripts/kdump-post.sh +#kdump_pre /var/crash/scripts/kdump-pre.sh +#extra_bins /usr/bin/lftp +#extra_modules gfs2 +#failure_action shell +#force_rebuild 1 +#force_no_rebuild 1 +#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" +#fence_kdump_args -p 7410 -f auto -c 0 -i 10 +#fence_kdump_nodes node1 node2 +EOF +} + +update_param() +{ + SED_EXP="${SED_EXP}s/^$1.*$/$1 $2/;" +} + +case "$1" in +aarch64) + ;; +i386) + ;; +ppc64) + ;; +ppc64le) + ;; +s390x) + update_param core_collector \ + "makedumpfile -c --message-level 7 -d 31" + ;; +x86_64) + ;; +*) + echo "Warning: Unknown architecture '$1', using default kdump.conf template." + ;; +esac + +generate diff --git a/SOURCES/kdump.conf b/SOURCES/kdump.conf deleted file mode 100644 index a0af268..0000000 --- a/SOURCES/kdump.conf +++ /dev/null @@ -1,185 +0,0 @@ -# This file contains a series of commands to perform (in order) in the kdump -# kernel after a kernel crash in the crash kernel(1st kernel) has happened. -# -# Directives in this file are only applicable to the kdump initramfs, and have -# no effect once the root filesystem is mounted and the normal init scripts are -# processed. -# -# Currently, only one dump target and path can be specified. If the dumping to -# the configured target fails, the failure action which can be configured via -# the "failure_action" directive will be performed. -# -# Supported options: -# -# raw -# - Will dd /proc/vmcore into . -# Use persistent device names for partition devices, -# such as /dev/vg/. -# -# nfs -# - Will mount nfs to , and copy /proc/vmcore to -# //%HOST-%DATE/, supports DNS. -# -# ssh -# - Will save /proc/vmcore to :/%HOST-%DATE/, -# supports DNS. -# NOTE: make sure the user has write permissions on the server. -# -# sshkey -# - Will use the sshkey to do ssh dump. -# Specify the path of the ssh key to use when dumping -# via ssh. The default value is /root/.ssh/kdump_id_rsa. -# -# -# - Will mount -t , and copy -# /proc/vmcore to //%DATE/. -# NOTE: can be a device node, label or uuid. -# It's recommended to use persistent device names -# such as /dev/vg/. -# Otherwise it's suggested to use label or uuid. -# -# path -# - "path" represents the file system path in which vmcore -# will be saved. If a dump target is specified in -# kdump.conf, then "path" is relative to the specified -# dump target. -# -# Interpretation of "path" changes a bit if the user didn't -# specify any dump target explicitly in kdump.conf. In this -# case, "path" represents the absolute path from root. The -# dump target and adjusted path are arrived at automatically -# depending on what's mounted in the current system. -# -# Ignored for raw device dumps. If unset, will use the default -# "/var/crash". -# -# core_collector -# - This allows you to specify the command to copy -# the vmcore. The default is makedumpfile, which on -# some architectures can drastically reduce vmcore size. -# See /sbin/makedumpfile --help for a list of options. -# Note that the -i and -g options are not needed here, -# as the initrd will automatically be populated with a -# config file appropriate for the running kernel. -# The default core_collector for raw/ssh dump is: -# "makedumpfile -F -l --message-level 7 -d 31". -# The default core_collector for other targets is: -# "makedumpfile -l --message-level 7 -d 31". -# -# "makedumpfile -F" will create a flattened vmcore. -# You need to use "makedumpfile -R" to rearrange the dump data to -# a normal dumpfile readable with analysis tools. For example: -# "makedumpfile -R vmcore < vmcore.flat". -# -# For core_collector format details, you can refer to -# kexec-kdump-howto.txt or kdump.conf manpage. -# -# kdump_post -# - This directive allows you to run a executable binary -# or script after the vmcore dump process terminates. -# The exit status of the current dump process is fed to -# the executable binary or script as its first argument. -# All files under /etc/kdump/post.d are collectively sorted -# and executed in lexical order, before binary or script -# specified kdump_post parameter is executed. -# -# kdump_pre -# - Works like the "kdump_post" directive, but instead of running -# after the dump process, runs immediately before it. -# Exit status of this binary is interpreted as follows: -# 0 - continue with dump process as usual -# non 0 - run the final action (reboot/poweroff/halt) -# All files under /etc/kdump/pre.d are collectively sorted and -# executed in lexical order, after binary or script specified -# kdump_pre parameter is executed. -# Even if the binary or script in /etc/kdump/pre.d directory -# returns non 0 exit status, the processing is continued. -# -# extra_bins -# - This directive allows you to specify additional binaries or -# shell scripts to be included in the kdump initrd. -# Generally they are useful in conjunction with a kdump_post -# or kdump_pre binary or script which depends on these extra_bins. -# -# extra_modules -# - This directive allows you to specify extra kernel modules -# that you want to be loaded in the kdump initrd. -# Multiple modules can be listed, separated by spaces, and any -# dependent modules will automatically be included. -# -# failure_action -# - Action to perform in case dumping fails. -# reboot: Reboot the system. -# halt: Halt the system. -# poweroff: Power down the system. -# shell: Drop to a bash shell. -# Exiting the shell reboots the system by default, -# or perform "final_action". -# dump_to_rootfs: Dump vmcore to rootfs from initramfs context and -# reboot by default or perform "final_action". -# Useful when non-root dump target is specified. -# The default option is "reboot". -# -# default -# - Same as the "failure_action" directive above, but this directive -# is obsolete and will be removed in the future. -# -# final_action -# - Action to perform in case dumping succeeds. Also performed -# when "shell" or "dump_to_rootfs" failure action finishes. -# Each action is same as the "failure_action" directive above. -# The default is "reboot". -# -# force_rebuild <0 | 1> -# - By default, kdump initrd will only be rebuilt when necessary. -# Specify 1 to force rebuilding kdump initrd every time when kdump -# service starts. -# -# force_no_rebuild <0 | 1> -# - By default, kdump initrd will be rebuilt when necessary. -# Specify 1 to bypass rebuilding of kdump initrd. -# -# force_no_rebuild and force_rebuild options are mutually -# exclusive and they should not be set to 1 simultaneously. -# -# override_resettable <0 | 1> -# - Usually an unresettable block device can't be a dump target. -# Specifying 1 when you want to dump even though the block -# target is unresettable -# By default, it is 0, which will not try dumping destined to fail. -# -# dracut_args -# - Pass extra dracut options when rebuilding kdump initrd. -# -# fence_kdump_args -# - Command line arguments for fence_kdump_send (it can contain -# all valid arguments except hosts to send notification to). -# -# fence_kdump_nodes -# - List of cluster node(s) except localhost, separated by spaces, -# to send fence_kdump notifications to. -# (this option is mandatory to enable fence_kdump). -# - -#raw /dev/vg/lv_kdump -#ext4 /dev/vg/lv_kdump -#ext4 LABEL=/boot -#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 -#nfs my.server.com:/export/tmp -#nfs [2001:db8::1:2:3:4]:/export/tmp -#ssh user@my.server.com -#ssh user@2001:db8::1:2:3:4 -#sshkey /root/.ssh/kdump_id_rsa -path /var/crash -core_collector makedumpfile -l --message-level 7 -d 31 -#core_collector scp -#kdump_post /var/crash/scripts/kdump-post.sh -#kdump_pre /var/crash/scripts/kdump-pre.sh -#extra_bins /usr/bin/lftp -#extra_modules gfs2 -#failure_action shell -#force_rebuild 1 -#force_no_rebuild 1 -#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" -#fence_kdump_args -p 7410 -f auto -c 0 -i 10 -#fence_kdump_nodes node1 node2 diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index 344a52a..1ea0a42 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.25 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -12,7 +12,7 @@ Source3: kdump.sysconfig.x86_64 Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd -Source8: kdump.conf +Source8: gen-kdump-conf.sh Source9: https://github.com/makedumpfile/makedumpfile/archive/1.7.1.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 @@ -158,6 +158,9 @@ cp %{SOURCE27} . cp %{SOURCE28} . cp %{SOURCE31} . +# Generate sysconfig file +%{SOURCE8} %{_target_cpu} > kdump.conf + make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic @@ -196,7 +199,7 @@ install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/mkdumprd install -m 755 %{SOURCE36} $RPM_BUILD_ROOT/usr/sbin/mkfadumprd -install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf +install -m 644 kdump.conf $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 install -m 644 %{SOURCE25} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 @@ -393,6 +396,10 @@ done %endif %changelog +* Fri Dec 2 2022 Pingfan Liu - 2.0.25-3 +- kdump.conf: use a simple generator script to maintain +- Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces + * Mon Oct 17 2022 Pingfan Liu - 2.0.25-2 - mkdumprd: Improve error messages on non-existing NFS target directories - fadump: avoid non-debug kernel use for fadump case