CPU host-passthrough技術與應用


為了保證虛擬機在不同宿主機之間遷移的時候的兼容性,Libvirt對CPU提煉出標准的幾種類型,在/usr/share/libvirt/cpu_map.xml中可以查到。cpu_map.xml不僅是CPU型號,還有生產商信息、每種型號的CPU特性定義等信息,如下所示:

<cpus>
  <arch name='x86'>
    <!-- vendor definitions -->
    <vendor name='Intel' string='GenuineIntel'/>
    <vendor name='AMD' string='AuthenticAMD'/>

    <!-- standard features, EDX -->
    <feature name='fpu'> <!-- CPUID_FP87 -->
      <cpuid function='0x00000001' edx='0x00000001'/>
    </feature>
    <feature name='vme'> <!-- CPUID_VME -->
      <cpuid function='0x00000001' edx='0x00000002'/>
    </feature>
    <feature name='de'> <!-- CPUID_DE -->
      <cpuid function='0x00000001' edx='0x00000004'/>
    </feature>
    <feature name='pse'> <!-- CPUID_PSE -->
      <cpuid function='0x00000001' edx='0x00000008'/>
    </feature>
    <feature name='tsc'> <!-- CPUID_TSC -->
      <cpuid function='0x00000001' edx='0x00000010'/>
    </feature>
    <feature name='msr'> <!-- CPUID_MSR -->
      <cpuid function='0x00000001' edx='0x00000020'/>
    </feature>
 ...
<!-- models -->
    <model name='486'>
      <feature name='fpu'/>
      <feature name='vme'/>
      <feature name='pse'/>
    </model>
...
  <!-- Intel CPU models -->
    <model name='Conroe'>
      <model name='pentiumpro'/>
      <vendor name='Intel'/>
      <feature name='mtrr'/>
      <feature name='mca'/>
      <feature name='pse36'/>
      <feature name='clflush'/>
      <feature name='pni'/>
      <feature name='ssse3'/>
      <feature name='syscall'/>
      <feature name='nx'/>
      <feature name='lm'/>
      <feature name='lahf_lm'/>
    </model>

Centos6.6所帶的Libvirt主要規定了以下幾種CPU型號:'486','pentium','pentium2','pentium3','pentiumpro','coreduo'

CPU模式配置

1)custom模式

xml配置文件如下:

<cpu mode='custom' match='exact'>
    <model fallback='allow'>kvm64</model>
</cpu>

2)host-model模式

根據物理CPU的特性,選擇一個最靠近的標准CPU型號。如果沒有指定CPU模式,默認也是使用這種模式,xml配置文件如下:

<cpu mode='host-model' />

3)host-passthrough模式

直接將物理CPU暴露給虛擬機使用,在虛擬機上完全可以看到的就是物理CPU的型號,xml配置文件如下:

<cpu mode='host-passthrough' />

注意:使用host-model模式,Libvirt會根據物理CPU的型號,從規定的CPU中選擇一種最接近的CPU型號,而使用host-passthrough模式直接看到的就是物理CPU的型號

CPU host-passthrough技術的應用場景

HOST技術使用於以下場景

1)需要將物理CPU的一些特性傳給虛擬機使用,比如使用虛擬機嵌套的nested技術的時候

2)需要在虛擬機里面看到和物理CPU一模一樣的CPU品牌型號,這個在公有雲很有意義,用戶體驗比較好

注意:使用CPU host-passthrough技術需要注意,不同型號的CPU宿主機之間虛擬機不能遷移

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM