diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 5a46c14ef..d812aab49 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -429,12 +429,19 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist s.tempDir = vmxDir } - /// Now to handle options that will modify the template + /// Now to handle options that will modify the template without using "vmxTemplateData" vmxData := vmwcommon.ParseVMX(vmxContents) + + // If no cpus were specified, then remove the entry to use the default if vmxData["numvcpus"] == "" { delete(vmxData, "numvcpus") } + // If some number of cores were specified, then update "cpuid.coresPerSocket" with the requested value + if config.HWConfig.CoreCount > 0 { + vmxData["cpuid.corespersocket"] = strconv.Itoa(config.HWConfig.CoreCount) + } + /// Write the vmxData to the vmxPath vmxPath := filepath.Join(vmxDir, config.VMName+".vmx") if err := vmwcommon.WriteVMX(vmxPath, vmxData); err != nil {