diff --git a/builder/hyperv/common/driver.go b/builder/hyperv/common/driver.go index a62e3112b..8cfe67582 100644 --- a/builder/hyperv/common/driver.go +++ b/builder/hyperv/common/driver.go @@ -72,7 +72,7 @@ type Driver interface { DeleteVirtualMachine(string) error - SetVirtualMachineCpu(string, uint) error + SetVirtualMachineCpu(string, uint, bool) error SetSecureBoot(string, bool) error diff --git a/builder/hyperv/common/driver_ps_4.go b/builder/hyperv/common/driver_ps_4.go index 15d6c6817..df1355c59 100644 --- a/builder/hyperv/common/driver_ps_4.go +++ b/builder/hyperv/common/driver_ps_4.go @@ -177,8 +177,8 @@ func (d *HypervPS4Driver) DeleteVirtualMachine(vmName string) error { return hyperv.DeleteVirtualMachine(vmName) } -func (d *HypervPS4Driver) SetVirtualMachineCpu(vmName string, cpu uint) error { - return hyperv.SetVirtualMachineCpu(vmName, cpu) +func (d *HypervPS4Driver) SetVirtualMachineCpu(vmName string, cpu uint, exposeVirtualizationExtensions bool) error { + return hyperv.SetVirtualMachineCpu(vmName, cpu, exposeVirtualizationExtensions) } func (d *HypervPS4Driver) SetSecureBoot(vmName string, enable bool) error { diff --git a/builder/hyperv/common/step_create_vm.go b/builder/hyperv/common/step_create_vm.go index a23c393c9..e67942920 100644 --- a/builder/hyperv/common/step_create_vm.go +++ b/builder/hyperv/common/step_create_vm.go @@ -22,6 +22,7 @@ type StepCreateVM struct { Generation uint Cpu uint EnableSecureBoot bool + ExposeVirtualizationExtensions bool } func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction { @@ -46,7 +47,7 @@ func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - err = driver.SetVirtualMachineCpu(s.VMName, s.Cpu) + err = driver.SetVirtualMachineCpu(s.VMName, s.Cpu, s.ExposeVirtualizationExtensions) if err != nil { err := fmt.Errorf("Error creating setting virtual machine cpu: %s", err) state.Put("error", err) diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index ac3fbae85..92d192424 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -89,6 +89,7 @@ type Config struct { Cpu uint `mapstructure:"cpu"` Generation uint `mapstructure:"generation"` EnableSecureBoot bool `mapstructure:"enable_secure_boot"` + EnableVirtualizationExtensions `mapstructure:"enable_virtualization_extensions` Communicator string `mapstructure:"communicator"` @@ -298,6 +299,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Generation: b.config.Generation, Cpu: b.config.Cpu, EnableSecureBoot: b.config.EnableSecureBoot, + EnableVirtualizationExtensions: b.config.EnableVirtualizationExtensions }, &hypervcommon.StepEnableIntegrationService{}, diff --git a/powershell/hyperv/hyperv.go b/powershell/hyperv/hyperv.go index 32952520f..b75a5e0b7 100644 --- a/powershell/hyperv/hyperv.go +++ b/powershell/hyperv/hyperv.go @@ -217,11 +217,11 @@ New-VM -Name $vmName -Path $path -MemoryStartupBytes $memoryStartupBytes -NewVHD } } -func SetVirtualMachineCpu(vmName string, cpu uint) error { +func SetVirtualMachineCpu(vmName string, cpu uint, exposeVirtualizationExtensions bool) error { var script = ` -param([string]$vmName, [int]$cpu) -Set-VMProcessor -VMName $vmName -Count $cpu +param([string]$vmName, [int]$cpu, [bool]$exposeVirtualizationExtensions) +Set-VMProcessor -VMName $vmName -Count $cpu -exposeVirtualizationExtensions $exposeVirtualizationExtensions ` var ps powershell.PowerShellCmd