bryansteiner / gpu-passthrough-tutorial

GNU General Public License v3.0
1.4k stars 91 forks source link

kvm.conf creation #6

Closed rupiperse closed 4 years ago

rupiperse commented 4 years ago

Tutorial doesn't say how to find your GPU PCI addresses. Would this work for my configuration? I used "lspci -nn" to show the PCI devices. My VM does not have NVME passthough or USB/GPU serial passthrough. Should I comment out those lines like this?:

Virsh devices

VIRSH_GPU_VIDEO=pci_0000_00_00_0 VIRSH_GPU_AUDIO=pci_0000_00_00_1

VIRSH_GPU_USB=pci_0000_0a_00_2

VIRSH_GPU_SERIAL=pci_0000_0a_00_3

VIRSH_NVME_SSD=pci_0000_04_00_0

bryansteiner commented 4 years ago

Tutorial does include this info. Go ahead and use the following script: /kvm/scripts/iommu.sh:

#!/bin/bash
for d in /sys/kernel/iommu_groups/*/devices/*; do
  n=${d#*/iommu_groups/*}; n=${n%%/*}
  printf 'IOMMU Group %s ' "$n"
  lspci -nns "${d##*/}"
done

Here's some example output:

...
IOMMU Group 1 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti Rev. A] [10de:1e07] (rev a1)
IOMMU Group 1 01:00.1 Audio device [0403]: NVIDIA Corporation TU102 High Definition Audio Controller [10de:10f7] (rev a1)
IOMMU Group 1 01:00.2 USB controller [0c03]: NVIDIA Corporation TU102 USB 3.1 Controller [10de:1ad6] (rev a1)
IOMMU Group 1 01:00.3 Serial bus controller [0c80]: NVIDIA Corporation TU102 UCSI Controller [10de:1ad7] (rev a1)
...

As you can see, my GPU video and audio device reside in IOMMU Group 1 and have the following PCI IDs: 01:00.0 and 01:00.1

From here it's trivial to convert these two PCI IDs to their corresponding virsh pci ids:

VIRSH_GPU_VIDEO=pci_0000_01_00_0
VIRSH_GPU_AUDIO=pci_0000_01_00_1

My VM does not have NVME passthough or USB/GPU serial passthrough. Should I comment out those lines like this?:

Yes, comment out those lines.

rupiperse commented 4 years ago

I must have missed that. I got to this page from somewhere and it opened the page at part 2. But that's good. I did it correctly. And I already have a working VM with passthrough. Just had to remove the kernel parameters that blacklist the GPU from Linux.

After installing and configuring the hook scripts virt manager gives out this error when attempting to run the VM:

"Error starting domain: Hook script execution failed: internal error: Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin /etc/libvirt/hooks/qemu win10 prepare begin -) unexpected exit status 127: /etc/libvirt/hooks/qemu: line 27: : command not found

Traceback (most recent call last): File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper callback(asyncjob, *args, kwargs) File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb callback(*args, *kwargs) File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn ret = fn(self, args, kwargs) File "/usr/share/virt-manager/virtManager/object/domain.py", line 1279, in startup self._backend.create() File "/usr/lib/python3.8/site-packages/libvirt.py", line 1152, in create if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self) libvirt.libvirtError: Hook script execution failed: internal error: Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin /etc/libvirt/hooks/qemu win10 prepare begin -) unexpected exit status 127: /etc/libvirt/hooks/qemu: line 27: : command not found"

Does this mean that the qemu script isn't working properly or the begin/bind script isn't working?