KVM nested virtualization

Nested virtualization allows you to run a virtual machine (VM) inside another VM while still using hardware acceleration from the host.

# Enable kvm/kvm-intel options (临时)
modprobe kvm-intel nested=1
modprobe kvm_intel ept=y
modprobe kvm ignore_msrs=1
# Enable kvm/kvm-intel options (永久)
cat > /etc/modprobe.d/nested.conf <<'EOF'
options kvm ignore_msrs=1
options kvm-intel nested=y ept=y
EOF
 
reboot
 
#Check to see if everything is configured to support Nested Hypervisors:
cat /sys/module/kvm_intel/parameters/nested
Y
cat /sys/module/kvm_intel/parameters/ept
Y
cat /sys/module/kvm/parameters/ignore_msrs
Y

2.1 新建虚拟机

virt-install –cpu host-passthrough or virt-install –cpu host-passthrough 来指明Guest需要HOST的CPU硬件虚拟化特性.

注意:nested的cpu型号应该使用host-model/host-passthrough

2.2 编辑已有虚拟机xml

virsh edit Guest > 添加以下参数,关闭Guest,再开启Guest:

<cpu mode='host-model' check='partial'>
<model fallback='allow'/>
</cpu>

登入Guest进行检查nest virtualization是否生效:

lscpu | egrep 'Virtualization|Hypervisor'
egrep -c '(vmx|svm)' /proc/cpuinfo

4.1 安装配置建议

  • CPU:2个或更多虚拟核心,文中虚拟了1个10核心1线程的CPU,共10线程;
  • 嵌套:请确认已经添加参数 –cpu host-passthrough;
  • 内存:2GB或更多内存,文中分配了16GB内存;
  • 磁盘:建议使用ide bus;1)
  • 网卡:建议使用intel e1000千兆网卡;2)
  • 显示:请务必配置vnc;
virt-install.sh
virt-install --name esxi6.5 \
     --ram 16384 \
     --vcpus 10,sockets=1,cores=10,threads=1 \
     --cpu host-passthrough \
     --arch=x86_64 \
     --os-type=linux \
     --os-variant=generic \
     --accelerate \
     --cdrom /mnt/DATA/SOFTWARES/vmware/vsphere/6.5/VMware-VMvisor-Installer-6.5.0-4564106.x86_64.iso  \
     --boot menu=on \
     --disk path=/mnt/ssd/kvm/esxi6.raw,format=raw,size=200,bus=ide \
     --network bridge=br1,model=e1000 \
     --graphics vnc,port=-1,listen=0.0.0.0 \
     --channel char_type='unix',target_type='virtio',name='org.qemu.guest_agent.0'

4.2 安装过程截图

截图是引用此文的使用KVM nested嵌套技术在KVM中安装esxi6.5


1) , 2)
esxi6.5不认识virtio设备
  • virtualization/kvm/kvm_nested_virtualization.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)