virtio-net explicity check for tap device, aupport for tap with filter attached.
Signed-off-by: Yang Hongyang <yan...@cn.fujitsu.com> --- hw/net/virtio-net.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 304d3dd..59e9707 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -16,6 +16,7 @@ #include "net/net.h" #include "net/checksum.h" #include "net/tap.h" +#include "net/filter.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "hw/virtio/virtio-net.h" @@ -406,11 +407,15 @@ static int peer_attach(VirtIONet *n, int index) return 0; } - if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_FILTER) { + nc = filter_backend(nc->peer); + } + + if (nc->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { return 0; } - return tap_enable(nc->peer); + return tap_enable(nc); } static int peer_detach(VirtIONet *n, int index) @@ -421,11 +426,15 @@ static int peer_detach(VirtIONet *n, int index) return 0; } - if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_FILTER) { + nc = filter_backend(nc->peer); + } + + if (nc->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { return 0; } - return tap_disable(nc->peer); + return tap_disable(nc); } static void virtio_net_set_queues(VirtIONet *n) -- 1.9.1