提交 83726a14 编写于 作者: P Peter Krempa

conf: Add helper to convert list of virDomains to a list of virDomainObjs

Add virDomainObjListConvert that will take a list of virDomains, apply
filters and return a list of virDomainObjs.
上级 cbe7bbf7
...@@ -23109,6 +23109,64 @@ virDomainObjListCollect(virDomainObjListPtr domlist, ...@@ -23109,6 +23109,64 @@ virDomainObjListCollect(virDomainObjListPtr domlist,
} }
int
virDomainObjListConvert(virDomainObjListPtr domlist,
virConnectPtr conn,
virDomainPtr *doms,
size_t ndoms,
virDomainObjPtr **vms,
size_t *nvms,
virDomainObjListACLFilter filter,
unsigned int flags,
bool skip_missing)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainObjPtr vm;
size_t i;
*nvms = 0;
*vms = NULL;
virObjectLock(domlist);
for (i = 0; i < ndoms; i++) {
virDomainPtr dom = doms[i];
virUUIDFormat(dom->uuid, uuidstr);
if (!(vm = virHashLookup(domlist->objs, uuidstr))) {
if (skip_missing)
continue;
virObjectUnlock(domlist);
virReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s' (%s)"),
uuidstr, dom->name);
goto error;
}
virObjectRef(vm);
if (VIR_APPEND_ELEMENT(*vms, *nvms, vm) < 0) {
virObjectUnlock(domlist);
virObjectUnref(vm);
goto error;
}
}
virObjectUnlock(domlist);
virDomainObjListFilter(vms, nvms, conn, filter, flags);
return 0;
error:
virObjectListFreeCount(*vms, *nvms);
*vms = NULL;
*nvms = 0;
return -1;
}
int int
virDomainObjListExport(virDomainObjListPtr domlist, virDomainObjListExport(virDomainObjListPtr domlist,
virConnectPtr conn, virConnectPtr conn,
......
...@@ -3062,6 +3062,15 @@ int virDomainObjListExport(virDomainObjListPtr doms, ...@@ -3062,6 +3062,15 @@ int virDomainObjListExport(virDomainObjListPtr doms,
virDomainPtr **domains, virDomainPtr **domains,
virDomainObjListACLFilter filter, virDomainObjListACLFilter filter,
unsigned int flags); unsigned int flags);
int virDomainObjListConvert(virDomainObjListPtr domlist,
virConnectPtr conn,
virDomainPtr *doms,
size_t ndoms,
virDomainObjPtr **vms,
size_t *nvms,
virDomainObjListACLFilter filter,
unsigned int flags,
bool skip_missing);
int int
virDomainDefMaybeAddController(virDomainDefPtr def, virDomainDefMaybeAddController(virDomainDefPtr def,
......
...@@ -386,6 +386,7 @@ virDomainObjGetPersistentDef; ...@@ -386,6 +386,7 @@ virDomainObjGetPersistentDef;
virDomainObjGetState; virDomainObjGetState;
virDomainObjListAdd; virDomainObjListAdd;
virDomainObjListCollect; virDomainObjListCollect;
virDomainObjListConvert;
virDomainObjListExport; virDomainObjListExport;
virDomainObjListFindByID; virDomainObjListFindByID;
virDomainObjListFindByName; virDomainObjListFindByName;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册