mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
network_conf: Introduce virNetworkObjListForEach
This API will be used in the future to call passed callback over each network object in the list. It's slightly different to its virDomainObjListForEach counterpart, because virDomainObjList uses a hash table to store domain object, while virNetworkObjList uses an array. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
54972be843
commit
454fe219ef
@ -4290,3 +4290,30 @@ virNetworkObjListExport(virConnectPtr conn,
|
||||
VIR_FREE(tmp_nets);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNetworkObjListForEach:
|
||||
* @nets: a list of network objects
|
||||
* @callback: function to call over each of object in the list
|
||||
* @opaque: pointer to pass to the @callback
|
||||
*
|
||||
* Function iterates over the list of network objects and calls
|
||||
* passed callback over each one of them.
|
||||
*
|
||||
* Returns: 0 on success, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
virNetworkObjListForEach(virNetworkObjListPtr nets,
|
||||
virNetworkObjListIterator callback,
|
||||
void *opaque)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t i = 0;
|
||||
|
||||
for (i = 0; i < nets->count; i++) {
|
||||
if (callback(nets->objs[i], opaque) < 0)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -445,6 +445,12 @@ int virNetworkObjListExport(virConnectPtr conn,
|
||||
virNetworkObjListFilter filter,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int (*virNetworkObjListIterator)(virNetworkObjPtr net,
|
||||
void *opaque);
|
||||
|
||||
int virNetworkObjListForEach(virNetworkObjListPtr nets,
|
||||
virNetworkObjListIterator callback,
|
||||
void *opaque);
|
||||
/* for testing */
|
||||
int
|
||||
virNetworkDefUpdateSection(virNetworkDefPtr def,
|
||||
|
@ -569,6 +569,7 @@ virNetworkObjFree;
|
||||
virNetworkObjGetPersistentDef;
|
||||
virNetworkObjIsDuplicate;
|
||||
virNetworkObjListExport;
|
||||
virNetworkObjListForEach;
|
||||
virNetworkObjListFree;
|
||||
virNetworkObjLock;
|
||||
virNetworkObjReplacePersistentDef;
|
||||
|
Loading…
x
Reference in New Issue
Block a user