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.
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.
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.
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 = "--RR----
R
"
cpuid.1.edx = "----"
T
cpuid.80000001.eax.amd = "xxxx----
xx
"
cpuid.80000001.ecx.amd = "---"
0
cpuid.80000001.edx = "----
H
"
cpuid.80000001.edx.amd = "---R--
HT--"
(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!
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?
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.
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
Note: use login credentials if needed
get-viserver <servername>
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 = "--R0----
R
"
$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. ![]()
Nice. I'll forward this thread to the people responsible for that KB.