Can you post the script (or a trimmed down version)?
qvm-shutdown does have a --wait parameter.
You can also check if $? is zero or non-zero after qvm-shutdown --wait to see if shutdown exited with unexpected results.
I’d probably also add a sleep 1 or sleep 2 statement between shutdown and start, just to be sure storage has also been properly cleaned up before qvm-start.
B
PS - in @airelemental 's snippet above, a) I’d prefer && instead of ; and b) then also check $? to see if the combined command line failed.
After a bunch more testing, I determined I can get the outcome I want without shutting down and restarting the qube. This made the script faster, and made the race condition moot.