Hyper-V How To: Set Processor Affinity in Hyper-V
You don’t.
Chances are you found this blog post by searching for some combination of the words in the bag “set processor affinity Hyper-V”.
As Ben explains in his blog post: Processor Affinity and why you don’t need it on Hyper-V, there is no way to set VM processor affinity in Hyper-V. Instead, you use the “virtual machine reserve” to 100. Turn off the VM, get an account with local admin perms, then:
To configure memory or processors for a virtual machine
Open Hyper-V Manager. Click Start, point to Administrative Tools, and then click Hyper-V Manager.
In the results pane, under Virtual Machines, select the virtual machine that you want to configure.
In the Action pane, under the virtual machine name, click Settings. Then, in the navigation pane, click the appropriate hardware setting as described in the following steps.
To configure the memory, click Memory. On the Memory page, specify the new amount of memory.
To configure the processor, click Processor. If multiple processors are supported by the guest operating system, specify the number of processors to assign to the virtual machine. Then click OK.
To set processor affinity, click Processor, and configure the Virtual machine reserve (percentage) to “100”:
This ensures that Hyper-V will dedicate the whole processor (or multiple whole processors – depending on how many virtual processors the virtual machine has) whenever the VM is running.
FYI the rest of the *important* stuff on this page relates to:
Virtual machine reserve. Of the processor resources available to a virtual machine, specifies the percentage that is reserved for the virtual machine. This setting guarantees that the percentage you specify will be available to the virtual machine. This setting can also affect how many virtual machines you can run at one time.
Virtual machine limit. Of the processor resources available to a virtual machine, specifies the maximum percentage that can be used by the virtual machine. This setting applies regardless of whether other virtual machines are running.
Relative weight. Specifies how Hyper-V allocates resources to this virtual machine when more than one virtual machine is running and the virtual machines compete for resources.
While you are on this page, if your VMs are highly-available (and why wouldn’t you want that?), then you need to review the settings in the Processor Compatibility section:
- The Migrate to a physical computer with a different processor version setting ensures that the virtual machine uses only the features of the processor that are available on all versions of a virtualization-capable processor by the same processor manufacturer. It does not provide compatibility between different processor manufacturers.
- The setting is useful for high availability and backup and recovery scenarios because it makes it easier to move a highly available virtual machine to another node in a cluster or restore the virtual machine to different hardware.
Note
If the physical computer has multiple processors and uses non-uniform memory architecture (NUMA), we recommend that you do not assign more processors or memory to a virtual machine than are available on a single NUMA node. For example, do not assign 4 processors to a virtual machine if each NUMA node has only two processors. For more information about the processor architecture of the physical computer, see the documentation that came with the computer.
Now, if your VM requires a specific CPU feature, then you have already determined that all the virtualization servers (hosts) in the cluster support the same feature, right? If not, then it is possible that the VM will not live or quick migrate. If the OS/and/or application you are running on a VM require a specific CPU feature, and that feature is not supported on the new host, then Hyper-V won’t migrate the VM.