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