Re: [PATCH 0/6] virObject for reference-counting

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

 



On 04/06/2011 01:18 AM, Hu Tao wrote:
> This series adds a virObject structure that manages reference-counting.
> 
> Some notes about referece-counting introduced by this series:
> 
> A thread owns a virObject by incrementing its reference-count by 1.
> If a thread owns a virObject, the virObject is guarenteed not be
> freed until the thread releases ownership by decrementing its
> reference-count by 1. A thread can't access a virObject after it
> releases the ownership of virObject because it can be freed at
> anytime.
> 
> A thread can own a virObject legally in these ways:
> 
> - a thread owns a virObject that it creates.
> - a thread owns a virObject if another thread passes the ownership
>   to it. Example: qemuMonitorOpen
> - a thread gets a virObject from a container.
>   Example: virDomainFindByUUID
> - a container owns a virObject by incrementing its reference-count
>   by 1 before adding it to the container
> - if a virObject is removed from a container its reference-count
>   must be decremented by 1
> 
> By following these rules, there is no need to protect operations on
> an object's reference-count by an external lock. (like in old ways
> virDomainObj lock protects qemu monitor's ref-count.)

These rules _need_ to be part of the patch series, preferably added at
the same time as patch 1/6 (see for example how src/qemu/THREADS.txt
documents threading issues related to qemu).  I don't know whether
virobject.h or a standalone document is better (but if you do a
standalone document, then virobject.h should at least mention it).

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
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]