On 05/20/2012 09:56 AM, Peter Krempa wrote: > This patch adds a basic implementation of the listing code for > virConnectListAllDomains() to qemu driver. The listing code does > not support any filtering flags yet, but they may be easily added > later. > --- > src/qemu/qemu_driver.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 97 insertions(+), 0 deletions(-) > +static void > +qemuPopulateDomainList(void *payload, > + const void *name ATTRIBUTE_UNUSED, > + void *opaque) > +{ > + struct virDomainListData *data = opaque; > + virDomainObjPtr vm = payload; > + > + if (data->error || > + (data->limit >= 0 && > + data->ndomains >= data->limit)) > + return; > + > + if (!data->populate) { > + data->ndomains++; > + return; > + } > + > + virDomainObjLock(vm); I just realized: Since we are executing this under the driver lock, and no VM can change state until we let go of the driver lock, it is not necessary to lock vms in this loop. That will help things go faster in computing the list. > +static int > +qemuListAllDomains(virConnectPtr conn, > + virDomainPtr **domains, > + int ndomains, > + unsigned int flags) > +{ > + struct qemud_driver *driver = conn->privateData; > + int ret = -1; > + int i; > + > + struct virDomainListData data = { conn, NULL, 0, 0, ndomains, > + false, !!domains}; > + > + virCheckFlags(0, -1); > + > + qemuDriverLock(driver); > + > + virHashForEach(driver->domains.objs, qemuPopulateDomainList, > + (void *) &data); -- 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