Can't exec proxmox-usb-hotplug in a vm hookscript

scarlaxx

Member
Mar 15, 2021
9
0
6
52
Hi. After having issues with usb passthough to a VM a was searching forums for a solution and ended up with proxmox-usb-hotplug. I followed the installation and now I'm able to manually run it from proxmox shell with
Bash:
proxmox-usb-hotplug --vmid $vmid -c /etc/usb-hotplug.conf -p $pwd

Next I created a hookscript in /var/lib/vz/snippets/usbhotplug.pl and added this script to my VM.

Now when VM is starting I get: Can't exec "proxmox-usb-hotplug": No such file or directory at /var/lib/vz/snippets/usbhotplug.pl line 41.

There is a part about installing it as a service which I don't understand, I'm a linux beginner. I suppose I miss some bit so that the hookscript cannot access the installed npm package to run it or maybe some permissions are missing.
 

Attachments

Next I created a hookscript in /var/lib/vz/snippets/usbhotplug.pl and added this script to my VM.

Now when VM is starting I get: Can't exec "proxmox-usb-hotplug": No such file or directory at /var/lib/vz/snippets/usbhotplug.pl line 41.
It probably does not have execute permissions set. Check if you see x's in ls -l /var/lib/vz/snippets/usbhotplug.pl
This can be fixed with chmod +x /var/lib/vz/snippets/usbhotplug.pl

Note that if you don't know the programming language Perl, you can also use Bash scripts or other executable scripting languages. It took me some time to realize this.
 
It probably does not have execute permissions set. Check if you see x's in ls -l /var/lib/vz/snippets/usbhotplug.pl
This can be fixed with chmod +x /var/lib/vz/snippets/usbhotplug.pl

Note that if you don't know the programming language Perl, you can also use Bash scripts or other executable scripting languages. It took me some time to realize this.
Thanks for the reply. The problem is not with executing this usbhotplug.pl script but with running a command inside that should trigger the proxmox-usb-hotplug. On usbhotplug.pl I did run chmod +x so it is executable and it runs.
 
Thanks for the reply. The problem is not with executing this usbhotplug.pl script but with running a command inside that should trigger the proxmox-usb-hotplug. On usbhotplug.pl I did run chmod +x so it is executable and it runs.
Ah right, sorry. Maybe proxmox-usb-hotplu is not in the $path when the hookscript runs? Try using the complete path of it (use which proxmox-usb-hotplug)? Or try running /bin/bash with proxmox-usb-hotplug as an argument?
If all you want to do is run a comamnd, then maybe using a Bash script is simpler than a Perl script:
Bash:
#!/bin/bash
echo 'GUEST HOOK: ' $*
if { "$2" == 'post-start' ]
then
    proxmox-usb-hotplug --vmid "$1" -c /etc/usb-hotplug.conf -p mypwdhere
fi
 
Thank you, it works now with the bash script after I added a full path to proxmox-usb-hoplug. Issue resolved.