[Plugin] USB_Manager


SimonF

Recommended Posts

Hi,

 

first of all thank you for the great plugin. The thing that I'm trying to accomplish is regarding usbip, so my usb device is on the remote system.

 

When there is no binded device on remote raspberry pi

image.thumb.png.4b7508c811097b44f2643583b2074f8d.png

I see this in Unraid USB plugin.

image.thumb.png.4bc8fdbd30f8a76e0c01fe89a1701c64.png

When I bind the device

image.thumb.png.2a116411da0af1fcc576aac5a55ee5d5.png

then in USB plugin I see the usb device and I can manually attach it.

image.thumb.png.3930bea723fe733270379c0c8ff9d846.png

The thing is that I would like for this device to be attached automatically whenever it is discovered. Is there some setting that I'm missing?

 

I have also found this in the settings.

image.thumb.png.d24dffee01b6f6ab00bc0d1b259ba261.png

Is this somehow related to the functionality that I'm trying to accomplish or what is the purpose of USBIP remote Checker?

Also I'm not able to make it enabled whatever settings I apply it is always grayed out.

 

Thank you very much for your help.

Link to comment
Posted (edited)
7 hours ago, Scarat said:

Is this somehow related to the functionality that I'm trying to accomplish or what is the purpose of USBIP remote Checker?

Hi

 

I think you may be using the beta vers, Its something I have started thinking of adding, but I forgot to hide the values when I released the beta version to handle the change in state processing.

 

It may appear in the future but currently no time frame.

Edited by SimonF
Link to comment

I have a Home Assistant VM that has a zwave device (zooz 700 stick) and a Zigbee device (sonoff zigbee plus). Both devices have the same info and show up as "silicon labs cp210x uart bridge (10c4:ea60). I can pass one through without issue, but if both are connected both get selected to pass through and I get an error stating that I can't pass duplicate devices through. Would this plugin "fix" this for me? I'm relatively new to unraid and certainly new to VMs, so take it easy on me. What settings would I ideally use if this is a viable solution? Thank you.

Link to comment
2 hours ago, crankyCowboy said:

I have a Home Assistant VM that has a zwave device (zooz 700 stick) and a Zigbee device (sonoff zigbee plus). Both devices have the same info and show up as "silicon labs cp210x uart bridge (10c4:ea60). I can pass one through without issue, but if both are connected both get selected to pass through and I get an error stating that I can't pass duplicate devices through. Would this plugin "fix" this for me? I'm relatively new to unraid and certainly new to VMs, so take it easy on me. What settings would I ideally use if this is a viable solution? Thank you.

 

From my experience with this plugin, even if you don't use it for USB/IP it can act as an extension of unassigned devices (UD) plugin where you can hotplug (attach/detach) USB devices on running VMs, yet UD has limitation where it cannot handle devices with the same name.

However, this plugin distinguishes the devices by their bus/id allocation and can hotplug them even when they share the same name or manufacturer info.

If I'm mistaken I hope someone can correct me since I don't have an Unraid machine nearby to back up my claims, but I'm fairly confident it will solve your problem at least when it comes to hotplugging the devices (attaching them to VM after it started).

Link to comment
5 hours ago, crankyCowboy said:

I have a Home Assistant VM that has a zwave device (zooz 700 stick) and a Zigbee device (sonoff zigbee plus). Both devices have the same info and show up as "silicon labs cp210x uart bridge (10c4:ea60). I can pass one through without issue, but if both are connected both get selected to pass through and I get an error stating that I can't pass duplicate devices through. Would this plugin "fix" this for me? I'm relatively new to unraid and certainly new to VMs, so take it easy on me. What settings would I ideally use if this is a viable solution? Thank you.

Yes it will allow that and was one of the reason for creating the plugin as  VM Manager uses the vendor and product to add to a VM where I use bus and dev to do the mapping. Do they show the same serial number?

 

You can attach using the USB port or by the device.

 

I have many Same make model USB sticks

root@computenode:~# lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 2109:0817 VIA Labs, Inc. USB3.0 Hub             
Bus 002 Device 004: ID 05e3:0749 Genesys Logic, Inc. SD Card Reader and Writer
Bus 002 Device 002: ID 05e3:0626 Genesys Logic, Inc. USB3.1 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 013: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 012: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 033: ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
Bus 001 Device 008: ID 2109:2817 VIA Labs, Inc. USB2.0 Hub             
Bus 001 Device 007: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 003: ID 1462:7d25 Micro Star International MYSTIC LIGHT 
Bus 001 Device 010: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 009: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 001 Device 006: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 004: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB
Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@computenode:~# 

 

