[PATCH 1/2] netdev: Use virNetDevIsVirtualFunction() properly

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

 



virNetDevIsVirtualFunction() returns 1 if the interface is a
virtual function, 0 if it isn't and -1 on error. This means that,
despite the name suggesting otherwise, using it as a predicate is
not correct.

Fix two callers that were doing so adding an explicit check on
the return value.
---
 src/util/virnetdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index ea95552..9e39c26 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2531,7 +2531,7 @@ virNetDevReplaceNetConfig(const char *linkdev, int vf,
     int ret = -1;
     char *pfdevname = NULL;
 
-    if (vf == -1 && virNetDevIsVirtualFunction(linkdev)) {
+    if (vf == -1 && virNetDevIsVirtualFunction(linkdev) == 1) {
         /* If this really *is* a VF and the caller just didn't know
          * it, we should set the MAC address via PF+vf# instead of
          * setting directly via VF, because the latter will be
@@ -2571,7 +2571,7 @@ virNetDevRestoreNetConfig(const char *linkdev, int vf, const char *stateDir)
     char *pfdevname = NULL;
     const char *vfdevname = NULL;
 
-    if (vf == -1 && virNetDevIsVirtualFunction(linkdev)) {
+    if (vf == -1 && virNetDevIsVirtualFunction(linkdev) == 1) {
         /* If this really *is* a VF and the caller just didn't know
          * it, we should set the MAC address via PF+vf# instead of
          * setting directly via VF, because the latter will be
-- 
2.5.0

--
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]