public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH 1/1] kvm: qemu: Handle tap fds with IFF_VNET_HDR
Date: Wed, 13 Aug 2008 15:39:53 +0100	[thread overview]
Message-ID: <1218638393.29159.38.camel@muff> (raw)
In-Reply-To: <48A1957C.4070007@qumranet.com>

On Tue, 2008-08-12 at 16:51 +0300, Avi Kivity wrote:
> Mark McLoughlin wrote:

> >         Lastly, I need to add a "vnet_hdr=on" param to "-net tap" so
> > that we can know if the supplied tap fd has IFF_VNET_HDR enabled.
> > There's no interface to query that on the fd right now, and even if
> > I did cook up a patch it probably wouldn't make 2.6.27.
> >   
> 
> except for this, as I agree with Anthony.  I think it can make it into 
> 2.6.27, but if it doesn't, libvirt should simply not enable vnet_hdr 
> unless it is sure qemu can query for the feature.

Okay, I've just sent a patch to add TUNGETIFF:

  http://marc.info/?l=linux-netdev&m=121863813904363

See below patch for how we'd use it. Don't apply this until the kernel
patch is accepted, obviously.

The -help string is what libvirt would use to detect whether qemu has
support for this; clearly libvirt would also need to detect the
availability of TUNGETIFF in the running kernel.

Cheers,
Mark.

Subject: [PATCH 1/1] kvm: qemu: Handle tap fds with IFF_VNET_HDR

Allow users to pass an IFF_VNET_HDR tap fd via "-net tap,fd=X"
by querying the fd with the newly added TUNGETIFF ioctl() to
see if IFF_VNET_HDR has been enabled.

Note: users wishing to pass an IFF_VNET_HDR tap fd to qemu
should check both that a) this version of qemu can handle
such an fd and b) that the TUNGETIFF ioctl() is available in
the running kernel.

We add a comment to the "qemu -help" output to indicate to
users that this version of qemu supports IFF_VNET_HDR.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 qemu/vl.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/qemu/vl.c b/qemu/vl.c
index 2dc1311..b9b202e 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -4536,6 +4536,22 @@ void tap_using_vnet_hdr(void *opaque, int using_vnet_hdr)
     s->using_vnet_hdr = using_vnet_hdr != 0;
 }
 
+static int tap_probe_vnet_hdr(int fd)
+{
+#if defined(TUNGETIFF) && defined(IFF_VNET_HDR)
+    struct ifreq ifr;
+
+    if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+	fprintf(stderr, "TUNGETIFF ioctl() failed: %s\n", strerror(errno));
+	return 0;
+    }
+
+    return ifr.ifr_flags & IFF_VNET_HDR;
+#else
+    return 0;
+#endif
+}
+
 #ifdef TUNSETOFFLOAD
 static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6,
 			    int ecn)
@@ -5501,7 +5517,7 @@ int net_client_init(const char *device, const char *p)
             fd = strtol(buf, NULL, 0);
             fcntl(fd, F_SETFL, O_NONBLOCK);
             ret = -1;
-            if (net_tap_fd_init(vlan, fd, 0))
+            if (net_tap_fd_init(vlan, fd, tap_probe_vnet_hdr(fd)))
                 ret = 0;
         } else {
             if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
@@ -8319,6 +8335,9 @@ static void help(int exitcode)
            "                and 'dfile' (default=%s);\n"
            "                use '[down]script=no' to disable script execution;\n"
            "                use 'fd=h' to connect to an already opened TAP interface\n"
+#if defined(TUNGETIFF) && defined(IFF_VNET_HDR)
+           "                'h' may optinally be configured with the IFF_VNET_HDR flag\n"
+#endif
 #endif
            "-net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port]\n"
            "                connect the vlan 'n' to another VLAN using a socket connection\n"
-- 
1.5.4.1




  parent reply	other threads:[~2008-08-13 14:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-11 20:12 [PATCH 0/12] virtio_net perf patches Mark McLoughlin
2008-08-11 20:12 ` [PATCH 01/12] kvm: qemu: Fix virtio_net tx timer Mark McLoughlin
2008-08-11 20:12   ` [PATCH 02/12] kvm: qemu: Remove virtio_net tx ring-full heuristic Mark McLoughlin
2008-08-11 20:12     ` [PATCH 03/12] kvm: qemu: Add VIRTIO_F_NOTIFY_ON_EMPTY Mark McLoughlin
2008-08-11 20:12       ` [PATCH 04/12] kvm: qemu: Disable recv notifications until avail buffers exhausted Mark McLoughlin
2008-08-11 20:12         ` [PATCH 05/12] kvm: qemu: Add support for partial csums and GSO Mark McLoughlin
2008-08-11 20:12           ` [PATCH 06/12] kvm: qemu: Rename tap_readv() to tap_receive_iov() Mark McLoughlin
2008-08-11 20:12             ` [PATCH 07/12] kvm: qemu: Move some code around for the next commit Mark McLoughlin
2008-08-11 20:12               ` [PATCH 08/12] kvm: qemu: Don't require all drivers to use virtio_net_hdr Mark McLoughlin
2008-08-11 20:12                 ` [PATCH 09/12] kvm: qemu: Actually enable GSO support Mark McLoughlin
2008-08-11 20:12                   ` [PATCH 10/12] kvm: qemu: Add a -net tap,fd=X,vnet_hdr=on option Mark McLoughlin
2008-08-11 20:12                     ` [PATCH 11/12] kvm: qemu: Increase size of virtio_net rings Mark McLoughlin
2008-08-11 20:12                       ` [PATCH 12/12] kvm: qemu: Drop the mutex while reading from tapfd Mark McLoughlin
2008-08-11 20:30                     ` [PATCH 10/12] kvm: qemu: Add a -net tap,fd=X,vnet_hdr=on option Anthony Liguori
2008-08-12 17:41                 ` [PATCH 08/12] kvm: qemu: Don't require all drivers to use virtio_net_hdr Mark McLoughlin
2008-08-13  9:13                   ` Avi Kivity
2008-08-11 20:30 ` [PATCH 0/12] virtio_net perf patches Anthony Liguori
2008-08-12 18:12   ` Mark McLoughlin
2008-08-12 18:28     ` Anthony Liguori
2008-08-12 23:39     ` Herbert Xu
2008-08-12 13:51 ` Avi Kivity
2008-08-12 14:55   ` Avi Kivity
2008-08-13 14:39   ` Mark McLoughlin [this message]
2008-08-13 16:24     ` [PATCH 1/1] kvm: qemu: Handle tap fds with IFF_VNET_HDR Avi Kivity
2008-08-13 16:28       ` Daniel P. Berrange
2008-08-20 17:04       ` [PATCH] " Mark McLoughlin
2008-08-20 17:09         ` Mark McLoughlin
2008-08-20 17:27           ` Avi Kivity
2008-08-20 17:49         ` Anthony Liguori
2008-08-20 17:51           ` Avi Kivity
2008-08-20 18:01             ` Anthony Liguori
2008-08-21  9:30             ` Mark McLoughlin
2008-08-21 13:55               ` Avi Kivity
2008-08-21 13:58                 ` Anthony Liguori
2008-08-20 18:11           ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218638393.29159.38.camel@muff \
    --to=markmc@redhat.com \
    --cc=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox