render / rpms / libvirt

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