From ede053f6bc2375aaba79a82a01568f2a698177a4 Mon Sep 17 00:00:00 2001 From: Dmitry Tretyakov Date: Tue, 16 Jan 2018 12:32:22 +0100 Subject: [PATCH] Add ability to control nested hardware virtualization Issue: #45 --- README.md | 1 + driver/vm.go | 2 ++ step_hardware.go | 2 ++ 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 64b93dd49..ca477d2ba 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Hardware customization: * `RAM_reservation` - Amount of reserved RAM in MB. Inherited from source VM by default. * `RAM_reserve_all` - Reserve all available RAM (bool). `false` by default. Cannot be used together with `RAM_reservation`. * `disk_size` - Change the disk size (in GB). VM should have a single disk. Cannot be used together with `linked_clone`. +* `NestedHV` - Allows to enable nested hardware virtualization for VM. Provisioning: * `ssh_username` - [**mandatory**] username in guest OS. diff --git a/driver/vm.go b/driver/vm.go index 01eab2cd0..4c23904b0 100644 --- a/driver/vm.go +++ b/driver/vm.go @@ -31,6 +31,7 @@ type HardwareConfig struct { RAMReservation int64 RAMReserveAll bool DiskSize int64 + NestedHV bool } func (d *Driver) NewVM(ref *types.ManagedObjectReference) *VirtualMachine { @@ -165,6 +166,7 @@ func (vm *VirtualMachine) Configure(config *HardwareConfig) error { confSpec.MemoryAllocation = &ramSpec confSpec.MemoryReservationLockedToMax = &config.RAMReserveAll + confSpec.NestedHVEnabled = &config.NestedHV if config.DiskSize > 0 { devices, err := vm.vm.Device(vm.driver.ctx) diff --git a/step_hardware.go b/step_hardware.go index aaf620b50..ed7a01c48 100644 --- a/step_hardware.go +++ b/step_hardware.go @@ -15,6 +15,7 @@ type HardwareConfig struct { RAMReservation int64 `mapstructure:"RAM_reservation"` RAMReserveAll bool `mapstructure:"RAM_reserve_all"` DiskSize int64 `mapstructure:"disk_size"` + NestedHV bool `mapstructure:"NestedHV"` } func (c *HardwareConfig) Prepare() []error { @@ -46,6 +47,7 @@ func (s *StepConfigureHardware) Run(state multistep.StateBag) multistep.StepActi RAMReservation: s.config.RAMReservation, RAMReserveAll: s.config.RAMReserveAll, DiskSize: s.config.DiskSize, + NestedHV: s.config.NestedHV, }) if err != nil { state.Put("error", err)