mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: new function virDomainNetRemoveByObj()
virDomainNetRemove() requires the index of the net device you want to remove from the list, but in some cases you may not have the index handy, only the object itself (or the object may not have been added to the domain's list). virDomainNetRemoveByObj() first tries to find the given object in the nets list, and deletes that if it is found. As with virDomainNetRemove() it always unconditionally tries to remove the device from the hostdevs list (in case it is the ridiculous combined net+hostdev device created for <interface type='hostdev'>). Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6731a6805d
commit
a52b74e7a3
@ -15740,6 +15740,24 @@ virDomainNetRemove(virDomainDef *def, size_t i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virDomainNetDef *
|
||||||
|
virDomainNetRemoveByObj(virDomainDef *def, virDomainNetDef *net)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
/* the device might have been added to hostdevs but not nets */
|
||||||
|
virDomainNetRemoveHostdev(def, net);
|
||||||
|
|
||||||
|
for (i = 0; i < def->nnets; i++) {
|
||||||
|
if (def->nets[i] == net) {
|
||||||
|
VIR_DELETE_ELEMENT(def->nets, i, def->nnets);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return net;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainNetUpdate(virDomainDef *def,
|
virDomainNetUpdate(virDomainDef *def,
|
||||||
size_t netidx,
|
size_t netidx,
|
||||||
|
@ -3580,6 +3580,7 @@ int virDomainNetUpdate(virDomainDef *def, size_t netidx, virDomainNetDef *newnet
|
|||||||
int virDomainNetDHCPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
|
int virDomainNetDHCPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
|
||||||
int virDomainNetARPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
|
int virDomainNetARPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
|
||||||
virDomainNetDef *virDomainNetRemove(virDomainDef *def, size_t i);
|
virDomainNetDef *virDomainNetRemove(virDomainDef *def, size_t i);
|
||||||
|
virDomainNetDef *virDomainNetRemoveByObj(virDomainDef *def, virDomainNetDef *net);
|
||||||
void virDomainNetRemoveHostdev(virDomainDef *def, virDomainNetDef *net);
|
void virDomainNetRemoveHostdev(virDomainDef *def, virDomainNetDef *net);
|
||||||
|
|
||||||
int virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev);
|
int virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev);
|
||||||
|
@ -543,6 +543,7 @@ virDomainNetModelTypeToString;
|
|||||||
virDomainNetNotifyActualDevice;
|
virDomainNetNotifyActualDevice;
|
||||||
virDomainNetReleaseActualDevice;
|
virDomainNetReleaseActualDevice;
|
||||||
virDomainNetRemove;
|
virDomainNetRemove;
|
||||||
|
virDomainNetRemoveByObj;
|
||||||
virDomainNetRemoveHostdev;
|
virDomainNetRemoveHostdev;
|
||||||
virDomainNetResolveActualType;
|
virDomainNetResolveActualType;
|
||||||
virDomainNetSetModelString;
|
virDomainNetSetModelString;
|
||||||
|
Loading…
Reference in New Issue
Block a user