[Plug-In] Hotplug USB for Virtual Machines


Recommended Posts

Libvirt Hotplug USB

 

This is my first plugin and alpha release.

 

Unraid Plugin for Hot-plugging USB Devices to Running VMs. Libvirt Hotplug USB allows mounting of USB Devices (e.g. Keyboard, Mouse, iPhone, FlashDrive etc) on running VMs. It uses virsh to attach the Devices which avoids Conflicts between different VMs.

 

Works perfectly with all of my USB Devices except iPhone, which requires detaching and attaching multiple times to be detected in the VM.

 

To install this plugin, paste the following URL into the Plugins / Install PlugIn section:

 

https://raw.githubusercontent.com/bshakil/unraid-libvirt-usbhotplug/master/plugins/libvirt.hotplug.usb.plg

 

screenshot_zpsn5hobija.png

 

  • Like 1
  • Upvote 2
Link to comment

Nice work.  Haven't got the need for this myself but can definitely see a demand for it.  Might need to talk to the mods about getting it moved to the V6.1 (Verified) section of the forum though.

 

 

 

My main use is for IOS Development on OSX. I was getting tired of restarting OSX everytime i want to plug-in my device.

Link to comment

2016-03-07T05:42:47.440277Z Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (super speed) to bus "usb.0", port "2.2" (full speed)

 

I end up with the above trying to connect a Kensington dock, tried attach/reattach multiple times

Link to comment

2016-03-07T05:42:47.440277Z Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (super speed) to bus "usb.0", port "2.2" (full speed)

 

I end up with the above trying to connect a Kensington dock, tried attach/reattach multiple times

 

From the error mentioned above. It seems like you are Plugging the usb 3.0 device into a usb 2.0 port on the host machine.

 

Please confirm

Link to comment

Not sure the message is linked to the usb port type as the number is rising

 

Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (high speed) to bus "usb.0", port "2.3" (full speed)

 

 

2016-03-07T14:33:50.314832Z Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (high speed) to bus "usb.0", port "2.4" (full speed)

Link to comment

Not sure the message is linked to the usb port type as the number is rising

 

Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (high speed) to bus "usb.0", port "2.3" (full speed)

 

 

2016-03-07T14:33:50.314832Z Warning: speed mismatch trying to attach usb device "Kensington USB3.0 Video Dock" (high speed) to bus "usb.0", port "2.4" (full speed)

 

Can you try the following. Take a backup of your XML configuration and then change your USB Controller to model 'nec-xhci'

 

For Example

 

 

<controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x7'/>
    </controller>

 

 

to

 


<controller type='usb' index='0' model='nec-xhci'>
      </controller>

 

I was facing issues with Iphone Detected in first attempt. After changing the model of USB Controller it started working in single go.

 

This fix is discovered my jonp and is being discussed in the following thread.

 

https://lime-technology.com/forum/index.php?topic=41922.0

 

Let me know if it helps

 

Link to comment

Thanks, there was no model= in the original xml config, however added in as you suggested and it showed up

 

original xml

 

    <controller type='usb' index='0'>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>

    </controller>

 

Although the correct drivers installed and the system (win10) required a reboot to complete, the device is not installed

 

Clicking on 'safely remove usb' shows 'Eject Renesas USB 3.0 eXtensible Host Controller', but in devices and printers it is not there.

 

while the device is connected, the VM log shows

 

usb_generic_handle_packet: ctrl buffer too small (16384 > 4096)

2016-03-09T02:16:41.970636Z qemu-system-x86_64: libusb_release_interface: -4 [NO_DEVICE]

 

on disconnect 

 

libusb: error [do_close] Device handle closed while transfer was still being processed, but the device is still connected as far as we know

libusb: warning [do_close] A cancellation for an in-flight transfer hasn't completed but closing the device handle

 

trying to eject the usb device via the VM locks up the VM

 

Also the xml edit causes the HDMI audio to be lost.

 

 

Link to comment

This is awesome!

 

2 things, though:

 

First, this does not work on VMs with a " " (Space) in their Name. My main one is called "Windows 10", the secondary "Slim" works.

 

Secondly, my phone is added with the slow USB option popup. So windows cant reach it in a fast manner.. (see: http://www.makeuseof.com/tag/usb-speederror/)

 

 

Great Stuff, however!  :)

 

Thanks for the feedback.

 

Please Update the plugin. Version 2016.03.13 fixes the VMs with Space " " Issue.

Also 6.2 Beta introduced Major USB 3.0 Changes. So on final release it should fix Issues related to USB Speed.

Also tested my plugin on 6.2 Beta 18 it seems to be placed at the Correct Position on VMs Page at the bottom instead of top on version 6.1.X

 

 

 

Link to comment
  • 3 weeks later...

I just want to say thank you for this plugin!!!  I built this server on top of skylake, and I have had the hardest time trying to pass a whole USB controller to my Windows 10 VM.  Nothing works, and the forum hasn't been the most helpful.  Your plugin at least gets me into the ballgame.  I can start my VM without having to plugin in my game controller.  I can add and re-attach devices without restarting the VM.  It would be awesome if your plugin could poll for devices (like the Unassigned Devices plugin) and add them automatically, but I am so thankful to have your work as it is.  Keep up with the excellence.

