[libvirt] [PATCH 0/6] virObject for reference-counting
Eric Blake
eblake at redhat.com
Wed Apr 6 21:30:50 UTC 2011
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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110406/ca304c5e/attachment-0001.sig>
More information about the libvir-list
mailing list