From 3fb356ebd297e4384208b7688d49cb3eb8f5b3e1 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 1 Sep 2017 11:05:56 +0200 Subject: [PATCH] zdev: Integrate firmware auto-configuration with dracut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a dracut hook that applies firmware-provided I/O configuration data as auto-configuration during boot. This way, all I/O devices configured by DPM are automatically brought online without further user interaction. This mechanism is active by default. It can be deactivated by specifying the following parameter on the kernel command line: rd.zdev=no-auto Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- zdev/dracut/95zdev/module-setup.sh | 19 +++++++++++---- zdev/dracut/95zdev/parse-zdev.sh | 38 ++++++++++++++++++++++++++++++ zdev/dracut/Makefile | 3 +++ 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 zdev/dracut/95zdev/parse-zdev.sh diff --git a/zdev/dracut/95zdev/module-setup.sh b/zdev/dracut/95zdev/module-setup.sh index 4c13a65b..9079f355 100644 --- a/zdev/dracut/95zdev/module-setup.sh +++ b/zdev/dracut/95zdev/module-setup.sh @@ -9,7 +9,8 @@ # 95zdev/module_setup.sh # 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. +# the root device was configured using the chzdev tool. In addition, +# a hook is installed to parse rd.zdev= kernel parameters. # check() { @@ -29,15 +30,23 @@ depends() { } installkernel() { - local _modules=$(lszdev --by-path / --columns MODULES --no-headings 2>/dev/null) - - [ -z "$_modules" ] && return 0 - [ ! -z "$_modules" ] && instmods $_modules + # Add modules for all device types supported by chzdev (required for + # auto-configuration) + instmods lcs qeth qeth_l2 qeth_l3 dasd_mod dasd_eckd_mod dasd_fba_mod \ + dasd_diag_mod zfcp } install() { local _tempfile + # Ensure that required tools are available + inst_multiple chzdev lszdev vmcp + + # Hook to parse zdev kernel parameter + inst_hook cmdline 95 "$moddir/parse-zdev.sh" + + # Obtain root device configuration + # Exit early if root device type is unknown if ! lszdev --by-path / >/dev/null 2>&1 ; then return 0 diff --git a/zdev/dracut/95zdev/parse-zdev.sh b/zdev/dracut/95zdev/parse-zdev.sh new file mode 100644 index 00000000..b70f5015 --- /dev/null +++ b/zdev/dracut/95zdev/parse-zdev.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# Copyright IBM Corp. 2017 +# +# 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-zdev.sh +# Parse the kernel command line for rd.zdev kernel parameters. These +# parameters are evaluated and used to configure z Systems specific devices. +# +# Format: +# rd.zdev=no-auto +# +# where +# +# no-auto: Indicates that firmware-provided I/O configuration data +# should not be applied. +# + +zdev_fw_file="/sys/firmware/sclp_sd/config/data" +zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet" + +if [ -e "$zdev_fw_file" ] ; then + zdev_auto=1 +else + zdev_auto=0 +fi + +for zdev_arg in $(getargs rd.zdev); do + if [ "$zdev_arg" = "no-auto" ] ; then + zdev_auto=0 + fi +done + +if [ $zdev_auto -eq 1 ] ; then + chzdev --import "$zdev_fw_file" $zdev_base_args +fi diff --git a/zdev/dracut/Makefile b/zdev/dracut/Makefile index f6fda853..835de706 100644 --- a/zdev/dracut/Makefile +++ b/zdev/dracut/Makefile @@ -11,11 +11,14 @@ ZDEVDIR := 95zdev # performs the following functions when dracut is run: # # - copy the persistent root device configuration to the initial ram disk +# - install a boot-time hook to apply firmware-provided configuration data +# to the system # ifeq ($(HAVE_DRACUT),1) install: $(INSTALL) -m 755 -d $(DESTDIR)$(MODDIR) $(INSTALL) -m 755 -d $(DESTDIR)$(MODDIR)/$(ZDEVDIR) $(INSTALL) -m 755 $(ZDEVDIR)/module-setup.sh \ + $(ZDEVDIR)/parse-zdev.sh \ $(DESTDIR)$(MODDIR)/$(ZDEVDIR)/ endif