VMware Cloud Community
jessey
Contributor
Contributor
Jump to solution

Hot to set vm's CpuFeatureMask ?

I guess I've to use something like:

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.CpuFeatureMask = New-Object VMware.Vim.VirtualMachineCpuIdInfoSpec

and then use the ReconfigVM_Task

But I get confused with the type VirtualMachineCpuIdInfoSpec, when I read CpuFeatureMask of an existing VM, it is an array of 10 elements, while the New-Object has only one element and not the same properties..?

Thanks for help.

1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

There's another object under VirtualMachineCpuIdInfoSpec where the real configuration happens.

Here's an example that will disable SSE4.1 extensions as shown in the VMware VMotion Info Guide (Appendix C)


# Mask SSE 4.1 Extensions to the guest.
function Mask-Extensions($vm) {
	$view = get-view $vm.id

	$vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
	$featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec
	$featureMask.info = new-object VMware.Vim.HostCpuIdInfo

	$featureMask.info.ecx = "---- ---- ---- 0--- ---- ---- ---- ----"
	$featureMask.info.level = 1

	$vmConfigSpec.CpuFeatureMask = $featureMask

	$view.ReconfigVM($vmConfigSpec)
}

Mask-Extensions (get-vm "My VM")

The code is also attached.

View solution in original post

Reply
0 Kudos
19 Replies
admin
Immortal
Immortal
Jump to solution

There's another object under VirtualMachineCpuIdInfoSpec where the real configuration happens.

Here's an example that will disable SSE4.1 extensions as shown in the VMware VMotion Info Guide (Appendix C)


# Mask SSE 4.1 Extensions to the guest.
function Mask-Extensions($vm) {
	$view = get-view $vm.id

	$vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec
	$featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec
	$featureMask.info = new-object VMware.Vim.HostCpuIdInfo

	$featureMask.info.ecx = "---- ---- ---- 0--- ---- ---- ---- ----"
	$featureMask.info.level = 1

	$vmConfigSpec.CpuFeatureMask = $featureMask

	$view.ReconfigVM($vmConfigSpec)
}

Mask-Extensions (get-vm "My VM")

The code is also attached.

Reply
0 Kudos
jessey
Contributor
Contributor
Jump to solution

Excellent, excellent, I love this forum.

