[Plugin] USB_Manager


SimonF

Recommended Posts

 

USB_Manager is in CA as of 6th June 2021, Please continue to use USBIP-GUI but will be replaced by USB_Manager.

 

The plugin supports attaching multiple USB devices of the same Vendor/Model to a VM. Also it will auto hotplug devices are plugged in if defined and the VM is started.

 

 

image.thumb.png.eb2ef605bfe0a8818ed3f5bd26f3df73.png

 

Dashboard View add in 16.02.2021.

 

image.png.77b08616188dadb896b080f5341a598a.png

 

 

To see USBIP Functions you need to enable in Settings. This function is only valid from 6.9.0-rc2 onwards.

 

image.thumb.png.b95501553dea38f93aa5e06aa15a9ff1.png

 

Once enabled additional panels are available. (USBIP status and connection host/ip from vers >14.02.21 

 

image.thumb.png.c01d23e98495b653ebb07a503c3a49c7.png

 

USB_Manager Change Log

 

2021.12.12a

 

Revert 2012.12.12

 

2021.12.12

 

 - Add Hub processing.You can define a port mapping for a hub. If connected or vm starts all devices on that hub will be connected to the VM.         Will not process next level down hubs.

  - Chg Disable device mapping for Root Hubs and Hubs. Disable port mapping for Root Hub.

  - Chg Detach button show next to connected port or device on the main line.

  - Fix Buttons if Hotplug mapping used.

  - Note reboot or disconnect/reconned of Hub may be required.

 

2021.09.18

 

  - Code review and update.

 

2021.09.01

 

  - Fix start of usbipd and load of modules on array start.

 

2021.08.01

 

  - Code clean up

  - Change to udev rules for 6.10+ support.

  - Enable zebra strips on tables.

 

2021.07.27

 

  - Fix Change Unraid Flash to Unraid inuse on the hub lines on dashboard page.

  - Chg Use Port as standard rather than Physical BUSI/Port.

 

2021.07.23

 

  - Fix Disable roothub and hubs used for Unraid Flash device.

 

2021.07.10

 

  - Add volume to device list in USBHotplug page.

 

2021.07.09a

 

  - Add display of Hotplug Devices on main USB page and allow detach.

 

2021.07.09

 

  - Fix Virsh error if both port and device mapping exist for a device a connection time.

  - Add USB Manager Hotplug page on VM page, to enable change options in settings. Base code from DLandons Hot plug plugin. Addition support to show on USB page if mapping doesn't exist in next release.

 

2021.06.02a

 

  - Fix table formating if both port and device mappings for new volume column

  - Add Log virsh calls.

 

2021.06.26

 

  - Enhancement Show Volume for USB Storage Devices.

 

2021.06.20

 

- Enhancement enable port processing for mappinng ports to VM at start.

- Update text on edit settings page to describe entry being changed.

 

2021.06.19

 

- Install QEMU hooks file code, thanks to ljm42 for code.

 

2021.06.08

 

- Fix USBIP command check.

 

 

2021.06.06

 

- Initial beta release.

 

If you are using USBIP-GUI continue to do so at this time. This plugin will suppercede USBIP-GUI in the future and will migrate configurations.

 

USBIP-GUI and USB_Manager cannot co-exist. If you want to replace USBIP-GUI then uninstall first, Config files we remane on the flash drive you can copy them to usb_manager directory.

 

USBIP and USBIP-HOST module are not loaded by default. If you want to use them enable USBIP in the Settings and click the install button to install the additional plug.

 

Add the following lines, see support page for complete code as cannot be insert here to /etc/libvirt/hooks/qemu after the PHP line, These will be automatically added in the a future release.


 

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]} ................

 

Includes all changes from USBIP-GUI + Topology Slider addition.

 

USBIP-GUI Change Log

 

2021.05.15

- Chg Fix Remove USB device from VM for devices not in a shutdown state, was previously only for running.

 

30.04.2021

- Add Remove USB Device from VM when disconnected.

 

2021.04.22
- Add Roothub and Hubs to view.
- Add Switch to show empty ports.
- No process added at this time for additional devices.

 

10.03.2021

 

- Add VM disconnect option to be used in pre sleep commands to remove USB mappings from VM before sleep.


09.03.2021

- Chg Fix issue introduce as part of port mapping for checking status.


