render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
79b470
From a89df2d899e6e93ab7bccdaa1afb130d01d9b286 Mon Sep 17 00:00:00 2001
79b470
Message-Id: <a89df2d899e6e93ab7bccdaa1afb130d01d9b286@dist-git>
79b470
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
79b470
Date: Thu, 8 Oct 2020 11:06:56 -0400
79b470
Subject: [PATCH] node_device: refactor udevProcessCCW
79b470
79b470
Refactor out CCW address parsing for later reuse.
79b470
79b470
Reviewed-by: Erik Skultety <eskultet@redhat.com>
79b470
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
79b470
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
79b470
(cherry picked from commit 0e7f8bb6c1c3a63cf892f7afcd34fcb979ef0155)
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-2-bfiuczyn@redhat.com>
79b470
Reviewed-by: Erik Skultety <eskultet@redhat.com>
79b470
---
79b470
 src/node_device/node_device_udev.c | 31 ++++++++++++++++++++----------
79b470
 1 file changed, 21 insertions(+), 10 deletions(-)
79b470
79b470
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
79b470
index ae3d081e66..9667a042bd 100644
79b470
--- a/src/node_device/node_device_udev.c
79b470
+++ b/src/node_device/node_device_udev.c
79b470
@@ -1058,27 +1058,38 @@ udevProcessMediatedDevice(struct udev_device *dev,
79b470
 
79b470
 
79b470
 static int
79b470
-udevProcessCCW(struct udev_device *device,
79b470
-               virNodeDeviceDefPtr def)
79b470
+udevGetCCWAddress(const char *sysfs_path,
79b470
+                  virNodeDevCapDataPtr data)
79b470
 {
79b470
-    int online;
79b470
     char *p;
79b470
-    virNodeDevCapDataPtr data = &def->caps->data;
79b470
-
79b470
-    /* process only online devices to keep the list sane */
79b470
-    if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
79b470
-        return -1;
79b470
 
79b470
-    if ((p = strrchr(def->sysfs_path, '/')) == NULL ||
79b470
+    if ((p = strrchr(sysfs_path, '/')) == NULL ||
79b470
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p == NULL ||
79b470
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p == NULL ||
79b470
         virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) {
79b470
         virReportError(VIR_ERR_INTERNAL_ERROR,
79b470
                        _("failed to parse the CCW address from sysfs path: '%s'"),
79b470
-                       def->sysfs_path);
79b470
+                       sysfs_path);
79b470
         return -1;
79b470
     }
79b470
 
79b470
+    return 0;
79b470
+}
79b470
+
79b470
+
79b470
+static int
79b470
+udevProcessCCW(struct udev_device *device,
79b470
+               virNodeDeviceDefPtr def)
79b470
+{
79b470
+    int online;
79b470
+
79b470
+    /* process only online devices to keep the list sane */
79b470
+    if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1)
79b470
+        return -1;
79b470
+
79b470
+    if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0)
79b470
+        return -1;
79b470
+
79b470
     if (udevGenerateDeviceName(device, def, NULL) != 0)
79b470
         return -1;
79b470
 
79b470
-- 
79b470
2.28.0
79b470