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