]> git.proxmox.com Git - qemu.git/commitdiff
tap: reset vnet header size on open
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 13 Nov 2012 10:23:23 +0000 (12:23 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 20 Nov 2012 14:38:37 +0000 (15:38 +0100)
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 <mst@redhat.com>
Tested-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
net/tap.c

index df89caaac6b8817e110a1bfcde58aa0db5f39e4f..1abfd44bd9116fd069fb3ddae90544f8c3358f69 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -341,6 +341,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;