From patchwork Fri Nov 16 13:40:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/4] tap: reset vnet header size on open Date: Fri, 16 Nov 2012 03:40:06 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 199598 Message-Id: <1353073206-31501-5-git-send-email-stefanha@redhat.com> To: Cc: Stefan Hajnoczi , "Michael S. Tsirkin" From: "Michael S. Tsirkin" For tap, we currently assume the vnet header size is 10 (the default value) but that might not be the case if tap is persistent and has been used by qemu previously. To fix, set host header size in tap device on open. Signed-off-by: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi --- net/tap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/tap.c b/net/tap.c index 7102b91..efd2bab 100644 --- a/net/tap.c +++ b/net/tap.c @@ -338,6 +338,13 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->using_vnet_hdr = 0; s->has_ufo = tap_probe_has_ufo(s->fd); tap_set_offload(&s->nc, 0, 0, 0, 0, 0); + /* + * Make sure host header length is set correctly in tap: + * it might have been modified by another instance of qemu. + */ + if (tap_probe_vnet_hdr_len(s->fd, s->host_vnet_hdr_len)) { + tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len); + } tap_read_poll(s, 1); s->vhost_net = NULL; return s;