Jump to content
We're Hiring! Full Stack Developer ×

PCI passthrough of USB 2.0 PCI card


jude

Recommended Posts

So I have been having issues with passing through the USB controller on my motherboard it works fine for devices that are connected when the Win8.1 guest starts but it cannot handle hotplugging once the guest is started.

 

To try and deal with this issue I picked up a Vantec USB 2.0 pci card. It has four external ports and would be ideal for my Win8.1 gaming VM.

 

The card is installed in the only PCI slot available on my motherboard and when i do lspci in terminal I get the following output relating to that card.

 

05:06.0 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 61)
05:06.1 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 61)
05:06.2 USB controller: VIA Technologies, Inc. USB 2.0 (rev 63)

 

So I added those addresses to my go file which now looks like this

 

/usr/local/sbin/vfio-bind 0000:01:00.0 0000:01:00.1 0000:00:12.0 0000:00:12.2 0000:05:06.0 0000:05:06.1 0000:05:06.2

 

The first two are my GPU and audio and the next two are the USB controller on the motherboard which passes through but does not support hotplugging.

 

Here is my XML file

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>windows81nvidiaMSIRAWUSB</name>
  <uuid>cc411d70-4463-4db7-bf36-d364c0cdaa5f</uuid>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <nosharepages/>
    <locked/>
  </memoryBacking>
  <vcpu placement='static'>6</vcpu>
  <iothreads>6</iothreads>
  <cputune>
    <vcpupin vcpu='0' cpuset='2'/>
    <vcpupin vcpu='1' cpuset='3'/>
    <vcpupin vcpu='2' cpuset='4'/>
    <vcpupin vcpu='3' cpuset='5'/>
    <vcpupin vcpu='4' cpuset='6'/>
    <vcpupin vcpu='5' cpuset='7'/>
    <iothreadpin iothread='1' cpuset='2'/>
    <iothreadpin iothread='2' cpuset='3'/>
    <iothreadpin iothread='3' cpuset='4'/>
    <iothreadpin iothread='4' cpuset='5'/>
    <iothreadpin iothread='5' cpuset='6'/>
    <iothreadpin iothread='6' cpuset='7'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-q35-2.1'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
    <hap/>
    <kvm>
      <hidden state='on'/>
    </kvm>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='6' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup' track='guest'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='directsync' io='native'/>
      <source file='/mnt/disk/vmdisk/Image Media/Win8.1ProN.raw'/>
      <target dev='hda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/disk/vmdisk/Images/en_windows_8_1_n_x64_dvd_2707896.iso'/>
      <target dev='hda' bus='sata'/>
      <readonly/>
      <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/disk/vmdisk/Images/virtio-win-0.1-100.iso'/>
      <target dev='hdd' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    </disk>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </controller>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:46:29:be'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-set'/>
    <qemu:arg value='device.virtio-disk0.x-data-plane=on'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=01:00.1,bus=pcie.0'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=00:12.0,bus=root.1,addr=00.1,'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=00:12.2,bus=root.1,addr=00.2'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=05:06.0,bus=root.1,addr=00.1'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=05:06.1,bus=root.1,addr=00.2'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=05:06.2,bus=root.1,addr=00.3'/>
  </qemu:commandline>
</domain>

 

The following is the error I get when starting the VM from Virsh.

 

virsh # start windows81nvidiaMSIRAWUSB
error: Failed to start domain windows81nvidiaMSIRAWUSB
error: internal error: early end of file from monitor: possible problem:
2015-04-17T17:27:27.923877Z qemu-system-x86_64: -device vfio-pci,host=05:06.0,bus=root.1,addr=00.1: PCI: slot 0 function 1 not available for vfio-pci, in use by vfio-pci
2015-04-17T17:27:27.923908Z qemu-system-x86_64: -device vfio-pci,host=05:06.0,bus=root.1,addr=00.1: Device initialization failed.
2015-04-17T17:27:27.923920Z qemu-system-x86_64: -device vfio-pci,host=05:06.0,bus=root.1,addr=00.1: Device 'vfio-pci' could not be initialized

 

Not sure what I need to change at this point.

Link to comment

Is it possible that vfio bind is not working properly for this PCI port and that it is only available to the host?

 

I purchased the card from a local retailer and can return it if a PCIe card is more likely to work. I just figured it would be a good use for that PCI slot and the price was right ($12). But if its going to be a headache I will look for a replacement. Is there a better chipset or brand of USB 3.0 cards that is more likely to work with KVM passthrough?

Link to comment
  • 4 months later...
  • 4 weeks later...

So last night I tried to passthrough two cards that I've passed through before with ESXi 5.5.

 

Sound Blaster Live! value PCI and a cheap PCI-e c-media sound card. These devices both have an additional gameport component (although the c-media card doesn't actually have it but that is a issue with bare metal as well) and they both are actually using a PCI to PCI-e bridge (the c-media appears to be a PCI device with an ASmedia bridge chip)

 

I'm having a similar problem to the original one. I'm adding hostdev to the XML like I did with another USB3 card and the onboard AMD USB controller. But I get an "unexpected end of file..." message talking about the "device being in use". If I try to add the bridge device (which is listed in system/lspci) I get an error message that there is no such device...even though the error message indicates its using the right port id or whatever. In all cases I was also passing through the gameport device.

 

Has anyone passed through traditional PCI devices? I guess I could try with the ACS override kernel setting/

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...