Skip to content

Commit 74035f2

Browse files
author
Cedric Bosdonnat
authored
Force removal of domains with snapshots or checkpoints (#899)
Libvirt needs special flags to actually delete a virtual machine if that one has a snapshot or a checkpoint. Use these flags when removing the domain resource to avoid any error if the VM has snapshots or checkpoints even added manually by the user.
1 parent ffb643b commit 74035f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libvirt/resource_libvirt_domain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ func resourceLibvirtDomainDelete(d *schema.ResourceData, meta interface{}) error
10731073
}
10741074
}
10751075

1076-
if err := virConn.DomainUndefineFlags(domain, libvirt.DomainUndefineNvram); err != nil {
1076+
if err := virConn.DomainUndefineFlags(domain, libvirt.DomainUndefineNvram|libvirt.DomainUndefineSnapshotsMetadata|libvirt.DomainUndefineManagedSave|libvirt.DomainUndefineCheckpointsMetadata); err != nil {
10771077
if e := err.(libvirt.Error); e.Code == uint32(libvirt.ErrNoSupport) || e.Code == uint32(libvirt.ErrInvalidArg) {
10781078
log.Printf("libvirt does not support undefine flags: will try again without flags")
10791079
if err := virConn.DomainUndefine(domain); err != nil {

0 commit comments

Comments
 (0)