-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
At least some nVidia GPUs in Optimus laptops work with GPU passthrough, but only if the video card ROM is passed manually, since getting it requires making an ACPI call on the host.
Unfortunately, while qemu in the stubdomain supports passing romfile= to device_add via QMP, libxl seems to have no support for passing that option; furthermore, when using romfile= the file needs to be in the stubdomain file system.
Hacking vchan-socket-proxy to add romfile= to the device_add call and patching the stubdomain to add the ROM makes nouveau in the VM properly recognize at least my card when passed through, but obviously it's not a very clean solution.
So, my suggestion would be to:
- Patch qemu to add a new "rombase64" option that passes a Base64-encoded ROM via QMP
- Patch libxl to recognize "romfile" for domains with a stubdomain, read the file, base64 encode it and pass via QMP
- If needed (probably not?), patch libvirt to pass romfile to libxl when the libvirt xml contains
- Patch qubes pci.xml to specify when a parameter is passed
- If needed (probably not?), patch qvm-pci to support the parameter for the ROM file
- Ideally patch qvm-pci and/or qubes-qube-manager to have Qubes automatically pick up the ROM file from a standard place (e.g. /var/lib/qubes/pci-roms/VENDOR_DEVICE_PCIID.rom)
Then it would be nice to provide an automatic setup tool for GPU passthrough, which in this case needs to:
- If the GPU was passed through, require a reboot
- Attach the GPU to dom0 if needed (unbind from pciback, rebind to the GPU driver such as nouveau)
- Load the video driver in dom0, dump the BIOS by reading /sys/kernel/debug/dri/<id>/vbios.rom and put it in the proper place
- Add the rd.qubes.hide_pci options to hide the GPU in dom0
As further work, it should be possible to have custom code that would extract the BIOS automatically on the fly without having to load a DRI driver, but that might not be worth the effort.