mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
network_conf: Introduce virNetworkObjListPrune
The API will iterate over the list of network object and remove desired ones from it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0ae7def635
commit
292acd202f
@ -4381,3 +4381,34 @@ virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNetworkObjListPrune:
|
||||
* @nets: a list of network objects
|
||||
* @flags: bitwise-OR of virConnectListAllNetworksFlags
|
||||
*
|
||||
* Iterate over list of network objects and remove the desired
|
||||
* ones from it.
|
||||
*/
|
||||
void
|
||||
virNetworkObjListPrune(virNetworkObjListPtr nets,
|
||||
unsigned int flags)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (i < nets->count) {
|
||||
virNetworkObjPtr obj = nets->objs[i];
|
||||
|
||||
virNetworkObjLock(obj);
|
||||
|
||||
if (virNetworkMatch(obj, flags)) {
|
||||
virNetworkObjUnlock(obj);
|
||||
virNetworkObjFree(obj);
|
||||
|
||||
VIR_DELETE_ELEMENT(nets->objs, i, nets->count);
|
||||
} else {
|
||||
virNetworkObjUnlock(obj);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -464,6 +464,9 @@ int virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
|
||||
virNetworkObjListFilter filter,
|
||||
virConnectPtr conn);
|
||||
|
||||
void virNetworkObjListPrune(virNetworkObjListPtr nets,
|
||||
unsigned int flags);
|
||||
|
||||
/* for testing */
|
||||
int
|
||||
virNetworkDefUpdateSection(virNetworkDefPtr def,
|
||||
|
@ -573,6 +573,7 @@ virNetworkObjListForEach;
|
||||
virNetworkObjListFree;
|
||||
virNetworkObjListGetNames;
|
||||
virNetworkObjListNumOfNetworks;
|
||||
virNetworkObjListPrune;
|
||||
virNetworkObjLock;
|
||||
virNetworkObjReplacePersistentDef;
|
||||
virNetworkObjSetDefTransient;
|
||||
|
Loading…
Reference in New Issue
Block a user