Link to comment

I just want to say thank you for this plugin!!!  I built this server on top of skylake, and I have had the hardest time trying to pass a whole USB controller to my Windows 10 VM.  Nothing works, and the forum hasn't been the most helpful.  Your plugin at least gets me into the ballgame.

It do help to post about the problem before complaining about not getting help on the forum  ;)

Link to comment

I just want to say thank you for this plugin!!!  I built this server on top of skylake, and I have had the hardest time trying to pass a whole USB controller to my Windows 10 VM.  Nothing works, and the forum hasn't been the most helpful.  Your plugin at least gets me into the ballgame.  I can start my VM without having to plugin in my game controller.  I can add and re-attach devices without restarting the VM.  It would be awesome if your plugin could poll for devices (like the Unassigned Devices plugin) and add them automatically, but I am so thankful to have your work as it is.  Keep up with the excellence.

 

I am glad you like this plugin. I understand the frustration. I had to restart OSX VM multiple times for it to Detect G9X Mouse.

 

For plugin to poll for devices and add them automatically. It is possible using UDEV. I will explore the possibility further and will update the plugin.

 

 

 

 

Link to comment

I just want to say thank you for this plugin!!!  I built this server on top of skylake, and I have had the hardest time trying to pass a whole USB controller to my Windows 10 VM.  Nothing works, and the forum hasn't been the most helpful.  Your plugin at least gets me into the ballgame.

It do help to post about the problem before complaining about not getting help on the forum  ;)

 

Sorry, if you took what I was saying as a complaint, but it reflects my experience.  I made an attempt to qualify my gratitude. I was referring to threads that purported to solve the issues that I was having not working for me.  It seems that the consensus was, if you were on a skylake platform, it could be pretty dicey. I stubbed my config, edited XML for my VM, ran Linux commands, etc.  I did the PCIe override, and did that earlier stuff all over again. I now know more about IOMMU than I ever thought I would - all from information provided by this forum.  I bought a seperate soundcard (that actually worked) and a seperate USB controller (didn't fix anything) just to make unRAID work for me. Though my background is in computer science, and I am a developer by trade - I didn't expect to spend this much time on a product forum trying to get this stuff working - after I just spent $90 bucks for unRAID, and an embarassing amount for the hardware for my build.  Again, please don't take that as a complaint. I am not whining about it, I knew I was taking a risk for building my rig this way.  If anybody is willing to help, I would definitely take it. Also, in the beta threads - 0 responses to my issues - so I downgraded back to stable, and I am a much happier person.  BShakil's plugin took away the last feeling of regret for doing this build.  unRAID is pretty awesome, especially after you get all the plugins and docker containers going.

 

Hopefully, I didn't detract from my intent of posting in the thread in the first place, and that was to say thank you.

Link to comment
  • 2 weeks later...

This is an awaesom plug-in! Works great.

It would, as already said, be great to add devices automatically.

 

I have a couple devices that disconnect from time to time. I now use your plugin to manually hotplug them to the VM again.

It would be awesome if this would be automatic.

Also for an htpc, adding usb sticks and such.

 

Thx for this plugin.!

Link to comment
  • 2 weeks later...
  • 2 weeks later...

Amazing work! And thank you!! I tried running on one of my vms and get an error thrown back trying to attach or detach, I also removed all usb presets, added back and retried and got the same error. Thinking this might be a bug?

 

Status:
error: failed to get domain 'Adam Gaming'
error: Domain not found: no domain with matching name 'Adam Gaming'

Link to comment

Having trouble with it saying it is attached but it it really isn't.

2016-05-05T23:14:48.841647Z Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)
2016-05-05T23:14:50.846662Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)
2016-05-05T23:14:52.851673Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)
2016-05-05T23:15:29.339799Z Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "4" (high speed)
2016-05-05T23:15:31.344832Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "4" (high speed)
2016-05-05T23:15:33.349855Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "4" (high speed)
2016-05-05T23:16:34.771175Z Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "5" (high speed)
2016-05-05T23:16:36.775188Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "5" (high speed)
2016-05-05T23:16:38.779193Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "5" (high speed)
2016-05-05T23:16:41.986233Z Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "6" (high speed)
2016-05-05T23:16:43.990302Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "6" (high speed)
2016-05-05T23:16:45.994311Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "6" (high speed)
2016-05-05T23:18:06.135774Z Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)
2016-05-05T23:18:08.140794Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)
2016-05-05T23:18:10.145803Z qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "FT232R USB UART" (full speed) to bus "usb.0", port "3" (high speed)

 

I wonder if I need to change the USB controller like in one of the first few posts.

 

Before I tried this plugin when I try and attach this with the normal Docker settings and then boot the VM, my keyboard stops working.  So am going to try and change the controller settings XML.

 

Link to comment
  • Squid locked this topic
Guest
This topic is now closed to further replies.