arighi / virtme-ng

Quickly build and run kernels inside a virtualized snapshot of your live system
GNU General Public License v2.0
417 stars 45 forks source link

NVIDIA gpu support #165

Closed ianm-nv closed 5 days ago

ianm-nv commented 6 days ago

This PR enables gpu passthrough with virtme-ng. It adds a new paramemeter "--nvgpu' which is used to provide the PCI address of the gpu. There are included instructions in the README for enabling VFIO passthrough support.

SPYFF commented 3 days ago

While this is a good addition, I wonder if it can be generalised. I used to pass-through the network interface with VFIO and the steps were almost identical. I'm afraid there are driver and device specific quirks, but the basic steps were the same as in this case:

  1. Find the PCIe address and device ID of the device 2a. Unbind it from its driver (on a running system) 2b. Blacklist the driver (if runtime unbind failed)
  2. Load the vfio-pci driver
  3. Map the device to the vfio-pci driver
  4. May or may not be visible and usable in QEMU

Sure, success is highly device and host dependent (e.g. the same i225 NIC worked in the VM on an Intel host, but not on an AMD, etc.), but a generic PCIe passthrough feature might be worth considering.

arighi commented 3 days ago

Absolutely, I totally agree on generalizing the concept of PCI passthrough and I think we can improve this in-tree. At this stage even if we break the API (command options) is not so critical as long as we don't break any previous behavior or option (maybe we should have a way to mark new options as "unstable"?). But I think it's good to have "something" merged, a lot of people have been asking me this feature for a while, so at least now people can start using it and improving it. 🙂

That said, I'll think about a proper interface for a generic PCI passthrough and maybe we can discuss it here or better create a separate issue.

Thanks!