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.
Note: This feature reqiures dracut >= 057
Signed-off-by: Tao Liu ltao@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
--- dracut-kdump.sh | 2 +- dracut-module-setup.sh | 2 +- kdump-lib-initramfs.sh | 24 +++++++++++++++++++++++- kdump-lib.sh | 32 ++++++++++++++------------------ kdump.conf | 2 ++ kdumpctl | 6 +++--- mkdumprd | 2 +- 7 files changed, 45 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 f7b659e..f5e3cd8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -81,35 +81,30 @@ 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
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 + + is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return }
is_dump_to_rootfs() @@ -125,6 +120,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@my.server.com diff --git a/kdumpctl b/kdumpctl index 126ecb9..5b0e5fd 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 3e250e0..958698e 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" ;;
In order to support the case when the VM's rootfs is a virtiofs shared directory and dumping the VM's vmcore to its subdirectory, the dracut module 95virtiofs is needed, which was introduced in dracut 057.
Without the module, the case will fail. So let's bump the version up.
Signed-off-by: Tao Liu ltao@redhat.com --- kexec-tools.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 24c616d..0d4a0e9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -66,9 +66,9 @@ Requires(post): servicelog Recommends: keyutils %endif Requires(pre): coreutils sed zlib -Requires: dracut >= 050 -Requires: dracut-network >= 050 -Requires: dracut-squash >= 050 +Requires: dracut >= 057 +Requires: dracut-network >= 057 +Requires: dracut-squash >= 057 Requires: ethtool Recommends: zstd Recommends: grubby
Hi Tao,
for the long term this patch will be needed. For the short term however this patch means that the kexec-tools rpm can only be build on rawhide. That's why I think we should quickly discuss this in the team meeting on Thursday.
Thanks Philipp
On Tue, 16 Aug 2022 16:49:20 +0800 Tao Liu ltao@redhat.com wrote:
In order to support the case when the VM's rootfs is a virtiofs shared directory and dumping the VM's vmcore to its subdirectory, the dracut module 95virtiofs is needed, which was introduced in dracut 057.
Without the module, the case will fail. So let's bump the version up.
Signed-off-by: Tao Liu ltao@redhat.com
kexec-tools.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 24c616d..0d4a0e9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -66,9 +66,9 @@ Requires(post): servicelog Recommends: keyutils %endif Requires(pre): coreutils sed zlib -Requires: dracut >= 050 -Requires: dracut-network >= 050 -Requires: dracut-squash >= 050 +Requires: dracut >= 057 +Requires: dracut-network >= 057 +Requires: dracut-squash >= 057 Requires: ethtool Recommends: zstd Recommends: grubby
Hi Philipp,
On Tue, Aug 16, 2022 at 6:24 PM Philipp Rudo prudo@redhat.com wrote:
Hi Tao,
for the long term this patch will be needed. For the short term however this patch means that the kexec-tools rpm can only be build on rawhide. That's why I think we should quickly discuss this in the team meeting on Thursday.
OK, sure.
Thanks Philipp
On Tue, 16 Aug 2022 16:49:20 +0800 Tao Liu ltao@redhat.com wrote:
In order to support the case when the VM's rootfs is a virtiofs shared directory and dumping the VM's vmcore to its subdirectory, the dracut module 95virtiofs is needed, which was introduced in dracut 057.
Without the module, the case will fail. So let's bump the version up.
Signed-off-by: Tao Liu ltao@redhat.com
kexec-tools.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index 24c616d..0d4a0e9 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -66,9 +66,9 @@ Requires(post): servicelog Recommends: keyutils %endif Requires(pre): coreutils sed zlib -Requires: dracut >= 050 -Requires: dracut-network >= 050 -Requires: dracut-squash >= 050 +Requires: dracut >= 057 +Requires: dracut-network >= 057 +Requires: dracut-squash >= 057 Requires: ethtool Recommends: zstd Recommends: grubby
Hi Tao,
one tiny nit below. With that fixed
Reviewed-by: Philipp Rudo prudo@redhat.com
On Tue, 16 Aug 2022 16:49:19 +0800 Tao Liu ltao@redhat.com wrote: [...]
diff --git a/kdump-lib.sh b/kdump-lib.sh index f7b659e..f5e3cd8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -81,35 +81,30 @@ 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
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
please make _fstype local.
- _target=$(get_target_from_path "$(get_save_path)")
- [[ -b $_target ]] && to_dev_name "$_target" && return
- is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return
personally I would reuse _fstype here so that the code is more consistent with the dracut_args case. But that's only a matter of taste.
Thanks Philipp
}
is_dump_to_rootfs() @@ -125,6 +120,7 @@ get_failure_action_target() # Get rootfs device name _target=$(get_root_fs_device) [[ -b $_target ]] && to_dev_name "$_target" && return
# Then, must be nfs root echo "nfs" fiis_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return
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@my.server.com diff --git a/kdumpctl b/kdumpctl index 126ecb9..5b0e5fd 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 3e250e0..958698e 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" ;;
Hi Philipp,
On Tue, Aug 16, 2022 at 6:24 PM Philipp Rudo prudo@redhat.com wrote:
Hi Tao,
one tiny nit below. With that fixed
Reviewed-by: Philipp Rudo prudo@redhat.com
Sure, I will add the Reviewed-by sign, thank you!
On Tue, 16 Aug 2022 16:49:19 +0800 Tao Liu ltao@redhat.com wrote: [...]
diff --git a/kdump-lib.sh b/kdump-lib.sh index f7b659e..f5e3cd8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -81,35 +81,30 @@ 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 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
please make _fstype local.
Agreed, sorry I missed that...
_target=$(get_target_from_path "$(get_save_path)")
[[ -b $_target ]] && to_dev_name "$_target" && return
is_fs_type_virtiofs "$(get_fs_type_from_target "$_target")" && echo "$_target" && return
personally I would reuse _fstype here so that the code is more consistent with the dracut_args case. But that's only a matter of taste.
OK, I will make it consistent.
Thanks, Tao Liu
Thanks Philipp
}
is_dump_to_rootfs() @@ -125,6 +120,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@my.server.com diff --git a/kdumpctl b/kdumpctl index 126ecb9..5b0e5fd 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 3e250e0..958698e 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" ;;