]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
nodeinfo: Check for SYSFS_INFINIBAND_DIR before open
authorJohn Ferlan <jferlan@redhat.com>
Thu, 23 Jul 2015 18:33:32 +0000 (14:33 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 24 Jul 2015 13:41:06 +0000 (09:41 -0400)
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. Also fix caller to check < 0 upon return.

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

src/util/virnetdev.c

index 7d91e2c0fd90a15b9fea57941f50e81ed816b532..1e20789b7bf16cc36ed4934667b4f5490e686637 100644 (file)
@@ -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))) {
         virReportSystemError(errno,
                              _("Failed to opendir path '%s'"),
@@ -3191,7 +3194,7 @@ virNetDevGetFeatures(const char *ifname,
         ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_TXUDPTNL));
 # endif
 
-    if (virNetDevRDMAFeature(ifname, out))
+    if (virNetDevRDMAFeature(ifname, out) < 0)
         return -1;
     return 0;
 }