Skip to content

Commit

Permalink
DASDDevice: dracut_setup_args() without deprecated dasd.conf (#180248…
Browse files Browse the repository at this point in the history
…2,#1937049)

Implements the dasd part of referenced bugs.

Depends on
ibm-s390-linux/s390-tools@689b894
("zdev: add helper to convert from zdev config to dasd_mod.dasd").
The spec file update reflects the new dependency on `zdev-to-dasd_mod.dasd`
in the new v2.31.0 of the s390 architecture specific sub-package
s390utils-core.

Delegate the generation of rd.dasd statements to a helper tool from
s390-tools, which gets its low-level config information from the
consolidated persistent configuration mechanism using chzdev.

Signed-off-by: Steffen Maier <[email protected]>
  • Loading branch information
steffen-maier authored and vojtechtrefny committed Aug 28, 2024
1 parent 8e69351 commit 6accb6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 56 deletions.
56 changes: 4 additions & 52 deletions blivet/devices/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,67 +530,19 @@ def __init__(self, device, **kwargs):
:type format: :class:`~.formats.DeviceFormat` or a subclass of it
:keyword str wwn: the disk's WWN
:keyword busid: bus ID
:keyword opts: options
:type opts: dict with option name keys and option value values
"""
self.busid = kwargs.pop('busid')
self.opts = kwargs.pop('opts')
DiskDevice.__init__(self, device, **kwargs)

@property
def description(self):
return "DASD device %s" % self.busid

def get_opts(self):
return ["%s=%s" % (k, v) for k, v in self.opts.items() if v == '1']

def dracut_setup_args(self):
conf = "/etc/dasd.conf"
line = None
if os.path.isfile(conf):
f = open(conf)
# grab the first line that starts with our bus_id
for l in f.readlines():
if l.startswith(self.busid):
line = l.rstrip()
break

f.close()

# See if we got a line. If not, grab our get_opts
if not line:
line = self.busid
for devopt in self.get_opts():
line += " %s" % devopt

# Create a translation mapping from dasd.conf format to module format
translate = {'use_diag': 'diag',
'readonly': 'ro',
'erplog': 'erplog',
'failfast': 'failfast'}

# this is a really awkward way of determining if the
# feature found is actually desired (1, not 0), plus
# translating that feature into the actual kernel module
# value
opts = []
parts = line.split()
for chunk in parts[1:]:
try:
feat, val = chunk.split('=')
if int(val):
opts.append(translate[feat])
except (ValueError, KeyError):
# If we don't know what the feature is (feat not in translate
# or if we get a val that doesn't cleanly convert to an int
# we can't do anything with it.
log.warning("failed to parse dasd feature %s", chunk)

if opts:
return set(["rd.dasd=%s(%s)" % (self.busid,
":".join(opts))])
else:
return set(["rd.dasd=%s" % self.busid])
devspec = util.capture_output(["/lib/s390-tools/zdev-to-dasd_mod.dasd",
"persistent", self.busid]).strip()
# strip to remove trailing newline, which must not appear in zipl BLS
return set(["rd.dasd=%s" % devspec])


NVMeController = namedtuple("NVMeController", ["name", "serial", "nvme_ver", "id", "subsysnqn",
Expand Down
3 changes: 0 additions & 3 deletions blivet/populator/helpers/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ def match(cls, data):
def _get_kwargs(self):
kwargs = super(DASDDevicePopulator, self)._get_kwargs()
kwargs["busid"] = udev.device_get_dasd_bus_id(self.data)
kwargs["opts"] = {}
for attr in ['readonly', 'use_diag', 'erplog', 'failfast']:
kwargs["opts"][attr] = udev.device_get_dasd_flag(self.data, attr)

log.info("%s is a dasd device", udev.device_get_name(self.data))
return kwargs
Expand Down
3 changes: 2 additions & 1 deletion python-blivet.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Source1: http://github.com/storaged-project/blivet/archive/%{realname}-%{realver
%global libblockdevver 3.1.0
%global libbytesizever 0.3
%global pyudevver 0.18
%global s390utilscorever 2.31.0

BuildArch: noarch

Expand Down Expand Up @@ -71,7 +72,7 @@ Recommends: libblockdev-swap >= %{libblockdevver}

%ifarch s390 s390x
Recommends: libblockdev-s390 >= %{libblockdevver}
Requires: s390utils-core
Requires: s390utils-core >= %{s390utilscorever}
%endif

Requires: python3-bytesize >= %{libbytesizever}
Expand Down

0 comments on commit 6accb6c

Please sign in to comment.