Adding nested virtualization support
This commit is contained in:
parent
6342e1525d
commit
f94c2cd2f7
|
@ -72,7 +72,7 @@ type Driver interface {
|
||||||
|
|
||||||
DeleteVirtualMachine(string) error
|
DeleteVirtualMachine(string) error
|
||||||
|
|
||||||
SetVirtualMachineCpu(string, uint) error
|
SetVirtualMachineCpu(string, uint, bool) error
|
||||||
|
|
||||||
SetSecureBoot(string, bool) error
|
SetSecureBoot(string, bool) error
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,8 @@ func (d *HypervPS4Driver) DeleteVirtualMachine(vmName string) error {
|
||||||
return hyperv.DeleteVirtualMachine(vmName)
|
return hyperv.DeleteVirtualMachine(vmName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *HypervPS4Driver) SetVirtualMachineCpu(vmName string, cpu uint) error {
|
func (d *HypervPS4Driver) SetVirtualMachineCpu(vmName string, cpu uint, exposeVirtualizationExtensions bool) error {
|
||||||
return hyperv.SetVirtualMachineCpu(vmName, cpu)
|
return hyperv.SetVirtualMachineCpu(vmName, cpu, exposeVirtualizationExtensions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *HypervPS4Driver) SetSecureBoot(vmName string, enable bool) error {
|
func (d *HypervPS4Driver) SetSecureBoot(vmName string, enable bool) error {
|
||||||
|
|
|
@ -22,6 +22,7 @@ type StepCreateVM struct {
|
||||||
Generation uint
|
Generation uint
|
||||||
Cpu uint
|
Cpu uint
|
||||||
EnableSecureBoot bool
|
EnableSecureBoot bool
|
||||||
|
ExposeVirtualizationExtensions bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction {
|
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
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
err = driver.SetVirtualMachineCpu(s.VMName, s.Cpu)
|
err = driver.SetVirtualMachineCpu(s.VMName, s.Cpu, s.ExposeVirtualizationExtensions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error creating setting virtual machine cpu: %s", err)
|
err := fmt.Errorf("Error creating setting virtual machine cpu: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
|
@ -89,6 +89,7 @@ type Config struct {
|
||||||
Cpu uint `mapstructure:"cpu"`
|
Cpu uint `mapstructure:"cpu"`
|
||||||
Generation uint `mapstructure:"generation"`
|
Generation uint `mapstructure:"generation"`
|
||||||
EnableSecureBoot bool `mapstructure:"enable_secure_boot"`
|
EnableSecureBoot bool `mapstructure:"enable_secure_boot"`
|
||||||
|
EnableVirtualizationExtensions `mapstructure:"enable_virtualization_extensions`
|
||||||
|
|
||||||
Communicator string `mapstructure:"communicator"`
|
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,
|
Generation: b.config.Generation,
|
||||||
Cpu: b.config.Cpu,
|
Cpu: b.config.Cpu,
|
||||||
EnableSecureBoot: b.config.EnableSecureBoot,
|
EnableSecureBoot: b.config.EnableSecureBoot,
|
||||||
|
EnableVirtualizationExtensions: b.config.EnableVirtualizationExtensions
|
||||||
},
|
},
|
||||||
&hypervcommon.StepEnableIntegrationService{},
|
&hypervcommon.StepEnableIntegrationService{},
|
||||||
|
|
||||||
|
|
|
@ -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 = `
|
var script = `
|
||||||
param([string]$vmName, [int]$cpu)
|
param([string]$vmName, [int]$cpu, [bool]$exposeVirtualizationExtensions)
|
||||||
Set-VMProcessor -VMName $vmName -Count $cpu
|
Set-VMProcessor -VMName $vmName -Count $cpu -exposeVirtualizationExtensions $exposeVirtualizationExtensions
|
||||||
`
|
`
|
||||||
|
|
||||||
var ps powershell.PowerShellCmd
|
var ps powershell.PowerShellCmd
|
||||||
|
|
Loading…
Reference in New Issue