Re: [PATCH 5/8] Collect DASD kernel parameter information during device tree scan (#526354).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 10 Oct 2009, Steffen Maier wrote:

On 10/10/2009 12:27 AM, David Cantrell wrote:
Expand the DASDDevice class to hold the device bus ID and flags that are
passed at boot time.  Add udev functions to return the bus ID and flag
values for DASD devices.  When building the device tree, read the DASD
information and pass that to the DASDDevice object.

Ah, that's how you do that. I thought, the DASDDevice would access udev/sysfs itself on dracutSetupData being called. But I don't mind retrieving that data before allocated DASDDevice object and handing it over to its constructor, if that is the anaconda storage code way.

---
 storage/devices.py    |   12 +++++++-----
 storage/devicetree.py |    5 +++++
 storage/udev.py       |   15 +++++++++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 6ed2c79..a37834f 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -3151,11 +3151,13 @@ class DASDDevice(DiskDevice):
     _type = "dasd"
     _forceDracut = True

-    def __init__(self, device, size=None, major=None, minor=None,
-                 parents=None, sysfsPath=''):
-        DiskDevice.__init__(self, device, size=size,
-                            major=major, minor=minor,
-                            parents=parents, sysfsPath=sysfsPath)
+    def __init__(self, *args, **kwargs):
+        self.busid = kwargs.get('busid')

+        self.readonly = kwargs.get('readonly')
+        self.diag = kwargs.get('diag')

I suppose you chose those names, so they match the dasd= module parameter of dasd_mod, which currently happens to be the syntax of dracut's rd_DASD=. Alas, in sysfs some are called differently. And readonly is called "ro" for the module parameter. I know that this is not exactly consistent.

Right.  As you saw in the later patch, I was matching the names here to what I
see in sysfs.  The dracutSetupData method for DASDDevice then builds the
kernel parameter from that.

+        self.erplog = kwargs.get('erplog')
+        self.failfast = kwargs.get('failfast')
+        DiskDevice.__init__(self, *args, **kwargs)


 class NFSDevice(StorageDevice, NetworkStorageDevice):
diff --git a/storage/devicetree.py b/storage/devicetree.py
index d355804..5c19e72 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1192,6 +1192,11 @@ class DeviceTree(object):
             kwargs["exists"]  = True
         elif udev_device_is_dasd(info):
             diskType = DASDDevice
+            kwargs["busid"] = udev_device_get_dasd_bus_id(info)
+            kwargs["readonly"] = udev_device_get_dasd_flag(info, "readonly")
+            kwargs["diag"] = udev_device_get_dasd_flag(info, "diag")

+            kwargs["diag"] = udev_device_get_dasd_flag(info, "use_diag")

Whoops.  Thanks.

+            kwargs["erplog"] = udev_device_get_dasd_flag(info, "erplog")
+            kwargs["failfast"] = udev_device_get_dasd_flag(info, "failfast")
             log.debug("%s is a dasd device" % name)
         else:
             diskType = DiskDevice
diff --git a/storage/udev.py b/storage/udev.py
index d051157..bbaa977 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -165,6 +165,21 @@ def udev_device_is_dasd(info):
     else:
         return False

+def udev_device_get_dasd_bus_id(info):
+    """ Return the CCW bus ID of the dasd device. """
+    return info.get("ID_PATH").split('-')[2]

ID_PATH is yet from some other program that generated it (path_id) out of sysfs data, which would be the definitive source: The path of the udev DB is, e.g.
"/devices/css0/0.0.0005/0.0.eb26/block/dasda/dasda1"
                       ^^^^^^^^
and there we could get the device bus ID directly.
Or readlink (with splitting) of /sys/block/dasda/device , but there we would need to strip the partition numbers first to get to the block device itself which does not seem very clean. There are just too many ways.

The parsing with splitting looks fragile. Remember my recent patch for the parser of ifcfg files?

Yeah, I'm not crazy about this line.  If there is a better way to find the bus
ID, I'd like to use it.  lsdasd has output I like, so maybe I'll look there.

+
+def udev_device_get_dasd_flag(info, flag=None):
+    """ Return the specified flag for the dasd device. """
+    if flag is None:
+        return None
+
+    path = "/sys" + info.get("sysfs_path") + "/device/" + flag
+    if not os.path.isfile(path):
+        return None
+
+    return bool(open(path, 'r').read().strip())
+
 def udev_device_is_cdrom(info):
     """ Return True if the device is an optical drive. """
     # FIXME: how can we differentiate USB drives from CD-ROM drives?

- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkrP2NgACgkQ5hsjjIy1Vklt1QCeKEGcTEbcRQ0hFcrESqwcLoFf
T7cAoOX+bQnvaG0437JccpmCjdyZosHa
=7v5n
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux