[Plugin] USB_Manager


SimonF

Recommended Posts

2 minutes ago, BurntOC said:

Ah, attempted to manually execute the install script you referenced and it returns:

 

Version is for qemu.d 6.12.8

 

No other output given.

that is fine the file should be in the hooks/qemu.d dir now.

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

may a question as i seems to missunderstand some config ;)

 

i have 2 Logitech Unify Receivers here for 2 VM's (1 GPU connected to a Mon, 1 GPU connected to a TV)

 

1/ AlsPC (Desktop VM Monitor)

2/AlsPC_Media (Gaming VM TV)

 

so i assigned the different ports to the different VM's, but it looks like, depending on the last VM state it "mixed" the assignements in the GUI at least (and also not auto connecting the 2nd one here)

 

now, when i start VM 1, i see the following screen

 

ApsPConly.thumb.png.e7ded88e9bc457657493ab605bf8db79.png

 

as i see in the bottom, the device on Port 3-1-1-4 changed to AlsPC while device on Port 1-12 is auto connected to VM 1 (as it should)

 

now, when i also start VM 2, i see the following screen

 

AlsPC_ALL_ON.thumb.png.3077391d181e475ac77dbf40630b7d75.png

 

the device on Port 3-1-1-4 stays on VM 1 (AlsPC) and is not auto working in VM 2

 

when i now change it again (3114) it will also change the upper setting in the GUI from VM 1 device (1-12) ...

 

image.thumb.png.bb9036e81583932348a5405e793ffb3c.png

 

while the usb vm_mapping config looks like this, possible that the 1st entry is "shuffling" around ?

 

image.thumb.png.a76ddfcf5b475d4f65c8a87e32ae9e46.png

 

my next step would be to delete this entry and look what happens ;)

 

or is there somethinng "special" todo with 2 simultan uuid devices ?

Link to comment
31 minutes ago, alturismo said:

may a question as i seems to missunderstand some config ;)

 

i have 2 Logitech Unify Receivers here for 2 VM's (1 GPU connected to a Mon, 1 GPU connected to a TV)

 

1/ AlsPC (Desktop VM Monitor)

2/AlsPC_Media (Gaming VM TV)

 

so i assigned the different ports to the different VM's, but it looks like, depending on the last VM state it "mixed" the assignements in the GUI at least (and also not auto connecting the 2nd one here)

 

now, when i start VM 1, i see the following screen

 

ApsPConly.thumb.png.e7ded88e9bc457657493ab605bf8db79.png

 

as i see in the bottom, the device on Port 3-1-1-4 changed to AlsPC while device on Port 1-12 is auto connected to VM 1 (as it should)

 

now, when i also start VM 2, i see the following screen

 

AlsPC_ALL_ON.thumb.png.3077391d181e475ac77dbf40630b7d75.png

 

the device on Port 3-1-1-4 stays on VM 1 (AlsPC) and is not auto working in VM 2

 

when i now change it again (3114) it will also change the upper setting in the GUI from VM 1 device (1-12) ...

 

image.thumb.png.bb9036e81583932348a5405e793ffb3c.png

 

while the usb vm_mapping config looks like this, possible that the 1st entry is "shuffling" around ?

 

image.thumb.png.a76ddfcf5b475d4f65c8a87e32ae9e46.png

 

my next step would be to delete this entry and look what happens ;)

 

or is there somethinng "special" todo with 2 simultan uuid devices ?

As it looks like both devices have the same serial ID you cannot use the device mapping. Just setup a port mapping per device to the correct VM.

Link to comment
24 minutes ago, SimonF said:

As it looks like both devices have the same serial ID you cannot use the device mapping. Just setup a port mapping per device to the correct VM.

ok, i thought thats what i did, but may didnt klick on the right spot and didnt notice im on "device" instead "port", seems removing device fixed it ;)

 

sorry and thanks.

  • Like 1
Link to comment

Posted just now · Hidden - This content must be approved before it can be edited.

Thanks a lot for the plugin it works great and brings me step closer to having Windows VM as my main Windows workstation.

 

I do have however a problem: after being woken up from sleep (another plugin) devices are not working any more, keyboard and mouse do not react.

After I de/attach them, either via USB page or physically, they start working but it will not be option any longer when this becomes my main Windows WS.

 

Is there some way to do it automatically after being woken up from sleep?

Sleep plugin has hooks to be executed before sleep and after being woken up, is there some command that could be executed?

Thanks again :)

Link to comment
4 hours ago, unacm2 said:

 

Thanks a lot for the plugin it works great and brings me step closer to having Windows VM as my main Windows workstation.

 

I do have however a problem: after being woken up from sleep (another plugin) devices are not working any more, keyboard and mouse do not react.

After I de/attach them, either via USB page or physically, they start working but it will not be option any longer when this becomes my main Windows WS.

 

Is there some way to do it automatically after being woken up from sleep?

Sleep plugin has hooks to be executed before sleep and after being woken up, is there some command that could be executed?

