Copilot commented on code in PR #12822:
URL: https://github.com/apache/cloudstack/pull/12822#discussion_r2972857964
##########
scripts/vm/hypervisor/kvm/nasbackup.sh:
##########
@@ -222,6 +224,19 @@ mount_operation() {
cleanup() {
local status=0
+ # Resume the VM if it was paused during backup to prevent it from
+ # remaining indefinitely paused when the backup job fails (e.g. due
+ # to storage full or I/O errors on the backup target)
+ local vm_state
+ vm_state=$(virsh -c qemu:///system domstate "$VM" 2>/dev/null)
Review Comment:
Because the script runs with `set -e`, the `vm_state=$(virsh ... domstate
...)` assignment will cause `cleanup()` (and the whole script) to exit
immediately if `virsh domstate` returns non-zero (e.g., libvirt unavailable,
domain not found). That would skip the rest of cleanup (rm/umount/rmdir) and
may leave the mount behind. Consider guarding the domstate call (e.g., `if
vm_state=$(virsh ... 2>/dev/null); then ... fi` or `vm_state=$(virsh ...
2>/dev/null || true)`) so cleanup best-effort behavior always runs even when
state detection fails.
```suggestion
vm_state=$(virsh -c qemu:///system domstate "$VM" 2>/dev/null || true)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]