mbox series

[v2,00/16] Add vhost-user-gpu support

Message ID cover.1566576129.git.crobinso@redhat.com
Headers show
Series Add vhost-user-gpu support | expand

Message

Cole Robinson Aug. 23, 2019, 4:21 p.m. UTC
v1: https://www.redhat.com/archives/libvir-list/2019-June/msg00102.html

This is v2 of Marc-André's series with minor changes. I'm not taking over
this series, I just fixed these as part of the patch rebase so I can review
it :)

Changes since v1:
    - rebase to master
    - if test file build by dropping LDADDS usage
    - syntax-check issues:
        * use #pragma once
        * if () bracket issues
        * jump label indent issues
        * error message %s usage
        * size_t for loops

I didn't know much about vhost-user-gpu before this series, here's what
I've learned.

vhost-user is a generic mechanism that allows implementing virtio device
dataplane handling in a separate userspace process. vhost-user-gpu here
notably moves the virgl 3d handling out of the main qemu process. The
external process will be /usr/libexec/vhost-user-gpu, which comes from
qemu.git contrib/vhost-user-gpu code, first released in qemu-4.1.

Part of this series deals with discovering the location on disk of the
vhost-user-gpu binary, and what capabilities it provides. This uses a
similar mechanism to firmware.json, described in qemu
docs/interop/vhost-user.json

https://github.com/qemu/qemu/blob/master/docs/interop/vhost-user.json

qemu 4.1 ships a 50-qemu-gpu.json to match. I believe virtio-fs
will use a similar mechanism when it lands in upstream qemu, as
virtiofsd is a separate process that communicates with qemu over
vhost-user.

For a bit more background on vhost-user-gpu process handling and
the json interop motivation, here's some of the qemu discussion:

https://lists.nongnu.org/archive/html/qemu-devel/2018-08/msg02610.html
https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg00807.html


For this series, the XML to enable this is:

  <video model='virtio' vhostuser='yes'>
    <acceleration accel3d='yes' rendernode='/path/to/rendernode'/>
  </video>

rendernode is optional
qemu_vhost_user.c handles vhost-user.json
qemu_vhost_user_gpu.c handles the process management for
vhost-user-gpu


Marc-André Lureau (16):
  qemu: extract out qemuFetchConfigs from firmware
  domain: add "vhostuser" attribute to virtio video model
  domain: add rendernode attribute on <accel>
  qemu-cgroup: allow accel rendernode access
  qemu: add vhost-user-gpu capabilities checks
  qemu: check that qemu is vhost-user-vga capable
  qemu: validate virtio-gpu with vhost-user
  qemu: restrict 'virgl=' option to non-vhostuser video type
  qemu: add vhost-user helpers
  qemu: add qemuSecurityStartVhostUserGPU helper
  qemu: add vhost-user-gpu helper unit
  qemu: prepare domain for vhost-user GPU
  qemu: start/stop the vhost-user-gpu external device
  qemu: build vhost-user GPU devices
  tests: mock execv/execve
  tests: add vhost-user-gpu xml2argv tests

 docs/formatdomain.html.in                     |  11 +
 docs/schemas/domaincommon.rng                 |  16 +-
 src/conf/device_conf.c                        |   1 +
 src/conf/device_conf.h                        |   2 +
 src/conf/domain_conf.c                        |  32 +-
 src/conf/domain_conf.h                        |   2 +
 src/qemu/Makefile.inc.am                      |   6 +
 src/qemu/qemu_capabilities.c                  |   4 +
 src/qemu/qemu_capabilities.h                  |   2 +
 src/qemu/qemu_cgroup.c                        |  24 ++
 src/qemu/qemu_command.c                       |  54 ++-
 src/qemu/qemu_configs.c                       | 183 ++++++++
 src/qemu/qemu_configs.h                       |  28 ++
 src/qemu/qemu_domain.c                        |  11 +-
 src/qemu/qemu_extdevice.c                     |  75 +++-
 src/qemu/qemu_extdevice.h                     |   5 +
 src/qemu/qemu_firmware.c                      | 144 +------
 src/qemu/qemu_process.c                       |  18 +-
 src/qemu/qemu_security.c                      |  47 +++
 src/qemu/qemu_security.h                      |   6 +
 src/qemu/qemu_vhost_user.c                    | 394 ++++++++++++++++++
 src/qemu/qemu_vhost_user.h                    |  48 +++
 src/qemu/qemu_vhost_user_gpu.c                | 305 ++++++++++++++
 src/qemu/qemu_vhost_user_gpu.h                |  50 +++
 tests/Makefile.am                             |   9 +
 .../caps_4.1.0.x86_64.xml                     |   2 +
 .../etc/qemu/vhost-user/40-gpu.json           |   1 +
 .../etc/qemu/vhost-user/50-gpu.json           |   0
 .../qemu/vhost-user/test-vhost-user-gpu       |  11 +
 .../usr/share/qemu/vhost-user/30-gpu.json     |   1 +
 .../usr/share/qemu/vhost-user/50-gpu.json     |   8 +
 .../usr/share/qemu/vhost-user/60-gpu.json     |   1 +
 tests/qemuvhostusertest.c                     | 132 ++++++
 .../vhost-user-gpu-secondary.args             |  38 ++
 .../vhost-user-gpu-secondary.xml              |  44 ++
 tests/qemuxml2argvdata/vhost-user-vga.args    |  35 ++
 tests/qemuxml2argvdata/vhost-user-vga.xml     |  41 ++
 tests/qemuxml2argvtest.c                      |  21 +
 tests/virfilewrapper.c                        |  22 +
 39 files changed, 1676 insertions(+), 158 deletions(-)
 create mode 100644 src/qemu/qemu_configs.c
 create mode 100644 src/qemu/qemu_configs.h
 create mode 100644 src/qemu/qemu_vhost_user.c
 create mode 100644 src/qemu/qemu_vhost_user.h
 create mode 100644 src/qemu/qemu_vhost_user_gpu.c
 create mode 100644 src/qemu/qemu_vhost_user_gpu.h
 create mode 120000 tests/qemuvhostuserdata/etc/qemu/vhost-user/40-gpu.json
 create mode 100644 tests/qemuvhostuserdata/etc/qemu/vhost-user/50-gpu.json
 create mode 100755 tests/qemuvhostuserdata/usr/libexec/qemu/vhost-user/test-vhost-user-gpu
 create mode 120000 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/30-gpu.json
 create mode 100644 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/50-gpu.json
 create mode 120000 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/60-gpu.json
 create mode 100644 tests/qemuvhostusertest.c
 create mode 100644 tests/qemuxml2argvdata/vhost-user-gpu-secondary.args
 create mode 100644 tests/qemuxml2argvdata/vhost-user-gpu-secondary.xml
 create mode 100644 tests/qemuxml2argvdata/vhost-user-vga.args
 create mode 100644 tests/qemuxml2argvdata/vhost-user-vga.xml

