mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
commit
15d12d1053
@ -207,6 +207,8 @@ end
|
||||
* `boot` - Change the boot order and enables the boot menu. Possible options are "hd", "network", "cdrom". Defaults to "hd" with boot menu disabled. When "network" is set without "hd", only all NICs will be tried; see below for more detail.
|
||||
* `nic_adapter_count` - Defaults to '8'. Only use case for increasing this count is for VMs that virtualize switches such as Cumulus Linux. Max value for Cumulus Linux VMs is 33.
|
||||
* `uuid` - Force a domain UUID. Defaults to autogenerated value by libvirt if not set.
|
||||
* `suspend_mode` - What is done on vagrant suspend. Possible values: 'pause', 'managedsave'. Pause mode executes a la `virsh suspend`, which just pauses execution of a VM, not freeing resources. Managed save mode does a la `virsh managedsave` which frees resources suspending a domain.
|
||||
|
||||
|
||||
|
||||
Specific domain settings can be set for each domain separately in multi-VM
|
||||
|
@ -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?
|
||||
|
@ -11,7 +11,28 @@ module VagrantPlugins
|
||||
def call(env)
|
||||
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
||||
raise Errors::NoDomainError if domain == nil
|
||||
|
||||
config = env[:machine].provider_config
|
||||
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
|
||||
if config.suspend_mode == 'managedsave'
|
||||
if libvirt_domain.has_managed_save?
|
||||
env[:result] = libvirt_domain.has_managed_save?
|
||||
else
|
||||
env[:result] = domain.state.to_s == 'paused'
|
||||
if env[:result]
|
||||
env[:ui].warn('One time switching to pause suspend mode, found a paused VM.')
|
||||
config.suspend_mode = 'pause'
|
||||
end
|
||||
end
|
||||
else
|
||||
if libvirt_domain.has_managed_save?
|
||||
env[:ui].warn('One time switching to managedsave suspend mode, state found.')
|
||||
env[:result] = true
|
||||
config.suspend_mode = 'managedsave'
|
||||
else
|
||||
env[:result] = domain.state.to_s == 'paused'
|
||||
end
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
@ -16,7 +16,14 @@ module VagrantPlugins
|
||||
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
||||
raise Errors::NoDomainError if domain == nil
|
||||
|
||||
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
|
||||
config = env[:machine].provider_config
|
||||
if config.suspend_mode == 'managedsave'
|
||||
domain.start
|
||||
else
|
||||
domain.resume
|
||||
end
|
||||
|
||||
@logger.info("Machine #{env[:machine].id} is resumed.")
|
||||
|
||||
@app.call(env)
|
||||
|
@ -17,7 +17,19 @@ module VagrantPlugins
|
||||
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
||||
raise Errors::NoDomainError if domain == nil
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
@logger.info("Machine #{env[:machine].id} is suspended ")
|
||||
|
||||
@app.call(env)
|
||||
|
@ -90,6 +90,9 @@ module VagrantPlugins
|
||||
# Inputs
|
||||
attr_accessor :inputs
|
||||
|
||||
# Suspend mode
|
||||
attr_accessor :suspend_mode
|
||||
|
||||
def initialize
|
||||
@uri = UNSET_VALUE
|
||||
@driver = UNSET_VALUE
|
||||
@ -140,6 +143,9 @@ module VagrantPlugins
|
||||
|
||||
# Inputs
|
||||
@inputs = UNSET_VALUE
|
||||
|
||||
# Suspend mode
|
||||
@suspend_mode = UNSET_VALUE
|
||||
end
|
||||
|
||||
def boot(device)
|
||||
@ -354,7 +360,13 @@ module VagrantPlugins
|
||||
# Storage
|
||||
@disks = [] if @disks == UNSET_VALUE
|
||||
@cdroms = [] if @cdroms == UNSET_VALUE
|
||||
|
||||
# Inputs
|
||||
@inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE
|
||||
|
||||
# Suspend mode
|
||||
@suspend_mode = "pause" if @suspend_mode == UNSET_VALUE
|
||||
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
|
Loading…
Reference in New Issue
Block a user