Skip to content

Commit 8a2434d

Browse files
committed
nasbackup.sh: keep cleanup() best-effort if domstate fails
With set -eo pipefail, a non-zero virsh domstate (libvirt unavailable or the domain gone) in the vm_state assignment would abort cleanup() before the rm/umount/rmdir. Append '|| true' so cleanup always runs to completion. Addresses the review suggestion (Copilot, endorsed by @abh1sar and @weizhouapache). Signed-off-by: James Peru <jmsperu@gmail.com>
1 parent 23be8d4 commit 8a2434d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/vm/hypervisor/kvm/nasbackup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ cleanup() {
228228
# remaining indefinitely paused when the backup job fails (e.g. due
229229
# to storage full or I/O errors on the backup target)
230230
local vm_state
231-
vm_state=$(virsh -c qemu:///system domstate "$VM" 2>/dev/null)
231+
vm_state=$(virsh -c qemu:///system domstate "$VM" 2>/dev/null || true)
232232
if [[ "$vm_state" == "paused" ]]; then
233233
log -ne "Resuming paused VM $VM during backup cleanup"
234234
if ! virsh -c qemu:///system resume "$VM" > /dev/null 2>&1; then

0 commit comments

Comments
 (0)