24.02.2021

- Add Support for port-based mappings Auto connecting to a VM when device is connected to a USB port. Only devices being plugged in are supported for Ports at this time. Support for port level will be added in the furture for VM Starts. Precedence is for device level mappings over port. If a device is set to autoconnect no then the auto connect at the port level will be evaluated.

 

17.02.2021

 

- Add Dashboard update and refresh.

 

16.02.2021

 

- Add USB Dashboard entry. Enable within settings.

 

14.02.2021

 

- Add Display host name or IP address for remote USBIP Clients.

 

13.02.2021

 

- Add Show remote connection status. Host/IP to follow WIP.

 

12.02.2021

 

- Chg Fix for Bind/Unbind Button.

 

10a.02.2021

- Add Disconnect update function implemented.

- Add Auto Connect on VM Start.

- Chg Auto Connect on device added checks VM Status

- Add Update Status when VM Stops.

 

Note you need to manually add code to /etc/libvirt/hooks/qemu for VM start/stop process to function. See support page.

 

Development yet to be completed.

 

Update of qemu hook file.

Add checks before historical info can be removed.

Rename Plugin to USB Manager

Change to include USBIP package install in the settings page.

 

08.02.2021

 

- Add: Autoconnect function. If VM defined and Autoconnect is set to Yes then when usb device is connected device will be connected to VM. If VM is not started Error is show.

- Chg: Main USB list is no longer depetant on USBIP. Version change to support 6.8. Error will be seen during install as it trys to install USBIP package which doesnt exist pre kernel 5.10.1, but is ignored.

 

Development yet to be completed.

 

Autoconnect function, check VM status before connecting. 

Autodisconnect function. Will provide log entry but no action taken at present.

Add checks before historical info can be removed.

Rename Plugin to USB Manager

VM Start/Stop process.

Change to include USBIP package install in the settings page.

 

07.02.2021

 

- Add: VM Mapping functions

- Add: Display USBIP function messages if not used. Enable/Disable for USBIP added to settings. Defaults to disable, change to enable if you are upgrading.

- Add: Historical Devices added, list includes current devices also which can be removed whilst inuse.

- Add: Failure Message for virsh errors.

 

Note,

 

Existing Libvirt plugin cannot be used to connect devices.


 

Development yet to be completed.

 

Autoconnect function. udev Rules exist and process works, but there are timing issues to be resolved.

Add checks before historical info can be removed.

Rename Plugin to USB Manager

VM Start/Stop process.

Changes to USB device list not to be depentant on usbip. Once change version pre-6.9.0-rc2 will be available.

 

31.01.2021

 

- Add: Revised Load process and addition of loading usbip package from ich777.

  USBIP package includes all commands and modules required for USBIP

 

28.01.2021

 

- Initial beta release.

 

 

 

 

 

image.png

image.png

image.png

image.png

Edited by SimonF
Updated Content
  • Like 2
  • Thanks 1
  • Upvote 1
Link to comment

Can this eventually be used to attach server connected USB peripherals to VM's with no USB passthrough?

 

For example, instead of passing through multiple sets of keyboards and mice, or trying to get several usb chipsets passed through cleanly to multiple vm's, could you manage all the mice and keyboards on unraid and connect them using the client inside the vm?

 

You say the host module is not included, is this something you plan to add, or is it up to limetech?

Link to comment
6 minutes ago, jonathanm said:

Can this eventually be used to attach server connected USB peripherals to VM's with no USB passthrough?

 

For example, instead of passing through multiple sets of keyboards and mice, or trying to get several usb chipsets passed through cleanly to multiple vm's, could you manage all the mice and keyboards on unraid and connect them using the client inside the vm?

 

You say the host module is not included, is this something you plan to add, or is it up to limetech?

The module is the kernel module usbip_host, I think initially limetech only included vhci_hcd and usbip_core. I guess it could be sideloaded with the new process but ideally it should be baked into standard modules if the other two are there already.

 

You could connect devices this way but I am not sure how slick it would be, also the they would not be available until you attach them on the client. The host part also needs to run the daemon usbipd. I think for VMs it would still be better to passthru the usb.

Link to comment
  • SimonF changed the title to [Plugin] USBIP commands and GUI
  • 2 weeks later...

[DESIRE TO KNOW MORE INTENSIFIES]

 

