I just upgrade my Proxmox VE to the latest v8.0.3. The release notes said the default CPU type of the new VM is X86-64-v2-AES.

The x86-64-v2-AES model is the new default CPU type for VMs created via the web interface. It provides important extra features over the qemu64/kvm64, and improves performance of many computing operations.

Previously, the default CPU type is kvm64. It may affect the guest OS performance and some OS has a minimum request on CPU.

I just noticed that CPU types.

First, my Proxmox VE is running on the AMD Ryzen 5 2400G.

AMD Ryzen 5 2400G
AMD Ryzen 5 2400G

 

The Specs:

AMD Ryzen 5 2400G Specs
AMD Ryzen 5 2400G Specs

When I tried to change the CPU type in VM settings, I saw a list of them.

CPU Type lists
CPU Type lists

 

I studied the Proxmox VE wiki page of the Virtual Machine settings.

The CPU types are from 486 to the latest Xeon processors. Usually, you should select for your VM a processor type that closely matches the CPU of the host system, as it means that the host CPU features(also called CPU flags) will be available in your VMs. if you want an exact match, you can set the CPU type to host in which case the VM will have exactly the same CPU flags as your host system. ( see the screenshot above the last one on the list is the host)

If you are working on the Cluster environment, or more than one Host, you may have a problem when making a live migration of VMs between different hosts. Because two different Hosts use different CPUs, they have different CPU types or different microcode versions.

For me, I have one HOST right now.  I will not make any changes in the near future. So, I don’t care about the live migration.

If you don’t care about live migration or have a homogeneous cluster where all nodes have the same CPU and same microcode version, set the CPU type to host, as in theory this will give your guests maximum performance.

The above is the suggestion from the wiki page. I do want to choose host as the CPU type, but I am still hesitant to do that. So I want to choose one from the QEMU CPU types.

QEMU CPU Types are virtual CPU types, compatible with both Intel and AMD host CPUs.

At the very beginning, Proxmox VE provides kvm64 CPU model. It is the level of Pentium 4. Our current CPU are far more advanced.

In the summer of 2020, AMD, Intel, Red Hat, and SUSE collaborated to define three x86-64 microarchitecture levels on top of the x86-64 baseline, with modern flags enabled.

Now on the list of the Proxmo VE CPU type list.

  • kvm64 (x86-64-v1): Compatible with Intel CPU >= Pentium 4, AMD CPU >= Phenom.
  • x86-64-v2: Compatible with Intel CPU >= Nehalem, AMD CPU >= Opteron_G3. Added CPU flags compared to x86-64-v1: +cx16, +lahf-lm, +popcnt, +pni, +sse4.1, +sse4.2, +ssse3.
  • x86-64-v2-AES: Compatible with Intel CPU >= Westmere, AMD CPU >= Opteron_G4. Added CPU flags compared to x86-64-v2: +aes.
  • x86-64-v3: Compatible with Intel CPU >= Broadwell, AMD CPU >= EPYC. Added CPU flags compared to x86-64-v2-AES: +avx, +avx2, +bmi1, +bmi2, +f16c, +fma, +movbe, +xsave.
  • x86-64-v4: Compatible with Intel CPU >= Skylake, AMD CPU >= EPYC v4 Genoa. Added CPU flags compared to x86-64-v3: +avx512f, +avx512bw, +avx512cd, +avx512dq, +avx512vl.

Even though the new default CPU type is x86-64-v2-AES, I still want to know the exact level of my AMD Ryzen 5 2400G.

Here are two scripts that can run on the Host to check the level.

#!/bin/sh -eu

flags=$(cat /proc/cpuinfo | grep flags | head -n 1 | cut -d: -f2)

supports_v2='awk "/cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/ {found=1} END {exit !found}"'
supports_v3='awk "/avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/ {found=1} END {exit !found}"'
supports_v4='awk "/avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/ {found=1} END {exit !found}"'

echo "$flags" | eval $supports_v2 || exit 2 && echo "CPU supports x86-64-v2"
echo "$flags" | eval $supports_v3 || exit 3 && echo "CPU supports x86-64-v3"
echo "$flags" | eval $supports_v4 || exit 4 && echo "CPU supports x86-64-v4"

I save the above to a script file named l.sh. Run the script in the terminal of the Host.

root@pve:~# bash l.sh
CPU supports x86-64-v2
CPU supports x86-64-v3
root@pve:~#

The result is x86-64-v2 and x86-64-v3.

The other script content is based on AWK, I save it as s.sh.

#!/usr/bin/awk -f

BEGIN {
    while (!/flags/) if (getline < "/proc/cpuinfo" != 1) exit 1
    if (/lm/&&/cmov/&&/cx8/&&/fpu/&&/fxsr/&&/mmx/&&/syscall/&&/sse2/) level = 1
    if (level == 1 && /cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/) level = 2
    if (level == 2 && /avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/) level = 3
    if (level == 3 && /avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/) level = 4
    if (level > 0) { print "CPU supports x86-64-v" level; exit level + 1 }
    exit 1
}

Run in the command line:

root@pve:~# ./s.sh
CPU supports x86-64-v3
root@pve:~#

Conclusion.

Now, I change all my VMs CPU types to x86-64-v3 in the Proxmox VE.

CPU Type
CPU Type x86-64-v3

 

 

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

One Reply to “How I choose VM CPU type in Proxmox VE”

  1. Nice. I like what you did there. I supposed the easiest way would be to pick the processor family/architecture, like Sandybridge or Westmere if you know which one it is (at least with intel). Your script is the only way I see to tell the same with AMD processors.

Leave a Reply

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