Building QEMU with virtio-gpu and rutabaga_gfx

Building QEMU with virtio-gpu and rutabaga_gfx

Date: on 2023-11-22 | Updated: on 2024-01-04

virtio-gpu-rutabaga device is available in QEMU 8.2 release candidates and later versions.

1. Install Debian host system dependencies

You might have to install more if you haven't built QEMU before on the host.

apt install -y {libpulse,libdrm,libglm,libstb,libegl,libgles,libvulkan,vulkan-validationlayers}-dev

In Debian trixie, vulkan-validation-layers-devhas been renamed to vulkan-utility-libraries-dev.

2. Build qemu

git clone https://gitlab.com/qemu-project/qemu.git

Checkout master or a 8.2 tagged release.

2.1 (maybe optional) Build libvirglrenderer

Depending on the system version you have you might need a newer libvirglrender

export PREFIX="$(pwd)"/prefix git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git cd virglrenderer meson setup -Dprefix=$PREFIX -Dlibdir=lib build cd build ninja install

2.2 Build rutabaga/gfxstream dependencies

You will need to build gfxstream and rutabaga_gfx dependencies for QEMU.

Instead of polluting the host root FS, you can put everything under a local prefix folder:

Here we will build every dependency and install them in prefix/

The following rutabaga_gfx build instructions were taken from https://crosvm.dev/book/appendix/rutabaga_gfx.html

2.2.1 - Build aemu

HEAD revision:

2.2.2 Build gfxstream

HEAD revision:

2.2.3 Build rutabaga FFI

You will also need rust/cargo.

Install the stable channel 1.68.2-{x86_64,aarch64}-unknown-linux-gnu toolchain with rustup if you don't have it already:

crosvm HEAD revision:

Important: if the Makefile did not find gfxstream with pkg-config, the library is built without the gfxstream feature. Make sure this step has worked.

2.2.4 Build qemu binary

After all that, go back to qemu/build and build QEMU:

3. Run the guest.

I used this QEMU invocation:

If you use Wayland, choose WAYLAND_SOCK=/run/user/1000/wayland-0 or similar. If you use weston inside Xorg run weston -S /tmp/wayland.sock and use WAYLAND_SOCK=/tmp/wayland.sock.

3.1 Running graphic apps in guest through sommelier

You will need to build sommelier inside the guest.

Clone the repository:

I used the HEAD revision: Mon Aug 14 02:58:30 2023 +0000 40e9663246e784fb4d3abc0385ac2fe717ecf460 Revert "vm_tools/9s: Replace crosvm_base::vsock with vsock crate"

On Debian, you will need the following build dependencies:

Then perform the build:

This should open weston-terminal and glmark2-wayland on your host's wayland compositor.