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

Ján Tomko jtomko at redhat.com
Wed Mar 25 18:48:33 UTC 2015


On Wed, Mar 25, 2015 at 07:35:12PM +0530, 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 at linux.vnet.ibm.com>
> ---
>  src/conf/network_conf.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index b334b64..8e9f3ac 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -3294,6 +3294,7 @@ int virNetworkBridgeInUse(virNetworkObjListPtr nets,
>                            const char *bridge,
>                            const char *skipname)
>  {
> +    int ret;
>      virNetworkObjPtr obj;
>      struct virNetworkBridgeInUseHelperData data = {bridge, skipname};
>  
> @@ -3301,7 +3302,12 @@ int virNetworkBridgeInUse(virNetworkObjListPtr nets,
>      obj = virHashSearch(nets->objs, virNetworkBridgeInUseHelper, &data);
>      virObjectUnlock(nets);
>  
> -    return obj != NULL;
> +    if (obj)
> +        ret = 1;
> +    else /* Bridge might have been created by a user manually outside libvirt */
> +        ret = virNetDevExists(bridge) ? 1 : 0;

I don't think we should parse the network differently based on the host
state. The existing check only looks at existing configs.

Can this be checked in networkValidate instead?

Jan

> +
> +    return ret;
>  }
>  
>  char *virNetworkAllocateBridge(virNetworkObjListPtr nets,
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150325/adf96905/attachment-0001.sig>


More information about the libvir-list mailing list