c480ed
From dce9613ddab9d780ce9aabeb9a084ffec307899c Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <dce9613ddab9d780ce9aabeb9a084ffec307899c@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 20 May 2019 10:12:55 +0200
c480ed
Subject: [PATCH] util: skip RDMA detection for non-PCI network devices
c480ed
c480ed
Only PCI devices have '/sys/class/net/<ifname>/device/resource' so we
c480ed
need to skip this check for all other network devices.
c480ed
c480ed
Without this patch and RDMA enabled libvirt will not detect any network
c480ed
device that doesn't have the path above which includes 'lo', 'virbr',
c480ed
'tun', etc.
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1639258
c480ed
c480ed
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit f38ef0fac0582ac0cbb749af9d3f8ba515a6084a)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1693299
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <5d2c32fd3f2d7e3f9664d395c00cdfc942c738ce.1558339954.git.phrdina@redhat.com>
c480ed
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
c480ed
---
c480ed
 src/util/virnetdev.c | 8 +++++++-
c480ed
 1 file changed, 7 insertions(+), 1 deletion(-)
c480ed
c480ed
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
c480ed
index b250af9e2c..9ca3ce69bc 100644
c480ed
--- a/src/util/virnetdev.c
c480ed
+++ b/src/util/virnetdev.c
c480ed
@@ -3016,8 +3016,14 @@ virNetDevRDMAFeature(const char *ifname,
c480ed
 
c480ed
     if (virAsprintf(&eth_devpath, SYSFS_NET_DIR "%s/device/resource", ifname) < 0)
c480ed
         goto cleanup;
c480ed
-    if (!virFileExists(eth_devpath))
c480ed
+
c480ed
+    /* If /sys/class/net/<ifname>/device/resource doesn't exist it is not a PCI
c480ed
+     * device and therefore it will not have RDMA. */
c480ed
+    if (!virFileExists(eth_devpath)) {
c480ed
+        ret = 0;
c480ed
         goto cleanup;
c480ed
+    }
c480ed
+
c480ed
     if (virFileReadAll(eth_devpath, RESOURCE_FILE_LEN, &eth_res_buf) < 0)
c480ed
         goto cleanup;
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed