diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index d841242ff..226d99061 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -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] = enable_virtualization_extensions if enable_virtualization_extensions env[:ui].detail("Creating and registering the VM...") server = env[:machine].provider.driver.import(options) diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index 1726bd45f..e4b40bb1f 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -26,6 +26,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 +42,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) diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 index 16055e135..9622ea067 100644 --- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 @@ -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, + [bool]$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"