Thanks a lot (as asoon as I test it, I'll give you a feedback): tested, works perfectly, thanks again.

VI Toolkit is definitely the greatest thing since sliced bread, saves me (us) tons of time.

Reply
0 Kudos
culbeda
Contributor
Contributor
Jump to solution

Thanks for the script. I've tried it and verified that the change registered in VC, but I'm still getting errors migrating from my Clovertown (X53xx) cores to my Harpertown cores (E54xx).

The error says:

Unable to migrate from <server1> to <server2>: Host CPU is incompatible with the virtual machine's requirements at CPUID level 0x1 register 'ecx'.

host bits: 0000:0000:0000:1100:1110:0011:1011:1101

required: 0000:0000:0000:010x:xxx0:0x1x:xxx1:x101

Mismatch detected for these features:

  • SSE4.1; refer to KB article 1993 for a possible solution

Based on that output, I would THINK it woudl work since the one must be masked has been.

I've reviewed KB 1993 and found it lacking. If I let VC migrate the machine cold, it puts in the following mask:

cpuid.1.eax = "xxxx--


xx--


"

cpuid.1.ecx = "--


RRR----


"

cpuid.1.edx = "--


T--"

cpuid.80000001.eax.amd = "xxxx--


xx--


"

cpuid.80000001.ecx.amd = "--


0-"

cpuid.80000001.edx = "--


H--


"

cpuid.80000001.edx.amd = "---R


H--T--"

(Certainly more involved than the cpuid.1.ecx="---- -


-


0--- -


-


-


" I was putting in.)

Anyway have any good ways to automate this? Turning all of my new VMs off and migrating them to another host is a bit of a drag.

Thanks!

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

I'm not much of an expert on this one, unfortunately. What I find really strange is the AMD extensions it added when you did the cold migration.

Did you restart the VMs before after you applied the CPU feature mask?

Reply
0 Kudos
culbeda
Contributor
Contributor
Jump to solution

I was curious about the AMD mask as well, but it keeps putting them in. And I performed the change while the VM was powered off. Still no love.

Reply
0 Kudos
culbeda
Contributor
Contributor
Jump to solution

OK, I have a workaround using a modified version of the script above since I couldn't find sufficient instructions on masking it in VirtualCenter. (If anyone knows how, I would love to know. KB 1993 is lacking in detail.)

Here is a modified version of the script above (thanks again) that updates all of your VMs on a server/farm that mimicks the processor masking that VC does when I cold-migrate a server (minus the AMD masking since I didn't need it):

Add-PSsnapin VMware.VimAutomation.Core

  1. Note: use login credentials if needed

get-viserver <servername>

  1. Mask SSE 4.1 Extensions to the guest.

function Mask-Extensions($vm) {

$view = get-view $vm.id

write-host "Setting Mask for: "$vm.Name

$vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec

$featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec

$featureMask.info = new-object VMware.Vim.HostCpuIdInfo

$featureMask.info.eax = "xxxx--


xx--


"

$featureMask.info.level = 1

$featureMask.info.ecx = "--


RR0----


"

$featureMask.info.level = 1

$featureMask.info.edx = "--


T--"

$featureMask.info.level = 1

$vmConfigSpec.CpuFeatureMask = $featureMask

$view.ReconfigVM($vmConfigSpec)

}

get-vm | ForEach {Mask-Extensions ($_)}

I'm sure there is a better way, but at least I can sleep now knowing that my VMs can HA/DRS. Smiley Wink

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Nice. I'll forward this thread to the people responsible for that KB.

Reply
0 Kudos
amorello
Contributor
Contributor
Jump to solution

I am trying to updated cpuid.80000001.edx.amd = ----0------H--------------------

to fix http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=206001...

But for AMD processors

I was giving that CPUID mask by VMware engineering but i am having an issue trying to apply it via powercli.

I this is where i am at, but its not working i know i have something wrong, but i am suck. Any ideas?

function Mask-Extensions($vm) {

    $view = get-view $vm.id

    write-host "Setting Mask for: "$vm.Name

    $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec

    $featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec

    $featureMask.info = new-object VMware.Vim.HostCpuIdInfo

    $featureMask.info.amd.edx = "----0------H--------------------"

    $featureMask.info.level = 80000001

    $vmConfigSpec.CpuFeatureMask = $featureMask

    $view.ReconfigVM($vmConfigSpec)

}

Connect-VIServer -server $vc

Mask-Extensions (get-vm c4w01332_test)

Disconnect-VIServer -Confirm:$false

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Anthonymo wrote:

I am trying to updated cpuid.80000001.edx.amd = ----0------H--------------------

to fix http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=206001...

But for AMD processors ...

Try...

    $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec

    $featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec

    $featureMask.info = new-object VMware.Vim.HostCpuIdInfo

    $featureMask.info.edx = "----0------H--------------------"

    $featureMask.info.vendor = "amd"

    $featureMask.info.level = 80000001

Reply
0 Kudos
amorello
Contributor
Contributor
Jump to solution

Thanks for the reply J, but i am still getting the following error. I looks like its getting further at least, Any ideas ?

Seems there is a problem with the variable that is being passed to ReconfigVM.

ERROR:

Exception calling "ReconfigVM" with "1" argument(s): "An error occurred during

host configuration."

At C:\Users\morelant\Desktop\cpuidfix.ps1:21 char:5

+     $view.ReconfigVM($vmConfigSpec)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

FULL SCRIPT:

$vc = "vCenter1"

function Mask-Extensions($vm) {

    $view = get-view $vm.id

    write-host "Setting Mask for: "$vm.Name

    $vmConfigSpec = new-object VMware.Vim.VirtualMachineConfigSpec

    $featureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec

    $featureMask.info = new-object VMware.Vim.HostCpuIdInfo

    $featureMask.info.edx = "----0------H--------------------"

  $featureMask.info.vendor = "amd"

    $featureMask.info.level = 80000001

    $vmConfigSpec.CpuFeatureMask = $featureMask

    $view.ReconfigVM($vmConfigSpec)

}

Connect-VIServer -server $vc

Mask-Extensions (get-vm vm1)

Disconnect-VIServer -Confirm:$false

Error i see in vCenter for the configuration task

Reconfigure virtual machine

c4w01332_test

An error

occurred

during host

configurati-

on.

AMERICAS\morelant

vCenter1

7/1/2014 10:28:57 AM

7/1/2014 10:28:57 AM

7/1/2014 10:28:58 AM

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Perhaps the spaces are necessary?

$featureMask.info.edx = "---- 0--- ---H ---- ---- ---- ---- ----"

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Or better yet, colons:

$featureMask.info.edx = "----:0---:---H:----:----:----:----:----"

Reply
0 Kudos
amorello
Contributor
Contributor
Jump to solution

Yea i tried no spaces, with spaces and :

no dice

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Is the VM powered off?

Reply
0 Kudos
amorello
Contributor
Contributor
Jump to solution

very much so

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Perhaps you can add this as a generic option:


Function Mask-Extensions($vm){
   $vmview = Get-vm $vm | Get-View
   $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

   $extra = New-Object VMware.Vim.optionvalue
   $extra.Key="cpuid.80000001.edx.amd"
   $extra.Value="----0------H--------------------"
   $vmConfigSpec.extraconfig += $extra

   $vmview.ReconfigVM($vmConfigSpec
)
}

Reply
0 Kudos
terminator24
Contributor
Contributor
Jump to solution

I am also facing the same issue.

When I set the level as 80000001, I get the following error.

"Exception calling "ReconfigVM" with "1" argument(s): An error occurred during host configuration"

But with same code and level as 0/1, it runs fine and I can see the changes in vmx file.

Can someone please let me know how to get past this error.

Here is the code I am trying:

$Newspec1 = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{

  cpuFeatureMask = new-object VMware.Vim.VirtualMachineCpuIdInfoSpec -Property @{

  info = new-object VMware.Vim.HostCpuIdInfo -Property @{

  eax = '---- ---- ---- ---- ---- ---- ---- ----'

  ebx = '---- ---- ---- ---- ---- ---- ---- ----'

  ecx = '---- ---- ---- ---- ---- ---- ---- ----'

  edx = '---- ---- ---H ---- ---- ---- ---- ----'

  level = 80000001

  }

  }

  }

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Shouldn't that be a hex value ?

level = 0x80000001


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

terminator24
Contributor
Contributor
Jump to solution

Thanks a lot, that worked.......Smiley Happy

Reply
0 Kudos