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.