archedraft

***GUIDE*** Passthrough Entire PCI USB Controller

Recommended Posts

root@Tower:~# lspci | grep USB
00:14.0 USB controller: Intel Corporation Device 8cb1
00:1a.0 USB controller: Intel Corporation Device 8cad
00:1d.0 USB controller: Intel Corporation Device 8ca6
0c:00.0 USB controller: ASMedia Technology Inc. Device 1142

 

So you are using the intel controller.  Crud, I was really hoping to avoid that.  Aren't the four rear USB ports and the internal port all on that controller?  That's a lot of ports for me to forward through when I only need one of them for my USB active extender, and that only leaves me with 2 for other machines.  Maybe I did my testing wrong.

Share this post


Link to post
Share on other sites

Yep, I am passing the Intel controller.The right usb ports (below the PS/2 KB) are USB5 and I had trouble passing it when using Win7 (no passthrough worked for me with Win7). I have not checked passing through the USB5 port with Win8. I think most of the ports are on usb3, the Intel controller. Maybe a x1 usb pcie card could help, like this one http://www.newegg.com/Product/Product.aspx?Item=N82E16815166026?

 

root@Tower:~# lspci | grep USB
00:14.0 USB controller: Intel Corporation Device 8cb1
00:1a.0 USB controller: Intel Corporation Device 8cad
00:1d.0 USB controller: Intel Corporation Device 8ca6
0c:00.0 USB controller: ASMedia Technology Inc. Device 1142

 

So you are using the intel controller.  Crud, I was really hoping to avoid that.  Aren't the four rear USB ports and the internal port all on that controller?  That's a lot of ports for me to forward through when I only need one of them for my USB active extender, and that only leaves me with 2 for other machines.  Maybe I did my testing wrong.

Share this post


Link to post
Share on other sites

Ok, so I think this might be the layout for our ASRock Xtreme 6 motherboards.  Each internal USB 2.0 mainboard header has its own controller (00:1a.0 and 00:1d.0). The onboard port, and 4 left USB 3.0 ports are the Intel 3.0 USB controller (00:14.0).  And the right two, and then 2 internal 20-pin USB 3.0 headers are the ASMedia controller (0c:00.0).  Only reason I think the internal 20-pin ports work off the ASMedia instead of Intel is because "6 ports Asmedia and 5 ports Intel" makes more sense than "2 ports Asmedia and 9 ports Intel".  I'll confirm this once some parts I just ordered arrive.

usbheaders.gif.dc3f4681d173032fb28990c941d0cfc0.gif

Share this post


Link to post
Share on other sites

My diagram is wrong.  Every single USB port on my board uses the 00:14.0 Intel controller besides the 2 ASMedia ports.  Ugh.  Guess I'm getting a USB controller card.

Share this post


Link to post
Share on other sites

Thank you for this thread archedraft. This has now re-ignited my desire and drive to create a Windows gaming VM on top of unRAID.

 

I would suggest this be a sticky somewhere or be included in the unRAID instructions! I think that the group file and command need to be at the top of the instructions though. I am using an old Intel Sckt775 workstation board for testing at the moment and the USB bus's were grouped into two groups. I had 8 USB bus's listed in total and I had to pass 4 of them to get the VM to start without error. Once this was done it worked like a flippin charm!

 

I can now unplug / connect my 360 controller into the front USB ports and Windows recognises it straight away (I am using Windows 8.1 pro)

Share this post


Link to post
Share on other sites

Thank you for this thread archedraft. This has now re-ignited my desire and drive to create a Windows gaming VM on top of unRAID.

 

I would suggest this be a sticky somewhere or be included in the unRAID instructions! I think that the group file and command need to be at the top of the instructions though. I am using an old Intel Sckt775 workstation board for testing at the moment and the USB bus's were grouped into two groups. I had 8 USB bus's listed in total and I had to pass 4 of them to get the VM to start without error. Once this was done it worked like a flippin charm!

 

