def cleanup(machine, _opts)
if machine.provider.driver.connection.nil?
raise Vagrant::Errors::Error('No libvirt connection')
end
@conn = machine.provider.driver.connection.client
begin
if machine.id && machine.id != ''
dom = @conn.lookup_domain_by_uuid(machine.id)
Nokogiri::XML(dom.xml_desc).xpath(
'/domain/devices/filesystem'
).each do |xml|
dom.detach_device(xml.to_s)
machine.ui.info 'Cleaned up shared folders'
end
end
rescue => e
machine.ui.error("could not detach device because: #{e}")
raise VagrantPlugins::ProviderLibvirt::Errors::DetachDeviceError,
error_message: e.message
end
end