From 4894873971ce1a6fa0c64b7a3f5fc622c45fc97c Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Fri, 11 Jan 2019 19:00:54 -0600 Subject: [PATCH] Added logic to the vmware-iso builder that appends the number of cores per socket to the vmx in `stepCreateVmx`. --- builder/vmware/iso/step_create_vmx.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 {