render / rpms / libvirt

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