Merge pull request #8325 from chrisroberts/enhancement/nested-hyperv

Nested Hyper-V
This commit is contained in:
Chris Roberts 2017-03-17 14:19:58 -07:00 committed by GitHub
commit 1c1adcad9a
5 changed files with 17 additions and 2 deletions

View File

@ -21,10 +21,12 @@ module VagrantPlugins
differencing_disk = env[:machine].provider_config.differencing_disk
auto_start_action = env[:machine].provider_config.auto_start_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 startup memory is #{memory}") if memory
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 differencing disk instead of cloning") if differencing_disk
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_stop_action] = auto_stop_action if auto_stop_action
options[:differencing_disk] = differencing_disk if differencing_disk
options[:enable_virtualization_extensions] = "$True" if enable_virtualization_extensions and enable_virtualization_extensions == true
env[:ui].detail("Creating and registering the VM...")
server = env[:machine].provider.driver.import(options)

View File

@ -14,6 +14,7 @@ module VagrantPlugins
attr_accessor :differencing_disk # Create differencing disk instead of cloning whole VHD [Boolean]
attr_accessor :auto_start_action #action on automatic start of VM. Values: Nothing, StartIfRunning, Start
attr_accessor :auto_stop_action #action on automatic stop of VM. Values: ShutDown, TurnOff, Save
attr_accessor :enable_virtualization_extensions # Enable virtualization extensions (nested virtualization). Values: true, false
def initialize
@ip_address_timeout = UNSET_VALUE
@ -26,6 +27,7 @@ module VagrantPlugins
@differencing_disk = UNSET_VALUE
@auto_start_action = UNSET_VALUE
@auto_stop_action = UNSET_VALUE
@enable_virtualization_extensions = UNSET_VALUE
end
def finalize!
@ -41,6 +43,7 @@ module VagrantPlugins
@differencing_disk = false if @differencing_disk == UNSET_VALUE
@auto_start_action = nil if @auto_start_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
def validate(machine)

View File

@ -10,7 +10,8 @@ Param(
[string]$cpus=$null,
[string]$vmname=$null,
[string]$auto_start_action=$null,
[string]$auto_stop_action=$null
[string]$auto_stop_action=$null,
[string]$enable_virtualization_extensions=$False
)
# 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
[regex]$rx="\d"

View File

@ -29,3 +29,6 @@ you may set. A complete reference is shown below:
virtual machine to report an IP address. This defaults to 120 seconds.
This may have to be increased if your VM takes longer to boot.
* `differencing_disk` (boolean) - Switch to use differencing disk intead of cloning whole VHD.
* `enable_virtualization_extensions` (boolean) - Enable virtualization extensions for the virtual CPUs.
This allows Hyper-V to be nested and run inside another Hyper-VM VM. It requires Windows 10 - 1511 (build 10586) or newer.
Default is not defined. This will be disabled if not set.

View File

@ -14,7 +14,7 @@ Vagrant comes with support out of the box for [Hyper-V](https://en.wikipedia.org
a native hypervisor written by Microsoft. Hyper-V is available by default for
almost all Windows 8.1 installs.
The Hyper-V provider is compatible with Windows 8.1 only. Prior versions
The Hyper-V provider is compatible with Windows 8.1 and later only. Prior versions
of Hyper-V do not include the necessary APIs for Vagrant to work.
Hyper-V must be enabled prior to using the provider. Most Windows installations