All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Luke Gorrie <lukego@gmail.com>
Cc: "snabb-devel@googlegroups.com" <snabb-devel@googlegroups.com>,
	qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] snabbswitch integration with QEMU for userspace ethernet I/O
Date: Tue, 28 May 2013 13:58:43 +0200	[thread overview]
Message-ID: <20130528115843.GB15905@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAA2XHbc=+OAAhjMPXDT6+PFVs+uSBN+ZVZHkEPZ-=Q_WtRYG4w@mail.gmail.com>

On Tue, May 28, 2013 at 12:10:50PM +0200, Luke Gorrie wrote:
> On 27 May 2013 11:34, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> > vhost_net is about connecting the a virtio-net speaking process to a
> > tun-like device.  The problem you are trying to solve is connecting a
> > virtio-net speaking process to Snabb Switch.
> >
> 
> Yep!
> 
> 
> > Either you need to replace vhost or you need a tun-like device
> > interface.
> >
> > Replacing vhost would mean that your switch implements virtio-net,
> > shares guest RAM with the guest, and shares the ioeventfd and irqfd
> > which are used to signal with the guest.
> 
> 
> This would be a great solution from my perspective. This is the design that
> I am now struggling to find a good implementation strategy for.

The switch needs 3 resources for direct virtio-net communication with
the guest:

1. Shared memory access to guest physical memory for guest physical to
   host userspace address translation.  vhost and data plane
   automatically guest access to guest memory and they learn about
   memory layout using the MemoryListener interface in QEMU (see
   hw/virtio/vhost.c:vhost_region_add() and friends).

2. Virtqueue kick notifier (ioeventfd) so the switch knows when the
   guest signals the host.  See virtio_queue_get_host_notifier(vq).

3. Guest interrupt notifier (irqfd) so the switch can signal the guest.
   See virtio_queue_get_guest_notifier(vq).

I don't have a detailed suggestion for how to interface the switch and
QEMU processes.  It may be necessary to communicate back and forth (to
handle the virtio device lifecycle) so a UNIX domain socket would be
appropriate for passing file descriptors.  Here is a rough idea:

$ switch --listen-path=/var/run/switch.sock
$ qemu --device virtio-net-pci,switch=/var/run/switch.sock

On QEMU startup:

(switch socket) add_port --id="qemu-$PID" --session-persistence

(Here --session-persistence means that the port will be automatically
destroyed if the switch socket session is terminated because the UNIX
domain socket is closed by QEMU.)

On virtio device status transition to DRIVER_OK:

(switch socket) configure_port --id="qemu-$PID"
                               --mem=/tmp/shm/qemu-$PID
			       --ioeventfd=2
			       --irqfd=3

On virtio device status transition from DRIVER_OK:

(switch socket) deconfigure_port --id="qemu-$PID"

I skipped a bunch of things:

1. virtio-net has several virtqueues so you need multiple ioeventfds.

2. QEMU needs to communicate memory mapping information, this gets
   especially interesting with memory hotplug.  Memory is more
   complicated than a single shmem blob.

3. Multiple NICs per guest should be supported.

Stefan

  parent reply	other threads:[~2013-05-28 11:58 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-26  9:32 [Qemu-devel] snabbswitch integration with QEMU for userspace ethernet I/O Luke Gorrie
2013-05-27  9:34 ` Stefan Hajnoczi
2013-05-27 15:18   ` Michael S. Tsirkin
2013-05-27 15:43   ` Paolo Bonzini
2013-05-27 16:18     ` Anthony Liguori
2013-05-27 16:18       ` Paolo Bonzini
2013-05-27 17:01         ` Anthony Liguori
2013-05-27 17:13           ` Michael S. Tsirkin
2013-05-27 18:31             ` Anthony Liguori
2013-05-28 10:39       ` Luke Gorrie
2013-05-28 10:10   ` Luke Gorrie
2013-05-28 10:35     ` Stefan Hajnoczi
2013-05-28 11:36     ` Julian Stecklina
2013-05-28 11:53       ` Michael S. Tsirkin
2013-05-28 12:09         ` Julian Stecklina
2013-05-28 13:56           ` Michael S. Tsirkin
2013-05-28 15:35             ` Julian Stecklina
2013-05-28 15:44               ` Michael S. Tsirkin
2013-05-28 12:48         ` [Qemu-devel] [snabb-devel:276] " Luke Gorrie
2013-05-28 13:12           ` Julian Stecklina
2013-05-28 13:42             ` [Qemu-devel] [snabb-devel:280] " Luke Gorrie
2013-05-28 14:42         ` [Qemu-devel] [snabb-devel:276] " Luke Gorrie
2013-05-28 15:33           ` Julian Stecklina
2013-05-28 17:00       ` [Qemu-devel] " Anthony Liguori
2013-05-28 17:17         ` Michael S. Tsirkin
2013-05-28 18:55           ` Anthony Liguori
2013-05-29 10:31             ` Stefano Stabellini
2013-05-29 12:25               ` Michael S. Tsirkin
2013-05-29 13:04                 ` Stefano Stabellini
2013-06-04 12:19               ` [Qemu-devel] [snabb-devel:300] " Luke Gorrie
2013-06-04 12:49                 ` Julian Stecklina
2013-06-04 20:09                   ` [Qemu-devel] [snabb-devel:326] " Luke Gorrie
2013-06-04 12:56                 ` [Qemu-devel] [snabb-devel:300] " Michael S. Tsirkin
2013-06-05  6:09                   ` [Qemu-devel] [snabb-devel:327] " Luke Gorrie
2013-05-29  7:49           ` [Qemu-devel] " Stefan Hajnoczi
2013-05-29  9:08             ` Michael S. Tsirkin
2013-05-29 14:21               ` Stefan Hajnoczi
2013-05-29 14:48                 ` Michael S. Tsirkin
2013-05-29 16:02                 ` Julian Stecklina
2013-05-30  2:35                   ` ronnie sahlberg
2013-05-30  6:46                   ` Stefan Hajnoczi
2013-05-30  6:55                     ` Michael S. Tsirkin
2013-05-30  7:11                     ` [Qemu-devel] [snabb-devel:308] " Luke Gorrie
2013-05-30  8:08                     ` [Qemu-devel] " Julian Stecklina
2013-05-29 12:32         ` Julian Stecklina
2013-05-29 14:31           ` Stefan Hajnoczi
2013-05-29 15:59             ` Julian Stecklina
2013-05-28 11:58     ` Stefan Hajnoczi [this message]
2013-10-21 10:29       ` Luke Gorrie

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=20130528115843.GB15905@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=lukego@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=snabb-devel@googlegroups.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 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.