[libvirt] [PATCHv1 6/9] vbox: Add support for virDomainList
Eric Blake
eblake at redhat.com
Wed Jun 6 01:53:34 UTC 2012
On 06/05/2012 07:19 AM, Peter Krempa wrote:
> The virtual box doesn't use the common virDomainObj implementation so
> this patch adds a separate implementation using the virtual box API.
>
> This driver implementation supports only the following filter flags:
> VIR_CONNECT_LIST_DOMAINS_ACTIVE
> VIR_CONNECT_LIST_DOMAINS_INACTIVE
> VIR_CONNECT_LIST_DOMAINS_TRANSIENT
> VIR_CONNECT_LIST_DOMAINS_PERSISTENT
> The latter two of these are irelevant as virtual box only supports
s/irelevant/irrelevant/
> persistent domains, so specifying only VIR_CONNECT_LIST_DOMAINS_TRANSIENT
> results into a empty list.
We should also be able to support _RUNNING, _PAUSED, _SHUTDOWN, and
_OTHER (see vboxDomainGetInfo for how) as well as
_HAS_SNAPSHOT/_NO_SNAPSHOT (see vboxDomainSnapshotNum for how).
> +
> + rc = vboxArrayGet(&machines, data->vboxObj, data->vboxObj->vtbl->GetMachines);
> + if (NS_FAILED(rc)) {
> + vboxError(VIR_ERR_INTERNAL_ERROR,
> + _("Could not get list of domains, rc=%08x"), (unsigned)rc);
> + goto cleanup;
> + }
> +
> + if (domains) {
> + if (VIR_ALLOC_N(doms, 1) < 0)
Instead of allocating this with 1, then reallocating down the road, I'd
suggest pre-allocating with machines.count+1, then only trimming at the
end if filtering took place.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120605/19fb3727/attachment-0001.sig>
More information about the libvir-list
mailing list