提交 454fe219 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
上级 54972be8
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册