[PATCH v2] qemu: cleanup tap devices on FreeBSD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 src/qemu/qemu_process.c | 7 +++++++
 src/util/virnetdevtap.h | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ffa939a..6806539 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -61,6 +61,7 @@
 #include "viruuid.h"
 #include "virprocess.h"
 #include "virtime.h"
+#include "virnetdevbridge.h"
 #include "virnetdevtap.h"
 #include "virbitmap.h"
 #include "viratomic.h"
@@ -4381,6 +4382,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
                              virDomainNetGetActualVirtPortProfile(net),
                              cfg->stateDir));
             VIR_FREE(net->ifname);
+#ifdef VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP
+        } else if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+            ignore_value(virNetDevBridgeRemovePort(virDomainNetGetActualBridgeName(net),
+                         net->ifname));
+            ignore_value(virNetDevTapDelete(net->ifname));
+#endif
         }
         /* release the physical device (or any other resources used by
          * this interface in the network driver
diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h
index a762b31..1e5bd19 100644
--- a/src/util/virnetdevtap.h
+++ b/src/util/virnetdevtap.h
@@ -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,
-- 
1.8.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]