render / rpms / libvirt

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