Handle pmsuspended resume and add state translation message (#1686)

Ensure there is a translation message for state and call the correct
wakeup depending on which form of suspend/pause the machine is in.

Closes: #1200
This commit is contained in:
Darragh Bailey 2022-12-03 08:05:58 +00:00 committed by GitHub
parent 612eb67f5f
commit 431cf867ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -20,7 +20,7 @@ module VagrantPlugins
if libvirt_domain.has_managed_save?
env[:result] = env[:machine].state.id == :shutoff
else
env[:result] = env[:machine].state.id == :paused
env[:result] = [:paused, :pmsuspended].include?(env[:machine].state.id)
if env[:result]
env[:ui].warn('One time switching to pause suspend mode, found a paused VM.')
config.suspend_mode = 'pause'
@ -32,7 +32,7 @@ module VagrantPlugins
env[:result] = [:shutoff, :paused].include?(env[:machine].state.id)
config.suspend_mode = 'managedsave'
else
env[:result] = env[:machine].state.id == :paused
env[:result] = [:paused, :pmsuspended].include?(env[:machine].state.id)
end
end

View File

@ -20,7 +20,9 @@ module VagrantPlugins
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'
if env[:machine].state.id == :pmsuspended
libvirt_domain.pmwakeup
elsif config.suspend_mode == 'managedsave'
domain.start
else
domain.resume

View File

@ -205,6 +205,8 @@ en:
states:
paused: |-
The Libvirt domain is suspended. Run `vagrant resume` to resume it.
pmsuspended: |-
The Libvirt domain is suspended. Run `vagrant resume` to resume it.
shutting_down: |-
The Libvirt domain is shutting down. Wait for it to complete and
then run `vagrant up` to start it or `vagrant destroy` to remove.