Apologies if this has been asked before...
Is it possible to set the cpuid.coresPerSocket advanced configuration using PowerCLI?
Hello, lldmka-
Yes, it is possible. Thanks to the new numCoresPerSocket property in v5 of the vSphere API (see http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/vim.vm.ConfigSpec....), you can do this like:
## create the VirtualMachineConfigSpec with which to reconfig the VM
$spec = New-Object -Type VMware.Vim.VirtualMachineConfigSpec -Property @{"NumCoresPerSocket" = 2}
## get the VM, and, using the ExtensionData to access the API, reconfig the VM
(Get-VM myVM).ExtensionData.ReconfigVM_Task($spec)
Or, if you are still on v4.x, you can use the ol' ExtraConfig property of the VirtualMachineConfigSpec, like:
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{
ExtraConfig = New-Object VMware.Vim.optionvalue -Property @{
Key = "cpuid.coresPerSocket"
## set the value to 4
Value = 4
} ## end new-object
} ## end new-object
## get the VM, and, using the ExtensionData to access the API, reconfig the VM
(Get-VM myVM).ExtensionData.ReconfigVM_Task($spec)
Both of these take a power cycle of the VM to take effect, I believe. Enjoy.
Hello, lldmka-
Yes, it is possible. Thanks to the new numCoresPerSocket property in v5 of the vSphere API (see http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/vim.vm.ConfigSpec....), you can do this like:
## create the VirtualMachineConfigSpec with which to reconfig the VM
$spec = New-Object -Type VMware.Vim.VirtualMachineConfigSpec -Property @{"NumCoresPerSocket" = 2}
## get the VM, and, using the ExtensionData to access the API, reconfig the VM
(Get-VM myVM).ExtensionData.ReconfigVM_Task($spec)
Or, if you are still on v4.x, you can use the ol' ExtraConfig property of the VirtualMachineConfigSpec, like:
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{
ExtraConfig = New-Object VMware.Vim.optionvalue -Property @{
Key = "cpuid.coresPerSocket"
## set the value to 4
Value = 4
} ## end new-object
} ## end new-object
## get the VM, and, using the ExtensionData to access the API, reconfig the VM
(Get-VM myVM).ExtensionData.ReconfigVM_Task($spec)
Both of these take a power cycle of the VM to take effect, I believe. Enjoy.
Thanks Matt, much appreciated!
This works fine for me, but I receive an error upon opening the CPU portion of the edit settings GUI for the VM that was changed. Any ideas? Adjusting it manually in the GUI doesn't produce the errors.
$spec = New-Object -Type VMware.Vim.VirtualMachineConfigSpec -Property @{"NumCoresPerSocket" = 3}
(Get-VM Test5).ExtensionData.ReconfigVM_Task($spec)
error -
Number of cores per socket cannot be greater than number of virtual CPUs
Matt's script is does not modify the numCPUs value. This should also be done:
$spec = New-Object -Type VMware.Vim.VirtualMachineConfigSpec -Property @{"NumCoresPerSocket" = 3}
should be:
$spec = New-Object -Type VMware.Vim.VirtualMachineConfigSpec -Property @{"NumCoresPerSocket" = 3;"numCPUs" = 3}
FYI.
The vmx files are exactly the same except for the cpuid.coresPerSocket difference. I am thinking this has something to do with how the script changes the setting - for some reason it's not refreshed or implemented the same?
@Robert - trying this now. Thanks.
That worked (thanks), but trying now to wrap my head around a disconnect I am having. I was thinking that the below for example would result in a VM with 3 as the "Number of virtual sockets" or "numvcpus" in .vmx and a value of 3 also for the "Number of cores per socket" or "cpuid.coresPerSocket" in .vmx
"NumCoresPerSocket" = 3;"NumCPUs" = 3
Any light you can shed on this would be much appreciated.
Thanks
If you divide the numCPUs by the numCoresPerSocket then you get the number of virtual sockets. So if you want to have 3 for the number of virtual sockets then you have to specify 9 for the numCPUs.
My have to refresh a bit on the details in the vmx as I thought these settings in the vmx match up with what's displayed in the GUI, but not in this case.
numvcpus = "3"
cpuid.coresPerSocket = "3"
Got it. Thanks!