mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
qemu: cleanup tap devices on FreeBSD
We have to explicitly destroy TAP devices on FreeBSD because they're not freed after being closed, otherwise we end up with orphaned TAP devices after destroying a domain.
This commit is contained in:
parent
d148a3e751
commit
075650ff40
@ -4375,7 +4375,10 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
||||
def = vm->def;
|
||||
for (i = 0; i < def->nnets; i++) {
|
||||
virDomainNetDefPtr net = def->nets[i];
|
||||
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
|
||||
vport = virDomainNetGetActualVirtPortProfile(net);
|
||||
|
||||
switch (virDomainNetGetActualType(net)) {
|
||||
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
||||
ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
|
||||
net->ifname, &net->mac,
|
||||
virDomainNetGetActualDirectDev(net),
|
||||
@ -4383,11 +4386,18 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
||||
virDomainNetGetActualVirtPortProfile(net),
|
||||
cfg->stateDir));
|
||||
VIR_FREE(net->ifname);
|
||||
break;
|
||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||
#ifdef VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP
|
||||
if (!(vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH))
|
||||
ignore_value(virNetDevTapDelete(net->ifname));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
/* release the physical device (or any other resources used by
|
||||
* this interface in the network driver
|
||||
*/
|
||||
vport = virDomainNetGetActualVirtPortProfile(net);
|
||||
if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
|
||||
ignore_value(virNetDevOpenvswitchRemovePort(
|
||||
virDomainNetGetActualBridgeName(net),
|
||||
|
@ -27,6 +27,12 @@
|
||||
# include "virnetdevvportprofile.h"
|
||||
# include "virnetdevvlan.h"
|
||||
|
||||
# ifdef __FreeBSD__
|
||||
/* This should be defined on OSes that don't automatically
|
||||
* cleanup released devices */
|
||||
# define VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP 1
|
||||
# endif
|
||||
|
||||
int virNetDevTapCreate(char **ifname,
|
||||
int *tapfd,
|
||||
int tapfdSize,
|
||||
|
Loading…
Reference in New Issue
Block a user