From: Laine Stump Date: Fri, 24 Apr 2015 18:15:44 +0000 (-0400) Subject: network: check newDef for used bridge names in addition to def X-Git-Tag: v1.2.15-rc2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06313277f2628647e3d8dd403fe0d84548ec5aeb;p=thirdparty%2Flibvirt.git network: check newDef for used bridge names in addition to def If someone has updated a network to change its bridge name, but the network is still active (so that bridge name hasn't taken effect yet), we still want to disallow another network from taking that new name. --- diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index aa8d6c632c..5b734f2622 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3270,15 +3270,22 @@ virNetworkBridgeInUseHelper(const void *payload, const void *name ATTRIBUTE_UNUSED, const void *opaque) { - int ret = 0; + int ret; virNetworkObjPtr net = (virNetworkObjPtr) payload; const struct virNetworkBridgeInUseHelperData *data = opaque; virObjectLock(net); - if (net->def->bridge && - STREQ(net->def->bridge, data->bridge) && - !(data->skipname && STREQ(net->def->name, data->skipname))) + if (data->skipname && + ((net->def && STREQ(net->def->name, data->skipname)) || + (net->newDef && STREQ(net->newDef->name, data->skipname)))) + ret = 0; + else if ((net->def && net->def->bridge && + STREQ(net->def->bridge, data->bridge)) || + (net->newDef && net->newDef->bridge && + STREQ(net->newDef->bridge, data->bridge))) ret = 1; + else + ret = 0; virObjectUnlock(net); return ret; }