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