[libvirt] [PATCH] nodeinfo: Check for SYSFS_INFINIBAND_DIR before open

John Ferlan jferlan at redhat.com
Thu Jul 23 18:40:19 UTC 2015

Commit id 'ac3ed2085' causes 'virsh nodedev-list --cap net' to fail
on any system without SYSFS_INFINIBAND_DIR (/sys/class/infiniband).

Rather than assume it's there and fail on the attempt to open the
non-existent directory, check if it's there - if not, return
success and move on.

As reported by Suren Hajyan <shajyan at redhat.com> from run of unit tests

Signed-off-by: John Ferlan <jferlan at redhat.com>
 src/util/virnetdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 7d91e2c..eb6a9fb 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2976,6 +2976,9 @@ virNetDevRDMAFeature(const char *ifname,
     struct dirent *dp;
     int ret = -1;
+    if (!virFileExists(SYSFS_INFINIBAND_DIR))
+        return 0;
     if (!(dirp = opendir(SYSFS_INFINIBAND_DIR))) {
                              _("Failed to opendir path '%s'"),

More information about the libvir-list mailing list