diff --git a/builder/vsphere/driver/vm.go b/builder/vsphere/driver/vm.go index aa1bae2fc..fa6a5e987 100644 --- a/builder/vsphere/driver/vm.go +++ b/builder/vsphere/driver/vm.go @@ -53,6 +53,7 @@ type NIC struct { type CreateConfig struct { DiskThinProvisioned bool + DiskEagerlyScrub bool DiskControllerType string // example: "scsi", "pvscsi" DiskSize int64 @@ -503,6 +504,7 @@ func addDisk(_ *Driver, devices object.VirtualDeviceList, config *CreateConfig) Backing: &types.VirtualDiskFlatVer2BackingInfo{ DiskMode: string(types.VirtualDiskModePersistent), ThinProvisioned: types.NewBool(config.DiskThinProvisioned), + EagerlyScrub: types.NewBool(config.DiskEagerlyScrub), }, }, CapacityInKB: config.DiskSize * 1024, diff --git a/builder/vsphere/iso/step_create.go b/builder/vsphere/iso/step_create.go index a78c5d34e..dade6847f 100644 --- a/builder/vsphere/iso/step_create.go +++ b/builder/vsphere/iso/step_create.go @@ -42,6 +42,8 @@ type CreateConfig struct { DiskSize int64 `mapstructure:"disk_size"` // Enable VMDK thin provisioning for VM. Defaults to `false`. DiskThinProvisioned bool `mapstructure:"disk_thin_provisioned"` + // Enable VMDK eager scrubbing for VM. Defaults to `false`. + DiskEagerlyScrub bool `mapstructure:"disk_eagerly_scrub"` // Set network VM will be connected to. Network string `mapstructure:"network"` // Set VM network card type. Example `vmxnet3`. @@ -115,6 +117,7 @@ func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multiste vm, err = d.CreateVM(&driver.CreateConfig{ DiskThinProvisioned: s.Config.DiskThinProvisioned, + DiskEagerlyScrub: s.Config.DiskEagerlyScrub, DiskControllerType: s.Config.DiskControllerType, DiskSize: s.Config.DiskSize, Name: s.Location.VMName,