Add the ability to configure the CPU model exposed to KVM virtual machines.
|Category:||Core & System|
One of the most important missing features was the ability to configure the CPU model exposed to KVM virtual machines. There are a couple of reasons for wanting to specify the CPU model
- To maximise performance of virtual machines by exposing new host CPU features to the guest
- To ensure a consistent default CPU across all machines, removing reliance of variable QEMU defaults.
In libvirt, the CPU is specified by providing a base CPU model name (which is a shorthand for a set of feature flags), a set of additional feature flags, and the topology (sockets/cores/threads). The libvirt KVM driver provides a number of standard CPU model names (defined in /usr/share/libvirt/cpu_map.xml):
"486", "pentium", "pentium2", "pentiumpro", "coreduo", "n270", "pentiumpro", "qemu32", "kvm32", "cpu64-rhel5", "cpu64-rhel5", "kvm64", "pentiumpro", "Conroe" "Penryn", "Nehalem", "Westmere", "pentiumpro", "cpu64-rhel5", "cpu64-rhel5", "Opteron_G1", "Opteron_G2", "Opteron_G3, "Opteron_G4"
It is also possible to request the host CPU model in two ways
- "host-model" - this causes libvirt to identify the named CPU model which most closely matches the host from the above list, and then request additional CPU flags to complete the match. This should give close to maximum functionality/performance, which maintaining good reliability/compatibility if the guest is migrated to another host with slightly different host CPUs.
- "host-passthrough" - this causes libvirt to tell KVM to passthrough the host CPU with no modifications. The difference to host-model, instead of just matching feature flags, every last detail of the host CPU is matched. This gives absolutely best performance, and can be important to some apps which check low level CPU details. The guest can only be migrated to an exactly matching host CPU.
This path is add CPUMODEL support:
OS = [ CPUMODEL="host" ] for host-passthrough
or for example
OS = [ CPUMODEL="core2duo" ] for custom CPU model. Full list of supported cpu shown by the command:
kvm -cpu ?
#8 Updated by Eugene W almost 4 years ago
Have found solution for CPU host-passthrough.
If need to to expose the underlying physical CPU to the virtual machine.
To do this, you need to modify your VM’s template to include the following raw attributes:
RAW=[ DATA="<cpu mode='host-passthrough'/>", TYPE="kvm" ]
You can add these attributes by following these steps:
- Choose your VM template
- Click on ‘UPDATE’
- Click on ‘Other’
- From the ‘RAW data’ dropdown menu, choose ‘KVM’
- In the DATA text box, insert: