mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: virdomainobjlist: Introduce 'virDomainObjListCollectAll'
Introduce a helper which will return a list of all domain objects inside of the list without filtering and thus without the need to lock individual members. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
f52bc2d54a
commit
cd3599c876
@ -913,6 +913,24 @@ virDomainObjListCollectIterator(void *payload,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virDomainObjListCollectAll(virDomainObjList *domlist,
|
||||
virDomainObj ***vms,
|
||||
size_t *nvms)
|
||||
{
|
||||
struct virDomainListData data = { NULL, 0 };
|
||||
|
||||
virObjectRWLockRead(domlist);
|
||||
data.vms = g_new0(virDomainObj *, virHashSize(domlist->objs));
|
||||
|
||||
virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data);
|
||||
virObjectRWUnlock(domlist);
|
||||
|
||||
*nvms = data.nvms;
|
||||
*vms = data.vms;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virDomainObjListFilter(virDomainObj ***list,
|
||||
size_t *nvms,
|
||||
@ -954,18 +972,8 @@ virDomainObjListCollect(virDomainObjList *domlist,
|
||||
virDomainObjListACLFilter filter,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct virDomainListData data = { NULL, 0 };
|
||||
|
||||
virObjectRWLockRead(domlist);
|
||||
data.vms = g_new0(virDomainObj *, virHashSize(domlist->objs));
|
||||
|
||||
virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data);
|
||||
virObjectRWUnlock(domlist);
|
||||
|
||||
virDomainObjListFilter(&data.vms, &data.nvms, conn, filter, flags);
|
||||
|
||||
*nvms = data.nvms;
|
||||
*vms = data.vms;
|
||||
virDomainObjListCollectAll(domlist, vms, nvms);
|
||||
virDomainObjListFilter(vms, nvms, conn, filter, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -145,6 +145,10 @@ virDomainObjListForEach(virDomainObjList *doms,
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \
|
||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT)
|
||||
|
||||
void
|
||||
virDomainObjListCollectAll(virDomainObjList *domlist,
|
||||
virDomainObj ***vms,
|
||||
size_t *nvms);
|
||||
int
|
||||
virDomainObjListCollect(virDomainObjList *doms,
|
||||
virConnectPtr conn,
|
||||
|
@ -1209,6 +1209,7 @@ virDomainMomentObjNew;
|
||||
# conf/virdomainobjlist.h
|
||||
virDomainObjListAdd;
|
||||
virDomainObjListCollect;
|
||||
virDomainObjListCollectAll;
|
||||
virDomainObjListConvert;
|
||||
virDomainObjListExport;
|
||||
virDomainObjListFindByID;
|
||||
|
Loading…
Reference in New Issue
Block a user