VM USB Passthrough Multiple Devices with the same Vendor/Product


Recommended Posts

Hello @Skitals, I have the same issue as the person you quoted. As you mentioned our AMD boards have a single vendorID for all the usb controllers =(. I installed VFIO-PCI Config and I use it to pass my pci drive (it works great!). But when I try to use for my audio device the computer hangs, I believe it is hanging because its grabbing all the usb controllers =/. 

 

 

These are my selections:image.thumb.png.6fe184d29b9153569a9c79bcbf093244.png

My server also hangs if I try to append

pcie_no_flr=1022:1485,1022:149c vfio-pci.ids=1022:1485,1022:149c

as it makes my unraid usb drive unmount during boot, making it unusable. I feel the same thing happens when I ty to pass 0b:00.* devices =/. 

I also tried just doing it via the XML: 
 

  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/isos/spaces_win_clover.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <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/isos/virtio-win-0.1.173-2.iso'/>
      <target dev='hdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='pci' index='0' model='pci-root'/>
    <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='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='xx:54:xx:6f:xx:xx'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <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>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
      </source>
      <rom file='/mnt/user/isos/zotak-1070.rom'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x09' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x0b' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0' multifunction='on'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x0b' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x0b' slot='0x00' function='0x3'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x0b' slot='0x00' function='0x4'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>

With and without multifunction='on' they both un mount my unraid drive.
 

Edited by RaidBoi1904
Link to comment
  • 4 months later...
On 6/27/2019 at 11:43 AM, jonp said:

I would definitely create a post in the feature request forum.  This isn't really something we would directly develop ourselves, but if we could find a way to "script" around this, I could see us devoting some time to doing that.  As of right now, it's not a development priority because there just aren't enough users out there complaining about it.  There are plenty of things we want to see improved and this is one of them, but we have to tackle things in the order of what's going to bring the most value to the most people first, and this definitely slides down the task list as a result.

 

Excuse me JONP, you know if. Is any team working on a solution like this?

https://www.labsrc.com/unraid-automatic-usb-hotplugging-libvirt/

 

In the link that I add there is also the solution to connect two devices with the same VID and the same PID.

 

in my case I need to connect an xbox controller to each virtual machine, (I have two virtual machines)

I imagine an option in UnRaid where I configure which usb ports I want to pass to which virtual machine (without having to buy additional hardware) and not worry about VIDs or PIDs

 

already look in the forum for "FEATURE REQUESTS ", but I can't find anything related.

 

Thank you for confirming if you know anything about this topic.

 

if you don't know anything about this topic. I will create the request.

 

I think that the solution to pass through several devices with the same supplier / product is not to pass the USB port to the machine, nor to pass the device to the machine.

 

The solution must be similar to the Parsec application that passes devices through the Network, this would require a plug-in to be installed on the host VM and in the unraid, a plugin should be installed where the configuration of the devices is carried out

 

 

 

Edited by JhonScript
Link to comment
13 hours ago, JhonScript said:

 

Excuse me JONP, you know if. Is any team working on a solution like this?

https://www.labsrc.com/unraid-automatic-usb-hotplugging-libvirt/

 

In the link that I add there is also the solution to connect two devices with the same VID and the same PID.

 

in my case I need to connect an xbox controller to each virtual machine, (I have two virtual machines)

I imagine an option in UnRaid where I configure which usb ports I want to pass to which virtual machine (without having to buy additional hardware) and not worry about VIDs or PIDs

 

already look in the forum for "FEATURE REQUESTS ", but I can't find anything related.

 

Thank you for confirming if you know anything about this topic.

 

if you don't know anything about this topic. I will create the request.

 

I think that the solution to pass through several devices with the same supplier / product is not to pass the USB port to the machine, nor to pass the device to the machine.

 

The solution must be similar to the Parsec application that passes devices through the Network, this would require a plug-in to be installed on the host VM and in the unraid, a plugin should be installed where the configuration of the devices is carried out

 

 

 

 

This is not an active development project for us at this time.  Please create a feature request if you can't find one.  Thank you!

Link to comment
  • 1 month later...

I will add this to the feature request also. I have started writing a plugin for usbip support, and was looking for ways to identify if usb devices are allocated to other services to restrict people from adding to usbip. I have already disabled the boot flash drive. But there doesn't seem to be an easy way to see USB devices allocated or in use at a host level for VMs, but came across this thread whilst looking for solutions.

 

Within the plugin I have all the details about the USB devices including serial number if the device uses it as some do not like the keyboard and BMC(kb and mouse) on my system. So I have started to see if I can add VMs. 

 

Currently working on the processing of udev rules to support updates to my list if someone plugs in devices, but this could also be enhanced to include attaching to the VM if it is running. I will use dlandons libvirt-hot-plug plugin to assist with this so you will need to have it installed also. And likewise remove from VM if unplugged.

 

If I can find a way to be informed of a VM being started I may also be able to allocate devices after it has started.

 

My plugin is still in beta but I have added VMs to the screen so far but it is way off being ready for use.

 

image.thumb.png.4694afaaef3e9fdbcf7f033da8d79fdb.png

 

My current VMs defined on this system.

 

image.thumb.png.2e765380eb7342c2e64a021b914af04a.png

Link to comment
5 hours ago, SimonF said:

And likewise remove from VM if unplugged.

THIS would be huge. There are MANY threads on here of people saying their VM is broken because a passed through USB device is no longer attached, and the VM won't start.

 

If you can help limetech provide a single point of USB comprehensive device management it would be very helpful.

Link to comment
On 2/3/2021 at 12:21 AM, jonathanm said:

THIS would be huge. There are MANY threads on here of people saying their VM is broken because a passed through USB device is no longer attached, and the VM won't start.

 

If you can help limetech provide a single point of USB comprehensive device management it would be very helpful.

 

The plugin now connects devices to a VM when it starts if specified in the settings, but you need to manually add a few lines to the qemu hooks file details on support page, working on how to do safely for install.

 

Plugging in a USB device if defined will connect to the VM if it is running.

 

image.png

Link to comment
On 12/13/2020 at 5:43 PM, JhonScript said:

 

 

I think that the solution to pass through several devices with the same supplier / product is not to pass the USB port to the machine, nor to pass the device to the machine.

 

 

 

 

 

Check out my plugin USB Manager.

Edited by SimonF
Link to comment
  • 3 months later...

This worked for me. I could pass through same realtek wifi usb adapters.

 

    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <address bus='3' device='10'/>
      </source>
      <alias name='hostdev0'/>
      <address type='usb' bus='0' port='2'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <address bus='3' device='9'/>
      </source>
      <alias name='hostdev1'/>
      <address type='usb' bus='0' port='3'/>
    </hostdev>

 

Link to comment
  • 1 year later...

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.