mbox series

[0/3] virtio: add vhost-user-vsock device

Message ID 20200515152110.202917-1-sgarzare@redhat.com (mailing list archive)
Headers show
Series virtio: add vhost-user-vsock device | expand

Message

Stefano Garzarella May 15, 2020, 3:21 p.m. UTC
This series add vhost-user-vsock base device and its PCI version
(vhost-user-vsock-pci).
The vhost-user-vsock device can be used to implement the virtio-vsock
device emulation in user-space.
An use case might be Kata, where they prefer to emulate devices
in user-space.

The first patch creates a new vhost-vsock-common parent class
with the common code usable for both vhost-vsock and vhost-user-vsock
devices.

The other patches add the vhost-user-vsock base device and its PCI
version.

I also implemented a vhost-user-vsock [1] (still WiP) application written in
Rust using crates from Cloud Hypervisor.
The application implements the Firecracker hybrid vsock (vsock over
unix domain socket) [2]

The vhost-user-vsock-pci device can be tested following these steps:

    # build vhost-user-vsock application
    git clone https://github.com/stefano-garzarella/cloud-hypervisor.git
    git checkout vhost-user-vsock
    cargo build

    # start vhost-user-vsock
    ./target/debug/vhost_user_vsock \
        --vsock-backend guest_cid=4,uds_path=/tmp/vm4.vsock,sock=/tmp/vhost4.socket

    # start QEMU
    qemu-system-x86_64 -m 1G -smp 2 -cpu host -M q35,accel=kvm \
        ... \
        -chardev socket,id=char0,reconnect=0,path=/tmp/vhost4.socket \
        -device vhost-user-vsock-pci,chardev=char0 -monitor stdio

    # Guest listening
    guest$ nc --vsock -l 1234

    host$ nc -U /tmp/vm4.vsock
    CONNECT 1234

    # Host listening
    host$ nc -l -U /tmp/vm4.vsock_1234

    guest$ nc --vsock 2 1234

[1] https://github.com/stefano-garzarella/cloud-hypervisor.git
    (vhost-user-vsock branch)
[2] https://github.com/firecracker-microvm/firecracker/blob/master/docs/vsock.md

Stefano Garzarella (3):
  vhost-vsock: add vhost-vsock-common abstraction
  virtio: add vhost-user-vsock base device
  virtio: add vhost-user-vsock-pci device

 configure                              |   3 +
 include/hw/virtio/vhost-user-vsock.h   |  36 ++++
 include/hw/virtio/vhost-vsock-common.h |  47 ++++
 include/hw/virtio/vhost-vsock.h        |  11 +-
 hw/virtio/vhost-user-vsock-pci.c       |  84 ++++++++
 hw/virtio/vhost-user-vsock.c           | 188 ++++++++++++++++
 hw/virtio/vhost-vsock-common.c         | 258 ++++++++++++++++++++++
 hw/virtio/vhost-vsock.c                | 283 ++++---------------------
 hw/virtio/Makefile.objs                |   4 +-
 9 files changed, 663 insertions(+), 251 deletions(-)
 create mode 100644 include/hw/virtio/vhost-user-vsock.h
 create mode 100644 include/hw/virtio/vhost-vsock-common.h
 create mode 100644 hw/virtio/vhost-user-vsock-pci.c
 create mode 100644 hw/virtio/vhost-user-vsock.c
 create mode 100644 hw/virtio/vhost-vsock-common.c

Comments

Stefan Hajnoczi May 21, 2020, 2:35 p.m. UTC | #1
On Fri, May 15, 2020 at 05:21:07PM +0200, Stefano Garzarella wrote:
> This series add vhost-user-vsock base device and its PCI version
> (vhost-user-vsock-pci).
> The vhost-user-vsock device can be used to implement the virtio-vsock
> device emulation in user-space.
> An use case might be Kata, where they prefer to emulate devices
> in user-space.

Looks good.

My main concern is live migration. If it hasn't been tested, please
remove the live migration code.

Stefan
Stefano Garzarella May 21, 2020, 3:07 p.m. UTC | #2
On Thu, May 21, 2020 at 03:35:59PM +0100, Stefan Hajnoczi wrote:
> On Fri, May 15, 2020 at 05:21:07PM +0200, Stefano Garzarella wrote:
> > This series add vhost-user-vsock base device and its PCI version
> > (vhost-user-vsock-pci).
> > The vhost-user-vsock device can be used to implement the virtio-vsock
> > device emulation in user-space.
> > An use case might be Kata, where they prefer to emulate devices
> > in user-space.
> 
> Looks good.
> 
> My main concern is live migration. If it hasn't been tested, please
> remove the live migration code.
> 

Right, I didn't test live migration with vhost-user-vsock.
I'll give it a try. If it doesn't work, I'll remove it.

Thanks for the review,
Stefano
Stefano Garzarella May 22, 2020, 10:06 a.m. UTC | #3
On Thu, May 21, 2020 at 03:35:59PM +0100, Stefan Hajnoczi wrote:
> On Fri, May 15, 2020 at 05:21:07PM +0200, Stefano Garzarella wrote:
> > This series add vhost-user-vsock base device and its PCI version
> > (vhost-user-vsock-pci).
> > The vhost-user-vsock device can be used to implement the virtio-vsock
> > device emulation in user-space.
> > An use case might be Kata, where they prefer to emulate devices
> > in user-space.
> 
> Looks good.
> 
> My main concern is live migration. If it hasn't been tested, please
> remove the live migration code.
> 

Migration is not working:

    QEMU 5.0.50 monitor - type 'help' for more information
    (qemu) migrate -d tcp:0:3333
    Error: Migration disabled: vhost-user backend lacks VHOST_USER_PROTOCOL_F_LOG_SHMFD feature.

Thanks for pointing that out, I'll remove it in v2.

Stefano