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:

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:

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:

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.