All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: kvm@vger.kernel.org
Subject: [PATCH 14/20] tap: add vhost/vhostfd options
Date: Thu, 4 Feb 2010 17:28:43 +0200	[thread overview]
Message-ID: <20100204152843.GO8461@redhat.com> (raw)
In-Reply-To: <cover.1265297173.git.mst@redhat.com>

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 net.c           |    8 ++++++++
 net/tap.c       |   29 +++++++++++++++++++++++++++++
 qemu-options.hx |    4 +++-
 3 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/net.c b/net.c
index 6ef93e6..b942d03 100644
--- a/net.c
+++ b/net.c
@@ -976,6 +976,14 @@ static struct {
                 .name = "vnet_hdr",
                 .type = QEMU_OPT_BOOL,
                 .help = "enable the IFF_VNET_HDR flag on the tap interface"
+            }, {
+                .name = "vhost",
+                .type = QEMU_OPT_BOOL,
+                .help = "enable vhost-net network accelerator",
+            }, {
+                .name = "vhostfd",
+                .type = QEMU_OPT_STRING,
+                .help = "file descriptor of an already opened vhost net device",
             },
 #endif /* _WIN32 */
             { /* end of list */ }
diff --git a/net/tap.c b/net/tap.c
index 7e9ca79..d9f2e41 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -41,6 +41,8 @@
 
 #include "net/tap-linux.h"
 
+#include "hw/vhost_net.h"
+
 /* Maximum GSO packet size (64k) plus plenty of room for
  * the ethernet and virtio_net headers
  */
@@ -57,6 +59,7 @@ typedef struct TAPState {
     unsigned int has_vnet_hdr : 1;
     unsigned int using_vnet_hdr : 1;
     unsigned int has_ufo: 1;
+    struct vhost_net *vhost_net;
 } TAPState;
 
 static int launch_script(const char *setup_script, const char *ifname, int fd);
@@ -252,6 +255,10 @@ static void tap_cleanup(VLANClientState *nc)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
 
+    if (s->vhost_net) {
+        vhost_net_cleanup(s->vhost_net);
+    }
+
     qemu_purge_queued_packets(nc);
 
     if (s->down_script[0])
@@ -307,6 +314,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
     s->has_ufo = tap_probe_has_ufo(s->fd);
     tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
     tap_read_poll(s, 1);
+    s->vhost_net = NULL;
     return s;
 }
 
@@ -456,6 +464,27 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
         }
     }
 
+    if (qemu_opt_get_bool(opts, "vhost", 0)) {
+        int vhostfd, r;
+        if (qemu_opt_get(opts, "vhostfd")) {
+            r = net_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
+            if (r == -1) {
+                return -1;
+            }
+            vhostfd = r;
+        } else {
+            vhostfd = -1;
+        }
+        s->vhost_net = vhost_net_init(&s->nc, vhostfd);
+        if (!s->vhost_net) {
+            qemu_error("vhost-net requested but could not be initialized\n");
+            return -1;
+        }
+    } else if (qemu_opt_get(opts, "vhostfd")) {
+        qemu_error("vhostfd= is not valid without vhost\n");
+        return -1;
+    }
+
     if (vlan) {
         vlan->nb_host_devs++;
     }
diff --git a/qemu-options.hx b/qemu-options.hx
index 5c1c398..4925461 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -832,7 +832,7 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
     "-net tap[,vlan=n][,name=str],ifname=name\n"
     "                connect the host TAP network interface to VLAN 'n'\n"
 #else
-    "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off]\n"
+    "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]\n"
     "                connect the host TAP network interface to VLAN 'n' and use the\n"
     "                network scripts 'file' (default=%s)\n"
     "                and 'dfile' (default=%s)\n"
@@ -842,6 +842,8 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
     "                default of 'sndbuf=1048576' can be disabled using 'sndbuf=0')\n"
     "                use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag\n"
     "                use vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition\n"
+    "                use vhost=on to enable experimental in kernel accelerator\n"
+    "                use 'vhostfd=h' to connect to an already opened vhost net device\n"
 #endif
     "-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n"
     "                connect the vlan 'n' to another VLAN using a socket connection\n"
-- 
1.6.6.144.g5c3af


  parent reply	other threads:[~2010-02-04 15:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1265297173.git.mst@redhat.com>
2010-02-04 15:27 ` [PATCH 01/20] exec: memory notifiers Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 02/20] kvm: move kvm_set_phys_mem around Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 03/20] kvm: move kvm to use memory notifiers Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 04/20] qemu-kvm: fixup after merging " Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 05/20] kvm: add API to set ioeventfd Michael S. Tsirkin
2010-02-04 15:27 ` [PATCH 06/20] notifier: event notifier implementation Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 07/20] virtio: add notifier support Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 08/20] virtio: add APIs for queue fields Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 09/20] virtio: add status change callback Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 10/20] virtio: move typedef to qemu-common Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 11/20] virtio-pci: fill in notifier support Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 12/20] tap: add interface to get device fd Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 13/20] vhost: vhost net support Michael S. Tsirkin
2010-02-04 15:28 ` Michael S. Tsirkin [this message]
2010-02-04 15:28 ` [PATCH 15/20] tap: add API to retrieve vhost net header Michael S. Tsirkin
2010-02-04 15:28 ` [PATCH 16/20] virtio-net: vhost net support Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 17/20] qemu-kvm: add vhost.h header Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 18/20] kvm: irqfd support Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 19/20] msix: add mask/unmask notifiers Michael S. Tsirkin
2010-02-04 15:29 ` [PATCH 20/20] virtio-pci: irqfd support Michael S. Tsirkin

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=20100204152843.GO8461@redhat.com \
    --to=mst@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.