Blob Blame History Raw
From c83c1121508cc4283f372789398a909146803b72 Mon Sep 17 00:00:00 2001
Message-Id: <c83c1121508cc4283f372789398a909146803b72@dist-git>
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date: Thu, 8 Oct 2020 11:06:59 -0400
Subject: [PATCH] node_device: detect DASD devices

Make Direct Access Storage Devices (DASDs) available in the node_device driver.

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
(cherry picked from commit 33bbf589dd739c48ff20d2120e8c4018d241d32f)
https://bugzilla.redhat.com/show_bug.cgi?id=1853289
https://bugzilla.redhat.com/show_bug.cgi?id=1865932
Message-Id: <20201008150700.52157-5-bfiuczyn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
---
 src/node_device/node_device_udev.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index efe3cebd6a..b6b28bc35a 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -870,6 +870,19 @@ udevProcessSD(struct udev_device *device,
 }
 
 
+static int
+udevProcessDASD(struct udev_device *device,
+                virNodeDeviceDefPtr def)
+{
+    virNodeDevCapStoragePtr storage = &def->caps->data.storage;
+
+    if (udevGetStringSysfsAttr(device, "device/uid", &storage->serial) < 0)
+        return -1;
+
+    return udevProcessDisk(device, def);
+}
+
+
 /* This function exists to deal with the case in which a driver does
  * not provide a device type in the usual place, but udev told us it's
  * a storage device, and we can make a good guess at what kind of
@@ -890,6 +903,19 @@ udevKludgeStorageType(virNodeDeviceDefPtr def)
                   def->sysfs_path);
         return 0;
     }
+
+    /* For Direct Access Storage Devices (DASDs) there are
+     * currently no identifiers in udev besides ID_PATH. Since
+     * ID_TYPE=disk does not exist on DASDs they fall through
+     * the udevProcessStorage detection logic. */
+    if (STRPREFIX(def->caps->data.storage.block, "/dev/dasd")) {
+        def->caps->data.storage.drive_type = g_strdup("dasd");
+        VIR_DEBUG("Found storage type '%s' for device "
+                  "with sysfs path '%s'",
+                  def->caps->data.storage.drive_type,
+                  def->sysfs_path);
+        return 0;
+    }
     VIR_DEBUG("Could not determine storage type "
               "for device with sysfs path '%s'", def->sysfs_path);
     return -1;
@@ -977,6 +1003,8 @@ udevProcessStorage(struct udev_device *device,
         ret = udevProcessFloppy(device, def);
     } else if (STREQ(def->caps->data.storage.drive_type, "sd")) {
         ret = udevProcessSD(device, def);
+    } else if (STREQ(def->caps->data.storage.drive_type, "dasd")) {
+        ret = udevProcessDASD(device, def);
     } else {
         VIR_DEBUG("Unsupported storage type '%s'",
                   def->caps->data.storage.drive_type);
-- 
2.28.0