qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Antonios Motakis <a.motakis@virtualopensystems.com>
To: qemu-devel@nongnu.org, snabb-devel@googlegroups.com
Cc: lukego@gmail.com,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com,
	mst@redhat.com
Subject: [Qemu-devel] [PATCH v7 00/13] Vhost and vhost-net support for userspace based backends
Date: Fri, 31 Jan 2014 18:34:29 +0100	[thread overview]
Message-ID: <1391189683-1602-1-git-send-email-a.motakis@virtualopensystems.com> (raw)

In this patch series we would like to introduce our approach for putting a
virtio-net backend in an external userspace process. Our eventual target is to
run the network backend in the Snabbswitch ethernet switch, while receiving
traffic from a guest inside QEMU/KVM which runs an unmodified virtio-net
implementation.

For this, we are working into extending vhost to allow equivalent functionality
for userspace. Vhost already passes control of the data plane of virtio-net to
the host kernel; we want to realize a similar model, but for userspace.

In this patch series the concept of a vhost-backend is introduced.

We define two vhost backend types - vhost-kernel and vhost-user. The former is
the interface to the current kernel module implementation. Its control plane is
ioctl based. The data plane is the kernel directly accessing the QEMU allocated,
guest memory.

In the new vhost-user backend, the control plane is based on communication
between QEMU and another userspace process using a unix domain socket. This
allows to implement a virtio backend for a guest running in QEMU, inside the
other userspace process. For this communication we use a chardev with a unix socket
backend. Vhost-user is client/server agnostic regarding the chardev, however
it does not support the 'nowait' and 'telnet' options.

We change -mem-path to QemuOpts and add prealloc and share as properties
to it. HugeTLBFS is required for this option to work.

The data path is realized by directly accessing the vrings and the buffer data
off the guest's memory.

The current user of vhost-user is only vhost-net. We add new netdev backend
that is intended to initialize vhost-net with vhost-user backend.

Example usage:

qemu -m 1024 -mem-path /hugetlbfs,share=on \
     -chardev socket,id=chr0,path=/path/to/socket \
     -netdev type=vhost-user,id=net0,chardev=chr0 \
     -device virtio-net-pci,netdev=net0

This code can be pulled from git@github.com:virtualopensystems/qemu.git vhost-user-v7

A reference vhost-user slave for testing is available from git@github.com:virtualopensystems/vapp.git

TODOs include:
 - Include a test in QEMU to avoid regressions
 - Slave reconnection and nowait support

Changes from v6:
 - Remove the 'unlink' property of '-mem-path'
 - Extend qemu-char: blocking read, send fds, monitor for connection close
 - Vhost-user uses chardev as a backend
 - Poll and reconnect removed (no VHOST_USER_ECHO).
 - Disconnect is deteced by the chardev (G_IO_HUP event)
 - vhost-backend.c split to vhost-user.c

Changes from v5:
 - Split -mem-path unlink option to a separate patch
 - Fds are passed only in the ancillary data
 - Stricter message size checks on receive/send
 - Netdev vhost-user now includes path and poll_time options
 - The connection probing interval is configurable

Changes from v4:
 - Use error_report for errors
 - VhostUserMsg has new field `size` indicating the following payload length.
   Field `flags` now has version and reply bits. The structure is packed.
 - Send data is of variable length (`size` field in message)
 - Receive in 2 steps, header and payload
 - Add new message type VHOST_USER_ECHO, to check connection status

Changes from v3:
 - Convert -mem-path to QemuOpts with prealloc, share and unlink properties
 - Set 1 sec timeout when read/write to the unix domain socket
 - Fix file descriptor leak

Changes from v2:
 - Reconnect when the backend disappears

Changes from v1:
 - Implementation of vhost-user netdev backend
 - Code improvements