image.thumb.png.f92abb42e793b790fc0d8e61e32bd2c5.png

Link to comment

@SimonF Thank you very much for the reply. I haven't installed your plugin yet, but intend to do that. Will the devices just show up like your second picture and I just click "vm attach" or "bind" in order for them to show up in the HA VM? attached are a picture of my usb devices. Thank you for your help, and for the awesome plugin.

 

usb2.JPG

Link to comment
8 minutes ago, crankyCowboy said:

Thank you for your help, and for the awesome plugin

Does 

 

lsusb -vs 001:030 | grep Serial

lsusb -vs 001:029 | grep Serial

 

provide different serial numbers, no need to share just confirm if that is the case or not.

 

You may need to use the Beta vers so it shows the connection as the stable version was using serial number as the key for state. Also you will have to map by port as device uses the serial number to ID the device.

 

with each entry you can specify if the device is connected automatically when you plug in or start vms etc.

 

You should remove any mappings for the usb device in VM Manager or you can just click attach if you want a manual method.

 

You do not need USBIP function so BIND will not show unless you enable USBIP.

 

Example Mappings.

 

image.thumb.png.8799aa408a1d9cd0c44f7f0e0f11ca1e.pngimage.thumb.png.4fd3651e02c90686fa8fbc83f10acccf.png

Link to comment

@SimonF I installed the plugin, and then on the usb tab, I have changed the device mapping to "auto connect at usb device pluging" and also "auto connect to vm at vm start" and selected HA as my VM. However, when I start the HA VM, the devices don't appear to connect automatically uniess I manually click "VM attach". Am I doing something wrong?  If I click VM attach, then they show conntected and everythign appears to work as expected (which is awesome by the way). I just don't understand why they aren't connecting automatically when the VM starts?

Link to comment
Posted (edited)

@crankyCowboyWhich version did you install.

 

If you are on unraid < 6.10 you should see a file in /etc/libvirt/hooks called QEMU with lines added at the beginning for USB Manager'.

 

#begin USB_MANAGER
if ($argv[2] == 'prepare' || $argv[2] == 'stopped'){
  shell_exec("/usr/local/emhttp/plugins/usb_manager/scripts/rc.usb_manager vm_action '{$argv[1]}' {$argv[2]} {$argv[3]} {$argv[4]}  >/dev/null 2>&1 & disown") ;
}
#end USB_MANAGER

 

 If >= 6.10 you should see a file  /etc/libvirt/hooks/qemu.d/USB_manager

 

What do you get in the log? Maybe be different from below as this is the newer version(Beta).

 

Jul  1 13:05:02 unraid usb_manager: Info: rc.usb_manager  vm_action Ubuntu stopped end -
Jul  1 13:05:02 unraid usb_manager: Info: rc.usb_manager VM Shutdown 002/006 vm: Ubuntu 
Jul  1 13:05:02 unraid usb_manager: Info: rc.usb_manager VM Shutdown 002/009 vm: Ubuntu 
Jul  1 13:05:08 unraid usb_manager: Info: rc.usb_manager  vm_action Ubuntu prepare begin -
Jul  1 13:05:09 unraid usb_manager: usb_manager virsh called Ubuntu 2 6 Device attached successfully  
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect Start 002/006 temp vm: Ubuntu 
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect Port Map Port:2-1.3  vm: Ubuntu 
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect Start 002/006 vm: Ubuntu Device in Use action ignored. 
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect for hub 002/009 Ubuntu;002;009;002/009;Auto;Hub; no
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect Port Map Port:2-1.3.2  vm: Ubuntu 
Jul  1 13:05:09 unraid usb_manager: usb_manager virsh called Ubuntu 2 9 Device attached successfully  
Jul  1 13:05:09 unraid usb_manager: Info: rc.usb_manager Autoconnect Start 002/009 temp vm: Ubuntu 

 

Also are you able to show me screen prints, happy for you to PM if you dont want to share on this page. 

 

image.thumb.png.5945a9017a717079ab2618de541259bd.png

Edited by SimonF
Link to comment

