[libvirt] [PATCH] nodeinfo: Check for SYSFS_INFINIBAND_DIR before open
Laine Stump
laine at laine.org
Thu Jul 23 20:19:39 UTC 2015
On 07/23/2015 02:40 PM, John Ferlan wrote:
> 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))) {
> virReportSystemError(errno,
> _("Failed to opendir path '%s'"),
Makes sense to me. ACK.
(BTW, I noticed when lookin up the call chain that the call to this
function does:
if (virNetDevRDMAFeature(ifname, out))
return -1;
instead of the more commonly used (in libvirt):
if (virNetDevRDMAFeature(ifname, out) < 1)
return -1;
The former implies that the function is returning a true/false, while
the latter makes it clear that it returns success/failure.)
More information about the libvir-list
mailing list