提交 136f17ef 编写于 作者: J John Ferlan

nodeinfo: Check for SYSFS_INFINIBAND_DIR before open

Commit id 'ac3ed208' 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
上级 c1c5eb6f
...@@ -2976,6 +2976,9 @@ virNetDevRDMAFeature(const char *ifname, ...@@ -2976,6 +2976,9 @@ virNetDevRDMAFeature(const char *ifname,
struct dirent *dp; struct dirent *dp;
int ret = -1; int ret = -1;
if (!virFileExists(SYSFS_INFINIBAND_DIR))
return 0;
if (!(dirp = opendir(SYSFS_INFINIBAND_DIR))) { if (!(dirp = opendir(SYSFS_INFINIBAND_DIR))) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to opendir path '%s'"), _("Failed to opendir path '%s'"),
...@@ -3191,7 +3194,7 @@ virNetDevGetFeatures(const char *ifname, ...@@ -3191,7 +3194,7 @@ virNetDevGetFeatures(const char *ifname,
ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_TXUDPTNL)); ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_TXUDPTNL));
# endif # endif
if (virNetDevRDMAFeature(ifname, out)) if (virNetDevRDMAFeature(ifname, out) < 0)
return -1; return -1;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册