<br><div class="gmail_quote">On Fri, May 18, 2012 at 6:52 PM, Eric Blake <span dir="ltr"><<a href="mailto:eblake@redhat.com" target="_blank">eblake@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Use of virConnectListDomains() and virConnectListDefinedDomains() is:<br>
<br>
1. inherently racy.  A domain can change between active and inactive<br>
between two back-to-back calls, and thus be entirely skipped or<br>
enumerated twice when concatenating lists.<br>
<br>
2. painful to use.  ListDomains gives ids, ListDefinedDomains gives<br>
names, and the user must then call virDomainLookupByID() and<br>
virDomainLookupByName() to convert into UUIDs.<br>
<br>
3. requires pre-allocation.  The user must call virConnectNumOfDomains()<br>
then over-allocate before calling virConnectListDomains(), in order to<br>
guarantee that the list size didn't change between the two calls.<br>
<br>
This is a proposal for a new API that addresses all three points - by<br>
returning virDomainPtr rather than id or strings, the UUID of each<br>
domain can be grabbed in one shot.  By consolidating things into a<br>
single API call, there is no race in trying to piece together the<br>
complete list.  By having libvirt allocate the resulting array, rather<br>
than making the caller pre-allocate, the user doesn't have to worry<br>
about a race between getting a count and using that count.  It also<br>
provides the convenience of returning smaller lists based on various<br>
filtering groups.<br>
<br>
Thoughts before I expand this API and add the actual implementation?<br>
<br>
<br></blockquote><div><br></div><div>Very nice idea.  Will the perl wrapper, Sys-Virt, be updated to expose this new C api?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Eric Blake   <a href="mailto:eblake@redhat.com">eblake@redhat.com</a>    +1-919-301-3266<br>
Libvirt virtualization library <a href="http://libvirt.org" target="_blank">http://libvirt.org</a><br>
<br>
</font></span><br>--<br>
libvir-list mailing list<br>
<a href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libvir-list" target="_blank">https://www.redhat.com/mailman/listinfo/libvir-list</a><br></blockquote></div><br>