diff options
-rw-r--r-- | libvirt/resource_libvirt_domain.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 5861eeea..924467a6 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -156,9 +156,17 @@ func resourceLibvirtDomainExists(d *schema.ResourceData, meta interface{}) (bool if virConn == nil { return false, fmt.Errorf("The libvirt connection was nil.") } + domain, err := virConn.LookupDomainByUUIDString(d.Id()) + if err != nil { + if err.(libvirt.Error).Code == libvirt.ERR_NO_DOMAIN { + return false, nil + } + return false, err + } defer domain.Free() - return err == nil, err + + return true, nil } func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error { |