I can now unplug / connect my 360 controller into the front USB ports and Windows recognises it straight away (I am using Windows 8.1 pro)

 

Glad you got it working and found this useful! I updated my guide (steps 8 & 9) with your suggestions. LT actually made it a lot easier to find out if your IOMMU groups have multiple devices.

Share this post


Link to post
Share on other sites

I'm trying to passthrough a PCIe USB3 controller card which is based on the Renasas chip, but I get the following pop-up dialog error when I try to run the my Win8 VM:

 

2015-07-23T23:43:26.497522Z qemu-system-x86_64: -device vfio-pci,host=09:00.0,bus=root.1,addr=00.1: Bus 'root.1' not found

 

I'm using the ASRock Z97 Extreme6 motherboard and I have discovered that the PCIe x1 slot that the USB controller card is plugged into sits behind an ASMedia 1184 PCIe switch. I'm not sure how to determine the correct setting for "bus=root.1,addr=00.1", but it seems like this is due to the PCIe switch device.

 

This is the output from the readlink command. The USB controller card is 09:00.0.

 

root@unraid:~# readlink /sys/bus/usb/devices/usb3
../../../devices/pci0000:00/0000:00:1c.3/0000:05:00.0/0000:06:05.0/0000:09:00.0/usb3

 

Any ideas what values I need to use for "bus" and "addr"?

 

Thanks.

 

 

Share this post


Link to post
Share on other sites

Would you mind posting in your entire VM XML?

 

After Googling a bit more I believe I don't have everything I need in the <qemu:commandline> section, but I'm not sure what needs to be added.

 

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>Windows 8</name>
  <uuid>1f5e5059-e6a1-7d99-e9b4-766bfeff4633</uuid>
  <description>Windows 8 Gaming</description>
  <metadata>
    <vmtemplate name="Custom" icon="windows.png" os="windows"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <nosharepages/>
    <locked/>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
    <loader type='pflash'>/usr/share/qemu/ovmf-x64/OVMF-pure-efi.fd</loader>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='4' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/cache/VM/Windows 8/vdisk1.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/ISO/win8.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/ISO/virtio-win-0.1.96.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <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='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:d4:78:d5'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/Windows 8.org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </memballoon>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-device'/>
    <qemu:arg value='vfio-pci,host=09:00.0,bus=root.1,addr=00.1'/>
  </qemu:commandline>
</domain>

Share this post


Link to post
Share on other sites

Try this:

 

  <qemu:commandline>

    <qemu:arg value='-device'/>

    <qemu:arg value='ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=2,chassis=1,id=root.1'/>

    <qemu:arg value='-device'/>

    <qemu:arg value='vfio-pci,host=09:00.0,bus=root.1,addr=00.0'/>

  </qemu:commandline>

Share this post


Link to post
Share on other sites

Try this:

 

  <qemu:commandline>

    <qemu:arg value='-device'/>

    <qemu:arg value='ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=2,chassis=1,id=root.1'/>

    <qemu:arg value='-device'/>

    <qemu:arg value='vfio-pci,host=09:00.0,bus=root.1,addr=00.0'/>

  </qemu:commandline>

 

:) :) :)

 

Looks like that did the trick. Can you give a brief explanation regarding that line with "ioh3420"? I'm also curious why it's "bus=pci.0" instead of "bus=pcie.0".

 

Thanks,

-Mike

Share this post


Link to post
Share on other sites

Try this:

 

  <qemu:commandline>

    <qemu:arg value='-device'/>

    <qemu:arg value='ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=2,chassis=1,id=root.1'/>

    <qemu:arg value='-device'/>

    <qemu:arg value='vfio-pci,host=09:00.0,bus=root.1,addr=00.0'/>

  </qemu:commandline>

 

Im curious where you got addr=00.0 instead of the first post 00.1, addr=00.0 worked for me

Share this post


Link to post
Share on other sites

Addr=00.0 is the first device you pass through then if you want to pass through a second device it is addr=00.1

 

On my VM my graphics card is 00.0 and my USB controller is 00.1

Share this post


