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 <sb...@linux.vnet.ibm.com>
---
 src/conf/network_conf.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index d7c5dec..c3ae2e4 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -3227,13 +3227,22 @@ virNetworkBridgeInUseHelper(const void *payload,
     int ret = 0;
     virNetworkObjPtr net = (virNetworkObjPtr) payload;
     const struct virNetworkBridgeInUseHelperData *data = opaque;
+    bool defined_bridge = false;
 
     virObjectLock(net);
     if (net->def->bridge &&
-        STREQ(net->def->bridge, data->bridge) &&
-        !(data->skipname && STREQ(net->def->name, data->skipname)))
-        ret = 1;
+            STREQ(net->def->bridge, data->bridge)) {
+            defined_bridge = true;
+            if (!(data->skipname && STREQ(net->def->name, data->skipname)))
+                 ret = 1;
+    }
+
     virObjectUnlock(net);
+
+    /* Bridge might have been created by a user manually outside libvirt */
+    if (!defined_bridge && !ret)
+        ret = virNetDevExists(data->bridge) ? 1 : 0;
+
     return ret;
 }
 

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

Reply via email to