News in Qemu graphics
the 2016 update
Gerd Hoffmann <kraxel@redhat.com>
KVM Forum 2016, Toronto
Outline.
- virtio-gpu
- guest support
- host support
- opengl rendering
- gpu assignment and vgpu
virtio-vga vs. virtio-gpu-pci
- virtio-vga = virtio-gpu-pci + stdvga
- set scanout virtio command switches to virtio-gpu mode
- device reset switches back to vga mode
- vga mode for backward compatibility and firmware framebuffer
- used by seavgabios, OVMF (x86) and SLOF (ppc)
- vga mode not working on arm (cache coherency issues)
- use virtio-gpu-pci instead
- edk2 gfx output WIP by László
virtio-vga mmio bar
fc800000-fcffffff (prio 1, RW): virtio-pci
fc800400-fc80041f (prio 0, RW): vga ioports remapped
fc800500-fc800515 (prio 0, RW): bochs dispi interface
fc800600-fc800607 (prio 0, RW): qemu extended regs
fcbfd000-fcbfdfff (prio 0, RW): virtio-pci-common
fcbfe000-fcbfefff (prio 0, RW): virtio-pci-isr
fcbff000-fcbfffff (prio 0, RW): virtio-pci-device
fcc00000-fcffffff (prio 0, RW): virtio-pci-notify
virtio-gpu guest support
- virtio-gpu.ko linux kernel drm driver
- 2d mode: linux 4.2
- 3d/virgl mode: linux 4.4
- multihead fixes: linux 4.8-rc1
- userspace driver: mesa 11.1
- xorg-x11-server support (using glamor)
- commit "5627708 dri2: add virtio-gpu pci ids" (master branch)
- backported to fedora xorg-x11-server-1.18 rpms
- almost completely upstream
virtio-gpu/3d distro support
- Fedora 24
- Fedora 23, with updates
- Android (android-x86.org)
- has mesa-based opengl es stack.
- Other distros should follow as they pick up upstream updates.
- check kernel: dmesg | grep virgl
- check mesa: glxinfo | grep virgl
virtio-gpu emulation
- virtio-gpu 2d mode: qemu 2.4
- virtio-gpu 3d/virgl mode: qemu 2.5
- virtio-gpu multihead fixes: qemu 2.7
- virtio-gpu 2d mode live migration: qemu 2.7
virglrenderer
- created by David Airlie
- mesa gallium command stream (from guest) => opengl (for host gpu)
- pretty complex and security sensitive
- sandboxing: WIP by Marc-André Lureau
- approach: use virtio-user to run virglrenderer in a separate process
opengl support in qemu UIs
- gtk: qemu 2.5
- different code for 3.16+ (GtkGlArea).
- sdl2: qemu 2.6
- spice, local only: qemu 2.6
- spice, remote display: in progress
- not (yet) playing nice with selinux
spice: local display
- uses render node (/dev/dri/render*) for headless opengl
- no display server dependency (unlike sdk2/gtk)
- passes guest display as dma-buf to spice client
- qemu: needs libepoxy 1.3.1, mesa 10.6
- qemu: needs spice-server 0.13.1 (devel release)
- qemu flatpaks don't play nice with libvirt (nested sandbox)
- virt-viewer: needs spice-gtk 0.32 (0.31 for gtk2)
- needs unix socket connection for dma-buf fd passing
pass display dma-bufs
- qemu
- render guest display into texture
- eglCreateImageKHR: texture -> image
- eglExportDMABUFImageMESA: image -> dma-buf filehandle
- send filehandle via unix socket (SCM_RIGHTS)
- spice client
- eglCreateImageKHR (using target=EGL_LINUX_DMA_BUF_EXT):
dma-buf filehandle -> image
- glBindTexture: bind image to texture
spice: libvirt config
<graphics type='spice'>
<listen type='none'/>
<gl enable='yes'/>
</graphics>
<video>
<model type='virtio'/>
</video>
virgl opengl display
vga opengl display
spice: remote display
- plan is to encode video and send that
- experimental patches exist
- using gstreamer support merged in spice-server recently
- hardware encoding support is tricky
- vaapi: created by intel, encode + decode
- vdpau: created by nvidia, also supported by others, decode only
- nvidia supports encoding via proprietary library (nvenc)
- patent issues around H.264 + H.265
- ciscos openh264 codec might help here
- recent intel hardware supports vp8 and vp9 too
vfio with gpus
- Not new for standalone gpus
2014 KVM Forum talk by Alex
- IGD support added (chipset quirks)
- needs: linux 4.6, qemu 2.7
- useful for intel vgpu too
- input-linux support added
- read input directly from linux evdev devices
- removes the need to have a otherwise unused emulated gfx device
and sdl/gtk/spice window for kbd+mouse input.
- needs: qemu 2.6
vfio with vgpu
- host gpu driver partitions hardware into multiple virtual gpus
- roughly comparable to SR/IOV
- separation & virtualization done by host gpu driver (instead of iommu)
- use well established vfio interface for vgpu too
- qemu -device vfio-pci will just work
- in development: mdev driver, for common tasks such as guest
memory tracking.
TODO: link nvidia slides here.
intel vgpu integration
- integrating into the i915 drm driver is in progress
0ad35fe drm/i915: gvt: Introduce the basic architecture of GVT-g (4.8-rc1)
- kvm integration depends on mdev driver (previous slide)
- guest display will be exported as dma-buf
vgpu opengl display
vgpu display, improved
guest video encoding
- with pci assigned gpu (also on bare metal)
- commercial solutions for that exist (game streaming)
- vgpu can do the same
- advantage: same setup on bare metal, assigned gpu, vgpu
- disadvantages:
- not transparent to the guest
- no spice integration
- worth trying?
- guest agent could send H.264 over virtio-serial ...
- vfio/vgpu BoF
/