[libvirt] [PATCH v1 23/31] network_conf: Introduce virNetworkObjEndAPI

Peter Krempa pkrempa at redhat.com
Tue Mar 3 13:23:15 UTC 2015


On Thu, Feb 26, 2015 at 15:17:32 +0100, Michal Privoznik wrote:
> This is practically copy of qemuDomObjEndAPI. The reason why is
> it so widely available is to avoid code duplication, since the
> function is going to be called from our bridge driver, test
> driver and parallels driver too.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/conf/network_conf.c  | 13 +++++++++++--
>  src/conf/network_conf.h  |  1 +
>  src/libvirt_private.syms |  1 +
>  3 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index 7e8b867..95d8b4d 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -130,6 +130,16 @@ virNetworkObjNew(void)
>      return NULL;
>  }
>  
> +void
> +virNetworkObjEndAPI(virNetworkObjPtr *net)
> +{
> +    if (!*net)
> +        return;
> +
> +    virObjectUnlock(*net);
> +    *net = NULL;
> +}
> +
>  virNetworkObjListPtr virNetworkObjListNew(void)
>  {
>      virNetworkObjListPtr nets;
> @@ -4240,8 +4250,7 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr nets,
>      }
>  
>   cleanup:
> -    if (net)
> -        virObjectUnlock(net);
> +    virNetworkObjEndAPI(&net);
>      return ret;
>  }

You should also convert the onle place in virNetworkLoadAllConfigs() to
this new helper since it will also return a referenced object. I'll
point out the problem later.

ACK with virNetworkLoadAllConfigs tweaked too.

Peter

-------------- 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/20150303/098e4e3f/attachment-0001.sig>


More information about the libvir-list mailing list