render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
79b470
From c83c1121508cc4283f372789398a909146803b72 Mon Sep 17 00:00:00 2001
79b470
Message-Id: <c83c1121508cc4283f372789398a909146803b72@dist-git>
79b470
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
79b470
Date: Thu, 8 Oct 2020 11:06:59 -0400
79b470
Subject: [PATCH] node_device: detect DASD devices
79b470
79b470
Make Direct Access Storage Devices (DASDs) available in the node_device driver.
79b470
79b470
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
79b470
Reviewed-by: Erik Skultety <eskultet@redhat.com>
79b470
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
79b470
(cherry picked from commit 33bbf589dd739c48ff20d2120e8c4018d241d32f)
79b470
https://bugzilla.redhat.com/show_bug.cgi?id=1853289
79b470
https://bugzilla.redhat.com/show_bug.cgi?id=1865932
79b470
Message-Id: <20201008150700.52157-5-bfiuczyn@redhat.com>
79b470
Reviewed-by: Erik Skultety <eskultet@redhat.com>
79b470
---
79b470
 src/node_device/node_device_udev.c | 28 ++++++++++++++++++++++++++++
79b470
 1 file changed, 28 insertions(+)
79b470
79b470
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
79b470
index efe3cebd6a..b6b28bc35a 100644
79b470
--- a/src/node_device/node_device_udev.c
79b470
+++ b/src/node_device/node_device_udev.c
79b470
@@ -870,6 +870,19 @@ udevProcessSD(struct udev_device *device,
79b470
 }
79b470
 
79b470
 
79b470
+static int
79b470
+udevProcessDASD(struct udev_device *device,
79b470
+                virNodeDeviceDefPtr def)
79b470
+{
79b470
+    virNodeDevCapStoragePtr storage = &def->caps->data.storage;
79b470
+
79b470
+    if (udevGetStringSysfsAttr(device, "device/uid", &storage->serial) < 0)
79b470
+        return -1;
79b470
+
79b470
+    return udevProcessDisk(device, def);
79b470
+}
79b470
+
79b470
+
79b470
 /* This function exists to deal with the case in which a driver does
79b470
  * not provide a device type in the usual place, but udev told us it's
79b470
  * a storage device, and we can make a good guess at what kind of
79b470
@@ -890,6 +903,19 @@ udevKludgeStorageType(virNodeDeviceDefPtr def)
79b470
                   def->sysfs_path);
79b470
         return 0;
79b470
     }
79b470
+
79b470
+    /* For Direct Access Storage Devices (DASDs) there are
79b470
+     * currently no identifiers in udev besides ID_PATH. Since
79b470
+     * ID_TYPE=disk does not exist on DASDs they fall through
79b470
+     * the udevProcessStorage detection logic. */
79b470
+    if (STRPREFIX(def->caps->data.storage.block, "/dev/dasd")) {
79b470
+        def->caps->data.storage.drive_type = g_strdup("dasd");
79b470
+        VIR_DEBUG("Found storage type '%s' for device "
79b470
+                  "with sysfs path '%s'",
79b470
+                  def->caps->data.storage.drive_type,
79b470
+                  def->sysfs_path);
79b470
+        return 0;
79b470
+    }
79b470
     VIR_DEBUG("Could not determine storage type "
79b470
               "for device with sysfs path '%s'", def->sysfs_path);
79b470
     return -1;
79b470
@@ -977,6 +1003,8 @@ udevProcessStorage(struct udev_device *device,
79b470
         ret = udevProcessFloppy(device, def);
79b470
     } else if (STREQ(def->caps->data.storage.drive_type, "sd")) {
79b470
         ret = udevProcessSD(device, def);
79b470
+    } else if (STREQ(def->caps->data.storage.drive_type, "dasd")) {
79b470
+        ret = udevProcessDASD(device, def);
79b470
     } else {
79b470
         VIR_DEBUG("Unsupported storage type '%s'",
79b470
                   def->caps->data.storage.drive_type);
79b470
-- 
79b470
2.28.0
79b470