Properly handle paused VirtualBox VMs [GH-1184]
This commit is contained in:
parent
c3bacf3e1d
commit
9d2f26604e
|
@ -80,6 +80,7 @@ IMPROVEMENTS / BUG FIXES:
|
|||
- Box adding doesn't use `/tmp` anymore which can avoid some cross-device
|
||||
copy issues. [GH-1199]
|
||||
- Vagrant works properly in folders with strange characters. [GH-1223]
|
||||
- Vagrant properly handles "paused" VirtualBox machines. [GH-1184]
|
||||
|
||||
## 1.0.6 (December 21, 2012)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ module VagrantPlugins
|
|||
autoload :ForwardPorts, File.expand_path("../action/forward_ports", __FILE__)
|
||||
autoload :HostName, File.expand_path("../action/host_name", __FILE__)
|
||||
autoload :Import, File.expand_path("../action/import", __FILE__)
|
||||
autoload :IsPaused, File.expand_path("../action/is_paused", __FILE__)
|
||||
autoload :IsRunning, File.expand_path("../action/is_running", __FILE__)
|
||||
autoload :IsSaved, File.expand_path("../action/is_saved", __FILE__)
|
||||
autoload :MatchMACAddress, File.expand_path("../action/match_mac_address", __FILE__)
|
||||
|
@ -110,6 +111,12 @@ module VagrantPlugins
|
|||
if env[:result]
|
||||
b2.use CheckAccessible
|
||||
b2.use DiscardState
|
||||
|
||||
b2.use Call, IsPaused do |env2, b3|
|
||||
next if !env2[:result]
|
||||
b3.use Resume
|
||||
end
|
||||
|
||||
b2.use Call, GracefulHalt, :poweroff, :running do |env2, b3|
|
||||
if !env2[:result]
|
||||
b3.use ForcedHalt
|
||||
|
@ -241,10 +248,18 @@ module VagrantPlugins
|
|||
if env2[:result]
|
||||
# The VM is saved, so just resume it
|
||||
b3.use action_resume
|
||||
else
|
||||
next
|
||||
end
|
||||
|
||||
b3.use Call, IsPaused do |env3, b4|
|
||||
if env3[:result]
|
||||
b4.use Resume
|
||||
next
|
||||
end
|
||||
|
||||
# The VM is not saved, so we must have to boot it up
|
||||
# like normal. Boot!
|
||||
b3.use action_boot
|
||||
b4.use action_boot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
module VagrantPlugins
|
||||
module ProviderVirtualBox
|
||||
module Action
|
||||
class IsPaused
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
# Set the result to be true if the machine is paused.
|
||||
env[:result] = env[:machine].state.id == :paused
|
||||
|
||||
# Call the next if we have one (but we shouldn't, since this
|
||||
# middleware is built to run with the Call-type middlewares)
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,12 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def call(env)
|
||||
if env[:machine].provider.state.id == :saved
|
||||
current_state = env[:machine].provider.state.id
|
||||
|
||||
if current_state == :paused
|
||||
env[:ui].info I18n.t("vagrant.actions.vm.resume.unpausing")
|
||||
env[:machine].provider.driver.resume
|
||||
elsif current_state == :saved
|
||||
env[:ui].info I18n.t("vagrant.actions.vm.resume.resuming")
|
||||
env[:action_runner].run(Boot, env)
|
||||
end
|
||||
|
|
|
@ -93,6 +93,7 @@ module VagrantPlugins
|
|||
:read_state,
|
||||
:read_used_ports,
|
||||
:read_vms,
|
||||
:resume,
|
||||
:set_mac_address,
|
||||
:set_name,
|
||||
:share_folders,
|
||||
|
|
|
@ -438,6 +438,11 @@ module VagrantPlugins
|
|||
nil
|
||||
end
|
||||
|
||||
def resume
|
||||
@logger.debug("Resuming paused VM...")
|
||||
execute("controlvm", @uuid, "resume")
|
||||
end
|
||||
|
||||
def start(mode)
|
||||
command = ["startvm", @uuid, "--type", mode.to_s]
|
||||
r = raw(*command)
|
||||
|
|
|
@ -438,6 +438,11 @@ module VagrantPlugins
|
|||
nil
|
||||
end
|
||||
|
||||
def resume
|
||||
@logger.debug("Resuming paused VM...")
|
||||
execute("controlvm", @uuid, "resume")
|
||||
end
|
||||
|
||||
def start(mode)
|
||||
command = ["startvm", @uuid, "--type", mode.to_s]
|
||||
r = raw(*command)
|
||||
|
|
|
@ -423,6 +423,11 @@ module VagrantPlugins
|
|||
nil
|
||||
end
|
||||
|
||||
def resume
|
||||
@logger.debug("Resuming paused VM...")
|
||||
execute("controlvm", @uuid, "resume")
|
||||
end
|
||||
|
||||
def start(mode)
|
||||
command = ["startvm", @uuid, "--type", mode.to_s]
|
||||
r = raw(*command)
|
||||
|
|
|
@ -675,6 +675,8 @@ en:
|
|||
beginning: "Running provisioner: %{provisioner}..."
|
||||
resume:
|
||||
resuming: Resuming suspended VM...
|
||||
unpausing: |-
|
||||
Unpausing the VM...
|
||||
share_folders:
|
||||
creating: Creating shared folders metadata...
|
||||
mounting: Mounting shared folders...
|
||||
|
|
Loading…
Reference in New Issue