May 25, 20251 yr I'm following this helpful guide for USB controller passthrough.I have followed the procedure and have developed a block for code for hostdev, as explained in step 11b: <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/> </source> </hostdev>I have found the way to see the XML code by editing the VM, and using the Form View / XML View at the right.The article does not say where the new hostdev section should be inserted in the overall XML.This post has someone's complete XML with a hostdev section.In that particular file, the hostdev code goes in the <devices> section, after <video> but before <memballoon model='virtio'>Is that always the case, or dependent on other factors? Are there any details on the XML format requirements that could explain where the <hostdev> section should be inserted? Edited May 25, 20251 yr by timg11
May 25, 20251 yr Author BTW, this is Unraid 7.0.1 on a Dell T440 serverI thought I'd try inserting the code into the XML, so I inserted it in <devices> next to last. (see below for full XML) I got this error when attempting to start the VM:Execution errorinternal error: Non-endpoint PCI devices cannot be assigned to guestsNot sure if that is due to the location of the hostdev section or something else.Background information: root@T440:~# lspci | grep USB00:14.0 USB controller: Intel Corporation C620 Series Chipset Family USB 3.0 xHCI Controller (rev 09)01:00.0 USB controller: ASMedia Technology Inc. ASM2142/ASM3142 USB 3.1 Host Controller Which PCI is each USB bus on?root@T440:~# readlink /sys/bus/usb/devices/usb1../../../devices/pci0000:00/0000:00:14.0/usb1root@T440:~# readlink /sys/bus/usb/devices/usb2../../../devices/pci0000:00/0000:00:14.0/usb2root@T440:~# readlink /sys/bus/usb/devices/usb3../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb3root@T440:~# readlink /sys/bus/usb/devices/usb4../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4The Inatech PCIe USB card appears as usb3 for USB2.0 device, and usb4 for USB3 devices. As a sanity check the Unraid boot USB drive is on usb2. IOMMU IOMMU group 15: [8086:a190] 00:1c.0 PCI bridge: Intel Corporation C620 Series Chipset Family PCI Express Root Port #1 (rev f9)So the Inatech PCIe USB controller is the only thing on 00:1c.0 . Is that not an endpoint? Here's the entire XML:<?xml version='1.0' encoding='UTF-8'?><domain type='kvm'> <name>Windows 11</name> <uuid>530f19ee-2c76-bb83-fe14-b9b745c7552e</uuid> <description>192.168.27.2</description> <metadata> <vmtemplate xmlns="unraid" name="Windows 11" icon="windows11.png" os="windowstpm" webui="" storage="default"/> </metadata> <memory unit='KiB'>33554432</memory> <currentMemory unit='KiB'>8388608</currentMemory> <memoryBacking> <nosharepages/> </memoryBacking> <vcpu placement='static'>4</vcpu> <cputune> <vcpupin vcpu='0' cpuset='4'/> <vcpupin vcpu='1' cpuset='5'/> <vcpupin vcpu='2' cpuset='6'/> <vcpupin vcpu='3' cpuset='7'/> </cputune> <os> <type arch='x86_64' machine='pc-i440fx-9.1'>hvm</type> <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi-tpm.fd</loader> <nvram>/etc/libvirt/qemu/nvram/530f19ee-2c76-bb83-fe14-b9b745c7552e_VARS-pure-efi-tpm.fd</nvram> </os> <features> <acpi/> <apic/> <hyperv mode='custom'> <relaxed state='on'/> <vapic state='on'/> <spinlocks state='on' retries='8191'/> <vpindex state='on'/> <synic state='on'/> <stimer state='on'/> <vendor_id state='on' value='none'/> </hyperv> </features> <cpu mode='host-passthrough' check='none' migratable='on'> <topology sockets='1' dies='1' clusters='1' cores='2' threads='2'/> <cache mode='passthrough'/> </cpu> <clock offset='localtime'> <timer name='hpet' present='no'/> <timer name='hypervclock' present='yes'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/local/sbin/qemu</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='writeback' discard='unmap'/> <source file='/mnt/user/domains/Windows 11/vdisk1.img'/> <target dev='hdc' bus='sata' rotation_rate='1'/> <serial>vdisk1</serial> <boot order='1'/> <address type='drive' controller='0' bus='0' target='0' unit='2'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/mnt/user/isos/Win11_24H2_English_x64.iso'/> <target dev='hda' bus='ide'/> <readonly/> <boot order='2'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/mnt/user/isos/virtio-win-0.1.271-1.iso'/> <target dev='hdb' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='1'/> </disk> <controller type='pci' index='0' model='pci-root'/> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </controller> <controller type='usb' index='0' model='qemu-xhci' ports='15'> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <interface type='bridge'> <mac address='52:54:00:c9:68:53'/> <source bridge='br0'/> <model type='virtio-net'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </interface> <serial type='pty'> <target type='isa-serial' port='0'> <model name='isa-serial'/> </target> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <channel type='unix'> <target type='virtio' name='org.qemu.guest_agent.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <channel type='qemu-vdagent'> <source> <clipboard copypaste='yes'/> <mouse mode='client'/> </source> <target type='virtio' name='com.redhat.spice.0'/> <address type='virtio-serial' controller='0' bus='0' port='2'/> </channel> <input type='tablet' bus='usb'> <address type='usb' bus='0' port='1'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <tpm model='tpm-tis'> <backend type='emulator' version='2.0' persistent_state='yes'/> </tpm> <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' sharePolicy='ignore'> <listen type='address' address='0.0.0.0'/> </graphics> <audio id='1' type='none'/> <video> <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/> </video> <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/> </source> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </hostdev> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices></domain>
May 25, 20251 yr Community Expert Solution 10 minutes ago, timg11 said:So the Inatech PCIe USB controller is the only thing on 00:1c.0 . Is that not an endpoint?That is the PCI root bridge the card is 01:00.0 You can bind to vfio in system devices and it will show in PCI other in the VM template. Or use bus 01, slot 00 function 0 in your xml
May 26, 20251 yr Author @SimonF thanks for the reply.I don't understand "bind to vfio in system devices". I searched on that phrase with the term unraid, and found only one article that didn't explain it. On the Unraid VM Edit page, I don't find "system devices" in the form view, or in the XML. I think I understand your second suggestion, though. You're saying because the IOMMU of 00:1c.0 is the PCI bridge, I should go down one level to the USB controller which is 01:00.0root@T440:~# readlink /sys/bus/usb/devices/usb3../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb3root@T440:~# readlink /sys/bus/usb/devices/usb4../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4That would make my hostdev section like this: <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x01' slot='0x0' function='0x0'/> </source> </hostdev>For my original question about the location of the hostdev section, I'm guessing the way I inserted it in the XML above is correct? With the changes in bus/slot/function it should work now?
May 26, 20251 yr Author Success! The XML with <address domain='0x0000' bus='0x01' slot='0x0' function='0x0'/> as shown above works.Inserting the XML between </video> and <memballoon model='virtio'> works.
May 26, 20251 yr Community Expert 5 hours ago, timg11 said:@SimonF thanks for the reply.I don't understand "bind to vfio in system devices". I searched on that phrase with the term unraid, and found only one article that didn't explain it. On the Unraid VM Edit page, I don't find "system devices" in the form view, or in the XML.I think I understand your second suggestion, though.You're saying because the IOMMU of 00:1c.0 is the PCI bridge, I should go down one level to the USB controller which is 01:00.0root@T440:~# readlink /sys/bus/usb/devices/usb3../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb3root@T440:~# readlink /sys/bus/usb/devices/usb4../../../devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4That would make my hostdev section like this: <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x01' slot='0x0' function='0x0'/> </source> </hostdev>For my original question about the location of the hostdev section, I'm guessing the way I inserted it in the XML above is correct?With the changes in bus/slot/function it should work now?Glad you got it working.Tools->system devices, check box allows to be bound to vfioThen a PCI card should show in this section - Other PCI
May 26, 20251 yr Author Thank you for showing me how the system devices are done. As I noted in my other thread, I'm also having trouble with passthrough of an embedded VGA controller. Now that I know how and where to bind to vfio in system devices, I'll remove the hostdev XML code and try the bind checkmark on the VGA controller.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.