Dies ist eine alte Version des Dokuments!


Grafikkartenpassthrough Proxmox ab version 4.3

Zum einen ist es wichtig hier eine VM und Grafikkarte mit UEFI Support zu haben. Getestet wurde das ganze hier mit Windows Server 2012r2 und Kubuntu 16.04 mit aktiven Kubuntu/backports PPA. Wichtig ist vorab zu sagen das diese Technologie sehr Hardware abhängig ist, hat z.B. das Motherboard die Devices in falschen oder besser gesagt unbrauchbaren Konstellationen zusammengeschlossen, wie z.B. PCIe-Slot und Netzwerknic, ist es mehr als unbrauchbar. Auch noch zu erwähnen das GPUpassthrough von Proxmox selbst nicht supportet wird. Erfolgreich getestet wurde es hier mit Supermicro. Wir gehen hier im ganzen Artikel von INTELchips aus. Lässt man den Grafikteil weg, ist das ganze hier auch für normalen PCIe Passthrough gültig, dabei wird auch kein UEFI benötigt.

Als erstes bereiten wir den Host auf die Grafikkarte vor. Hierfür tragen wir in Grub die Iommu Unterstützung ein.

nano /etc/default/grub

ändere

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

in

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

Danach Grub updaten:

update-grub

Module einragen:

nano  /etc/modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

it will not be possible to use PCI passthrough without interrupt remapping. Device assignment will fail with a 'Failed to assign device „[device name]“ : Operation not permitted' error for users of KVM, and a 'Interrupt Remapping hardware not found, passing devices to unprivileged domains is insecure. Systems which don't support interrupt remapping:

All systems using an Intel processor and chipset that have support for Intel Virtualization Technology for Directed I/O (VT-d), but do not have support for interrupt remapping. Interrupt remapping support is provided in newer processors and chipsets. To identify if your system has support for interrupt remapping:

dmesg | grep ecap

On the IOMMU lines, the hexadecimal value after „ecap“ indicates whether interrupt remapping is supported. If the last character of this value is an 8, 9, a, b, c, d, e, or an f, interrupt remapping is supported. For example, „ecap 1000“ indicates there is no interrupt remapping support. „ecap 10207f“ indicates interrupt remapping support, as the last character is an „f“. Interrupt remapping will only be enabled if every IOMMU supports it.

If your system doesn't support interrupt remapping, you can allow unsafe interrupts with:

echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf

Von wird aber im produktivem Betrieb abgeraten.

Da wir eine Nvidiakarte benutzen (Quadro K4000) müssen wir auch die Module in die Blacklist des Hosts eintragen, damit diese nicht automatisch genutzt wird:

echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf 
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf

Nach dem Neustart kann man die Garte dem Gast übergeben. Vorher prüfen wir noch die Iommu Gruppen. To have pci passthrough working fine, you need dedicated iommu group for your pci devices.

find /sys/kernel/iommu_groups/ -type l

Mit etwas Glück hängt der Slot alleine auf unserem Board. So wie hier.

First, find the device and vendor id of your vga card:

lspci -n -s 01:00
01:00.0 0300: 10de:1381 (rev a2)
01:00.1 0403: 10de:0fbc (rev a1)

Hier können auch mehrer ID's verfügbar sein, meist Karten mit Audio. Wir benötigen aber nur Grafik, also:

echo "options vfio-pci ids=10de:1381 disable_vga=1" > /etc/modprobe.d/vfio.conf

Nun fügt mal folgende Einträge zur VM hinzu:

machine: q35
hostpci0: 01:00,pcie=1,x-vga=on

Bevor man das tut sollte aber sicher sein das man per Remote auf den Host zugreifen kann, also VNC und RDP, oder bei Linux Nomachine und VNC. Warum? Ganz einfach da eine Konsole in PVE dann nicht mehr verfügbar ist. Man kann auch einen Monitor direkt an der Grafikkarte anschließen, dann hat man die VM direkt auf dem Schirm. Könnte man so auch über einen HardwareKVM lösen. Hat man alle Einstellungen getroffen, Host nochmal durchstarten.