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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/06/2012 05:52 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---

>  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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]