Link to post
Share on other sites

Addr=00.0 is the first device you pass through then if you want to pass through a second device it is addr=00.1

 

On my VM my graphics card is 00.0 and my USB controller is 00.1

 

Thanks for the explanation  :)

Share this post


Link to post
Share on other sites

Appreciate the detailed thread Arched and was hoping for a little help.  Attempting to passthrough the USB 3.0 controller on my ASRock - B75 Pro3-M.

 

Output of

lspci | grep USB

 

00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)

 

Bus 004
Bus 004
Bus 003 - Lexar
Bus 003
Bus 003
Bus 002
Bus 001 - Bus my device is listed on 

 

output of readlink command

 

../../../devices/pci0000:00/00000:00:14.0/usb1

 

i have run /usr/local/sbin/vfio-bind 0000:00:14.0 and confirm Bus 001 no longer appears if i run lsusb

(have not added to go file yet, waiting to confirm it is working fine first)

 

copy of XML

 

<domain type='kvm'>
  <name>rTorrent</name>
  <uuid>a8d7f9a9-59a3-91a3-1ee0-19de892dd49f</uuid>
  <description>Torrent + VPN</description>
  <metadata>
    <vmtemplate name="Custom" icon="windows7.png" os="windows7"/>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <memoryBacking>
    <nosharepages/>
    <locked/>
  </memoryBacking>
  <vcpu placement='static'>1</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='1' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='writeback'/>
      <source file='/mnt/cache/appdata/virtual-machines/ruTorrent/vdisk1.qcow2'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:56:90:1b'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/rTorrent.org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vmvga' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
    <qemu:commandline> 
      <qemu:arg value='-device'/>
      <qemu:arg value='vfio-pci,host=00:14.0,bus=root.1,addr=00.1'/>
    </qemu:commandline>
</domain>

 

have tried addr=00.0 as well

 

when starting VM i get the following error

 

Error: internal error: early end of file from monitor: possible problem:

2015-07-29T19:38:56.073222Z qemu-system-x86_64: -device vfio-pci,host=00:14.0,bus=root.1,addr=00.1: Bus 'root.1' not found

Share this post


Link to post
Share on other sites

 

Try this:

 

  <qemu:commandline>

    <qemu:arg value='-device'/>

    <qemu:arg value='ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=2,chassis=1,id=root.1'/>

    <qemu:arg value='-device'/>

    <qemu:arg value='vfio-pci,host=00:14.0,bus=root.1,addr=00.0'/>

  </qemu:commandline>

 

Share this post


Link to post
Share on other sites

much better thank you! except it failed in windows whilst looking for a driver

 

You may want to try searching for motherboard's manufactures website for drivers for Win 7. Or give Windows 8 a try.

Share this post


Link to post
Share on other sites

Thanks for the tutorial, it's working great for me. One thing I did notice is that the VM I created with the GUI already had the code from hint one in the beginning of the XML.

Share this post


Link to post
Share on other sites

 

Thanks for the tutorial, it's working great for me. One thing I did notice is that the VM I created with the GUI already had the code from hint one in the beginning of the XML.

 

Awesome and thanks for the feedback. You are correct, the GUI should already have that line of code in it. I noticed that a few users didn't have that in their XML's so added it as a double check for anyone following the guide.

Share this post


Link to post
Share on other sites

This has been working great for me, today I rebooted my unraid server and added some memory to my VM. After making those changes the edits were gone from my go file and from the VM's XML. Any idea why that disappeared? I'm assuming that this doesn't need to be done with every reboot.

Share this post


Link to post
Share on other sites

 

This has been working great for me, today I rebooted my unraid server and added some memory to my VM. After making those changes the edits were gone from my go file and from the VM's XML. Any idea why that disappeared? I'm assuming that this doesn't need to be done with every reboot.

 

Your assumption is correct, you should not need to do this after every reboot. You may want to double check that your unRAID  flash drive isn't read only by sticking it in a windows PC and seeing if it wants to repair the flash drive.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.