Antonios Motakis (13):
  Convert -mem-path to QemuOpts and add prealloc and share properties
  Add chardev API  qemu_chr_fe_read_all
  Add chardev API qemu_chr_fe_set_msgfds
  Add G_IO_HUP handler for socket chardev
  vhost_net should call the poll callback only when it is set
  Refactor virtio-net to use a generic get_vhost_net
  vhost_net_init will use VhostNetOptions to get all its arguments
  Add vhost_ops to the vhost_dev struct and replace all relevant ioctls
  Add vhost-backend and VhostBackendType
  Add vhost-user as a vhost backend.
  Add new vhost-user netdev backend
  Add the vhost-user netdev backend to command line
  Add vhost-user protocol documentation

 docs/specs/vhost-user.txt         | 249 ++++++++++++++++++++++++++++
 exec.c                            |  30 +++-
 hmp-commands.hx                   |   4 +-
 hw/net/vhost_net.c                | 142 +++++++++++-----
 hw/net/virtio-net.c               |  42 ++---
 hw/scsi/vhost-scsi.c              |  20 ++-
 hw/virtio/Makefile.objs           |   2 +-
 hw/virtio/vhost-backend.c         |  71 ++++++++
 hw/virtio/vhost-user.c            | 331 ++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 |  55 ++++---
 include/exec/cpu-all.h            |   3 -
 include/hw/virtio/vhost-backend.h |  38 +++++
 include/hw/virtio/vhost.h         |   8 +-
 include/net/vhost-user.h          |  17 ++
 include/net/vhost_net.h           |  11 +-
 include/sysemu/char.h             |  28 ++++
 net/Makefile.objs                 |   2 +-
 net/clients.h                     |   3 +
 net/hub.c                         |   1 +
 net/net.c                         |   2 +
 net/tap.c                         |  18 ++-
 net/vhost-user.c                  | 217 +++++++++++++++++++++++++
 qapi-schema.json                  |  18 ++-
 qemu-char.c                       | 185 ++++++++++++++++++++-
 qemu-options.hx                   |  25 ++-
 vl.c                              |  37 ++++-
 26 files changed, 1425 insertions(+), 134 deletions(-)
 create mode 100644 docs/specs/vhost-user.txt
 create mode 100644 hw/virtio/vhost-backend.c
 create mode 100644 hw/virtio/vhost-user.c
 create mode 100644 include/hw/virtio/vhost-backend.h
 create mode 100644 include/net/vhost-user.h
 create mode 100644 net/vhost-user.c

-- 
1.8.3.2

             reply	other threads:[~2014-01-31 17:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 17:34 Antonios Motakis [this message]
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 01/13] Convert -mem-path to QemuOpts and add prealloc and share properties Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 02/13] Add chardev API qemu_chr_fe_read_all Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 03/13] Add chardev API qemu_chr_fe_set_msgfds Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 04/13] Add G_IO_HUP handler for socket chardev Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 05/13] vhost_net should call the poll callback only when it is set Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 06/13] Refactor virtio-net to use a generic get_vhost_net Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 07/13] vhost_net_init will use VhostNetOptions to get all its arguments Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 08/13] Add vhost_ops to the vhost_dev struct and replace all relevant ioctls Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 09/13] Add vhost-backend and VhostBackendType Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 10/13] Add vhost-user as a vhost backend Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 11/13] Add new vhost-user netdev backend Antonios Motakis
2014-02-10  8:42   ` Michael S. Tsirkin
2014-02-10 16:05     ` Antonios Motakis
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 12/13] Add the vhost-user netdev backend to command line Antonios Motakis
2014-02-10  8:49   ` Michael S. Tsirkin
2014-02-10 16:43   ` Eric Blake
2014-01-31 17:34 ` [Qemu-devel] [PATCH v7 13/13] Add vhost-user protocol documentation Antonios Motakis
2014-02-10  8:57 ` [Qemu-devel] [PATCH v7 00/13] Vhost and vhost-net support for userspace based backends Michael S. Tsirkin
2014-02-10 16:02   ` 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=1391189683-1602-1-git-send-email-a.motakis@virtualopensystems.com \
    --to=a.motakis@virtualopensystems.com \
    --cc=lukego@gmail.com \
    --cc=mst@redhat.com \
    --cc=n.nikolaev@virtualopensystems.com \
    --cc=qemu-devel@nongnu.org \
    --cc=snabb-devel@googlegroups.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).