From: John Ferlan Date: Thu, 23 Jul 2015 18:33:32 +0000 (-0400) Subject: nodeinfo: Check for SYSFS_INFINIBAND_DIR before open X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=136f17efd123593abed4d7d7a18e147bbf534527;p=libvirt.git nodeinfo: Check for SYSFS_INFINIBAND_DIR before open 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 from run of unit tests --- diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 7d91e2c0fd..1e20789b7b 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))) { 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; }