lae / ansible-role-proxmox

IaC for Proxmox VE clusters.
MIT License
468 stars 139 forks source link

feature/vfio-support #202

Closed ol3d closed 2 weeks ago

ol3d commented 1 year ago

Added basic support for PCIe Passthrough using Intel or AMD based CPU's. Feature is disabled by default as to prevent breaking change. Mediated devices are supported, however, this is a modifiable attribute since not all devices support gtv-g. IOMMU unsafe interupts are not necessary but can be beneficial so support was added for that as well.

lae commented 1 year ago

I see you've updated the role variable names, cool. Asides from that, can you enable this for the tests in tests/? Mainly need it for tests/vagrant/ as I haven't gotten around to fixing/re-enabling CI. I'll do a proper review later when I can.

ol3d commented 1 year ago

As this is the first time I have used Vagrant, I messaged on Discord for help if you don't mind :)

lae commented 1 year ago

Sorry for the late follow-up, I'm busy and haven't gotten a chance to run tests (takes forever) and just test it out in general, but this is on my radar and I'll let you know when I can.

There was one thing I was wondering whether or not to point out, but since it's probably gonna take me a while to actually get to this, I might as well. A lot of folks looking for VFIO in Proxmox are likely wanting it for their GPU(s), and in most cases that requires stubbing the GPU's vendor/product ID so that drivers don't try to drive them on the host. This PR is missing that and I was thinking it could be a separate follow-up PR, but since I think most folks need it anyway it could also be part of this one. It is explained in the PVE wiki a bit: https://pve.proxmox.com/wiki/Pci_passthrough#GPU_Passthrough

It may not be the best explanation (in fact, https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Isolating_the_GPU is a better read), but as a real-world example this is my Proxmox workstation that I rely on to passthrough GPUs and USB controllers:

~$ cat /etc/modprobe.d/vfio.conf
softdep amdgpu pre: vfio-pci
softdep radeon pre: vfio-pci
options vfio-pci ids=1002:67df,1002:aaf0,1b73:1100,1002:6981,1002:aae0,1002:73e3 disable_vga=1
~$ grep vfio /etc/default/grub
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX amd_iommu=on iommu=pt vfio-pci.ids=1002:67df,1002:aaf0,1b73:1100,1002:6981,1002:aae0,1002:73e3 pci.stub.ids=1002:67df,1002:aaf0,1002:6981,1002:aae0,1002:73e3"

Think adding a role variable+task for another GRUB_CMDLINE_LINUX line could work?

ol3d commented 1 year ago

Yes another line could handle this, I can take a look into it a bit more since I have not really had experience with dedicated GPU passhthrough, only integrated devices. I know this could require modifying/creating blacklists for drivers as well depending on device vendor/use case. Either way I can look into it a bit and possibly branch off of this PR to see if I can get something working properly

lae commented 1 year ago

I don't think we have to worry too much about trying to cater to specific vendors in particular. Just having the user specify IDs and what drivers to use softdep on (I guess this is an alternative to actually blacklisting them) would get us most of the way, and if the user needs to do something else they can probably just add it to their playbook.

ol3d commented 1 year ago

Enabled pci id and driver vars that can configure default grub and vfio.conf file for gpu and other device passthrough. I think at this point a separate section in the README for PCIe Passthrough: would be appropriate to help people understand more in depth how this works. I'll write something up for that

If there is a spot you'd like it added in the README let me know and I can move stuff around a bit

ol3d commented 1 year ago

Commenting to track progress on review of PR

lae commented 1 year ago

I'll be available to review this properly mid-Oct. Please remind me then if I haven't.

ol3d commented 1 year ago

Reminder to take a look into this PR more in depth

ol3d commented 1 year ago

Closing due to inactivity, may re-open in the future

ol3d commented 7 months ago

re-opening since I have more free time again to look into these changes. I have some additional changes I made for my own homelab branch to add into this one as well.