Fix Hyper-v and VirtualBox check

Prior to this commit, the hyper-v and virtualbox system crash check
existed within the initialize function of the virtualbox provider. That
caused an issue when running with other providers, because the
virtualbox provider still gets initialized even if not used. This commit
changes that by placing the check inside of one of the virtualbox
provider actions that checks if virtualbox is installed and ready to
use. This action is action is used by the main vbox provider actions,
and should not be called when other providers are being used with
Vagrant.
This commit is contained in:
Brian Cain 2018-02-23 11:24:30 -08:00
parent 3e01df47a4
commit f2954a64c6
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
2 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,5 @@
require 'vagrant/util/platform'
module VagrantPlugins module VagrantPlugins
module ProviderVirtualBox module ProviderVirtualBox
module Action module Action
@ -5,6 +7,7 @@ module VagrantPlugins
class CheckVirtualbox class CheckVirtualbox
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@logger = Log4r::Logger.new("vagrant::provider::virtualbox")
end end
def call(env) def call(env)
@ -13,6 +16,12 @@ module VagrantPlugins
# which will break us out of execution of the middleware sequence. # which will break us out of execution of the middleware sequence.
Driver::Meta.new.verify! Driver::Meta.new.verify!
if Vagrant::Util::Platform.windows? && Vagrant::Util::Platform.windows_hyperv_enabled?
@logger.error("Virtualbox and Hyper-V cannot be used together at the same time on Windows and will result in a system crash.")
raise Vagrant::Errors::HypervVirtualBoxError
end
# Carry on. # Carry on.
@app.call(env) @app.call(env)
end end

View File

@ -78,12 +78,6 @@ module VagrantPlugins
end end
end end
if Vagrant::Util::Platform.windows? && Vagrant::Util::Platform.windows_hyperv_enabled?
@logger.error("Virtualbox and Hyper-V cannot be used together at the same time on Windows and will result in a system crash.")
raise Vagrant::Errors::HypervVirtualBoxError
end
# Fall back to hoping for the PATH to work out # Fall back to hoping for the PATH to work out
@vboxmanage_path ||= "VBoxManage" @vboxmanage_path ||= "VBoxManage"
@logger.info("VBoxManage path: #{@vboxmanage_path}") @logger.info("VBoxManage path: #{@vboxmanage_path}")