环境
- Red Hat Virtualization 4
- Red Hat Enterprise Virtualization 3
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 6
- libvirt
- qemu-kvm
问题
- Where can I find the mapping between CPU models and flags for Virtualization?
- How can I enabled or disable a specific feature/flag?
- Which CPU flags are enabled when I select Sandy Bridge?
- Which CPU flags are enabled when I select Haswell?
- Which CPU flags are enabled when I select Broadwell?
- Which CPU flags are enabled when I select Opteron_G5?
决议
The definitions are stored in /usr/share/libvirt/cpu_map.xml
.
Raw
$ cat /usr/share/libvirt/cpu_map.xml | egrep 'Opteron_G5|Broadwell' -A5
<model name='Broadwell'>
<vendor name='Intel'/>
<feature name='3dnowprefetch'/>
<feature name='adx'/>
<feature name='aes'/>
<feature name='apic'/>
...
--
<model name='Opteron_G5'>
<vendor name='AMD'/>
<feature name='3dnowprefetch'/>
<feature name='abm'/>
<feature name='aes'/>
<feature name='apic'/>
...
NOTE: the below is not valid for Red Hat Virtualization. It's only intended for RHEL KVM.
To enable or disable a specific flag, edit the VM definition using virsh edit <vm name>
and edit the cpu
section of the xml with:
Raw
<cpu ....>
<feature policy='policy' name='flag'/>
</cpu>
Where flag
is the feature, such as vmx
. And policy
is one of the below:
Policy | Description |
force | The virtual CPU will claim the feature is supported regardless of it being supported by host CPU. |
require | Guest creation will fail unless the feature is supported by host CPU. |
optional | The feature will be supported by virtual CPU if and only if it is supported by host CPU. |
disable | The feature will not be supported by virtual CPU. |
forbid | Guest creation will fail if the feature is supported by host CPU. |
For example, to require the vmx feature to be passed to the Virtual Machine CPU:
Raw
<cpu ....>
<feature policy='require' name='vmx'/>
</cpu>