ok, I understand that KB and mouse are dealt by RDP, no need to USB over IP them.

 

Could I RDP into a computer using a Rpi, plug something on the usb, like a Hardlock/hardkey/keylock/HASPKey and it would look like it is connected to the virtual machine? and what about Yubico/FIDO keys? and printers? and thumbdrives?

 

Most really heavy simulations can run better on a hefty server and not on the client machine. but licensing / management of the licenses can be a pain due the hardware keys.

Link to comment

HI @GuilhermeFluis

 

USBIP can be used to share USB Devices between systems. On the client side they appear as if they are connected directly.

 

Note that USBIP is not a secure setup so should only be used in local networks.

 

Uses are for connecting usb dongles/keys to servers etc. i.e. if you have home automation then connecting a ZWave USB controller to Openhab or Home Assistant running in a docker or VM.

 

USBIP doesn't reconnect automatically if there are failures etc.

 

You could have a keyboard, mouse, usb flash drive and connected to a pi and shared with remote host if the remote host has client support. There is a windows client, but I have not tested it as yet. But use a test signed driver. https://github.com/barbalion/usbip-win-client

 

On the client side you need to install the usbip tools. eg on Raspberry pi 4

sudo apt-get install usbip

 

Depending on if you device is the client or the server different kernel modules are required.

 

Server: usbip-host

Client: vhci_hcd

 

If they are not installed modprobe the one you need. vhci_hcd loads two(USB2 and USB3) virtual USB hubs for devices to be connected to of the remote system

 

