jessey
Contributor
Contributor

Hot to set vm's CpuFeatureMask ?

Jump to solution

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

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

0 Kudos
19 Replies
admin
Immortal
Immortal

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.

0 Kudos
jessey
Contributor
Contributor

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.

0 Kudos
culbeda
Contributor
Contributor

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!

0 Kudos
admin
Immortal
Immortal

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?

0 Kudos
culbeda
Contributor
Contributor

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.

0 Kudos
culbeda
Contributor
Contributor

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

0 Kudos
admin
Immortal
Immortal

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

0 Kudos
amorello
Contributor
Contributor

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

0 Kudos
admin
Immortal
Immortal

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

0 Kudos
amorello
Contributor
Contributor

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

0 Kudos
admin
Immortal
Immortal

Perhaps the spaces are necessary?

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

0 Kudos
admin
Immortal
Immortal

Or better yet, colons:

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

0 Kudos
amorello
Contributor
Contributor

Yea i tried no spaces, with spaces and :

no dice

0 Kudos
admin
Immortal
Immortal

Is the VM powered off?

0 Kudos
amorello
Contributor
Contributor

very much so

0 Kudos
admin
Immortal
Immortal

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
)
}

0 Kudos
terminator24
Contributor
Contributor

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

  }

  }

  }

0 Kudos
LucD
Leadership
Leadership

Shouldn't that be a hex value ?

level = 0x80000001


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

terminator24
Contributor
Contributor

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

0 Kudos