Re: [PATCH 10/12] kvm: qemu: Add a -net tap,fd=X,vnet_hdr=on option

Anthony Liguori
2008-08-11T20:31:29Z

Mark McLoughlin wrote:
> 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.
>

Sounds like we should just patch the kernel to add a mechanism to query
the IF_VNET_HDR flag.

Regards,

Anthony Liguori

> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
> ---
> 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) {
>