pi@pi-gud:~ $ sudo apt-get install usbip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  usbip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 683 kB of archives.
After this operation, 778 kB of additional disk space will be used.
Get:1 http://www.mirrorservice.org/sites/archive.raspbian.org/raspbian buster/main armhf usbip armhf 2.0+4.18.20-2+rpi1 [683 kB]
Fetched 683 kB in 1s (1,069 kB/s)
Selecting previously unselected package usbip.
(Reading database ... 39839 files and directories currently installed.)
Preparing to unpack .../usbip_2.0+4.18.20-2+rpi1_armhf.deb ...
Unpacking usbip (2.0+4.18.20-2+rpi1) ...
Setting up usbip (2.0+4.18.20-2+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
pi@pi-gud:~ $ sudo modprobe vhci_hcd
pi@pi-gud:~ $ lsmod | grep vhci_hcd
vhci_hcd               32768  0
usbip_core             20480  1 vhci_hcd

 

You query the remote server using  usbip list -r <ip> command.

 

On the server side you need to also have usbip-host module loaded and the usbipd running to service requests from the clients, which can be started with usbipd -D

 

You have to bind devices to the module for them to be visible on the client.

 

image.png.7d4f42e7082a5ebf2e2282aabf9bcefb.png

 

and on the client.

 

image.thumb.png.400923b886aeaad1d4f593fe82a7cfdf.png

 

To attach the device to the client you need to run the usbip attach -r <remote ip> -b <remote busid> i.e. 1-1.3.1

 

Hope this helps provide a bit more of an overview?

  • Like 1
Link to comment

Awesome, Thank you for working on this.

 

Do you plan on supporting more than vm's attached to unraid? I have use-case's for usb hardware keys, where this would be a great feature for moving between multiple machines on local networks. (Windows is the biggest hurdle at the moment.) I was able to use this in conjunction with unraid cli to share to other machines on the network.

Link to comment
7 hours ago, dstark4 said:

Awesome, Thank you for working on this.

 

Do you plan on supporting more than vm's attached to unraid? I have use-case's for usb hardware keys, where this would be a great feature for moving between multiple machines on local networks. (Windows is the biggest hurdle at the moment.) I was able to use this in conjunction with unraid cli to share to other machines on the network.

If you DM me on what you did with CLI i can see if I can add it.

Link to comment
1 hour ago, CS01-HS said:

I haven't tested enough to confirm it's related but some time after installing the GUI plugin my syslog server started logging to syslog-127.0.0.1.log rather than syslog-<my unraid server's IP>. After uninstalling it it's back to normal. Strange.

you can remove 

 

99_usbip_syslog.conf from /etc/rsyslog.d/

 

and restart 

 

/etc/rc.d/rc.rsyslogd restart

 

If you want to use the plugin. Rules are only required for USBIP

Update to plugin script not to install rsyslog rules

Edited by SimonF
  • Thanks 1
Link to comment
  • 2 weeks later...
37 minutes ago, garydapogi said:

@SimonF Hi, I've installed the plugin successfully, however when I visit the setting page it's empty, just a white screen. How to fix?

 

Do you have the image.png.d63210ff17e48babd494eb1e1816ceb1.png or is it the page blank when you image.png.937959d1f651c05961119888cc357085.pnggo via this in the settings page?

 

What vers of OS are you on,

 

You will only see these two options on the settings page.

 

image.thumb.png.d5f1e44e9ec9326b10cce3a2dc028603.png

 

Main USB page is via the Menu at the top.

Edited by SimonF
Link to comment

Oh yah! I see the Tab. I did not noticed that before. thanks @SimonF

 

I was looking at the wrong place - the usual gear icon of an app. 

 

Will this plugin solve my case, where (no. 5):

1. I suspend a Linux VM

2. Suspend unRaid server via S3 Plugin

3. Wakes up unRaid

4. Wakes up the Linux VM

5. USB Mouse won't re-attach

 

unRAID 6.9.0

Edited by garydapogi
added OS version
Link to comment
3 minutes ago, garydapogi said:

Oh yah! I see the Tab. I did not noticed that before. thanks @SimonF

 

I was looking at the wrong place - the usual gear icon of an app. 

 

Will this plugin solve my case, where (no. 5):

1. I suspend a Linux VM

2. Suspend unRaid server via S3 Plugin

3. Wakes up unRaid

4. Wakes up the Linux VM

5. USB Mouse won't re-attach

 

OK I may need to look at suspend. Just to check to did the change to the hook file in the first post.

 

Just to confirm you suspend VM just via the VM menu(Hibernate) options or by some other process?

 

Do you see any messages similar to these in the syslog if you have added lines into hook file?

 

Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui vm_action UbuntuDesktop stopped end -
Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui VM Shutdown USB_Flash_Drive_A5B8E821183F2D4F vm: UbuntuDesktop
Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui VM Shutdown Generic_Mass_Storage_037388E2 vm: UbuntuDesktop
Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui Autoconnect Start 18f8_USB_GAMING_MOUSE vm: UbuntuDesktop Device in Use action ignored.
Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui vm_action UbuntuDesktop release end -
Mar 8 09:41:45 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui Autoconnect Start 18f8_USB_GAMING_MOUSE vm: UbuntuDesktop Device in Use action ignored.
Mar 8 09:41:58 Tower kernel: br0: port 2(vnet0) entered blocking state
Mar 8 09:41:58 Tower kernel: br0: port 2(vnet0) entered disabled state
Mar 8 09:41:58 Tower kernel: device vnet0 entered promiscuous mode
Mar 8 09:41:58 Tower kernel: br0: port 2(vnet0) entered blocking state
Mar 8 09:41:58 Tower kernel: br0: port 2(vnet0) entered forwarding state
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui vm_action UbuntuDesktop prepare begin -
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui Autoconnect Start 18f8_USB_GAMING_MOUSE vm: UbuntuDesktop Device in Use action ignored.
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui vm_action UbuntuDesktop start begin -
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui Autoconnect Start 18f8_USB_GAMING_MOUSE vm: UbuntuDesktop Device in Use action ignored.
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui vm_action UbuntuDesktop started begin -
Mar 8 09:41:58 Tower unraid.usbip-gui: Info: rc.unraid.usbip-gui Autoconnect Start 18f8_USB_GAMING_MOUSE vm: UbuntuDesktop Device in Use action ignored.

Link to comment
4 minutes ago, SimonF said:

Just to confirm you suspend VM just via the VM menu(Hibernate) options or by some other process?

 

Im using Linuxmint Mint, I click on the Suspend button in the VM itself.

 

Quote

Do you see any messages similar to these in the syslog if you have added lines into hook file?

 

I can't do this now, however I have a copy of the exact error code in the Linux VM, it says:
libusb_release_interface: -4 [NO_DEVICE]

 

The moment I see that line, mouse is not working, so I have to manually attach it via the Libvirt USB Hotplug.

I will get back with the syslog you're asking. Machine is dismantled for the time being.

Link to comment
7 hours ago, garydapogi said:


I will get back with the syslog you're asking. Machine is dismantled for the time being.

 

No worries, I am creating a Mint VM with an RTX2060 +kb and mouse to test suspend. An will see if I need to change anything.

Edited by SimonF
Link to comment

OK, Suspending a Mint VM does not provide any notification from hooks. So unless we get some disconnect, reconnect of the USB then there doesn't seem to be a way to trigger an event.

 

I will try sleep functions on my test server to see if I can see anyway to detect as I don't normally use them.

 

Do you use the S3 sleep plugin as it has before and after scripts so may be able to script the removing before sleep and reconnecting after.

 

Are you able to provide me a screen print of the usb page pm me if you dont want to post it here

Edited by SimonF
Link to comment
5 hours ago, SimonF said:

Do you use the S3 sleep plugin as it has before and after scripts

Yes I do use it, however Im I know nothing about the before/after scripts. But yah, I get the idea, we could use that feature to do as you you said. 

 

Here's my screenshot btw:

- In my VM setting, the mouse is passed through: https://i.snipboard.io/IGghF4.jpg

- In USB Page, mouse is set to auto connect on VM start, not sure how to use the settings on there tho. Also, I see the virsh error there after waking up the VM - https://i.snipboard.io/fMhSYx.jpg

 

So the workflow I tried:

1. I suspend the Linux VM via the Linuxmint Suspend button.

2. Suspend the unRaid server using the Sleep Button provided by the S3 plugin

3. Wake the unRaid server up > Manually unpaused the Linuxmint VM via GUI, result: mouse not working, virsh error pop up on the USB page.

 

Syslog, sending via PM

Link to comment

Hello, I need some help I intall the plugin and try to passtrue my 2 joysticks with same vendor id, after some test dosn't give good result and i remove the plugin, after that my server going crazy. First if i try to start my VM with passtru video card 750TI, he give kernel: vfio-pci 0000:27:00.0: BAR 1: can't reserve and VM stuck at Boot logo. And after a while in the logs i see :
Mar 13 12:53:57 xxxxx kernel: NVRM: GPU 0000:27:00.0: RmInitAdapter failed! (0x26:0x65:1290)
Mar 13 12:53:57 xxxxx kernel: NVRM: GPU 0000:27:00.0: rm_init_adapter failed, device minor number 0

The server reboot itself, how can i repair or roolback all change maded by this plugin. Thanks!
Just a coincidence, it has nothing to do with the plugin.

Edited by b0n3v
Link to comment

The plugin doesnt make any changes to the GPU settings, if you have removed the plugin and reboot there should be nothing left of the plugin.

 

Did you change anything apart from install the plugin?

Edited by SimonF
Link to comment
  • 4 weeks later...
26 minutes ago, RiDDiX said:

Since Unraid Version: 6.9.2. 

 

I just get the messege: Following are missing or not loaded: usbip_host module.

 

Did there got something remove for usbip? With Version 6.9.1 everything worked -.-

Its working for me on 6.9.2.

 

Did you upgrade before the usbip package was built? Have you tired uninstalling and re-installing?

 

What does your settings look like?

 

image.thumb.png.4ac54b3be4a611df8b4fea2889a35654.png

Edited by SimonF
  • Like 1
Link to comment
5 minutes ago, SimonF said:

Its working for me on 6.9.2.

 

Did you upgrade before the usbip package was built? Have you tired uninstalling and re-installing?

 

What does your settings look like?

 

image.thumb.png.4ac54b3be4a611df8b4fea2889a35654.png

I attached my settings there are like yours but with the error as mentioned. I already uninstalled both plugins and reinstalled them. But I still see this "error/warning".

Unraid USBIP.JPG

Link to comment
4 minutes ago, RiDDiX said:

I attached my settings there are like yours but with the error as mentioned. I already uninstalled both plugins and reinstalled them. But I still see this "error/warning".

Unraid USBIP.JPG

Looks like the additional USBIP package hasn't been installed. The vhcd are included in stock unraid.

 

You should be able to remove plugin and reinstall to fix.

  • Like 1
Link to comment
  • SimonF changed the title to [Plugin] USB_Manager/USBIP commands and GUI
  • SimonF changed the title to [Plugin] USB_Manager

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.