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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx> from run of unit tests
>
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  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.)

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]