Comments

Cole Robinson Aug. 23, 2019, 4:40 p.m. UTC | #1
On 8/23/19 12:21 PM, Cole Robinson wrote:
> v1: https://www.redhat.com/archives/libvir-list/2019-June/msg00102.html
> 
> This is v2 of Marc-André's series with minor changes. I'm not taking over
> this series, I just fixed these as part of the patch rebase so I can review
> it :)
> 
> Changes since v1:
>     - rebase to master
>     - if test file build by dropping LDADDS usage
>     - syntax-check issues:
>         * use #pragma once
>         * if () bracket issues
>         * jump label indent issues
>         * error message %s usage
>         * size_t for loops
> 
> I didn't know much about vhost-user-gpu before this series, here's what
> I've learned.
> 
> vhost-user is a generic mechanism that allows implementing virtio device
> dataplane handling in a separate userspace process. vhost-user-gpu here
> notably moves the virgl 3d handling out of the main qemu process. The
> external process will be /usr/libexec/vhost-user-gpu, which comes from
> qemu.git contrib/vhost-user-gpu code, first released in qemu-4.1.
> 
> Part of this series deals with discovering the location on disk of the
> vhost-user-gpu binary, and what capabilities it provides. This uses a
> similar mechanism to firmware.json, described in qemu
> docs/interop/vhost-user.json
> 
> https://github.com/qemu/qemu/blob/master/docs/interop/vhost-user.json
> 
> qemu 4.1 ships a 50-qemu-gpu.json to match. I believe virtio-fs
> will use a similar mechanism when it lands in upstream qemu, as
> virtiofsd is a separate process that communicates with qemu over
> vhost-user.
> 
> For a bit more background on vhost-user-gpu process handling and
> the json interop motivation, here's some of the qemu discussion:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2018-08/msg02610.html
> https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg00807.html
> 
> 
> For this series, the XML to enable this is:
> 
>   <video model='virtio' vhostuser='yes'>
>     <acceleration accel3d='yes' rendernode='/path/to/rendernode'/>
>   </video>

That's wrong, it's

  <video>
    <model type='virtio' vhostuser='yes'>
      <acceleration accel3d='yes' rendernode='/path/to/rendernode'/>
    </model>
  </video>

- Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list