On 03/24/2015 05:59 AM, Shivaprasad G Bhat wrote: > 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 | 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; > } This function is intended to be called once for each defined network on the host, with data->bridge being the same each time, but net->def->bridge being different, so adding the check for data->bridge existence here may work, but it's a bit convoluted. Instead, you should leave this function alone, and just add the extra check directly in the function virNetworkBridgeInUse() (either before locking, or after unlocking "nets"). -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list