How to Configure CPU Compatibility Mode in Hyper-V

Table of contents

If you’re administrating a Hyper-V cluster that is a few years in age and you’re thinking of expanding, you might be at the point where it is no longer feasible to purchase a new host with hardware that matches your existing hosts. However, if the CPU on the newer host is of a different version or generation, live migration or restoring a saved state VM between the new and old host will fail. Luckily, Hyper-V comes with a feature called CPU compatibility mode that will allow these functions to continue between CPU generations.

Why Does My Live Migration Fail?

As the newer generation processors are released by manufacturers, they come with extra features that improve either security or performance.  When the VM is powered on, the OS and some applications detect the features of the CPU. So, if a VM that is powered on is going to migrate to a host with an older CPU that does not have those features, it could potentially cause issues and result in the VM crashing. This is why you would normally have to power off the VM in order to migrate the VM between hosts with dissimilar CPUs. This is also true for restoring VMs from a saved state. Be aware that if you have a cluster of hosts with different CPU manufactures such as Intel and AMD, you’re out of luck. CPU compatibility mode will only allow live migration for generations within each processor family.

How to Enable CPU Compatibility Mode in Hyper-V

This feature is also enabled at the VM level, which gives us granularity. So if you have a Hyper-V VM that requires the special new features of the newer processor you have the option to leave it out of CPU compatibility mode.

In order to enable this feature on a VM it must be powered off. Open up Hyper-V Manager and power off the VM that’s going to be configured for CPU compatibility mode. Right-click on the VM. Select Settings:

1-CPUCompat

On the left, expand Processor and select Compatibility. Then check the box for Migrate to a physical computer with a different processor version:

2-CPUCompat

 

Click Ok. Power on the VM and we can now live migrate across hosts with different CPU generations.

Will This Impact the Performance of My VMs?

When the box is checked to enable CPU compatibility mode, the VM is then limited to only a generic set of CPU features that is lower than all the CPUs in that family. In fact, it’s so generic that Microsoft even states that this generic instruction set is stripped of many of the processor features that have been introduced in the last 10 years! Enabling CPU compatibility mode will cause the VM to lose out on some of the newer CPU optimization technologies and depending on the workload that the VM is running, a noticeable performance hit could occur. Typically software that is very dependent on hardware optimizations like encryption or compression will see the performance impacts with this feature. So, if your VM is utilizing some of the CPU optimization features of the newer processors, you will most likely notice a performance hit. If not, the chance of noticing a difference in performance is pretty slim.

How to Turn On CPU Compatibility Mode for Multiple VMs

What if you have over 30 VMs in your Hyper-V cluster and want to enable CPU compatibility mode for all of them? You would first have to power off all the VMs. Then you’d have to manually check the box for each VM – which can get pretty tedious if you have 30+ VMs to configure. Luckily our friend PowerShell can turn this task into a quick process. In the demonstration below we have a two host cluster (Luke-HV03 and Luke-HV04). We will use Get-VMProcessor with the asterisk (*) symbol to specify all VMs followed by the –ComputerName parameter to define the hosts in the cluster to query:

Get-VMProcessor * -Computername 'Luke-HV03','Luke-hv04'

3-CPUCompat

This provides us a list all of our VMs and displays whether or not they are configured for CPU compatibility under the column “CompatiblityForMigrationEnabled”. This command is very useful if you have a lot of VMs and want to see which ones have the feature enabled.

To enable CPU compatibility mode on all our VMs we will pipe the information we’ve collected with the previous command to the Set-VMProcessor cmdlet and use the –CompatbilityForMigrationEnabled parameter:

Get-VMProcessor * -Computername 'luke-hv03','luke-hv04' | Set-VMProcessor -CompatibilityForMigrationEnabled 1

4-CPUCompat

Also note that this will only affect VMs that are powered off. In my demonstration I left one VM powered on still while running the command:

5-CPUCompat

When we run Get-VMProcessor again, we can see that the VM that was left powered on was not configured for CPU compatibility:

6-CPUCompat

If we wanted to automate the entire process of shutting down the VMs, enabling CPU compatibility mode, and powering them back on all in one command we could run the following:

$hosts ='Luke-hv03','Luke-hv04'
                
Stop-VM * -Computername $hosts -passthru | Set-VMProcessor -CompatibilityForMigrationEnabled 1 -passthru | Start-VM -name {$_.VMname} -Computername $hosts

Because processor version plays such a big role in Hyper-V clusters, it’s a good idea when specing out an entirely new Hyper-V cluster to go with the newest CPU generation available. That way down the road if you need to add an additional host you are more likely to be able to get the same CPU model so there aren’t any caveats.

 

 

Altaro Hyper-V Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

14 thoughts on "How to Configure CPU Compatibility Mode in Hyper-V"

  • Adedeji says:

    Amazing! It really helped me a lot. Thanks

  • dinesh says:

    Very very helpful to implement CPU compatibility at my environment.

  • Giles Ogram says:

    Hi,
    Being a bit new to Hyper-V, I am trying to import a VM from a restore, onto a different Hyper-V host. CPU compatibility was turned off on the original VM and I need to enable it (within the XML file?) so that the import works.
    How can I set this parameter if the VM is not registered in Hyper-V manager?
    Cheers
    Giles

    • CPU compatibility is more for scenarios where you don’t need to power off or reboot the machine. So like live migrations and production checkpoints. A simple export and import of your VM should do the trick without having to modify CPU compatibility settings until the VM is imported.

Leave a comment or ask a question

Your email address will not be published. Required fields are marked *

Your email address will not be published. Required fields are marked *

Notify me of follow-up replies via email

Yes, I would like to receive new blog posts by email

What is the color of grass?

Please note: If you’re not already a member on the Dojo Forums you will create a new account and receive an activation email.