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

Re: [libvirt] [PATCH 4/6] conf: Refactor domain list collection critical section




On 04/30/2015 08:44 AM, Peter Krempa wrote:

...

> 
> -    if (!(dom = virGetDomain(data->conn, vm->def->name, vm->def->uuid))) {
> -        data->error = true;
> -        goto cleanup;
> +
> +int
> +virDomainObjListCollect(virDomainObjListPtr domlist,
> +                        virConnectPtr conn,
> +                        virDomainObjPtr **vms,
> +                        size_t *nvms,
> +                        virDomainObjListACLFilter filter,
> +                        unsigned int flags)
> +{
> +    struct virDomainListData data = { NULL, 0 };
> +
> +    virObjectLock(domlist);
> +    if (VIR_ALLOC_N(data.vms, virHashSize(domlist->objs)) < 0) {

Coverity checker wasn't very happy with this especially if virHashSize
returns a negative number.

John
> +        virObjectUnlock(domlist);
> +        return -1;
>      }
> 
> -    dom->id = vm->def->id;
> +    virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data);
> +    virObjectUnlock(domlist);
> 
> -    data->domains[data->ndomains++] = dom;
> +    virDomainObjListFilter(&data.vms, &data.nvms, conn, filter, flags);
> 
> - cleanup:
> -    virObjectUnlock(vm);
> -    return;
> +    *nvms = data.nvms;
> +    *vms = data.vms;
> +
> +    return 0;
>  }
> 


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