From cb499833b53b90c8dd4da2c1ec83c86ecae7e7ea Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Mon, 7 Aug 2017 18:21:37 +0200 Subject: ensure volumes are free'd if there are no errors Make sure to only then free volumes if there are no errors. This fixes #151. Signed-off-by: Thomas Hipp --- libvirt/resource_libvirt_domain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 844b6cf7..975b1b93 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -804,11 +804,11 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error { virVol, err = virPool.LookupStorageVolByName(diskDef.Source.Volume) } - defer virVol.Free() if err != nil { return fmt.Errorf("Error retrieving volume for disk: %s", err) } + defer virVol.Free() virVolKey, err := virVol.GetKey() if err != nil { -- cgit v1.2.3