Starting support for Hyper-V nested virtualization

This commit is contained in:
Patrick Lang 2016-08-17 22:41:32 -07:00 committed by Chris Roberts
parent 24ba508c86
commit 6900fc3904
3 changed files with 12 additions and 1 deletions

View File

@ -21,10 +21,12 @@ module VagrantPlugins
differencing_disk = env[:machine].provider_config.differencing_disk differencing_disk = env[:machine].provider_config.differencing_disk
auto_start_action = env[:machine].provider_config.auto_start_action auto_start_action = env[:machine].provider_config.auto_start_action
auto_stop_action = env[:machine].provider_config.auto_stop_action auto_stop_action = env[:machine].provider_config.auto_stop_action
enable_virtualization_extensions = env[:machine].provider_config.enable_virtualization_extensions
env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory
env[:ui].output("Configured startup memory is #{memory}") if memory env[:ui].output("Configured startup memory is #{memory}") if memory
env[:ui].output("Configured cpus number is #{cpus}") if cpus env[:ui].output("Configured cpus number is #{cpus}") if cpus
env[:ui].output("Configured enable virtualization extensions is #{enable_virtualization_extensions}") if enable_virtualization_extensions
env[:ui].output("Configured vmname is #{vmname}") if vmname env[:ui].output("Configured vmname is #{vmname}") if vmname
env[:ui].output("Configured differencing disk instead of cloning") if differencing_disk env[:ui].output("Configured differencing disk instead of cloning") if differencing_disk
env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action
@ -145,6 +147,7 @@ module VagrantPlugins
options[:auto_start_action] = auto_start_action if auto_start_action options[:auto_start_action] = auto_start_action if auto_start_action
options[:auto_stop_action] = auto_stop_action if auto_stop_action options[:auto_stop_action] = auto_stop_action if auto_stop_action
options[:differencing_disk] = differencing_disk if differencing_disk options[:differencing_disk] = differencing_disk if differencing_disk
options[:enable_virtualization_extensions] = enable_virtualization_extensions if enable_virtualization_extensions
env[:ui].detail("Creating and registering the VM...") env[:ui].detail("Creating and registering the VM...")
server = env[:machine].provider.driver.import(options) server = env[:machine].provider.driver.import(options)

View File

@ -26,6 +26,7 @@ module VagrantPlugins
@differencing_disk = UNSET_VALUE @differencing_disk = UNSET_VALUE
@auto_start_action = UNSET_VALUE @auto_start_action = UNSET_VALUE
@auto_stop_action = UNSET_VALUE @auto_stop_action = UNSET_VALUE
@enable_virtualization_extensions = UNSET_VALUE
end end
def finalize! def finalize!
@ -41,6 +42,7 @@ module VagrantPlugins
@differencing_disk = false if @differencing_disk == UNSET_VALUE @differencing_disk = false if @differencing_disk == UNSET_VALUE
@auto_start_action = nil if @auto_start_action == UNSET_VALUE @auto_start_action = nil if @auto_start_action == UNSET_VALUE
@auto_stop_action = nil if @auto_stop_action == UNSET_VALUE @auto_stop_action = nil if @auto_stop_action == UNSET_VALUE
@enable_virtualization_extensions = false if @enable_virtualization_extensions == UNSET_VALUE # TODO will this work?
end end
def validate(machine) def validate(machine)

View File

@ -10,7 +10,8 @@ Param(
[string]$cpus=$null, [string]$cpus=$null,
[string]$vmname=$null, [string]$vmname=$null,
[string]$auto_start_action=$null, [string]$auto_start_action=$null,
[string]$auto_stop_action=$null [string]$auto_stop_action=$null,
[bool]$enable_virtualization_extensions=$False
) )
# Include the following modules # Include the following modules
@ -170,6 +171,11 @@ if ($generation -ne 1) {
} }
} }
# Enable nested virtualization if configured
if ($enable_virtualization_extensions) {
Set-VMProcessor -VM $vm -ExposeVirtualizationExtensions $true
}
# A regular expression pattern to pull the number from controllers # A regular expression pattern to pull the number from controllers
[regex]$rx="\d" [regex]$rx="\d"