suspend to disk? #411

* Error handler in case of error when saving domain state with a hint
how to handle the problem. 
* Managed saves are deleted prior to undefining a domain.

Task-Url: https://github.com/pradels/vagrant-libvirt/issues/411
Signed-off-by: Max Kutsevol <max@coolvds.com>
This commit is contained in:
Max Kutsevol 2015-09-27 15:13:22 +03:00
parent 837a344724
commit 0345bc3bd0
2 changed files with 11 additions and 1 deletions

View File

@ -28,6 +28,11 @@ module VagrantPlugins
end
end
# must remove managed saves
if libvirt_domain.has_managed_save?
libvirt_domain.managed_save_remove
end
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
if env[:machine].provider_config.disks.empty?

View File

@ -20,7 +20,12 @@ module VagrantPlugins
config = env[:machine].provider_config
if config.suspend_mode == 'managedsave'
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
libvirt_domain.managed_save
begin
libvirt_domain.managed_save
rescue => e
env[:ui].error("Error doing a managed save for domain. It may have entered a paused state.
Check the output of `virsh managedsave DOMAIN_NAME --verbose` on the VM host, error: #{e.message}")
end
else
domain.suspend
end