diff --git a/lib/vagrant-libvirt/action/destroy_domain.rb b/lib/vagrant-libvirt/action/destroy_domain.rb index 9948ab6..6d13d6a 100644 --- a/lib/vagrant-libvirt/action/destroy_domain.rb +++ b/lib/vagrant-libvirt/action/destroy_domain.rb @@ -44,7 +44,16 @@ module VagrantPlugins libvirt_disk = env[:libvirt_compute].volumes.all.select do |x| x.name == diskname end.first - libvirt_disk.destroy if libvirt_disk + if libvirt_disk + libvirt_disk.destroy + elsif disk[:path] + poolname = env[:machine].provider_config.storage_pool_name + libvirt_disk = env[:libvirt_compute].volumes.all.select do |x| + # FIXME can remove pool/target.img and pool/123/target.img + x.path =~ /\/#{disk[:path]}$/ && x.pool_name == poolname + end.first + libvirt_disk.destroy if libvirt_disk + end end # remove root storage