render / rpms / libvirt

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