[libvirt] [PATCH] qemu: cleanup tap devices on FreeBSD

Daniel P. Berrange berrange at redhat.com
Tue Feb 25 11:22:05 UTC 2014


On Mon, Feb 24, 2014 at 11:12:33PM +0400, Roman Bogorodskiy wrote:
> 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 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index ffa939a..9181423 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);
> +        } else if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_BRIDGE) {
> +            /* On some OSes, e.g. FreeBSD, tap devices are not cleaned up when released,
> +             * so we have to handle that manually */
> +            ignore_value(virNetDevBridgeRemovePort(virDomainNetGetActualBridgeName(net),
> +                         net->ifname));
> +            ignore_value(virNetDevTapDelete(net->ifname));
>          }
>          /* release the physical device (or any other resources used by
>           * this interface in the network driver

Conceptually ok, but I fear this impl will result in the logs getting
polluted with "cannot delete tap device" or similar log messages on OS
where TAP device deletion is automatic.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list