VMware Cloud Community
nicad449
Contributor
Contributor

Set Default CPU Masking options

What is the best method of resetting all the CPU Masking options back to default via the PowerCLI? I'm looking for the equivelent to choosing CPUID Mask > Advanced > Reset All to Default. I am able to easily set CPU masks (as per a number of helpful posts in this community), however finding out how to Reset them has proven more difficult.

Doug

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

This is in my opinion more difficult than it looks.

Afaik, the default CPUId masks depends on

*) the type of processor you have on your ESX/ESXi server

*) the type of guest OS you have defined on the guest.

*) the hard ESX/ESXi version you are using (reflected in the virtual HW version you see in the VMX file)

The default CPUId masks for all these combinations (and all the registers) can be found in the XML files in the /etc/vmware/hostd/env folder on your ESX/ESXi server.

So you could read in the XML files and let your script do all the logic.

But it would be, imho, a tremendous task.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nicad449
Contributor
Contributor

Thanks LucD,

My situation is that I have a set of CPU masks that will allow me to VMotion accross my different hosts, however there are some VMs that have older masks, or just ones that are not complete. I was thinking if I could apply the default options then apply the masks which work, things would be relatively consistent.

Reply
0 Kudos
LucD
Leadership
Leadership

Why can't you apply the mask that works immediately ?

Why first go to the default mask ?

Did you try applying the mask that works ?

You can use something like the script in


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nicad449
Contributor
Contributor

I tried applying the correct settings as is, however it seems as though the settings that already exist contain mask entries that are either not correct (some of the masks seem very odd, but may be a result of an ESX upgrade if I understand correctly). For those that don't work, if I reset to default and apply the correct ones, they work fine. That was why I was hoping there was a way to use a script to do the reset.

For example, I have one VM that has masks like:

Level : 1

Vendor :

Eax : xxxxXXXXXXXX--xx--


Ebx :

Ecx : R--RR-RRRR-0----


0

Edx : -


T----

and

Level : -2147483647

Vendor :

Eax :

Ebx :

Ecx : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0

Edx : xx0xxxxxxxx0xxxxxxxx-xxxxxxxxxxx

Thanks again for your help.

Reply
0 Kudos
nicad449
Contributor
Contributor

Using the Alpha of Project Onyx, I was able to get the answer I was looking for using the following:

Function Reset-VMCPUMask ($vm) {

$vmspec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmspec.files = New-Object VMware.Vim.VirtualMachineFileInfo
$vmspec.cpuFeatureMask = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec[] (4)
$vmspec.cpuFeatureMask[0] = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec
$vmspec.cpuFeatureMask[0].operation = "remove"
$vmspec.cpuFeatureMask[0].info = New-Object VMware.Vim.HostCpuIdInfo
$vmspec.cpuFeatureMask[0].info.level = 1

$vmspec.cpuFeatureMask[1] = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec
$vmspec.cpuFeatureMask[1].operation = "remove"
$vmspec.cpuFeatureMask[1].info = New-Object VMware.Vim.HostCpuIdInfo
$vmspec.cpuFeatureMask[1].info.level = 1
$vmspec.cpuFeatureMask[1].info.vendor = "amd"

$vmspec.cpuFeatureMask[2] = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec
$vmspec.cpuFeatureMask[2].operation = "remove"
$vmspec.cpuFeatureMask[2].info = New-Object VMware.Vim.HostCpuIdInfo
$vmspec.cpuFeatureMask[2].info.level = -2147483647

$vmspec.cpuFeatureMask[3] = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec
$vmspec.cpuFeatureMask[3].operation = "remove"
$vmspec.cpuFeatureMask[3].info = New-Object VMware.Vim.HostCpuIdInfo
$vmspec.cpuFeatureMask[3].info.level = -2147483647
$vmspec.cpuFeatureMask[3].info.vendor = "amd"

$vmView = Get-View -Id $vm.id
$vmView.ReconfigVM_Task($vmspec)

}

Reset-VMCPUMask (get-vm vmname)

This seems to have the same effect of clicking "Reset All to Default" under the CPU Identification Mask Advanced settings.

Reply
0 Kudos