Limit Access to a USB mapping

robinlog

New Member
Jun 29, 2023
4
0
1
We are trying to create a VM where it requires a hardware licence that is plugged into the server and a mapping is created to be able to use the software within the VM.
The issue is that if a second VM is started, with the same mapping, it will remove the USB from the first VM causing the software to error due to lack of licence.

Now we can potentially manage this through procedures to check for vms etc, but I'm looking to see if its possible to block a VM starting IF the usb mapping is in use.
The USB itself does not have any storage, it is purely a licence key and does not show up as a mapped drive on either the host or the VM.

Any ideas?
 
such checks are currently not built in. what you could do is to add a hookscript to the vms that check the other running vms in the prestart phase and abort if it detects it
requires a bit of scripting but shouldn't be too hard
 
Thanks, I've looked at the hookscript example that's shown in the documentation.
So it looks like I could do a qm list command to find the running IDs, then use the qm config <id> -current to get the config and search for the mapping. My perl isn't great but I'm sure I can muddle my way through that.
If there's a more streamlined way, I'd be happy to hear it. If I get a working script, I'll post it here
 
Thanks, I've looked at the hookscript example that's shown in the documentation.
So it looks like I could do a qm list command to find the running IDs, then use the qm config <id> -current to get the config and search for the mapping. My perl isn't great but I'm sure I can muddle my way through that.
If there's a more streamlined way, I'd be happy to hear it. If I get a working script, I'll post it here
that's basically the approach i would take

maybe we introduce some feature in the future where usb devices are reserved for vms (like pci devices are) but it we did not need that in the past
 
that's basically the approach i would take

maybe we introduce some feature in the future where usb devices are reserved for vms (like pci devices are) but it we did not need that in the past
If we can work around it this way, I'm happy this is probably a fringe case. If more people request it then it might be useful.
I think I've managed to make a script, so I'll post after testing
 
It does not have to be perl as any executable (script) format should work, but I have only used bash.
Good to know...I just learnt enough Perl to get this running! Python or Bash would have been better options in hindsight, but its done now :)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!