VMware

This Question is Answered

2 "helpful" answers available (6 pts)
7 Replies Last post: Jun 4, 2008 8:26 AM by c_shanklin  

Hot to set vm's CpuFeatureMask ? posted: Jun 2, 2008 7:32 AM

Click to view jessey's profile Novice 9 posts since
Jan 9, 2007
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.

Re: Hot to set vm's CpuFeatureMask ?

1. Jun 2, 2008 12:22 PM in response to: jessey
Click to view c_shanklin's profile Master 758 posts since
Dec 3, 2007
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.
Attachments:

Re: Hot to set vm's CpuFeatureMask ?

3. Jun 3, 2008 1:09 PM in response to: c_shanklin
Click to view culbeda's profile Novice 13 posts since
Jul 13, 2006

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 = "--------R--RR-------------------"
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!

Re: Hot to set vm's CpuFeatureMask ?

4. Jun 3, 2008 1:59 PM in response to: culbeda
Click to view c_shanklin's profile Master 758 posts since
Dec 3, 2007

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?

Re: Hot to set vm's CpuFeatureMask ?

5. Jun 3, 2008 2:23 PM in response to: c_shanklin
Click to view culbeda's profile Novice 13 posts since
Jul 13, 2006

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.

Re: Hot to set vm's CpuFeatureMask ?

6. Jun 4, 2008 8:06 AM in response to: culbeda
Click to view culbeda's profile Novice 13 posts since
Jul 13, 2006

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 = "--------R--R0-------------------"
$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. ;-)

Re: Hot to set vm's CpuFeatureMask ?

7. Jun 4, 2008 8:26 AM in response to: culbeda
Click to view c_shanklin's profile Master 758 posts since
Dec 3, 2007
Nice. I'll forward this thread to the people responsible for that KB.

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Incoming Links

Communities