CentOS6/7开启nested嵌套虚拟化

CentOS6

  1. 升级系统内核到Linux 3.X版本
    rpm -ivh kernel-ml-3.18.3-1.el6.elrepo.x86_64.rpm
  2. 修改grub.conf

    vi /etc/grub.conf
    将default=1改为default=0;且在 kernel 那一行的末端加上 "kvm-intel.nested=1"

CentOS7

  1. 通过KVM intel模块启用嵌套虚拟化。AMD处理器使用不同的模块

    cat << EOF > /etc/modprobe.d/kvm_intel.conf
    options kvm-intel nested=1
    options kvm-intel enable_shadow_vmcs=1
    options kvm-intel enable_apicv=1
    options kvm-intel ept=1
    EOF

  2. 为了与嵌套的VM通信,您需要禁用反向路径过滤,否则RHEL将丢弃任何网络数据包,以防止不对称路由

    cat << EOF > /etc/sysctl.d/98-rp-filter.conf
    net.ipv4.conf.default.rp_filter = 0
    net.ipv4.conf.all.rp_filter = 0
    EOF

  3. 重启生效后检查:

    cat /sys/module/kvm_intel/parameters/nested
    Y

  4. 建立支持vmx的虚拟机

    virsh edit KVM

     <cpu mode='custom' match='exact'>
       <model fallback='allow'>core2duo</model>
       <feature policy='require' name='vmx'/>
     </cpu>
    

参考:
http://www.cnblogs.com/jython/p/4458807.html
http://fatmin.com/2015/12/28/enable-nested-virtualization-on-rhel-7/

Last modification:July 23rd, 2017 at 11:27 pm

Leave a Comment