qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Antonios Motakis <a.motakis@virtualopensystems.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Michael Tokarev <mjt@tls.msk.ru>,
	Markus Armbruster <armbru@redhat.com>,
	n.nikolaev@virtualopensystems.com,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	lukego@gmail.com,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	tech@virtualopensystems.com
Subject: [Qemu-devel] [PATCH 3/5] Add vhostsock option
Date: Fri, 29 Nov 2013 20:52:24 +0100	[thread overview]
Message-ID: <1385754746-21172-4-git-send-email-a.motakis@virtualopensystems.com> (raw)
In-Reply-To: <1385754746-21172-1-git-send-email-a.motakis@virtualopensystems.com>

Adding a new tap network backend option - vhostsock. It points
to a named unix domain socket, that will be used to communicate
with vhost-user backend. This is a temporary work around; in future
versions of this series vhost-user will be made independent from
the tap network backend.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
---
 hw/net/vhost_net.c      | 22 +++++++++++++++++-----
 include/net/vhost_net.h |  5 ++++-
 net/tap.c               |  4 +++-
 qapi-schema.json        |  3 +++
 qemu-options.hx         |  3 ++-
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 58a1880..8c9d425 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -91,15 +91,27 @@ static int vhost_net_get_fd(NetClientState *backend)
     }
 }
 
-struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
-                                 bool force)
+struct vhost_net *vhost_net_init(NetClientState *backend, char *vhostsock,
+                                 int devfd, bool force)
 {
     int r;
     struct vhost_net *net = g_malloc(sizeof *net);
+    const char *backend_sock = 0;
+    VhostBackendType backend_type = VHOST_BACKEND_TYPE_NONE;
+
     if (!backend) {
         fprintf(stderr, "vhost-net requires backend to be setup\n");
         goto fail;
     }
+
+    if (vhostsock && strcmp(vhostsock, VHOST_NET_DEFAULT_SOCK) != 0) {
+        backend_type = VHOST_BACKEND_TYPE_USER;
+        backend_sock = vhostsock;
+    } else {
+        backend_type = VHOST_BACKEND_TYPE_KERNEL;
+        backend_sock = VHOST_NET_DEFAULT_SOCK;
+    }
+
     r = vhost_net_get_fd(backend);
     if (r < 0) {
         goto fail;
@@ -112,7 +124,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
     net->dev.nvqs = 2;
     net->dev.vqs = net->vqs;
 
-    r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", VHOST_BACKEND_TYPE_KERNEL, force);
+    r = vhost_dev_init(&net->dev, devfd, backend_sock, backend_type, force);
     if (r < 0) {
         goto fail;
     }
@@ -282,8 +294,8 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
     vhost_virtqueue_mask(&net->dev, dev, idx, mask);
 }
 #else
-struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
-                                 bool force)
+struct vhost_net *vhost_net_init(NetClientState *backend, char *vhostsock,
+                                 int devfd, bool force)
 {
     error_report("vhost-net support is not compiled in");
     return NULL;
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 2d936bb..7bb6435 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -3,10 +3,13 @@
 
 #include "net/net.h"
 
+#define VHOST_NET_DEFAULT_SOCK  "/dev/vhost-net"
+
 struct vhost_net;
 typedef struct vhost_net VHostNetState;
 
-VHostNetState *vhost_net_init(NetClientState *backend, int devfd, bool force);
+VHostNetState *vhost_net_init(NetClientState *backend, char *vhostsock,
+                              int devfd, bool force);
 
 bool vhost_net_query(VHostNetState *net, VirtIODevice *dev);
 int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queues);
diff --git a/net/tap.c b/net/tap.c
index 39c1cda..c4eba01 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -632,7 +632,9 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
             vhostfd = -1;
         }
 
