From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] kvm: qemu: Handle tap fds with IFF_VNET_HDR Date: Wed, 20 Aug 2008 12:49:23 -0500 Message-ID: <48AC5923.3040901@codemonkey.ws> References: <1218485535-877-1-git-send-email-markmc@redhat.com> <48A1957C.4070007@qumranet.com> <1218638393.29159.38.camel@muff> <48A30ABE.3040903@qumranet.com> <1219251898.5068.33.camel@muff> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org To: Mark McLoughlin Return-path: Received: from wr-out-0506.google.com ([64.233.184.234]:44372 "EHLO wr-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbYHTRuI (ORCPT ); Wed, 20 Aug 2008 13:50:08 -0400 Received: by wr-out-0506.google.com with SMTP id 69so493786wri.5 for ; Wed, 20 Aug 2008 10:50:07 -0700 (PDT) In-Reply-To: <1219251898.5068.33.camel@muff> Sender: kvm-owner@vger.kernel.org List-ID: Mark McLoughlin wrote: > Allow users to pass an IFF_VNET_HDR tap fd via "-net tap,fd=X" > by querying the fd with the recently 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. > The -help output is not a supported interface. An info command in the monitor would be a better way to detect this. Regards, Anthony Liguori > Signed-off-by: Mark McLoughlin > --- > 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" >