[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv1 6/9] vbox: Add support for virDomainList

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:
> The latter two of these are irelevant as virtual box only supports


> 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 redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]