It returns something like “dm-85”, but it changes with each boot, so I cant do qvm-block attach -p vmname dom0:dm-85 since it won’t exist on next boot.
I can script it to attach it on boot, but then if I restart a VM it won’t be attached anymore.
Some tips for future readers, to debug you can restart libvirtd manually instead of rebooting completely, systemctl restart libvirtd
exit 0 as quickly as possible if it’s not your target operation/VM
the subshell and redirection of output seems to prevent locking/hanging, if it’s not used the VM wouldn’t boot properly, probably for the same reason a terminal might hang until you hit cancel. And if that happens you can barely kill the VM because it’s in a locked state
look for alternative faster qvm- tools like qubesdb-read rather than qubes-block ls, any time wasted in the hook is time lost on boot
My script is highly personalized with personal device names and VM names, so not useful for the public, but I hope this helps someone else solve the same issue