Worth marking patches like this as RFC or similar in future, so everybody looking at it is on the same page about its status. (I'm assuming this was meant as a proof of concept and not meant to be applied as is.) Demi Marie Obenour <demiobenour@gmail.com> writes:
This exposes GPU acceleration to VMs via virtio-GPU native contexts on AMD and Qualcomm GPUs. Apple GPU support also exists but might require patches to virglrenderer that are not upstream yet.
On a system with an AMD GPU, this has been tested by running vkcube in the VM. It reports that the AMD GPU is being used for rendering.
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com> --- I used an empty string for the hashes in 'gitfetch' and 'buildRustPackage'. This is, of course, incorrect. The correct value according to my own testing is "sha256-EOMkQ0aPRjsowdGuZjy5K1yKyKEzd5AVYxaECTz7n6k=" (git hash) and "sha256-k3dmxIuCQoOrn/VwauTdzuRw/XKQB6LPLgO5ql0rE7E=" (cargoHash). However, these should be validated before applying them, which is why I didn't include them in the patch themselves. This is a security precaution: anyone who wants to inject malicious content must serve it to multiple people, not just one. --- .../template/data/service/vhost-user-gpu/run | 2 +- img/app/Makefile | 2 +- img/app/default.nix | 14 ++++++++++++-- img/app/image/etc/mdev.conf | 1 + .../notification-fd | 0 .../notification-fd.license | 0 .../{wayland-proxy-virtwl => wl-cross-domain-proxy}/run | 17 +++++------------ .../type | 0 .../type.license | 0 9 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run index fb9ac9971aef82dabe0b54c1299ac8c66d133eb5..87d72f55e293ea81b6f4aa12786a993bafc623e2 100755 --- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run +++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run @@ -42,4 +42,4 @@ bwrap crosvm --no-syslog device gpu --fd 0 --wayland-sock $WAYLAND_DISPLAY - --params "{\"context-types\":\"cross-domain\"}" + --params "{\"context-types\":\"cross-domain:drm\"}"
I suppose we'll need to get some sort of graceful fallback into crosvm/rutabaga, or to somehow detect native contexts support in this script before we enable it on the crosvm command line? 2026-01-29 14:06:30.082434936 [2026-01-29T14:06:30.082073581+00:00 ERROR rutabaga_gfx::virgl_renderer] failed to initialize drm renderer 2026-01-29 14:06:30.082842461 [2026-01-29T14:06:30.082652949+00:00 WARN rutabaga_gfx::rutabaga_core] error initializing gpu backend=virglrenderer, falling back to 2d. 2026-01-29 14:06:30.099779984 [2026-01-29T14:06:30.099379669+00:00 WARN devices::virtio::gpu::virtio_gpu] virtio-gpu get_capset_info(index=1) failed. intentionally poisoning response --- FYI: I needed the following additional diff to test the rootfs with this patch: diff --git a/img/app/default.nix b/img/app/default.nix index 1ce3225..d19f5f8 100644 --- a/img/app/default.nix +++ b/img/app/default.nix @@ -15,9 +15,9 @@ let src = fetchgit { url = "https://codeberg.org/drakulix/wl-cross-domain-proxy"; rev = "167b5ade788d297cd19929c2f367484a09a87316"; - hash = ""; + hash = "sha256-EOMkQ0aPRjsowdGuZjy5K1yKyKEzd5AVYxaECTz7n6k="; }; - cargoHash = ""; + cargoHash = "sha256-k3dmxIuCQoOrn/VwauTdzuRw/XKQB6LPLgO5ql0rE7E="; }; kernelTarget = if stdenvNoCC.hostPlatform.isx86 then diff --git a/img/app/file-list.mk b/img/app/file-list.mk index 815b63a..443e6f2 100644 --- a/img/app/file-list.mk +++ b/img/app/file-list.mk @@ -41,7 +41,6 @@ LINKS = \ S6_RC_FILES = \ image/etc/s6-rc/app/dependencies.d/dbus \ image/etc/s6-rc/app/dependencies.d/pipewire \ - image/etc/s6-rc/app/dependencies.d/wayland-proxy-virtwl \ image/etc/s6-rc/app/run \ image/etc/s6-rc/app/type \ image/etc/s6-rc/dbus-vsock/notification-fd \ @@ -64,10 +63,10 @@ S6_RC_FILES = \ image/etc/s6-rc/pipewire/notification-fd \ image/etc/s6-rc/pipewire/run \ image/etc/s6-rc/pipewire/type \ - image/etc/s6-rc/wayland-proxy-virtwl/notification-fd \ - image/etc/s6-rc/wayland-proxy-virtwl/run \ - image/etc/s6-rc/wayland-proxy-virtwl/type \ image/etc/s6-rc/wireplumber/dependencies.d/dbus \ image/etc/s6-rc/wireplumber/dependencies.d/pipewire \ image/etc/s6-rc/wireplumber/run \ - image/etc/s6-rc/wireplumber/type + image/etc/s6-rc/wireplumber/type \ + image/etc/s6-rc/wl-cross-domain-proxy/notification-fd \ + image/etc/s6-rc/wl-cross-domain-proxy/run \ + image/etc/s6-rc/wl-cross-domain-proxy/type diff --git a/img/app/image/etc/s6-rc/app/dependencies.d/wayland-proxy-virtwl b/img/app/image/etc/s6-rc/app/dependencies.d/wayland-proxy-virtwl deleted file mode 100644 index e69de29..0000000