[PATCH] qemu: snapshot: Restructure control flow to detect errors sooner and work around compiler