Skip to content

Commit

Permalink
write persistent config of any (dasd,zfcp,znet) s390 devices to sysro…
Browse files Browse the repository at this point in the history
…ot (#1802482,#1937049)

Implements a part of the referenced bugs.

Depends on https://github.com/ibm-s390-linux/s390-tools commit
bc4f4551512c ("zdev/dracut: retain early persistent config over switch
root").
The spec file update reflects this new dependency on a new version of the
s390 architecture specific sub-package s390utils-core.

A new s390-tools zdev dracut module hook retain-zdev.sh copies the zdev
persistent configuration from the initrd into /run/zdev.initrd.config.
Import that persistent device configuration. It can be used:
* to transfer the configuration into the installed system.
* by python-blivet ZFCPDiskDevice.dracut_setup_args(),

Any s390 device configuration in the installer user interface produces
persistent zdev config entries.

Instead of treating each s390 device type differently, simply transfer the
entire combined resulting zdev persistent config into the installed system.

The import above also fixes the problem that installations, which got zfcp
paths activated by means of rd.zfcp= dracut cmdline arguments, were missing
those paths in the installed system.
Since commit 87ab1ab ("Support cio_ignore functionality for zFCP
devices (#533492)"), /etc/zfcp.conf replaced /tmp/fcpconfig.
Since commit 011ea0a ("Remove linuxrc.s390"), /etc/zfcp.conf only
exists if the user specified dracut cmdline parameter rd.zfcp=.
https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/
handles parsing of rd.zfcp= without /etc/zfcp.conf as of commit
06a30ae529a5 ("zdev/dracut: add rd.zfcp cmdline option handling").
https://src.fedoraproject.org/rpms/s390utils.git
no longer writes /etc/zfcp.conf during deprecated parsing of rd.zfcp=
as of commit
("zfcp: migrate to consolidated persistent device config with zdev")
Hence, nothing populates /etc/zfcp.conf during installer boot anymore.
So python-blivet has no more initial import input to carry forward.

Signed-off-by: Steffen Maier <[email protected]>
  • Loading branch information
steffen-maier committed Jan 11, 2024
1 parent 747a54c commit 1d9b688
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 51 deletions.
3 changes: 2 additions & 1 deletion anaconda.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Source0: https://github.com/rhinstaller/%{name}/releases/download/%{name}-%{vers
%define subscriptionmanagerver 1.26
%define utillinuxver 2.15.1
%define rpmostreever 2023.2
%define s390utilscorever FIXME

BuildRequires: libtool
BuildRequires: gettext-devel >= %{gettextver}
Expand Down Expand Up @@ -118,7 +119,7 @@ Requires: cracklib-dicts
Requires: teamd
%ifarch s390 s390x
Requires: openssh
Requires: s390utils-core
Requires: s390utils-core >= %{s390utilscorever}
%endif
Requires: NetworkManager >= %{nmver}
Requires: NetworkManager-libnm >= %{nmver}
Expand Down
1 change: 1 addition & 0 deletions data/systemd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dist_systemd_DATA = anaconda.service \
anaconda-nm-config.service \
anaconda-nm-disable-autocons.service \
anaconda-pre.service \
anaconda-s390-device-config-import.service \
anaconda-fips.service

dist_generator_SCRIPTS = anaconda-generator
Expand Down
21 changes: 21 additions & 0 deletions data/systemd/anaconda-s390-device-config-import.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
# This service is to be run before anaconda starts and log data before anaconda changes them
# Import persistent config of any s390 devices (dasd, zfcp, znet) from
# initrd to retain user choices made with rd.dasd, rd.zfcp, rd.znet.
Description=pre-anaconda s390 device persistent config import
ConditionArchitecture=s390x
Requires=basic.target
After=basic.target
Before=anaconda.target
Wants=rsyslog.service
Wants=systemd-udev-settle.service
Wants=plymouth-quit.service plymouth-quit-wait.service
Wants=systemd-logind.service

[Service]
Type=oneshot
ExecStart=-/sbin/chzdev --import /run/zdev.initrd.config --persistent --yes --no-root-update --force --verbose
StandardInput=tty
StandardOutput=journal+console
StandardError=journal+console
TimeoutSec=0
1 change: 1 addition & 0 deletions data/systemd/anaconda.target
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Wants=anaconda-direct.service anaconda.service
Wants=anaconda-sshd.service
Wants=anaconda-pre.service
Wants=anaconda-fips.service
Wants=anaconda-s390-device-config-import.service
Wants=systemd-logind.service
Wants=brltty.service
Wants=rhsm.service
Expand Down
1 change: 0 additions & 1 deletion dracut/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dist_dracut_SCRIPTS = module-setup.sh \
anaconda-copy-cmdline.sh \
anaconda-copy-dhclient.sh \
anaconda-copy-prefixdevname.sh \
anaconda-copy-s390ccwconf.sh \
anaconda-ifcfg.sh \
anaconda-set-kernel-hung-timeout.sh \
anaconda-error-reporting.sh \
Expand Down
3 changes: 0 additions & 3 deletions dracut/anaconda-copy-s390ccwconf.sh

This file was deleted.

1 change: 0 additions & 1 deletion dracut/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ install() {
inst "$moddir/anaconda-diskroot" "/sbin/anaconda-diskroot"
inst_hook pre-pivot 50 "$moddir/anaconda-copy-ks.sh"
inst_hook pre-pivot 50 "$moddir/anaconda-copy-cmdline.sh"
inst_hook pre-pivot 50 "$moddir/anaconda-copy-s390ccwconf.sh"
inst_hook pre-pivot 90 "$moddir/anaconda-copy-dhclient.sh"
inst_hook pre-pivot 91 "$moddir/anaconda-copy-prefixdevname.sh"
inst_hook pre-pivot 95 "$moddir/anaconda-set-kernel-hung-timeout.sh"
Expand Down
62 changes: 17 additions & 45 deletions pyanaconda/modules/storage/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.i18n import _
from pyanaconda.core.util import join_paths
from pyanaconda.core.util import join_paths, execWithRedirect
from pyanaconda.core.path import make_directories
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, ZFCP, NVME
from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, NVME
from pyanaconda.modules.common.constants.services import STORAGE
from pyanaconda.modules.common.errors.installation import StorageInstallationError
from pyanaconda.modules.common.task import Task
Expand Down Expand Up @@ -290,13 +290,10 @@ def _write_storage_configuration(self, storage, sysroot=None):
fcoe_proxy = STORAGE.get_proxy(FCOE)
fcoe_proxy.WriteConfiguration()

zfcp_proxy = STORAGE.get_proxy(ZFCP)
zfcp_proxy.WriteConfiguration()

nvme_proxy = STORAGE.get_proxy(NVME)
nvme_proxy.WriteConfiguration()

self._write_dasd_conf(storage, sysroot)
self._write_s390_device_config(sysroot)

def _write_escrow_packets(self, storage, sysroot):
"""Write the escrow packets.
Expand Down Expand Up @@ -357,46 +354,21 @@ def _write_lvm_devices_file(storage, sysroot):
make_directories(os.path.dirname(out_filename))
shutil.copyfile(in_filename, out_filename)

def _write_dasd_conf(self, storage, sysroot):
"""Write DASD configuration to sysroot.
def _write_s390_device_config(self, sysroot):
"""Copy entire persistent config of any s390 devices to sysroot.
Write /etc/dasd.conf to target system for all DASD devices
configured during installation.
This includes config imported from initrd as well as anything the user
configured via the installer user interface.
:param storage: the storage object
:param sysroot: a path to the target OS installation
"""
dasds = [d for d in storage.devices if d.type == "dasd"]
dasds.sort(key=lambda d: d.name)
if not (arch.is_s390() and dasds):
return

with open(os.path.realpath(sysroot + "/etc/dasd.conf"), "w") as f:
for dasd in dasds:
fields = [dasd.busid] + dasd.get_opts()
f.write("%s\n" % " ".join(fields),)

# check for hyper PAV aliases; they need to get added to dasd.conf as well
sysfs = "/sys/bus/ccw/drivers/dasd-eckd"

# in the case that someone is installing with *only* FBA DASDs,the above
# sysfs path will not exist; so check for it and just bail out of here if
# that's the case
if not os.path.exists(sysfs):
return

# this does catch every DASD, even non-aliases, but we're only going to be
# checking for a very specific flag, so there won't be any duplicate entries
# in dasd.conf
devs = [d for d in os.listdir(sysfs) if d.startswith("0.0")]
with open(os.path.realpath(sysroot + "/etc/dasd.conf"), "a") as f:
for d in devs:
aliasfile = "%s/%s/alias" % (sysfs, d)
with open(aliasfile, "r") as falias:
alias = falias.read().strip()

# if alias == 1, then the device is an alias; otherwise it is a
# normal dasd (alias == 0) and we can skip it, since it will have
# been added to dasd.conf in the above block of code
if alias == "1":
f.write("%s\n" % d)
if arch.is_s390():
execWithRedirect("chzdev",
["--export", "/tmp/zdev.config",
"--all", "--type", "--persistent",
"--verbose"])
execWithRedirect("chzdev",
["--import", "/tmp/zdev.config",
"--persistent",
"--yes", "--no-root-update", "--force", "--verbose",
"--base", "/etc=%s/etc" % sysroot])

0 comments on commit 1d9b688

Please sign in to comment.