mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41: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
|
static void
|
||||||
virDomainObjListFilter(virDomainObj ***list,
|
virDomainObjListFilter(virDomainObj ***list,
|
||||||
size_t *nvms,
|
size_t *nvms,
|
||||||
@ -954,18 +972,8 @@ virDomainObjListCollect(virDomainObjList *domlist,
|
|||||||
virDomainObjListACLFilter filter,
|
virDomainObjListACLFilter filter,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct virDomainListData data = { NULL, 0 };
|
virDomainObjListCollectAll(domlist, vms, nvms);
|
||||||
|
virDomainObjListFilter(vms, nvms, conn, filter, flags);
|
||||||
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;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,10 @@ virDomainObjListForEach(virDomainObjList *doms,
|
|||||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \
|
VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \
|
||||||
VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT)
|
VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT)
|
||||||
|
|
||||||
|
void
|
||||||
|
virDomainObjListCollectAll(virDomainObjList *domlist,
|
||||||
|
virDomainObj ***vms,
|
||||||
|
size_t *nvms);
|
||||||
int
|
int
|
||||||
virDomainObjListCollect(virDomainObjList *doms,
|
virDomainObjListCollect(virDomainObjList *doms,
|
||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
|
@ -1209,6 +1209,7 @@ virDomainMomentObjNew;
|
|||||||
# conf/virdomainobjlist.h
|
# conf/virdomainobjlist.h
|
||||||
virDomainObjListAdd;
|
virDomainObjListAdd;
|
||||||
virDomainObjListCollect;
|
virDomainObjListCollect;
|
||||||
|
virDomainObjListCollectAll;
|
||||||
virDomainObjListConvert;
|
virDomainObjListConvert;
|
||||||
virDomainObjListExport;
|
virDomainObjListExport;
|
||||||
virDomainObjListFindByID;
|
virDomainObjListFindByID;
|
||||||
|
Loading…
Reference in New Issue
Block a user