talex5 / wayland-proxy-virtwl

Allow guest VMs to open windows on the host
Apache License 2.0
114 stars 12 forks source link

Add some docs on how to build crosvm #48

Closed madushan1000 closed 2 years ago

madushan1000 commented 2 years ago

Hi, Can you add some docs on how to add crosvm from source to work with this? I tried to build crosvm HEAD like this cargo run --features=linux-x86_64,gpu,virgl_renderer,virgl_renderer_next but it looks like cross_domain capabilities are never exposed to the guest. And this proxy exits with

wayland-proxy-virtwl: internal error, uncaught exception:
                      Unix.Unix_error(Unix.EINVAL, "DRM_IOCTL_VIRTGPU_GET_CAPS", "")

I'm not sure what I'm doing wrong, do I have to patch the guest kernel somehow?(Using mainline 6.0 kernel on a ubuntu guest)

talex5 commented 2 years ago

I use the Nix file at https://gitlab.com/talex5/qubes-lite. That will build crosvm with the patches I use.

It's using an older crosvm, though. I'm hoping to upgrade to the latest version soon, but haven't got it working reliably yet. You will need to run it with --gpu=context-types=cross-domain:virgl2 at least.

@puckipedia might have got a more recent version working.

puckipedia commented 2 years ago

I got a very recent version of crosvm working, though running it with only cross-domain context breaks; this is likely due to a kernel bug but it's kinda hard to nail down; https://puck.moe/git/security-context-demo/tree/fence.patch seems to fix it, but likely breaks (haven't tried it) if you try to use virgl with it applied.

madushan1000 commented 2 years ago

I figured out I had to pass context-types=* just now. Looks like everything works okay in crosvm HEAD with ---gpu backend=virglrenderer,width=1920,height=1080,context-types=virgl2:cross-domain. Just running with context-types=cross-domain doesn't work. I'll try the patch later.

madushan1000 commented 2 years ago

I noticed that the windows drawn inside X or Wayland window made by crosvm(the one where gnome run) has hardware accelerated rendering via virgl, but the windows created via the proxy use llvmpipe. Is there a way to use virgl for those too?

puckipedia commented 2 years ago

Yeah; this requires support for certain passthrough trickery, and some amount of guest kernel support (due to virgl semantics and having to fix up strides on some gpu archs) - see #43

madushan1000 commented 2 years ago

Thanks! I'll check it out :)

talex5 commented 2 years ago

I've pushed a patched version of crosvm here: https://gitlab.com/talex5/crosvm/

It seems to be working now, though it sometimes logs warnings (e.g. WARNING: CPU: 0 PID: 31 at block/blk-mq.c:1143 blk_mq_start_request+0x113/0x140).