kvm_qemu: Don't create snapshots for offline VMs

This commit is contained in:
deajan 2025-06-26 13:56:27 +02:00
parent af8c8f5df4
commit f8c729cd33

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Script ver 2025042801
# Script ver 2025062501
#TODO: blockcommit removes current snapshots, even if not done by cube
# - it's interesting to make housekeeping, let's make this an option
@ -68,6 +68,12 @@ function create_snapshot {
# Add VM xml description from virsh
## At least use a umask
if [ "$(virsh domstate $vm)" == "shut off" ]; then
log "Domain is not running, no need for snapshots"
return
fi
# Don't redirect direct virsh output or SELinux may complain that we cannot write with virsh context
xml=$(virsh dumpxml --security-info $vm || log "Failed to create XML file" "ERROR")
echo "${xml}" > "${ROOT_DIR}/${vm}.xml"