VMware Cloud Community
lldmka
Enthusiast
Enthusiast
Jump to solution

cpuid.coresPerSocket

Apologies if this has been asked before...

Is it possible to set the cpuid.coresPerSocket advanced configuration using PowerCLI?

1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

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.

View solution in original post

0 Kudos
10 Replies
mattboren
Expert
Expert
Jump to solution

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.

0 Kudos
lldmka
Enthusiast
Enthusiast
Jump to solution

Thanks Matt, much appreciated!

0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

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

error.JPG

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
mark_chuman
Hot Shot
Hot Shot
Jump to solution

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?

0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

@Robert - trying this now.  Thanks.

0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

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

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

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"

error2.JPG

0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

Got it.  Thanks!

0 Kudos