[SOLVED] Assign USB Devices to an already Running VM

apax

Active Member
Apr 3, 2019
11
6
43
61
I am extremely happy with proxmox but I have a simple question on which I am stuck searching since several days.

I need my virtual machines to access more than the 5 maximum USB devices in vm.conf and I am using the "device_add" command in qm monitor on the host. This is simply achieved by reading the "info usbhost" result and typing the command (for example "device_add usb-host,bus=xhci.0,hostbus=3,hostport=3.1.2,id=a34") with the appropriate parameter as described in https://pve.proxmox.com/wiki/USB_Devices_in_Virtual_Machines

I need now to automate the 'device_add' and the 'device_del' commands into 'qm monitor'. I have quite some programming skills in multiple languages and I am open to any solution including shell scripts, python, network sockets, or whatever. However I am been unable to send these commands to qm monitor using a script from the command line interface outside qm monitor.

Would anyone have a suggestion on how to achieve this simple task ?

Regards, apax
 
  • Like
Reactions: Icakis
you can use pvesh

Code:
pvesh create /nodes/NODE/qemu/VMID/monitor --command "yourcommandhere"
 
  • Like
Reactions: Icakis and doge
THANKS !!! It worked perfectly !

You have made my day !

Regards, apax