diff --git a/zdev/dracut/95zdev-kdump/module-setup.sh b/zdev/dracut/95zdev-kdump/module-setup.sh index 5d7f2172..ff759a7e 100755 --- a/zdev/dracut/95zdev-kdump/module-setup.sh +++ b/zdev/dracut/95zdev-kdump/module-setup.sh @@ -9,7 +9,7 @@ # 95zdev-kdump/module_setup.sh # This module installs configuration files (udev rules and modprobe.conf # files) required to enable the kdump target on s390. In addition, -# a hook is installed to parse rd.zfcp= kernel parameters. +# hooks are installed to parse rd.zfcp= and rd.dasd= kernel parameters. # # called by dracut @@ -71,6 +71,12 @@ install() { # Hook to parse zfcp dracut cmdline parameter inst_hook cmdline 95 "$moddir/../95zdev/parse-zfcp.sh" + # Hook to parse dasd dracut cmdline parameter + # Must be the first one to use chzdev so dasd_mod is not yet loaded. + inst_hook cmdline 94 "$moddir/../95zdev/parse-dasd.sh" + inst_multiple /lib/s390-tools/zdev-from-dasd_mod.dasd + + inst_rules "59-dasd.rules" # Obtain kdump target device configuration diff --git a/zdev/dracut/95zdev/module-setup.sh b/zdev/dracut/95zdev/module-setup.sh index 925d2b47..2bc9ce87 100644 --- a/zdev/dracut/95zdev/module-setup.sh +++ b/zdev/dracut/95zdev/module-setup.sh @@ -10,7 +10,8 @@ # This module installs configuration files (udev rules and modprobe.conf # files) required to enable the root device on s390. It will only work when # the root device was configured using the chzdev tool. In addition, -# hooks are installed to parse rd.zdev= and rd.zfcp= kernel parameters. +# hooks are installed to parse rd.zdev= and rd.zfcp= and rd.dasd= +# kernel parameters. # # called by dracut @@ -76,10 +77,16 @@ install() { inst_hook cmdline 95 "$moddir/parse-zdev.sh" # Hook to parse zfcp dracut cmdline parameter inst_hook cmdline 95 "$moddir/parse-zfcp.sh" + # Hook to parse dasd dracut cmdline parameter + # Must be the first one to use chzdev so dasd_mod is not yet loaded. + inst_hook cmdline 94 "$moddir/parse-dasd.sh" + inst_multiple /lib/s390-tools/zdev-from-dasd_mod.dasd # Rule to automatically enable devices when running in DPM inst_rules "81-dpm.rules" + inst_rules "59-dasd.rules" + # Obtain early + root device configuration # shellcheck disable=SC2154 diff --git a/zdev/dracut/95zdev/parse-dasd.sh b/zdev/dracut/95zdev/parse-dasd.sh new file mode 100644 index 00000000..a97801fe --- /dev/null +++ b/zdev/dracut/95zdev/parse-dasd.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright IBM Corp. 2023 +# +# s390-tools is free software; you can redistribute it and/or modify +# it under the terms of the MIT license. See LICENSE for details. +# +# 95zdev/parse-dasd.sh +# Parse the command line for rd.dasd parameters. These +# parameters are evaluated and used to configure dasd devices. +# + +# shellcheck source=/dev/null +type zdev_parse_dasd_list > /dev/null 2>&1 || . /lib/s390-tools/zdev-from-dasd_mod.dasd + +# at this point in time dracut's vinfo() only logs to journal which is hard for +# s390 users to find and access on a line mode console such as 3215 mode +# so use a vinfo alternative that still prints to the console via kmsg +zdev_vinfo() { + local _zdev_vinfo_line + while read -r _zdev_vinfo_line || [ -n "$_zdev_vinfo_line" ]; do + # Prefix "<30>" represents facility LOG_DAEMON 3 and loglevel INFO 6: + # (facility << 3) | level. + echo "<30>dracut: $_zdev_vinfo_line" > /dev/kmsg + done +} + +zdev_parse_rd_dasd() { + local _zdev_dasd _zdev_dasd_list + for _zdev_dasd in $(getargs rd.dasd -d 'rd_DASD='); do + _zdev_dasd_list="${_zdev_dasd_list:+${_zdev_dasd_list},}$_zdev_dasd" + done + echo "$_zdev_dasd_list" +} + +zdev_parse_rd_dasd | zdev_parse_dasd_list globals 2>&1 | zdev_vinfo +zdev_parse_rd_dasd | zdev_parse_dasd_list ranges 2>&1 | zdev_vinfo diff --git a/zdev/dracut/95zdev/zdev-lib.sh b/zdev/dracut/95zdev/zdev-lib.sh index 6643b9f8..5a48c76f 100644 --- a/zdev/dracut/95zdev/zdev-lib.sh +++ b/zdev/dracut/95zdev/zdev-lib.sh @@ -37,15 +37,16 @@ zdev_zfcp_auto_lun_scan_active() { return 1 } -# zdev_check_dev() can be extended for other device types such as DASD or PCIe +# zdev_check_dev() can be extended for other device types such as PCIe zdev_check_dev() { local _dev=$1 local _devsysfs _devtype _subsystem _driver local _intlun _fcplun _scsitarget _wwpn _hbaid + local _busid _arg _devsysfs=$( cd -P /sys/dev/block/"$_dev" 2> /dev/null && echo "$PWD" ) - # This is roughly what systemd's udev-builtin-path_id does for zfcp: + # This is roughly what systemd's udev-builtin-path_id does: while [[ -n "$_devsysfs" ]]; do # ascend to parent: strip last path part _devsysfs=${_devsysfs%/*} @@ -97,6 +98,13 @@ zdev_check_dev() { fi break fi + # check for DASD device bus-ID + if [[ "${_driver##*/}" == dasd-* ]]; then + _busid=${_devsysfs##*/} + _arg=$(/lib/s390-tools/zdev-to-dasd_mod.dasd "active" "$_busid") + printf " rd.dasd=%s\n" "$_arg" + break + fi fi done } diff --git a/zdev/dracut/Makefile b/zdev/dracut/Makefile index 5da887a1..e8410105 100644 --- a/zdev/dracut/Makefile +++ b/zdev/dracut/Makefile @@ -22,6 +22,7 @@ install: $(ZDEVDIR)/parse-zdev.sh \ $(ZDEVDIR)/zdev-lib.sh \ $(ZDEVDIR)/parse-zfcp.sh \ + $(ZDEVDIR)/parse-dasd.sh \ $(DESTDIR)$(DRACUTMODDIR)/$(ZDEVDIR)/ $(INSTALL) -m 755 -d $(DESTDIR)$(DRACUTMODDIR)/$(ZDEVKDUMPDIR) $(INSTALL) -m 755 $(ZDEVKDUMPDIR)/module-setup.sh \