[PATCH] Skip reading /etc/defaut/grub for s390x
by Coiby Xu
Currently, updating kexec-tools gives the warning
sed: can't read /etc/default/grub: No such file or directory
This happens because s390x doesn't use GRUB and /etc/default/grub
doesn't exist. We need to skip both reading and writing to
/etc/default/grub.
Reported-by: Jie Li <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index c7efa2c3..498bb964 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1428,10 +1428,6 @@ _update_kernel_arg_in_grub_etc_default()
{
local _para=$1 _val=$2 _para_val
- if [[ $(uname -m) == s390x ]]; then
- return
- fi
-
if [[ -n $_val ]]; then
_para_val="$_para=$_val"
fi
@@ -1606,6 +1602,10 @@ update_crashkernel_in_grub_etc_default_after_update()
local _crashkernel _fadump_val
local _dump_mode _old_default_crashkernel _new_default_crashkernel
+ if [[ $(uname -m) == s390x ]]; then
+ return
+ fi
+
_crashkernel=$(_read_kernel_arg_in_grub_etc_default crashkernel)
if [[ -z $_crashkernel ]]; then
--
2.37.3
1 year, 1 month
[PATCH] Fix grep warnings "grep: warning: stray \ before -"
by Coiby Xu
Latest grep (3.8) warns about unneeded backslashes when building kdump
initrd [1],
kdump: Rebuilding /boot/initramfs-6.0.0-0.rc5.a335366bad13.40.test.fc38.aarch64kdump.img
grep: warning: stray \ before -
grep: warning: stray \ before -
grep: warning: stray \ before -
grep: warning: stray \ before -
grep: warning: stray \ before -
Use the -- argument (don't treat the following - as options) to get rid
of these warnings.
[1] https://s3.us-east-1.amazonaws.com/arr-cki-prod-datawarehouse-public/data...
Reported-by: Baoquan He <bhe(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdump-lib-initramfs.sh | 4 ++--
kdumpctl | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 84e6bf75..73a464d5 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -58,13 +58,13 @@ is_fs_type_nfs()
# If $1 contains dracut_args "--mount", return <filesystem type>
get_dracut_args_fstype()
{
- echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3
+ echo $1 | grep -- "--mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3
}
# If $1 contains dracut_args "--mount", return <device>
get_dracut_args_target()
{
- echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1
+ echo $1 | grep -- "--mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1
}
get_save_path()
diff --git a/kdumpctl b/kdumpctl
index 0e37d36e..3503befe 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -224,7 +224,7 @@ parse_config()
case "$config_opt" in
dracut_args)
if [[ $config_val == *--mount* ]]; then
- if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
+ if [[ $(echo "$config_val" | grep -o -- "--mount" | wc -l) -ne 1 ]]; then
derror 'Multiple mount targets specified in one "dracut_args".'
return 1
fi
@@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount
# point and file system. If any of them mismatches then rebuild
- if echo "$_dracut_args" | grep -q "\-\-mount"; then
+ if echo "$_dracut_args" | grep -q -- "--mount"; then
# shellcheck disable=SC2046
set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3)
_old_dev=$1
--
2.37.3
1 year, 1 month
[PATCH v2 00/11] reuse NetworkManager connection profiles to set up kdump network
by Coiby Xu
Currently, kexec-tools parses legacy ifcfg-* configuration files or
NetworkManager .nmconnection connection profiles to build up dracut
command line parameters like ip=. Then dracut parses these parameters and
runs nm-initrd-generator to generate NetworkManager connection profiles.
Taking a bonding network as an example, nm-initrd-generator generates two
connections as follows,
$ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection]
id=mybond0
uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
interface-name=mybond0
[ipv4]
dhcp-timeout=90
...
*** Connection 'kdump-eth0' ***
[connection]
id=kdump-eth0
uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b
type=ethernet
interface-name=kdump-eth0
master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
slave-type=bond
wait-device-timeout=60000
...
Later in kdump initrd, dracut starts NetworkManager to activate these
profiles to bring up the network connections. This way of setting up
kdump network is tedious, error-prone and unnecessary. A better way is
to directly copy the needed connection profiles to initrd. A potential
benefit of this approach for the users is they can simply edit the
connection profile directly like changing ipv4.dhcp-timeout instead of
being forced to use the hard-coded value enforced by
nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to setup kdump
network. It also reduces the memory consumption of network drivers and
fix other issues at the same time. A machine could have multiple network
drivers and a network driver may manage multiple NICs. It's possible
kdump may only need one NIC. In this case, there is no need to install
unneeded network drivers or bring up unneeded NICs.
There are cases where a NIC may have a different name in the kdump
kernel. Currently, kexec-tools creates udev rules to rename NIC to have
a consistent name. With the new approach, we can simply ask NM to match
the connection profile by MAC address instead.
Here are the bug list that addressed by this patch set,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm
- bugs related to OOM caused by network driver
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump
- Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target
- Bug 1890021 - be2net is using too much memory during kdump
- Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
Note this patch set is available for review on
https://github.com/coiby/kexec-tools/pull/9
v2:
- removes useless cat which also avoids SC2013
- fix code format issue and shellcheck warning
- squash four commits "set up kdump network {bridge,vlan,bridge,team} by directly
copying NM connection profile to initrd" to switch to the new approach
all at once to avoid confusion and causing trouble for git bisection
- fix several issues found by Philipp
- add missing reference
- use an array instead of supress shellchek SC2086 warning
- use $_netifs instead of $_netif_allowlist to intruct NM to only
manage specified NICs
- multiple typos
- use nmcli --get-values to get type first then construct MAC field
name
- get rid of the extra indentation
- s/uniq_name/unique_name/
v1:
- refactor complex kdump_copy_nmconnection_file [Philipp]
- clean up temporary file in a trap [Philipp]
- improve sed [Philipp]
- use long name consistently [Philipp]
- use nmcli -t, --terse option to suppress printing of the header [Philipp]
- don't pass kdumpip to initrd [Kairui]
- address the case where kdump_install_net is called multiple times like
fence kdump
- call kdump_install_nm_netif_allowlist after all kdump_install_net
calls have been finished
- ask NM to match a connection profile to a physical NIC by MAC address
- stop treating vlan specially when its parent interface is a physical NIC
- don't add unused NIC drivers to kdump initrd
- fix the error of "/etc/NetworkManager/system-connections/*.nmconnection" not exist
grep: /etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
- redirect the messages of nmcli to ddebug
- use "grep -s" to get rid of the following warnings
grep: /var/tmp/dracut.6tqUm0/initramfs//etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
grep: /etc/sysconfig/network-scripts/ifcfg-*: No such file or directory
grep: /etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
Coiby Xu (11):
add function to copy NetworkManage connection profile to the initramfs
clone NM connection profiles to support legacy ifcfg automatically
ask NM to wait the network device to be available
stop dracut 35network-manager from running nm-initrd-generator
fix error for vlan over team network interface
set up kdump network by directly copying NM connection profile to
initrd
clean up unneeded code after copying .nmconnection to initrd
reduce kdump memory consumption by not letting NetworkManager manage
unneeded network interfaces
reduce kdump memory consumption by only installing needed NIC drivers
address the cases where a NIC has a different name in kdump kernel
simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 39 +-
dracut-module-setup.sh | 483 ++++++++----------
dracut-module-setup.sh.fix | 994 +++++++++++++++++++++++++++++++++++++
kdump-lib-initramfs.sh | 14 +
mkdumprd | 2 +-
5 files changed, 1243 insertions(+), 289 deletions(-)
create mode 100755 dracut-module-setup.sh.fix
--
2.37.1
1 year, 1 month
[PATCH 1/2] Choosing the most memory-consuming key slot when estimating the memory requirement for LUKS-encrypted target
by Coiby Xu
When there are multiple key slots, "kdumpctl estimate" uses the least
memory-consuming key slot. For example, when there are two memory slots
created with --pbkdf-memory=1048576 (1G) and --pbkdf-memory=524288 (512M),
"kdumpctl estimate" thinks the extra memory requirement is only 512M.
This will of course lead to OOM if the user uses the more
memory-consuming key slot. Fix it by sorting in reverse order.
Fixes: e9e6a2c ("kdumpctl: Add kdumpctl estimate")
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
kdumpctl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 126ecb9..ee40d33 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1241,7 +1241,7 @@ do_estimate()
for _dev in $(get_all_kdump_crypt_dev); do
_crypt_info=$(cryptsetup luksDump "/dev/block/$_dev")
[[ $(echo "$_crypt_info" | sed -n "s/^Version:\s*\(.*\)/\1/p") == "2" ]] || continue
- for _mem in $(echo "$_crypt_info" | sed -n "s/\sMemory:\s*\(.*\)/\1/p" | sort -n); do
+ for _mem in $(echo "$_crypt_info" | sed -n "s/\sMemory:\s*\(.*\)/\1/p" | sort -n -r); do
crypt_size=$((crypt_size + _mem * 1024))
break
done
--
2.37.1
1 year, 1 month
[PATCH v1 00/14] reuse NetworkManager connection profiles to set up kdump network
by Coiby Xu
Currently, kexec-tools parses legacy ifcfg-* configuration files or
NetworkManager .nmconnection connection profiles to build up dracut
command line parameters like ip=. Then dracut parses these parameters and
runs nm-initrd-generator to generate NetworkManager connection profiles.
Taking a bonding network as an example, nm-initrd-generator generates two
connections as follows,
$ /usr/libexec/nm-initrd-generator -s -- bootdev=mybond0 rd.neednet kdumpnic=mybond0 bond=mybond0:kdump-eth0
*** Connection 'mybond0' ***
[connection]
id=mybond0
uuid=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
interface-name=mybond0
[ipv4]
dhcp-timeout=90
...
*** Connection 'kdump-eth0' ***
[connection]
id=kdump-eth0
uuid=ed6a7448-b5f8-4f8a-b718-3e24ea1c924b
type=ethernet
interface-name=kdump-eth0
master=ed87d02b-dd44-4f0e-8b11-37db7e89bb48
slave-type=bond
wait-device-timeout=60000
...
Later in kdump initrd, dracut starts NetworkManager to activate these
profiles to bring up the network connections. This way of setting up
kdump network is tedious, error-prone and unnecessary. A better way is
to directly copy the needed connection profiles to initrd. A potential
benefit of this approach for the users is they can simply edit the
connection profile directly like changing ipv4.dhcp-timeout instead of
being forced to use the hard-coded value enforced by
nm-initrd-generator.
This patch set reuses NetworkManager connection profiles to setup kdump
network. It also reduces the memory consumption of network drivers and
fix other issues at the same time. A machine could have multiple network
drivers and a network driver may manage multiple NICs. It's possible
kdump may only need one NIC. In this case, there is no need to install
unneeded network drivers or bring up unneeded NICs.
Here are the bug list that addressed by this patch set,
- Bug 1962421 - [RHEL-9]"eth0: Failed to rename network interface 3 from 'eth0' to 'kdump-eth0': File exists"
- Bug 2064708 - kdump: mkdumprd: failed to make kdump initrd for bridge network on z15 z/vm
- bugs related to OOM caused by network driver
- Bug 1950282 - shutdown those unneeded network interfaces to save memory for kdump
- Bug 1958587 - the kdump initramfs includes unnecessary NIC drivers for SSH/NFS dumping target
- Bug 1890021 - be2net is using too much memory during kdump
- Bug 1662202 - [RHEL-8.1] aarch64: hpe-apache crashkernel OOM when dump to network targe
v1:
- refactor complex kdump_copy_nmconnection_file [Philipp]
- clean up temporary file in a trap [Philipp]
- improve sed [Philipp]
- use long name consistently [Philipp]
- use nmcli -t, --terse option to suppress printing of the header [Philipp]
- don't pass kdumpip to initrd [Kairui]
- address the case where kdump_install_net is called multiple times like
fence kdump
- call kdump_install_nm_netif_allowlist after all kdump_install_net
calls have been finished
- ask NM to match a connection profile to a physical NIC by MAC address
- stop treating vlan specially when its parent interface is a physical NIC
- don't add unused NIC drivers to kdump initrd
- fix the error of "/etc/NetworkManager/system-connections/*.nmconnection" not exist
grep: /etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
- redirect the messages of nmcli to ddebug
- use "grep -s" to get rid of the following warnings
grep: /var/tmp/dracut.6tqUm0/initramfs//etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
grep: /etc/sysconfig/network-scripts/ifcfg-*: No such file or directory
grep: /etc/NetworkManager/system-connections/*.nmconnection: No such file or directory
Coiby Xu (14):
add function to copy NetworkManage connection profile to the initramfs
clone NM connection profiles to support legacy ifcfg automatically
ask NM to wait the network device to be available
stop dracut 35network-manager from running nm-initrd-generator
set up kdump network bridge by directly copying NM connection profile
to initrd
set up kdump bonding network by directly copying NM connection profile
to initrd
fix error for vlan over team network interface
set up kdump vlan network by directly copying NM connection profile to
initrd
set up kdump teaming network by directly copying NM connection profile
to initrd
clean up unneeded code after copying .nmconnection to initrd
reduce kdump memory consumption by not letting NetworkManager manage
unneeded network interfaces
reduce kdump memory consumption by only installing needed NIC drivers
address the cases where a NIC has a different name in kdump kernel
simplify setup_znet by copying connection profile to initrd
dracut-kdump.sh | 25 ++-
dracut-module-setup.sh | 484 ++++++++++++++++++-----------------------
kdump-lib-initramfs.sh | 12 +
mkdumprd | 2 +-
4 files changed, 239 insertions(+), 284 deletions(-)
--
2.35.3
1 year, 1 month
[PATCH 1/2] Prefix reset-crashkernel-{for-installed_kernel,after-update} with underscore
by Coiby Xu
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2048690
To indicate they are for internal use only, underscore them.
Reported-by: rcheerla(a)redhat.com
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
92-crashkernel.install | 2 +-
kdumpctl | 4 ++--
kexec-tools.spec | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/92-crashkernel.install b/92-crashkernel.install
index 1d67a133..19bd0784 100755
--- a/92-crashkernel.install
+++ b/92-crashkernel.install
@@ -7,7 +7,7 @@ KERNEL_IMAGE="$4"
case "$COMMAND" in
add)
- kdumpctl reset-crashkernel-for-installed_kernel "$KERNEL_VERSION"
+ kdumpctl _reset-crashkernel-for-installed_kernel "$KERNEL_VERSION"
exit 0
;;
esac
diff --git a/kdumpctl b/kdumpctl
index 0e37d36e..19febd53 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1764,12 +1764,12 @@ main()
shift
reset_crashkernel "$@"
;;
- reset-crashkernel-after-update)
+ _reset-crashkernel-after-update)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then
reset_crashkernel_after_update
fi
;;
- reset-crashkernel-for-installed_kernel)
+ _reset-crashkernel-for-installed_kernel)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then
reset_crashkernel_for_installed_kernel "$2"
fi
diff --git a/kexec-tools.spec b/kexec-tools.spec
index ee43b13c..5f0e1b53 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -343,7 +343,7 @@ done
# 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The
# former case is used to set up crashkernel for osbuild
if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then
- kdumpctl reset-crashkernel-after-update
+ kdumpctl _reset-crashkernel-after-update
rm /tmp/old_default_crashkernel 2>/dev/null
%ifarch ppc64 ppc64le
rm /tmp/old_default_crashkernel_fadump 2>/dev/null
--
2.37.2
1 year, 1 month
[PATCH v3] Seperate dracut and dracut-squash compressor for zstd
by Tao Liu
Previously kexec-tools will pass "--compress zstd" to dracut. It
will make dracut to decide whether: a) call mksquashfs to make a
zstd format squash-root.img, b) call cmd zstd to make a initramfs.
Since dracut(>= 057) has decoupled the compressor for dracut and
dracut-squash, So in this patch, we will pass the compressor seperately.
Note:
The is_squash_available && !dracut_has_option --squash-compressor
&& !is_zsdt_command_available case is left unprocessed on purpose.
Actually, the situation when we want to call zstd compression is:
1) If squash function OK, we want dracut to invoke mksquashfs to make
a zstd format squash-root.img within initramfs.
2) If squash function is not OK, and cmd zstd presents, we want dracut
to invoke cmd zstd to make a zstd format initramfs.
is_zstd_command_available check can handle case 2 completely.
However, for the is_squash_available check, it cannot handle case 1
completely. It only checks if the kernel supports squashfs, it doesn't
check whether the squash module has been added by dracut when making
initramfs. In fact, in kexec-tools we are unable to do the check,
there are multiple ways to forbit dracut to load a module, such as
"dracut -o module" and "omit_dracutmodules in dracut.conf".
When squash dracut module is omitted, is_squash_available check will
still pass, so "--compress zstd" will be appended to dracut cmdline,
and it will call cmd zstd to do the compression. However cmd zstd may
not exist, so it fails.
The previous "--compress zstd" is ambiguous, after the intro of
"--squash-compressor", "--squash-compressor" only effect for
mksquashfs and "--compress" only effect for specific cmd.
So for the is_squash_available && !dracut_has_option
--squash-compressor && !is_zsdt_command_available case, we just leave
it to be handled the default way.
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
v1 -> v2:
1) Add a checker if dracut doesn't have "--squash-compressor"
option.
2) Removed the "Recommends: zstd" in spec file. Since it is optional
and won't break any function if not present.
v2 -> v3: updated the commit log.
---
kdump-lib.sh | 8 +++++++-
kexec-tools.spec | 1 -
mkdumprd | 7 +++----
mkfadumprd | 4 +++-
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 4b88908..f93e7d6 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -37,6 +37,12 @@ is_zstd_command_available()
[[ -x "$(command -v zstd)" ]]
}
+dracut_have_option()
+{
+ local _option=$1
+ ! $(dracut "$_option" 2>&1 | grep -q "unrecognized option")
+}
+
perror_exit()
{
derror "$@"
@@ -458,7 +464,7 @@ is_wdt_active()
have_compression_in_dracut_args()
{
[[ "$(kdump_get_conf_val dracut_args)" =~ \
- (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress)([[:space:]]|$) ]]
+ (^|[[:space:]])--(gzip|bzip2|lzma|xz|lzo|lz4|zstd|no-compress|compress|squash-compressor)([[:space:]]|$) ]]
}
# If "dracut_args" contains "--mount" information, use it
diff --git a/kexec-tools.spec b/kexec-tools.spec
index ee43b13..c829bbe 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -64,7 +64,6 @@ Requires: dracut >= 050
Requires: dracut-network >= 050
Requires: dracut-squash >= 050
Requires: ethtool
-Recommends: zstd
Recommends: grubby
Recommends: hostname
BuildRequires: make
diff --git a/mkdumprd b/mkdumprd
index c0f131d..f553b45 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -432,10 +432,9 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- # Here zstd is set as the default compression method. If squash module
- # is available for dracut, libzstd will be used by mksquashfs. If
- # squash module is unavailable, command zstd will be used instead.
- if is_squash_available || is_zstd_command_available; then
+ if is_squash_available && dracut_have_option "--squash-compressor"; then
+ add_dracut_arg "--squash-compressor" "zstd"
+ elif is_zstd_command_available; then
add_dracut_arg "--compress" "zstd"
fi
fi
diff --git a/mkfadumprd b/mkfadumprd
index 86dfcee..f353f15 100644
--- a/mkfadumprd
+++ b/mkfadumprd
@@ -64,7 +64,9 @@ fi
# Same as setting zstd in mkdumprd
if ! have_compression_in_dracut_args; then
- if is_squash_available || is_zstd_command_available; then
+ if is_squash_available && dracut_have_option "--squash-compressor"; then
+ _dracut_isolate_args+=(--squash-compressor zstd)
+ elif is_zstd_command_available; then
_dracut_isolate_args+=(--compress zstd)
fi
fi
--
2.33.1
1 year, 1 month
[PATCH v3] virtiofs support for kexec-tools
by Tao Liu
This patch add virtiofs support for kexec-tools by introducing a new option
for /etc/kdump.conf:
virtiofs myfs
Where myfs is a variable tag name specified in qemu cmdline
"-device vhost-user-fs-pci,tag=myfs".
The patch covers the following cases:
1) Dumping VM's vmcore to a virtiofs shared directory;
2) When the VM's rootfs is a virtiofs shared directory and dumping the
VM's vmcore to its subdirectory, such as /var/crash;
3) The combination of case 1 & 2: The VM's rootfs is a virtiofs shared
directory and dumping the VM's vmcore to another virtiofs shared
directory.
Case 2 & 3 need dracut >= 057, otherwise VM cannot boot from virtiofs
shared rootfs. But it is not the issue of kexec-tools.
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
v1 -> v2:
1) Bump the dracut version to 057
2) Merged get_user_configured_dump_disk() to get_block_dump_target()
since the latter is the only user.
3) Updated kdump.conf with supported fstype
v2 -> v3:
1) Make _fstype local
2) Drop the dracut version bumping patch. As explained in the
commit, if dracut < 057, or no virtiofs module added into initramfs,
the VM won't boot up from virtiofs shared rootfs. So the successful
booting can ensure virtiofs exist, we don't need to re-ensure it in
kexec-tools.
---
dracut-kdump.sh | 2 +-
dracut-module-setup.sh | 2 +-
kdump-lib-initramfs.sh | 24 +++++++++++++++++++++++-
kdump-lib.sh | 33 +++++++++++++++------------------
kdump.conf | 2 ++
kdumpctl | 6 +++---
mkdumprd | 2 +-
7 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index f4456a1..5c980a8 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -519,7 +519,7 @@ read_kdump_confs()
DUMP_INSTRUCTION="dump_fs $config_val"
fi
;;
- ext[234] | xfs | btrfs | minix | nfs)
+ ext[234] | xfs | btrfs | minix | nfs | virtiofs)
config_val=$(get_mntpoint_from_target "$config_val")
DUMP_INSTRUCTION="dump_fs $config_val"
;;
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 4c6096a..a790a93 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -673,7 +673,7 @@ kdump_install_conf() {
_pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val")
sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf"
;;
- ext[234] | xfs | btrfs | minix)
+ ext[234] | xfs | btrfs | minix | virtiofs)
_pdev=$(kdump_get_persistent_dev "$_val")
sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf"
;;
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 84e6bf7..e982b14 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -55,6 +55,11 @@ is_fs_type_nfs()
[ "$1" = "nfs" ] || [ "$1" = "nfs4" ]
}
+is_fs_type_virtiofs()
+{
+ [ "$1" = "virtiofs" ]
+}
+
# If $1 contains dracut_args "--mount", return <filesystem type>
get_dracut_args_fstype()
{
@@ -110,6 +115,23 @@ is_raw_dump_target()
[ -n "$(kdump_get_conf_val raw)" ]
}
+is_virtiofs_dump_target()
+{
+ if [ -n "$(kdump_get_conf_val virtiofs)" ]; then
+ return 0
+ fi
+
+ if is_fs_type_virtiofs "$(get_dracut_args_fstype "$(kdump_get_conf_val dracut_args)")"; then
+ return 0
+ fi
+
+ if is_fs_type_virtiofs "$(get_fs_type_from_target "$(get_target_from_path "$(get_save_path)")")"; then
+ return 0
+ fi
+
+ return 1
+}
+
is_nfs_dump_target()
{
if [ -n "$(kdump_get_conf_val nfs)" ]; then
@@ -129,5 +151,5 @@ is_nfs_dump_target()
is_fs_dump_target()
{
- [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix")" ]
+ [ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|virtiofs")" ]
}
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 6d081a8..817652d 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -81,35 +81,31 @@ to_dev_name()
is_user_configured_dump_target()
{
- [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh") ]] || is_mount_in_dracut_args
-}
-
-get_user_configured_dump_disk()
-{
- local _target
-
- _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw")
- [[ -n $_target ]] && echo "$_target" && return
-
- _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")")
- [[ -b $_target ]] && echo "$_target"
+ [[ $(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh\|virtiofs") ]] || is_mount_in_dracut_args
}
get_block_dump_target()
{
- local _target _path
+ local _target _fstype
if is_ssh_dump_target || is_nfs_dump_target; then
return
fi
- _target=$(get_user_configured_dump_disk)
+ _target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|raw\|virtiofs")
[[ -n $_target ]] && to_dev_name "$_target" && return
- # Get block device name from local save path
- _path=$(get_save_path)
- _target=$(get_target_from_path "$_path")
- [[ -b $_target ]] && to_dev_name "$_target"
+ _target=$(get_dracut_args_target "$(kdump_get_conf_val "dracut_args")")
+ [[ -b $_target ]] && to_dev_name "$_target" && return
+
+ _fstype=$(get_dracut_args_fstype "$(kdump_get_conf_val "dracut_args")")
+ is_fs_type_virtiofs "$_fstype" && echo "$_target" && return
+
+ _target=$(get_target_from_path "$(get_save_path)")
+ [[ -b $_target ]] && to_dev_name "$_target" && return
+
+ _fstype=$(get_fs_type_from_target "$_target")
+ is_fs_type_virtiofs "$_fstype" && echo "$_target" && return
}
is_dump_to_rootfs()
@@ -125,6 +121,7 @@ get_failure_action_target()
# Get rootfs device name
_target=$(get_root_fs_device)
[[ -b $_target ]] && to_dev_name "$_target" && return
+ is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return
# Then, must be nfs root
echo "nfs"
fi
diff --git a/kdump.conf b/kdump.conf
index d4fc78b..e598a49 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -43,6 +43,7 @@
# It's recommended to use persistent device names
# such as /dev/vg/<devname>.
# Otherwise it's suggested to use label or uuid.
+# Supported fs types: ext[234], xfs, btrfs, minix, virtiofs
#
# path <path>
# - "path" represents the file system path in which vmcore
@@ -171,6 +172,7 @@
#ext4 /dev/vg/lv_kdump
#ext4 LABEL=/boot
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
+#virtiofs myfs
#nfs my.server.com:/export/tmp
#nfs [2001:db8::1:2:3:4]:/export/tmp
#ssh user(a)my.server.com
diff --git a/kdumpctl b/kdumpctl
index 0e37d36..c7efa2c 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -239,7 +239,7 @@ parse_config()
_set_config _fstype "$config_opt" || return 1
config_opt=_target
;;
- ext[234] | minix | btrfs | xfs | nfs | ssh)
+ ext[234] | minix | btrfs | xfs | nfs | ssh | virtiofs)
_set_config _fstype "$config_opt" || return 1
config_opt=_target
;;
@@ -478,8 +478,8 @@ check_fs_modified()
fi
# No need to check in case of raw target.
- # Currently we do not check also if ssh/nfs target is specified
- if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target; then
+ # Currently we do not check also if ssh/nfs/virtiofs target is specified
+ if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || is_virtiofs_dump_target; then
return 0
fi
diff --git a/mkdumprd b/mkdumprd
index c0f131d..2e5659d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -391,7 +391,7 @@ while read -r config_opt config_val; do
extra_modules)
extra_modules="$extra_modules $config_val"
;;
- ext[234] | xfs | btrfs | minix | nfs)
+ ext[234] | xfs | btrfs | minix | nfs | virtiofs)
check_user_configured_target "$config_val" "$config_opt"
add_mount "$config_val" "$config_opt"
;;
--
2.33.1
1 year, 2 months
[PATCH] fadump: avoid non-debug kernel use for fadump case
by Hari Bathini
Since commit c5bdd2d8f195 ("kdump-lib: use non-debug kernels first"),
non-debug kernel is preferred, over the debug variant, as dump capture
kernel to reduce memory consumption. This works alright for kdump as
the capture kernel is loaded using kexec.
In case of fadump, regular boot loader is used to load the capture
kernel. So, the default kernel needs to be used as capture kernel as
well. But with commit c5bdd2d8f195, initrd of a different kernel is
made dump capture capable breaking fadump's able to capture dump
properly. Fix this by sticking with the debug variant in case of
fadump.
Fixes: c5bdd2d8f195 ("kdump-lib: use non-debug kernels first")
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
---
kdump-lib.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index f7b659e..6d081a8 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -680,7 +680,13 @@ prepare_kdump_bootinfo()
if [[ -z $KDUMP_KERNELVER ]]; then
KDUMP_KERNELVER=$(uname -r)
- nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER")
+
+ # Fadump uses the regular bootloader, unlike kdump. So, use the same version
+ # for default kernel and capture kernel unless specified explicitly with
+ # KDUMP_KERNELVER option.
+ if ! is_fadump_capable; then
+ nondebug_kernelver=$(sed -n -e 's/\(.*\)+debug$/\1/p' <<< "$KDUMP_KERNELVER")
+ fi
fi
# Use nondebug kernel if possible, because debug kernel will consume more memory and may oom.
--
2.37.3
1 year, 2 months
[PATCH] mkdumprd: Improve error messages on non-existing NFS target directories
by Lichen Liu
When kdump is configured with a NFS location, and the remote directory does
not exist, kdump.service fails with a confusing error message.
kdumpctl[2172]: kdump: Dump path "/tmp/mkdumprd.ftWhOF/target/dumps"
does not exist in dump target "10.111.113.2:/srv/kdump"
We just need to print the remote directory "dumps" in such case, because
"/tmp/mkdumprd.ftWhOF/target" is the local temporary mount point.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index 3e250e0..c0f131d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -242,7 +242,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 \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\""
+ perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\""
fi
check_size fs "$_target"
--
2.31.1
1 year, 2 months