[PATCH v2 2/2] network_conf: check if bridge exists on host for user created bridges

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

 



virNetworkBridgeInUse() doesn't check if the bridge is manually created
outside of libvirt. Check if the bridge actually exist on host using the
virNetDevExists().

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
---
 src/conf/network_conf.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index d0e7e1b..3ab087c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -3074,16 +3074,23 @@ int virNetworkBridgeInUse(virNetworkObjListPtr nets,
 {
     size_t i;
     unsigned int ret = 0;
+    int defined_bridge = 0;
 
     for (i = 0; i < nets->count; i++) {
         virNetworkObjLock(nets->objs[i]);
         if (nets->objs[i]->def->bridge &&
-            STREQ(nets->objs[i]->def->bridge, bridge) &&
-            !(skipname && STREQ(nets->objs[i]->def->name, skipname)))
+            STREQ(nets->objs[i]->def->bridge, bridge)) {
+            defined_bridge = 1;
+            if (!(skipname && STREQ(nets->objs[i]->def->name, skipname)))
                 ret = 1;
+        }
         virNetworkObjUnlock(nets->objs[i]);
     }
 
+    /* Bridge might have been created by a user manually outside libvirt */
+    if (!defined_bridge && !ret)
+        ret = virNetDevExists(bridge) ? 1 : 0;
+
     return ret;
 }
 

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