Thanks again :)

Yes you can, issue is that the real usb changes due to power state so you need to disconnect them before sleep and readd if the vm isin a suspend state.

 

custom command before sleep:

sleep 30
rc.usb_manager vm_action "vmname" disconnect

 

custom command after wakeup:

if [[ $(virsh list | grep "vmname") != "" ]]
then
    rc.usb_manager vm_action "vmname" prepare
    virsh dompmwakeup "vmname"
else
     echo "Not Running!" > /dev/null 2>&1
fi

 

These are example scripts.

Link to comment

Thanks a lot SimonF,

I am currently abroad so I cannot test, but that's what I need.

I have currently in sleep hooks virsh suspend and resume which I need to replace by your commands?

I presume disconnect does dompmsuspend as you did not call it explicitly?

And this sleep 30 is probably some empirical value based on your experience?

Again thanks on great plugin and great support,

 

Link to comment
5 minutes ago, unacm2 said:

Thanks a lot SimonF,

I am currently abroad so I cannot test, but that's what I need.

I have currently in sleep hooks virsh suspend and resume which I need to replace by your commands?

I presume disconnect does dompmsuspend as you did not call it explicitly?

And this sleep 30 is probably some empirical value based on your experience?

Again thanks on great plugin and great support,

 

No these scripts need to be set in the sleep plug post and pre scripts. It is to disconnect the devices from the VM as they get renumbered at host resume. The disconnect just removes the attached usb devices from the VM. Is there a option to suspend as part of the sleep. I don't use sleep but these are options I provided to another user with the same issues.

Link to comment
On 10/8/2023 at 1:46 PM, dboris said:

It works. Reboot bug was because somehow virsh wasn't interpreting the VM name when using parenthesis.

So the script part for sleep is : 

virsh suspend HomeAssistant
rc.usb_manager vm_action HomeAssistant disconnect


And wake up :

rc.usb_manager vm_action HomeAssistant prepare
virsh resume HomeAssistant

The irony at me having the same issue months later and searching again until I find my message.

Edited by dboris
Link to comment
On 4/29/2021 at 5:36 AM, SimonF said:

@garydapogiOk I can produce the error on my test machine.

 

I thought QEMU removed the device when it was disconnected from the host, but doesn't seem to be the case. Will add function to disconnect the device if udev detects a change.

 

Do you get this once the system wakes up from sleep? Can you provide an extract of your syslog after a wake up so I can see if there are any USB disconnects.

 

 

I couldn't find if or where this was ever addressed. I currently use a kvm switch to move between vm and laptop. This disconnects the usb devices when switching to the laptop and I have to reconnect when switching back to vm. After doing this ~5-8 times, depending on how many devices I am using at the time, the available ports (15) fill up and I am forced to stop the vm. 

Link to comment
On 3/21/2024 at 5:37 PM, galloglypg said:

 

 

I couldn't find if or where this was ever addressed. I currently use a kvm switch to move between vm and laptop. This disconnects the usb devices when switching to the laptop and I have to reconnect when switching back to vm. After doing this ~5-8 times, depending on how many devices I am using at the time, the available ports (15) fill up and I am forced to stop the vm. 

I thought I had implemented but will look over the weekend. Normally when a usb device disconnects it is automatically removed from the guest.

Link to comment
  • 2 weeks later...

Love this plugin, it's made my setup a lot less complicated :)

One thing I want to do is to disconnect USB devices from one VM, and connect them to another via a script / SSH (for a keyboard/mouse and bluetooth adapter). Is there a way I can do this? I've had a look at the
rc.usb_manager script but I can't quite work out which parameters are which. Preferably attaching by port instead of device.

Thanks!

Link to comment
16 hours ago, IVData said:

Love this plugin, it's made my setup a lot less complicated :)

One thing I want to do is to disconnect USB devices from one VM, and connect them to another via a script / SSH (for a keyboard/mouse and bluetooth adapter). Is there a way I can do this? I've had a look at the
rc.usb_manager script but I can't quite work out which parameters are which. Preferably attaching by port instead of device.

Thanks!

Not currently an option with rc script. I can look to add options.

 

Have created code, but not merged and pacakged as yet.

 

two options one for port and one for device serial_id

Quote

root@computenode:~# rc.usb_manager cmdlineport "1-2" "Unraid-VM" "attach" 
Device attached successfully

root@computenode:~# rc.usb_manager cmdlinedevice "MSI_MYSTIC_LIGHT_A02021081203" "Unraid-VM" "detach"
Device detached successfully

root@computenode:~# 

 

 

https://github.com/SimonFair/USB_Manager/commit/552567430e0d67d6f3bb08920578ca99ad4e00f6

 

image.png

image.png

Link to comment

It would be amazing if you could add that! I have a LibreELEC VM and a windows VM for gaming both attached to my TV and being able to connect peripherals to whichever one I'm using automatically would be 👌

Link to comment
12 hours ago, IVData said:

