From e127b8962487c02ab545dfc9885bfe21fca80724 Mon Sep 17 00:00:00 2001 From: Benjamin Block Date: Fri, 17 Sep 2021 13:50:22 +0200 Subject: [PATCH] chreipl-fcp-mpath: optional dracut config to bundle toolset into initrd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a dracut configuration file that might optionally be installed along with the toolset (per default to: $(USRLIBDIR)/dracut/dracut.conf.d). It causes the udev rules and helper scripts to be included into an initial ramdisk, when (re-)built with dracut; along with any dependency. This is only done when passing `HAVE_DRACUT` set to 1 during the installation (default is 0), e.g.: make install HAVE_DRACUT=1. Enabling the toolset during the initial ramdisk phase has the advantage that paths can be audited earlier in the life cycle of this Linux runtime, e.g. to record the WWID in the ID-file. Reviewed-by: Steffen Maier Signed-off-by: Benjamin Block Signed-off-by: Jan Höppner --- chreipl-fcp-mpath/.gitignore | 1 + chreipl-fcp-mpath/Makefile | 26 +++++++++++++++++++ chreipl-fcp-mpath/chreipl-fcp-mpath.mak | 8 ++++++ .../70-chreipl-fcp-mpath.conf.in | 16 ++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 chreipl-fcp-mpath/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf.in diff --git a/chreipl-fcp-mpath/.gitignore b/chreipl-fcp-mpath/.gitignore index 0fd34f24..203a7f6d 100644 --- a/chreipl-fcp-mpath/.gitignore +++ b/chreipl-fcp-mpath/.gitignore @@ -5,3 +5,4 @@ /chreipl-fcp-mpath-is-reipl-zfcp /chreipl-fcp-mpath-record-volume-identifier /chreipl-fcp-mpath-try-change-ipl-path +/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf diff --git a/chreipl-fcp-mpath/Makefile b/chreipl-fcp-mpath/Makefile index 0645d0d2..1bd40015 100644 --- a/chreipl-fcp-mpath/Makefile +++ b/chreipl-fcp-mpath/Makefile @@ -66,6 +66,17 @@ udev/rules.d/70-chreipl-fcp-mpath.rules: $(CHREIPL_FCP_MPATH_UDEV_HELPER) chreipl-fcp-mpath: udev/rules.d/70-chreipl-fcp-mpath.rules chreipl-fcp-mpath-clean: chreipl-fcp-mpath-udev-helper-clean +dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf: $(MAKEFILE_LIST) +dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf: % : %.in + $(call chreiplzfcpmp-sed-buildvar-replace,$(<),$(@)) + +.PHONY: chreipl-fcp-mpath-dracut-clean +chreipl-fcp-mpath-dracut-clean: + rm -f dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf + +chreipl-fcp-mpath: dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf +chreipl-fcp-mpath-clean: chreipl-fcp-mpath-dracut-clean + # ## Install # @@ -113,6 +124,21 @@ chreipl-fcp-mpath-install-libfiles: $(CHREIPL_FCP_MPATH_COMMON) chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-libfiles +ifeq ($(HAVE_DRACUT),1) + +# install dracut config files +INSTDIRS += $(DRACUTCONFDIR) + +.PHONY: chreipl-fcp-mpath-install-dracut-config +chreipl-fcp-mpath-install-dracut-config: | $(DESTDIR)$(DRACUTCONFDIR) +chreipl-fcp-mpath-install-dracut-config: dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf + $(INSTALL_DATA) -t $(DESTDIR)$(DRACUTCONFDIR) \ + dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf + +chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-dracut-config + +endif + # ## Utility # diff --git a/chreipl-fcp-mpath/chreipl-fcp-mpath.mak b/chreipl-fcp-mpath/chreipl-fcp-mpath.mak index 08bd03a0..9d0c9d64 100644 --- a/chreipl-fcp-mpath/chreipl-fcp-mpath.mak +++ b/chreipl-fcp-mpath/chreipl-fcp-mpath.mak @@ -13,11 +13,17 @@ ## Paths and Build Variables # +# Install the configuration file for dracut, to automatically pull in the +# toolset into the initial ramdisk, when built with it. +HAVE_DRACUT = 0 + # https://www.gnu.org/software/make/manual/make.html#Directory-Variables CHREIPLZFCPMPDIR = $(USRLIBDIR)/chreipl-fcp-mpath UDEVDIR = $(USRLIBDIR)/udev UDEVRULESDIR = $(UDEVDIR)/rules.d UDEVRUNDIR = /run/udev +DRACUTDIR = $(USRLIBDIR)/dracut +DRACUTCONFDIR = $(DRACUTDIR)/dracut.conf.d DEBUGOUTDIR = $(UDEVRUNDIR) INSTALL_EXEC = $(INSTALL) -g $(GROUP) -o $(OWNER) --preserve-timestamps @@ -43,6 +49,8 @@ tmpout=$$(mktemp -p ./ .make.tmp.XXXXXXXXXXXXXXXX) && { \ -e 's|@chreiplzfcpmp-fwlock-file@|$(chreiplzfcpmp-fwlock-file)|g' \ -e 's|@chreiplzfcpmp-lib@|$(CHREIPLZFCPMPDIR)/chreipl-fcp-mpath-common.sh|g' \ -e 's|@debugoutdir@|$(DEBUGOUTDIR)|g' \ + -e 's|@udevdir@|$(UDEVDIR)|g' \ + -e 's|@udevrulesdir@|$(UDEVRULESDIR)|g' \ $(1) > $${tmpout} \ && mv $${tmpout} $(2) \ || { rm $${tmpout}; false; } \ diff --git a/chreipl-fcp-mpath/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf.in b/chreipl-fcp-mpath/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf.in new file mode 100644 index 00000000..3a2f8ae2 --- /dev/null +++ b/chreipl-fcp-mpath/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf.in @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MIT +# +# chreipl-fcp-mpath: use multipath information to change FCP IPL target +# (C) Copyright IBM Corp. 2021 + +add_dracutmodules+=" bash multipath udev-rules " + +install_items+=" @udevrulesdir@/70-chreipl-fcp-mpath.rules " +install_items+=" @chreiplzfcpmp-lib@ " +install_items+=" @udevdir@/chreipl-fcp-mpath-is-ipl-tgt " +install_items+=" @udevdir@/chreipl-fcp-mpath-is-ipl-vol " +install_items+=" @udevdir@/chreipl-fcp-mpath-is-reipl-zfcp " +install_items+=" @udevdir@/chreipl-fcp-mpath-record-volume-identifier " +install_items+=" @udevdir@/chreipl-fcp-mpath-try-change-ipl-path " + +install_items+=" flock hexdump logger mktemp readlink sync truncate "