diff --git a/lib/vagrant-parallels/action.rb b/lib/vagrant-parallels/action.rb index dfb85608..a45a1a92 100644 --- a/lib/vagrant-parallels/action.rb +++ b/lib/vagrant-parallels/action.rb @@ -82,11 +82,8 @@ def self.action_halt next end - b1.use Call, IsState, :suspended do |env2, b2| - if env2[:result] - b2.use Resume - end - end + # Resume/Unpause the VM if needed. + b1.use Resume b1.use Call, GracefulHalt, :stopped, :running do |env2, b2| if !env2[:result] @@ -285,14 +282,22 @@ def self.action_start b1.use Call, IsState, :suspended do |env2, b2| if env2[:result] - # The VM is suspended, so just resume it + # The VM is suspended, go to resume b2.use action_resume next end - # The VM is not saved, so we must have to boot it up - # like normal. Boot! - b2.use action_boot + b2.use Call, IsState, :paused do |env3, b3| + if env3[:result] + # The VM is paused, just run the Resume action to unpause it + b3.use Resume + next + end + + # The VM is not suspended or paused, so we must have to + # boot it up like normal. Boot! + b3.use action_boot + end end end end diff --git a/lib/vagrant-parallels/action/resume.rb b/lib/vagrant-parallels/action/resume.rb index fcd40e20..b8e977f1 100644 --- a/lib/vagrant-parallels/action/resume.rb +++ b/lib/vagrant-parallels/action/resume.rb @@ -9,9 +9,13 @@ def initialize(app, env) def call(env) current_state = env[:machine].state.id + # Driver method "resume" works for suspended and paused state as well if current_state == :suspended env[:ui].info I18n.t('vagrant.actions.vm.resume.resuming') env[:machine].provider.driver.resume + elsif current_state == :paused + env[:ui].info I18n.t('vagrant.actions.vm.resume.unpausing') + env[:machine].provider.driver.resume end @app.call(env)