[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

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.