Thank you again @SimonF. I guess I'm about to display my ignorance here. I can navigate to my qemu file via terminal; however, i  don't know how to view it. I should possibly also mention that in my /etc directory, I have a /libvert and a /libvert- directory. Both seem to have "hooks" within them. Not sure if that matters. I am on the beta version of the plugin, and also on unraid 6.10.0. Below is the picture that you requested as well as my usb devices (hopefully there isn't anythign in there I should have greyed out). In any case, thank you for the help.

usb-save.JPG

Link to comment
1 hour ago, crankyCowboy said:

Thank you again @SimonF. I guess I'm about to display my ignorance here. I can navigate to my qemu file via terminal; however, i  don't know how to view it. I should possibly also mention that in my /etc directory, I have a /libvert and a /libvert- directory. Both seem to have "hooks" within them. Not sure if that matters. I am on the beta version of the plugin, and also on unraid 6.10.0. Below is the picture that you requested as well as my usb devices (hopefully there isn't anythign in there I should have greyed out). In any case, thank you for the help.

usb-save.JPG

If you are 6.10 cat /etc/libvirt/hooks/qemu.d/USB_Manager should show this result.

root@computenode:~# cat /etc/libvirt/hooks/qemu.d/USB_Manager 
#!/usr/bin/env php

<?php

#begin USB_MANAGER
if ($argv[2] == 'prepare' || $argv[2] == 'stopped'){
      shell_exec("/usr/local/emhttp/plugins/usb_manager/scripts/rc.usb_manager vm_action '{$argv[1]}' {$argv[2]} {$argv[3]} {$argv[4]}  >/dev/null 2>&1 & disown") ;
}
#end USB_MANAGER
?>
root@computenode:~# 

As you dont have devices with the same serial you can run the stable version.

 

if you detach the devices, remove the beta version and then install the stable version. Setting should still be in place.

 

Then try stopping and starting the VM to see if they autoconnect.

Link to comment

@SimonF Thank you again. I uninstalled the beta version and installed the stable version. Entering the data above in terminal did yield the same results as you indicated above. When I start the VM, now the devices connect, but I'm getting a virt error now (on both devices). I have to hover to get the exact error so it's sort of hard to see, but please see the error. any suggestions or fixing it?

Screenshot (2).png

Link to comment
Posted (edited)
1 hour ago, crankyCowboy said:

any suggestions or fixing it

Sorry I forgot to get you to remove the state file. This will rename it.

 

Remove the plugin, run this command mv  /usr/local/emhttp/state/usb.ini /usr/local/emhttp/state/usbold.ini and then reload the plugin from CA.

Edited by SimonF
  • Like 1
Link to comment
6 hours ago, SimonF said:

Sorry I forgot to get you to remove the state file. This will rename it.

 

Remove the plugin, run this command mv  /usr/local/emhttp/state/usb.ini /usr/local/emhttp/state/usbold.ini and then reload the plugin from CA.

@SimonF You are the best man! Thank you very much. That worked and has me back in business. I can't tell you how long I searched for a solution to this. Thank you!

  • Like 1
Link to comment
Posted (edited)
On 4/13/2022 at 1:52 PM, casperse said:

Hi Again

 

UPDATE: This seem to be a problem in the way Unraid detects the Conbee2 stick USB in 6.10 releases 

 

This would be really cool if the "USB Manager" could fix this?

 

 

If the USB manager could resolve the Conbee serial ID and create the correct device path?

 

 

 

***************************************

OLD POST

***************************************

 

I just upgraded from 6.9.2 -> 6.10.RC4

And I only using this plugin to passthrough USB to my HAssio VM but it seems it dosent work in 6.10.RC4?

 

But the error I have after reboot is this:

kernel: usb 1-1: usbfs: process 17779 (qemu-system-x86) did not claim interface 1 before use

Its filling up and have been running since my reboot

 

 

Again thanks for this great plugin! Thinking about rooling back it work 100% in 6.9.2

  

image.thumb.png.e2af5f04476028c1ff765adaf08bca8c.png

I have started to add support for mapping devices as a Serial connection to a VM. So you wont have to use the XML fix.

 

Function works for starting/stopping VM, hotplug removal but doesnt work for hotplug add at this point due to the way i need to get the by-id name.

 

I am using the following for testing for the XML. Will look to make the USB port configurable. 

	$usbstr .= "<serial type='dev'>
	<source path='${isSerialPath}'/>
	<target type='usb-serial' port='1'>
	<model name='usb-serial'/>
	</target>
	<alias name='ua-serial${usbbus}${usbdev}'/>
	<address type='usb' bus='0' port='04'/>
	</serial>" ;

<serial type='dev'>
<source path='/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DEXX-if00'/>
<target type='usb-serial' port='1'>
<model name='usb-serial'/>
</target>
<alias name='ua-serial001026'/>
<address type='usb' bus='0' port='04'/>
</serial>

 

image.thumb.png.c3069c00d851301bfab7126de7f82eaf.png

 

image.thumb.png.1340f5403acaccf51a3bcfe05027080c.png

Edited by SimonF
  • Like 1
  • Thanks 3
Link to comment
Posted (edited)

Version 2022.07.18a released.

 

Reworked the USB Manager VM Hotplug page to only show available devices for Attach, and shows only devices attached to the selected VM for detach.

 

image.thumb.png.c78f30b4f229561eb651434898ca65a1.png

 

Edited by SimonF
  • Like 1
Link to comment
On 6/29/2022 at 1:52 PM, Scarat said:

Hi,

 

first of all thank you for the great plugin. The thing that I'm trying to accomplish is regarding usbip, so my usb device is on the remote system.

 

When there is no binded device on remote raspberry pi

image.thumb.png.4b7508c811097b44f2643583b2074f8d.png

I see this in Unraid USB plugin.

image.thumb.png.4bc8fdbd30f8a76e0c01fe89a1701c64.png

When I bind the device

image.thumb.png.2a116411da0af1fcc576aac5a55ee5d5.png

then in USB plugin I see the usb device and I can manually attach it.

image.thumb.png.3930bea723fe733270379c0c8ff9d846.png

The thing is that I would like for this device to be attached automatically whenever it is discovered. Is there some setting that I'm missing?

 

I have also found this in the settings.

image.thumb.png.d24dffee01b6f6ab00bc0d1b259ba261.png

Is this somehow related to the functionality that I'm trying to accomplish or what is the purpose of USBIP remote Checker?

Also I'm not able to make it enabled whatever settings I apply it is always grayed out.

 

Thank you very much for your help.

+1 for this.

 

It would be great if USB Manager could mount remote USBIP devices automatically if they are discovered.

 

I have a couple of them set to attach automatically to the VM when they are available, but if I restart the remote host that has the USB devices plugged in, I have to manually attach them so that they then attach to the local VM.

 

Amazing plugin btw. Keep up the good work..

Edited by muzo178
Link to comment
8 hours ago, muzo178 said:

+1 for this.

 

It would be great if USB Manager could mount remote USBIP devices automatically if they are discovered.

 

I have a couple of them set to attach automatically to the VM when they are available, but if I restart the remote host that has the USB devices plugged in, I have to manually attach them so that they then attach to the local VM.

 

Amazing plugin btw. Keep up the good work..

Will look in to it.

Link to comment

@muzo178 @Scarat

 

Started thinking about this. And looking to add two parts. One to detect USBIP hosts automatically and add them into the remote users list. Options to set as Manual i.e. no action or Auto. Auto would then use the frequency an action to add, remove or both, option to exclude the local host if running USBIP. Looking at this being able to run on the following

 

image.png.5a59404b914ca1b3d1ff0ad63bc9d8a4.png

 

Second part will be to check if that host is on and attach devices how would you like that to work, any options when connecting etc?

 

Sample options below.

 

image.thumb.png.c3152fc04ae3e08d351c13be1d604d0d.png

Link to comment

Release 2022.07.23

 

I have add the to processes to detect new hosts and check if the host is available and attach the devices. Please test @muzo178 & @Scarat and let me know if that meets your use case or you want additional function let me know.

 

2022.07.23

Add USBIP host finder and checker options and processing. Checker will attach a USBIP device found not connected to host already. Finder will look for devices in the local subnet using port 3240 and depending on options add or remove the host from the remote USBIP hosts, removal is for a host no longer found.

Link to comment
On 7/23/2022 at 3:11 PM, SimonF said:

Release 2022.07.23

 

I have add the to processes to detect new hosts and check if the host is available and attach the devices. Please test @muzo178 & @Scarat and let me know if that meets your use case or you want additional function let me know.

 

2022.07.23

Add USBIP host finder and checker options and processing. Checker will attach a USBIP device found not connected to host already. Finder will look for devices in the local subnet using port 3240 and depending on options add or remove the host from the remote USBIP hosts, removal is for a host no longer found.

 

this is fantastic in initial testing.

 

I am getting this in my syslog every minute though..

 

UNRAID usb_manager: Info: rc.usb_manager USBIP Host Check attached failed Array

 

Link to comment
Posted (edited)
6 minutes ago, muzo178 said:

 

this is fantastic in initial testing.

 

I am getting this in my syslog every minute though..

 

UNRAID usb_manager: Info: rc.usb_manager USBIP Host Check attached failed Array

 

I have just updated to version 2022.07.24 which should fix?

Edited by SimonF
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.