-        s->vhost_net = vhost_net_init(&s->nc, vhostfd,
+        s->vhost_net = vhost_net_init(&s->nc,
+                                      tap->has_vhostsock ? tap->vhostsock : 0,
+                                      vhostfd,
                                       tap->has_vhostforce && tap->vhostforce);
         if (!s->vhost_net) {
             error_report("vhost-net requested but could not be initialized");
diff --git a/qapi-schema.json b/qapi-schema.json
index 83fa485..dc35929 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2891,6 +2891,8 @@
 #
 # @vhostforce: #optional vhost on for non-MSIX virtio guests
 #
+# @vhostsock: #optional vhost backend socket
+#
 # @queues: #optional number of queues to be created for multiqueue capable tap
 #
 # Since 1.2
@@ -2909,6 +2911,7 @@
     '*vhostfd':    'str',
     '*vhostfds':   'str',
     '*vhostforce': 'bool',
+    '*vhostsock':  'str',
     '*queues':     'uint32'} }
 
 ##
diff --git a/qemu-options.hx b/qemu-options.hx
index 8b94264..9f80720 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1370,7 +1370,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][,fds=x:y:...:z][,ifname=name][,script=file][,downscript=dfile][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h][,vhostfds=x:y:...:z][,vhostforce=on|off][,queues=n]\n"
+    "-net tap[,vlan=n][,name=str][,fd=h][,fds=x:y:...:z][,ifname=name][,script=file][,downscript=dfile][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h][,vhostfds=x:y:...:z][,vhostforce=on|off][,queues=n][,vhostsock=file]\n"
     "                connect the host TAP network interface to VLAN 'n'\n"
     "                use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n"
     "                to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
@@ -1390,6 +1390,7 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
     "                use 'vhostfd=h' to connect to an already opened vhost net device\n"
     "                use 'vhostfds=x:y:...:z to connect to multiple already opened vhost net devices\n"
     "                use 'queues=n' to specify the number of queues to be created for multiqueue TAP\n"
+    "                use 'vhostsock=file' vhost-user backend socket\n"
     "-net bridge[,vlan=n][,name=str][,br=bridge][,helper=helper]\n"
     "                connects a host TAP network interface to a host bridge device 'br'\n"
     "                (default=" DEFAULT_BRIDGE_INTERFACE ") using the program 'helper'\n"
-- 
1.8.3.2

  parent reply	other threads:[~2013-11-29 19:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-29 19:52 [Qemu-devel] [RFC 0/5] Vhost and vhost-net support for userspace based backends Antonios Motakis
2013-11-29 19:52 ` [Qemu-devel] [PATCH 1/5] Decouple vhost from kernel interface Antonios Motakis
2013-11-29 19:52 ` [Qemu-devel] [PATCH 2/5] Add vhost-kernel and the vhost-user skeleton Antonios Motakis
2013-12-04 13:47   ` Stefan Hajnoczi
2013-12-04 15:23     ` Antonios Motakis
2013-11-29 19:52 ` Antonios Motakis [this message]
2013-12-04 13:42   ` [Qemu-devel] [PATCH 3/5] Add vhostsock option Stefan Hajnoczi
2013-12-04 15:21     ` Antonios Motakis
2013-12-04 14:28   ` Eric Blake
2013-11-29 19:52 ` [Qemu-devel] [PATCH 4/5] Add domain socket communication for vhost-user backend Antonios Motakis
2013-11-29 19:52 ` [Qemu-devel] [PATCH 5/5] Add vhost-user calls implementation Antonios Motakis
2013-12-04 20:00   ` Michael S. Tsirkin
2013-12-10 12:05     ` Antonios Motakis
2013-12-04 13:56 ` [Qemu-devel] [RFC 0/5] Vhost and vhost-net support for userspace based backends Stefan Hajnoczi
2013-12-04 15:23   ` Antonios Motakis

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=1385754746-21172-4-git-send-email-a.motakis@virtualopensystems.com \
    --to=a.motakis@virtualopensystems.com \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lukego@gmail.com \
    --cc=mjt@tls.msk.ru \
    --cc=mst@redhat.com \
    --cc=n.nikolaev@virtualopensystems.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tech@virtualopensystems.com \
    /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;
as well as URLs for NNTP newsgroup(s).