zdev/dracut: add rd.zfcp cmdline option handling

Add parsing of dracut cmdline option "rd.zfcp=..." at initrd runtime.
It delegates configuration to chzdev.

Implement `dracut --print-cmdline` and `dracut --hostonly-cmdline` for
initrd build time. Emit an rd.zfcp option for each zfcp-attached SCSI disk
in dracut's device dependency graph (to mount the root-fs, or to access the
kdump target).

This allows a distribution independent device configuration.
Configuration is consistent by using chzdev as backend.
It also prevents duplicate activations of the same device.

Along with the existing functionality of zdev/dracut, it makes the
following dracut modules superfluous:
https://github.com/dracutdevs/dracut/tree/master/modules.d/95zfcp
[rd.zfcp.conf is no longer needed and thus ignored here; the preceding
 ("zdev/dracut: fix marking hostonly files so delete option works")
 makes rd.hostonly=0 work as a generic replacement]
https://github.com/dracutdevs/dracut/tree/master/modules.d/95zfcp_rules

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158
Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Steffen Maier
2023-01-20 17:44:04 +01:00
committed by Jan Höppner
parent ed106d7f28
commit 06a30ae529
5 changed files with 169 additions and 3 deletions
+30 -1
View File
@@ -8,7 +8,8 @@
#
# 95zdev-kdump/module_setup.sh
# This module installs configuration files (udev rules and modprobe.conf
# files) required to enable the kdump target on s390.
# files) required to enable the kdump target on s390. In addition,
# a hook is installed to parse rd.zfcp= kernel parameters.
#
# called by dracut
@@ -26,6 +27,7 @@ check() {
# Ensure that required tools are available
require_binaries chzdev lszdev || return 1
require_binaries grep sort uniq || return 1
return 0
}
@@ -35,6 +37,19 @@ depends() {
return 0
}
# called by dracut and (conditionally) locally by install()
# Generate rd.zfcp dracut cmdline options for each zfcp-attached
# SCSI disk in dracut's device dependency graph (to mount the root-fs,
# or to access the kdump target). With "dracut --print-cmdline", dracut
# prints the list. With "dracut --hostonly-cmdline", dracut stores the
# list inside the generated initrd.
cmdline() {
# shellcheck disable=SC2154
if [[ $hostonly ]]; then
for_each_host_dev_and_slaves_all zdev_check_dev | sort | uniq
fi
}
# called by dracut
installkernel() {
# Add modules for all device types supported by chzdev (required for
@@ -51,8 +66,22 @@ install() {
# installing avoids error messages from zdev site udev rule processing
inst_multiple -o /lib/s390-tools/zdev_id
# Ensure that required tools are available
inst_multiple chzdev grep
# Hook to parse zfcp dracut cmdline parameter
inst_hook cmdline 95 "$moddir/../95zdev/parse-zfcp.sh"
# Obtain kdump target device configuration
# shellcheck disable=SC2154
if [[ $hostonly_cmdline == "yes" ]]; then
local _rdsomedev
for _rdsomedev in $(cmdline); do
printf "%s\n" "$_rdsomedev" >> "${initdir:?}/etc/cmdline.d/94zdev.conf"
done
fi
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
# work with systems that are not based on chzdev persistent config