USB Passthrough Help Please


Recommended Posts

Hi All,

 

Hoping someone can help me with this.

 

I am trying to passthrough an Anker 3.0 USB Docking station(https://www.anker.com/products/68ANDOCKS-BA) to a Windows 7 VM.  I have attempted this a couple of times but just cant seem to get it to work.  I am hoping someone can tell me exactly what I have to put in my xml to pass through the USB based on the below information(this follows the guide I found https://lime-technology.com/forum/index.php?topic=36768.0):

 

2.  my usb controllers

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family US                                        B xHCI (rev 05)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family US                                        B EHCI #2 (rev 05)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family US                                        B EHCI #1 (rev 05)

 

3. my mother board

I have attached the manual in case that is helpful

 

4. Unraid is on USB bus

Bus 003 Device 002: ID 0781:5583 SanDisk Corp.

 

Here is everything:

Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Bus 003 Device 005: ID 0557:2419 ATEN International Co., Ltd
Bus 003 Device 003: ID 0000:0001
Bus 003 Device 002: ID 0781:5583 SanDisk Corp.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

 

5. plugged in a DataTraveler USB and then I run lsusb again

Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Bus 003 Device 005: ID 0557:2419 ATEN International Co., Ltd
Bus 003 Device 003: ID 0000:0001
Bus 003 Device 002: ID 0781:5583 SanDisk Corp.
Bus 003 Device 006: ID 0951:1607 Kingston Technology DataTraveler 100
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

Based on the above it appears that the usb port I want to use is running on the same bus.  I believe this is an issue and probably why docker and vm freaked out during my first try at this.  Can you someone confirm?  It seems this should be on bus 004 since that is the 3.0 root hub, correct?  If that is the case everything after this point may need to be adjusted after feedback.

 

ok, so moving on so everything is complete....with the understanding I may need to change the bus

 

6. ran readlink /sys/bus/usb/devices/usb3

 

../../../devices/pci0000:00/0000:00:14.0/usb3

 

8. checked IOMMU Groups

/sys/kernel/iommu_groups/0/devices/0000:00:00.0
/sys/kernel/iommu_groups/1/devices/0000:00:01.0
/sys/kernel/iommu_groups/1/devices/0000:00:01.1
/sys/kernel/iommu_groups/1/devices/0000:02:00.0
/sys/kernel/iommu_groups/2/devices/0000:00:14.0
/sys/kernel/iommu_groups/3/devices/0000:00:1a.0
/sys/kernel/iommu_groups/4/devices/0000:00:1c.0
/sys/kernel/iommu_groups/5/devices/0000:00:1c.2
/sys/kernel/iommu_groups/6/devices/0000:00:1c.3
/sys/kernel/iommu_groups/7/devices/0000:00:1d.0
/sys/kernel/iommu_groups/8/devices/0000:00:1f.0
/sys/kernel/iommu_groups/8/devices/0000:00:1f.2
/sys/kernel/iommu_groups/8/devices/0000:00:1f.3
/sys/kernel/iommu_groups/8/devices/0000:00:1f.6
/sys/kernel/iommu_groups/9/devices/0000:03:00.0
/sys/kernel/iommu_groups/9/devices/0000:04:00.0
/sys/kernel/iommu_groups/10/devices/0000:05:00.0
/sys/kernel/iommu_groups/11/devices/0000:06:00.0

 

9.  the identified device number is part of group 2

/sys/kernel/iommu_groups/2/devices/0000:00:14.0

 

11.  I run into an issue trying to use Hostdev instead of the qemu:arg.  It does not save in my XML.  Now sure why.......

 

Using 11a method

 

Here is my XML code prior to any changes

 
<domain type='kvm' id='6'>
  <name>Windows 7 Sandbox</name>
  <uuid>4d35c4bb-8b42-44dc-b99f-67071d94b17c</uuid>
  <description>Windows 7 Copy for Sandabox</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'>2</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='3'/>
    <vcpupin vcpu='1' cpuset='4'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <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='2' 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='raw' cache='writeback'/>
      <source file='/mnt/cache/VM/Windows 7 Sandbox/vdisk1.img'/>
      <backingStore/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/Backup/Software/OS Images/AcronisBootableMedia.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <alias name='ide0-0-0'/>
      <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/Backup/Software/UNRAID VM Drivers/virtio-win-0.1.96.iso'/>
      <backingStore/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:f1:2d:56'/>
      <source bridge='br0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/Windows 7 Sandbox.org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' websocket='5700' 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'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>

 

and here it is after I have added what i think I need to add

  
<domain type='kvm' id='6'>
  <name>Windows 7 Sandbox</name>
  <uuid>4d35c4bb-8b42-44dc-b99f-67071d94b17c</uuid>
  <description>Windows 7 Copy for Sandabox</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'>2</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='3'/>
    <vcpupin vcpu='1' cpuset='4'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <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='2' 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='raw' cache='writeback'/>
      <source file='/mnt/cache/VM/Windows 7 Sandbox/vdisk1.img'/>
      <backingStore/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/Backup/Software/OS Images/AcronisBootableMedia.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <boot order='2'/>
      <alias name='ide0-0-0'/>
      <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/Backup/Software/UNRAID VM Drivers/virtio-win-0.1.96.iso'/>
      <backingStore/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:f1:2d:56'/>
      <source bridge='br0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/Windows 7 Sandbox.org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' websocket='5700' 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'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
  <qemu:commandline>
<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=00:14.0,bus=root.1,addr=00.0'/>
  </qemu:commandline>
</domain>

 

 

Greatly appreciate you looking at all of this and helping me getting this resolved. 

 

X10SL7-F.png.b56a5fe4faf9ba0201ed6b2fa8670d8d.png

Link to comment

Try this in your xml

 

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      </source>
    </hostdev>

 

Put it in right between "</video>" and "<memballoon model='virtio'>"

Link to comment

Try this in your xml

 

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      </source>
    </hostdev>

 

Put it in right between "</video>" and "<memballoon model='virtio'>"

 

Ok, I will try this but one questions first:  It seems my UNRAID USB is on the same slot as the device I am trying to pass.  I have moved the UNRAID usb around and no matter which slot I move it to is still gives me ../../../devices/pci0000:00/0000:00:14.0  Any ideas how I can make sure BUS 3 and 4 are not on the same number ../../../devices/pci0000:00/0000:00:14.0/

 

root@Tower:~# lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 0557:2419 ATEN International Co., Ltd
Bus 003 Device 003: ID 0000:0001
Bus 003 Device 002: ID 0781:5583 SanDisk Corp.
Bus 003 Device 010: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Bus 003 Device 012: ID 2109:2813
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@Tower:~# readlink /sys/bus/usb/devices/usb4
../../../devices/pci0000:00/0000:00:14.0/usb4
root@Tower:~# readlink /sys/bus/usb/devices/usb3
../../../devices/pci0000:00/0000:00:14.0/usb3
root@Tower:~# readlink /sys/bus/usb/devices/usb2
../../../devices/pci0000:00/0000:00:1d.0/usb2
root@Tower:~# readlink /sys/bus/usb/devices/usb1
../../../devices/pci0000:00/0000:00:1a.0/usb1

Link to comment

Oops,  sorry I read that wrong.

 

Usb buses 3 and 4 are the same controller. Separate buses for usb 3.0 and 2.0 using the same physical usb ports (I'm assuming those are all usb3 ports that are backwards compatible)

 

I guess you can either try and move all existing usb devices to the usb 2.0 only ports (should be buses 1 and 2) and passthrough the usb3 controller,

 

Or you can get a usb3 pci card and pass that through. They are around $25 on amazon

 

I also hear there is a new method for passing through usb without the whole bus. Jonp has a thread where he is asking folks to test it

Link to comment

Oops,  sorry I read that wrong.

 

Usb buses 3 and 4 are the same controller. Separate buses for usb 3.0 and 2.0 using the same physical usb ports (I'm assuming those are all usb3 ports that are backwards compatible)

 

I guess you can either try and move all existing usb devices to the usb 2.0 only ports (should be buses 1 and 2) and passthrough the usb3 controller,

 

Or you can get a usb3 pci card and pass that through. They are around $25 on amazon

 

I also hear there is a new method for passing through usb without the whole bus. Jonp has a thread where he is asking folks to test it

 

Ok, thanks I will check into Jonp's post again.  I looked at it earlier but I didn't quite understand it.  With my new found knowledge it may make more sense now. 

 

What is strange though is when I plug in my spare USB drive to what the motherboard shows as USB0 and USB1 it still shows up in lsusb as USB3.  Could this be because I am using a USB 2.0 drive and because it is reverse compatible it is assigning it to a different BUS?

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.