[libvirt] [PATCH v3 03/10] Turn virDomainObjPtr into a virObjectPtr

Eric Blake eblake at redhat.com
Mon Aug 6 17:14:27 UTC 2012


On 08/06/2012 05:52 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Switch virDomainObjPtr to use the virObject APIs for reference
> counting. The main change is that virObjectUnref does not return
> the reference count, merely a bool indicating whether the object
> still has any refs left. Checking the return value is also not
> mandatory.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---

>  13 files changed, 93 insertions(+), 126 deletions(-)

This whole series has a lot of nice diffstats.

> @@ -1909,9 +1912,6 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
>                                 void *opaque);
>  
>  void virDomainDefFree(virDomainDefPtr vm);
> -void virDomainObjRef(virDomainObjPtr vm);
> -/* Returns 1 if the object was freed, 0 if more refs exist */
> -int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;

Oh my - that deleted comment was a bold-faced lie - we used to return 0
on no more refs, > 0 if still in use.  I did a double-take on whether
you had inverted logic (since virObjectUnref returns non-zero when still
in use), and thankfully the code was correct and just the comment wrong.

> @@ -3165,10 +3162,10 @@ qemuProcessReconnect(void *opaque)
>          driver->nextvmid = obj->def->id + 1;
>  
>  endjob:
> -    if (qemuDomainObjEndJob(driver, obj) == 0)
> +    if (!qemuDomainObjEndJob(driver, obj))
>          obj = NULL;
>  
> -    if (obj && virDomainObjUnref(obj) > 0)
> +    if (obj && virObjectUnref(obj))

Straight translation; but a future patch could simplify this to:

if (virObjectUnref(obj))

since virObjectUnref is safe to call on NULL.

ACK.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120806/456866ac/attachment-0001.sig>


More information about the libvir-list mailing list