talex5 / wayland-proxy-virtwl

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

Document requirements for the guest VM and host #51

Closed msm-code closed 1 year ago

msm-code commented 1 year ago

Hi,

Very interesting project, thanks for sharing. And I understand this is not a support forum. Nevertheless I'm trying to use this project[^1], and I can't for the life of me figure out how to get it to run.

Problem symptoms: when I run the binary in the VM, i get a scary looking exception with EINVAL:

[root@chromium:/sys/kernel/debug/dri/0/Virtual-1]# wayland-proxy-virtwl --virtio-gpu
wayland-proxy-virtwl: internal error, uncaught exception:
                      Unix.Unix_error(Unix.EINVAL, "DRM_IOCTL_VIRTGPU_GET_CAPS", "")

relevant strace:

ioctl(4, DRM_IOCTL_VERSION, 0x27b2510)  = 0
ioctl(4, DRM_IOCTL_VERSION, 0x27b2510)  = 0
ioctl(4, DRM_IOCTL_VIRTGPU_GET_CAPS, 0x7ffc08a064c0) = -1 EINVAL (Invalid argument)

I'm suspect the root cause is that I don't have context_init enabled in my VM:

[user@chromium:~]$ dmesg | grep drm
[    3.971081] systemd[1]: Starting Load Kernel Module drm...
[    4.055096] ACPI: bus type drm_connector registered
[    4.080238] [drm] pci: virtio-vga detected at 0000:00:02.0
[    4.082277] [drm] features: +virgl +edid -resource_blob -host_visible
[    4.082279] [drm] features: -context_init
[    4.083024] [drm] number of scanouts: 1
[    4.083029] [drm] number of cap sets: 2
[    4.092992] [drm] cap set 0: id 1, max-version 1, max-size 308
[    4.094368] [drm] cap set 1: id 2, max-version 2, max-size 696
[    4.094636] [drm] Initialized virtio_gpu 0.1.0 0 for 0000:00:02.0 on minor 0
[    4.101540] fbcon: virtio_gpudrmfb (fb0) is primary device
[    4.101640] virtio-pci 0000:00:02.0: [drm] drm_plane_enable_fb_damage_clips() not called
[    4.107921] virtio-pci 0000:00:02.0: [drm] fb0: virtio_gpudrmfb frame buffer device

Docs say that I need virtio_gpu, but it can't be just it - I have it installed in my VM:

[user@chromium:~]$ lsmod | grep virtio_gpu
virtio_gpu             77824  10
virtio_dma_buf         16384  1 virtio_gpu
drm_shmem_helper       24576  1 virtio_gpu
drm_kms_helper        217088  3 virtio_gpu
drm                   634880  10 drm_kms_helper,drm_shmem_helper,virtio_gpu
virtio                 16384  7 virtio_rng,virtio_console,virtio_balloon,9pnet_virtio,virtio_gpu,virtio_pci,virtio_blk
virtio_ring            45056  7 virtio_rng,virtio_console,virtio_balloon,9pnet_virtio,virtio_gpu,virtio_pci,virtio_blk

I use libvirt, and this is my graphic device configuration:

    <graphics type='spice'>
      <listen type='address'/>
      <gl enable='yes' />
    </graphics>
    <video>
      <model type='virtio' heads='1' primary='yes'>
        <acceleration accel3d='yes'/>
      </model>
    </video>

I have two GPUs and use a nouveau driver on the host (and in the VM):

$ lspci | grep -i "VGA"
00:02.0 VGA compatible controller: Intel Corporation CometLake-H GT2 [UHD Graphics] (rev 05)
01:00.0 VGA compatible controller: NVIDIA Corporation TU117GLM [Quadro T2000 Mobile / Max-Q] (rev a1)

I have also asked my friend to test this project (he has a similar setup to mine), and he encountered the same problem.

So basically my question is: is there any obvious step that we've missed? Or are there any requirements for the host GPU (or host drivers) for the project to work? What can I do to debug it better?

Hope you don't mind me asking. Feel free to close otherwise.

Thanks for help.

[^1]: actually, I'm trying to integrate it with my project.

talex5 commented 1 year ago

I've only used it with crosvm. In particular, I use --gpu=context-types=cross-domain:virgl2: https://gitlab.com/talex5/qubes-lite/-/blob/873e2f3630247809fbde894817f2c918ed089b57/default.nix#L185

(see https://github.com/talex5/wayland-proxy-virtwl#crosvm-setup)

msm-code commented 1 year ago

Thanks. For some reason I've assumed qemu is also supported (my fault, nothing in the documentation suggests that). I've tried to run this project with libvirt + qemu + virtio-gpu, with no success so far (my understanding is that context_init is not yet supported by mainline qemu).

I'll investigate a bit more, but I'll probably migrate to crossvm then. Thanks again.

polarathene commented 1 year ago

For some reason I've assumed qemu is also supported

FWIW, this may change later this year. I came across this project via link while reading this, which itself was from a link discussing Mesa PR for AMD native context and related work to support that. A couple months ago a Collabora blogpost comment section on QEMU + Venus support also had a comment added that work towards upstreaming that was under way as well.

The 2nd link there (Gitlab) does talk about cross-domain and changes needed to virglrenderer / virtio-gpu IIRC, so I'm pretty sure QEMU will be more compatible once all of that lands :)