Update: Proxmox 6 now has built-in support for this! If you’re getting “Duplicate ID ‘ich9-pcie-port-5’ for device”, be sure to remove any additions you’ve made to /usr/share/qemu-server/pve-q35-4.0.cfg
By default in Proxmox 4.4 and 5, you are unable to pass through more than 4 PCIe devices to the guest. If you try, you’ll get an error when attempting to start the VM which reads:
vm 100 - unable to parse value of 'hostpci4' - unknown setting 'hostpci4'
Passed-through PCIe devices are attached to the four ports called “ich9-pcie-port-{1,2,3,4}” which are defined in /usr/share/qemu-server/pve-q35.cfg
. These ports occupy PCIe function numbers 0-3, leaving function numbers 4-7 unused.
It’s a simple matter to add definitions for an extra 4 ports to use up those spare function numbers in /usr/share/qemu-server/pve-q35.cfg
(Proxmox 4 and 5):
[device "ich9-pcie-port-5"] driver = "ioh3420" multifunction = "on" bus = "pcie.0" addr = "1c.4" port = "5" chassis = "5" [device "ich9-pcie-port-6"] driver = "ioh3420" multifunction = "on" bus = "pcie.0" addr = "1c.5" port = "6" chassis = "6" [device "ich9-pcie-port-7"] driver = "ioh3420" multifunction = "on" bus = "pcie.0" addr = "1c.6" port = "7" chassis = "7" [device "ich9-pcie-port-8"] driver = "ioh3420" multifunction = "on" bus = "pcie.0" addr = "1c.7" port = "8" chassis = "8"
Note that this file is a bit sensitive to extra whitespace on empty lines, so make sure empty lines are fully empty. Then we just need to patch the VM configuration parser in /usr/share/perl5/PVE/QemuServer.pm
and /usr/share/perl5/PVE/QemuServer/PCI.pm
to accept “hostpci4” through “hostpci7” as valid:
Patch for Proxmox 5.1 (also 5.2)
Do note that this patch doesn’t add support for PCI devices in those new positions, only PCIe ones.
In Proxmox 5.1 I’ve found that editing the VM configuration with the web interface sometimes drops the new hostpci definitions, so be sure to keep a backup of those in the VM comments in case you have to re-add them.
After applying those patches, stopping my VM, and starting it again, VM configurations like this that pass through 5 PCIe devices now become valid:
hostpci0: 03:00,pcie=1,x-vga=on hostpci1: 00:1a.0,pcie=1 hostpci2: 00:1d.0,pcie=1 hostpci3: 82:00.0,pcie=1 hostpci4: 81:00.0,pcie=1
This allowed me to pass through 3 USB controllers, an NVMe SSD, a network adapter, and a graphics card to my macOS VM!
This modification is made at your own risk! There might have been a good reason why the number of PCIe devices was limited to 4 (although I suspect that the reason was that the number of available PCI device numbers was running out).
It seems not work in proxmox 5.4
Still working fine for me in 5.4-6
Things seem to have changed a bit for Proxmox 6.0. At the time of writing on 6.0.9, the config files show up to 16 devices, but any more than 4 results in the following error:
kvm: -device pcie-root-port,id=ich9-pcie-port-5,addr=10.0,x-speed=16,x-width=32,multifunction=on,bus=pcie.0,port=5,chassis=5: Duplicate ID ‘ich9-pcie-port-5’ for device
Any ideas?
Update: I updated and rebooted Proxmox and it seems to behave now. Not sure what that was about!
It looks like Proxmox 6 now has builtin support for this (yay!) and none of these patches are required – you’ll need to remove the additions made to /usr/share/qemu-server/pve-q35-4.0.cfg to have it start working.