From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: [PATCH 10/12] kvm: qemu: Add a -net tap,fd=X,vnet_hdr=on option Date: Mon, 11 Aug 2008 21:12:13 +0100 Message-ID: <1218485535-877-11-git-send-email-markmc@redhat.com> References: <1218485535-877-1-git-send-email-markmc@redhat.com> <1218485535-877-2-git-send-email-markmc@redhat.com> <1218485535-877-3-git-send-email-markmc@redhat.com> <1218485535-877-4-git-send-email-markmc@redhat.com> <1218485535-877-5-git-send-email-markmc@redhat.com> <1218485535-877-6-git-send-email-markmc@redhat.com> <1218485535-877-7-git-send-email-markmc@redhat.com> <1218485535-877-8-git-send-email-markmc@redhat.com> <1218485535-877-9-git-send-email-markmc@redhat.com> <1218485535-877-10-git-send-email-markmc@redhat.com> Cc: kvm@vger.kernel.org, Mark McLoughlin To: Avi Kivity Return-path: Received: from mail19.svc.cra.dublin.eircom.net ([159.134.118.218]:40584 "HELO mail19.svc.cra.dublin.eircom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1757544AbYHKUMf (ORCPT ); Mon, 11 Aug 2008 16:12:35 -0400 In-Reply-To: <1218485535-877-10-git-send-email-markmc@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Some management apps like libvirt creates a tap interface, adds it to a bridge and then passes the fd to qemu-kvm. Since we have no way of querying whether the IFF_VNET_HDR flag has been enabled on the interface, the app needs to tell us if has enabled it. Signed-off-by: Mark McLoughlin --- qemu/vl.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/qemu/vl.c b/qemu/vl.c index 14a66e0..499d6f9 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -5487,10 +5487,19 @@ int net_client_init(const char *device, const char *p) int fd; vlan->nb_host_devs++; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { + int vnet_hdr = 0; fd = strtol(buf, NULL, 0); fcntl(fd, F_SETFL, O_NONBLOCK); + if (get_param_value(buf, sizeof(buf), "vnet_hdr", p) > 0) { + if (strcmp(buf, "on") == 0) { + vnet_hdr = 1; + } else if (strcmp(buf, "off") != 0) { + fprintf(stderr, "qemu: '%s' invalid vnet_hdr option\n", buf); + return 0; + } + } ret = -1; - if (net_tap_fd_init(vlan, fd, 0)) + if (net_tap_fd_init(vlan, fd, vnet_hdr)) ret = 0; } else { if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { -- 1.5.4.1