Skip to content

KVM NAS backup: resume VM and exit on backup failure#12872

Open
jmsperu wants to merge 1 commit intoapache:4.22from
jmsperu:fix/nasbackup-resume-vm-on-failure
Open

KVM NAS backup: resume VM and exit on backup failure#12872
jmsperu wants to merge 1 commit intoapache:4.22from
jmsperu:fix/nasbackup-resume-vm-on-failure

Conversation

@jmsperu
Copy link

@jmsperu jmsperu commented Mar 20, 2026

Summary

Fix three bugs in nasbackup.sh that caused VMs to remain paused indefinitely when backup jobs fail (e.g. storage full, I/O error):

  1. Infinite polling loop: backup_running_vm() falls through the Failed case without exiting, causing the script to poll the already-failed job forever. Fixed by adding exit 1 after cleanup.

  2. Continued processing after failure: backup_stopped_vm() continues processing subsequent disks after qemu-img convert fails. Fixed by adding exit 1 after cleanup.

  3. VM never resumed: cleanup() removes temp files and unmounts but never resumes the VM that was paused by virsh backup-begin. Fixed by adding a VM state check and virsh resume at the top of cleanup().

Root Cause

When virsh backup-begin starts a backup, the VM may be paused. If the backup fails for any reason (storage full, network issue, I/O error), the script's cleanup path never calls virsh resume, leaving the VM paused until manual intervention.

Test Plan

  • Trigger a backup with insufficient NAS storage — verify VM is resumed after failure
  • Trigger a backup with NAS unmounted mid-backup — verify VM is resumed
  • Normal backup completes successfully (no regression)
  • Verify qemu-img convert failure on stopped VM exits cleanly

Fixes #12821

Fix three bugs in nasbackup.sh that caused VMs to remain paused
indefinitely when backup jobs fail (e.g. storage full):

1. Add exit after cleanup on Failed backup job status to prevent
   infinite polling loop in backup_running_vm()
2. Add exit after cleanup on qemu-img convert failure in
   backup_stopped_vm() to stop processing subsequent disks
3. Add VM state check and virsh resume to cleanup() so paused VMs
   are automatically resumed after backup failure

Fixes apache#12821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant