Sorry I must have messed up some syntax in the previous attempt. I delted the file and started over and copied your script exactly.
sys usb does start now but sys-audio does not.
I am assuming you still want me to leave autostart unchecked.
Here is the log from that attempt|attachment (343.9 KB)
I believe sys-audio will autostart if check autostart and I delete the script and detach both 2-4 and 2-5.3 and I believe audio works like that so maybe I should just leave them unattached. I’m just not sure why its so difficult or if I am doing something fundamentally wrong
Ok, I’ve found the issue.
Previously the qvm-usb list vmname
didn’t show the persistently attached devices that are not present, but now it shows them even if there is no device present.
Attach both USB devices to sys-audio, change the script to this and try again:
#!/bin/bash
guest_name="$1"
libvirt_operation="$2"
timeout=60
guest_to_start_on_usb="sys-audio"
if [ "$guest_name" = "sys-usb" ] && [ "$libvirt_operation" = "started" ]; then
(
exec 0</dev/null
exec 1>/dev/null
exec 2>/dev/null
guest_attached_usb_list=$(qvm-usb list "$guest_to_start_on_usb" | awk '{ print $1 }')
for i in $(seq 1 $timeout);
do
if qvm-ls --running $guest_name | grep -q Running; then
present_usb_list=$(qvm-usb list | grep -w "$guest_to_start_on_usb" | awk '{ print $1 }')
if [ "$guest_attached_usb_list" = "$present_usb_list" ]; then
qvm-start --skip-if-running -q $guest_to_start_on_usb
break
fi
fi
sleep 1
done
) & disown
fi
UPD:
I’ve updated the script, since it was error-prone and with updated script you don’t need to specify the attached USB devices.
1 Like
AMAZING! It worked! Thank you so much for your patience in helping me fix this!