This is a third version of the virConnectListAllDomains patch. The
API is now slightly different from previous proposals. We only allow
filtering on All/Active/Inactive, and not by a long list of
fine-grained states. The reason is twofold: (1) a simpler
implementation and (2) doubtful that anyone would actually use the
fine-grained filtering feature.
The new API is shown below.
I have tested this out with mlvirsh and virt-top and of course in the
remote case there is a substantial saving in terms of round-trip
times, although it's hard to precisely measure what the difference is
when I've got only a couple of guests running.
There is still no Xen-specific implementation, but note that in the
remote case you get some of the benefit anyway.
Rich.
----------------------------------------------------------------------
/**
* virConnectListAllDomains:
* @conn: pointer to the hypervisor connection
* @domains: pointer to returned array of domain pointers (must not be NULL)
* @infos: pointer to returned array of virDomainInfo structures (may be NULL)
* @stateflags: state of domains of interest
* @flags: other flags (always 0)
*
* This call returns the list of all domains, active or inactive,
* and their virDomainInfo structures.
*
* This call is usually more efficient than using the old method
* of calling virConnectListDomains and virConnectListDefinedDomains
* and then loading each domain and its info. This call is supported
* for all hypervisor types. (If the backend driver doesn't support it
* directly, then the call is emulated for you).
*
* @stateflags allows only the domains of interest to be
* returned. Callers must pass one of:
* VIR_DOMAIN_LIST_ACTIVE to return running domains,
* VIR_DOMAIN_LIST_INACTIVE to return defined but not running domains,
* VIR_DOMAIN_LIST_ALL to return all domains,
* 0 to return no domains.
*
* @flags may be used in the future. Always pass 0 for this parameter.
*
* If there is no error then @domains will be updated to point to an
* array of virDomainPtr.
*
* If there is no error and @infos is not NULL, then @infos will be
* updated to point to an array of virDomainInfo structures, with
* the same length as the array of domains.
*
* Returns the number of domains in the @domains array, or -1 in
* case of error.
*
* If there was no error then the caller must free each domain
* with virDomainFree, free the array of @domains pointers,
* and if necessary free the array of @infos structures.
*/
int
virConnectListAllDomains(virConnectPtr conn,
virDomainPtr **domains,
virDomainInfo **infos,
unsigned long stateflags,
unsigned long flags);
----------------------------------------------------------------------
--
Richard Jones, Emerging Technologies, Red Hat
http://et.redhat.com/~rjones
Read my OCaml programming blog:
http://camltastic.blogspot.com/
Fedora now supports 64 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora