Currently, the vm_checkpoint() function has no error handling for
certain failures. Because of that, a suspend could report success and
destroy the VM even though the snapshot metadata was not properly
written, resulting in a snapshot that could not be restored.
- xo_finish_h() might fail and return -1; check its return value and abort snapshotting if it failed. Additionally, ensure successful write with ferror().
- fclose() might fail too; check its return value and put that before the "done" label so we can still resume the VM on error.
Reported by: llm-postcr
Fixes: 483d953a86a2 ("Initial support for bhyve save and restore.")
Sponsored by: The FreeBSD Foundation