It would be amazing if you could add that! I have a LibreELEC VM and a windows VM for gaming both attached to my TV and being able to connect peripherals to whichever one I'm using automatically would be 👌

Release 2024.04.03

Link to comment

Hi Simon, thank you for your work and your patience answering all the questions.

 

I have a Gigabyte C246M-WU4-CF Mainboard. This Motherboard has in total 12 USB-Ports, but it seems that this Motherboard has only one USB-Controller (Link: server_manual_c246m-wu4_e_1101.pdf (gigabyte.com), Page 7).

 

My goal is to passthrou 2 USB Ports to a Win 10 VM.

 

I installed the USB-Manager and the additional USBIP plugin. After the installation, all buttuons i see are grey. Does that mean that i can not passthrough single USB-Ports to a VM?

image.thumb.png.529443e0754a0fa0a15b9991b5494ca7.png

 

Thank you very much.

Link to comment
38 minutes ago, HGWBLN said:

Hi Simon, thank you for your work and your patience answering all the questions.

 

I have a Gigabyte C246M-WU4-CF Mainboard. This Motherboard has in total 12 USB-Ports, but it seems that this Motherboard has only one USB-Controller (Link: server_manual_c246m-wu4_e_1101.pdf (gigabyte.com), Page 7).

 

My goal is to passthrou 2 USB Ports to a Win 10 VM.

 

I installed the USB-Manager and the additional USBIP plugin. After the installation, all buttuons i see are grey. Does that mean that i can not passthrough single USB-Ports to a VM?

image.thumb.png.529443e0754a0fa0a15b9991b5494ca7.png

 

Thank you very much.

I guess you dont have any devices connected. If you connect a device you will see it appear and then you can create a port or device mapping.

 

If you have enabled hotplug you can attach devices via the VM tab also.

image.png

 

If you toggle empty ports it will show empty ports also.

 

image.png

 

Example with empty ports.

 

image.png

 

Click on these icons.

 

image.png

 

Left is for ports, right for Device Mapping and you will see.

The settings.

This is for a device.

 

image.png

This is where you can specify VM and actions. 

 

Auto connect at plugin will attach usb device when connected.

Auto connect at Start will attach at VM start.

 

Start/Resume will start/resume a VM when as device is connect and and connect at plugin is enabled.

 

Serial only is if you need to attach as a serial port, Things like ConbeeII needs this. Default is port 4 but if you have multiple you may need to change this.

 

Port mapping is the same as a device but will connect any device on that port to a VM. Device will only do that device but will work across any port.

 

Hope this helps.

 

ps usbip extra is only required if you want to use usb devices over networks from/to other ser ers pcs etc

 

  • Thanks 1
Link to comment

Hello, I'm having issues passing through one specific USB device to my windows VM. The device will not show up in the windows device manager. When i start the VM it says its connected, but the log says "no mapping found".
 

image.thumb.png.6bff6a9f1e87715207eb596efd9cdf29.png

image.thumb.png.713bc6910c6fb1470e1586a3a98c8eeb.png


If I detach and re-attach it I get a Virsh error, which I'm not sure what that means or what might cause it.
image.thumb.png.35596693f04d9f9b2afdd677b5435203.png

 

I have the device and the 1-11 port already set up to auto connect on plugin and VM startup. All other devices seem to be working fine except this one.

Any ideas what might be the issue?
 

Link to comment
7 minutes ago, Reid B said:

Hello, I'm having issues passing through one specific USB device to my windows VM. The device will not show up in the windows device manager. When i start the VM it says its connected, but the log says "no mapping found".
 

image.thumb.png.6bff6a9f1e87715207eb596efd9cdf29.png

image.thumb.png.713bc6910c6fb1470e1586a3a98c8eeb.png


If I detach and re-attach it I get a Virsh error, which I'm not sure what that means or what might cause it.
image.thumb.png.35596693f04d9f9b2afdd677b5435203.png

 

I have the device and the 1-11 port already set up to auto connect on plugin and VM startup. All other devices seem to be working fine except this one.

Any ideas what might be the issue?
 

Have you enabled serial in the mapping? Also looks like you have the USB defined in the VM Template.

 

can you provide the output from this command. cat /usr/local/emhttp/state/usb.ini |  grep -n6  virsh

Link to comment

By enabled serial in the mapping do you mean the "Connect as serial only" option? If that is the case then no.

I do have the pass through selected as part of the VM settings, I set it up like that initially but had the issues and installed the plugin to try and troubleshoot.

Here is the output of the command
image.png.f02979eb8fae5aca0db8188305ed6365.png

Link to comment
13 minutes ago, Reid B said:

By enabled serial in the mapping do you mean the "Connect as serial only" option? If that is the case then no.

I do have the pass through selected as part of the VM settings, I set it up like that initially but had the issues and installed the plugin to try and troubleshoot.

Here is the output of the command
image.png.f02979eb8fae5aca0db8188305ed6365.png

Strange I would expect to see an error 

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.