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

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

 




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;
>  }
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]