This paper tests the physical machine as centos6.5
Physical machine using INTEL-V virtualization architecture, installing QEMU-KVM version 0.12
We know that KVM virtualization technology requires server hardware support virtualization (INTEL-V/AMD-T) to improve virtual machine performance, if we need to test an OpenStack cluster, but not too many physical servers to use, If our virtual machines are capable of supporting hardware virtualization like physical machines, then the problem is solved, and using nested virtualization can solve this problem
Nested virtual nested is a feature that can be enabled through kernel parameters. It enables a virtual machine to look like a physical machine with a physical machine CPU feature that supports VMX or SVM hardware virtualization
1. First check the CPU information of a common KVM virtual machine
[Email protected] ~]# lscpu Architecture: x86_64...vendor ID: Genuineintelhypervisor Vendor: Kvmvirtualization type: cat /pro/cpuinfoprocessor 1vendor_id : GENUINEINTELCPU family 6model model name : QEMU Virtual CPU Version (Cpu64-rhel6) ... flags : FPU de PSE TSC MSR PAE, MCE cx8 APIC Sep mtrr PGE MCA Cmov PSE3 6 Clflush MMX FXSR SSE SSE2 syscall nx LM unfair_spinlock PNI cx16 hypervisor lahf_lm
As you can see, this virtual machine is used for full virtualization, using CPUs that are simulated by QEMU and does not support hardware virtualization (no VMX in flags)
2. Turn on nested support on the physical server
To enable the physical machine kernel to support nested, the first step is to upgrade the system kernel to the Linux 3.X version, and the second step is to add a new boot parameter to the kernel
By default, the system does not support nested
#查看当前系统是否支持nested
Systool-m kvm_intel-v grep -i nested
nested = "n" #或者这样查看 cat /sys/module/kvm_intel/parameters/nested n
The first step to upgrade the kernel, test with 3.18 kernel, upgrade the kernel is very simple, download the compiled kernel RPM package, here is, install, and then modify the grub.conf default boot kernel for the new kernel
The second step to add the boot parameters is also simple, just add "kvm-intel.nested=1" to the end of the kernel line
#升级内核rpm-IVH kernel-ml-3.18.3-1. el6.elrepo.x86_64.rpm# Modify Grub.confdefault=0 #使用新内核Timeout=5Splashimage= (hd0,0)/grub/splash.xpm.gzhiddenmenutitle Red Hat Enterprise Linux Server (3.18.3-1. el6.elrepo.x86_64) Root (hd0,0) Kernel/vmlinuz-3.18.3-1. el6.elrepo.x86_64 ro root=uuid=9c1afc64-f751-473c-aaa6-9161fff08f6f rd_no_luks rd_no_lvm lang=en_us. utf-8RD_NO_MD sysfont=Latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us rd_no_dm rhgb quietkvm-intel.nested=1
...
After the above modification, reboot the system, use "uname-r" to view the system kernel, and check whether nested supports
3. Create a virtual machine that supports "VMX" if you use Libvirt to manage virtual machines, you need to modify the definition of the CPU in the virtual machine XML file, and the following three definitions can
#可以使用这种<CPUMode= ' Custom 'Match= ' exact '> <Modelfallback= ' Allow '>Core2duo</Model> <featurePolicy= ' require 'name= ' VMX '/> </CPU>#这种方式为虚拟机定义需要模拟的CPU类型 "Core2duo" and add the "VMX" attribute to the virtual machine
#也可以使用这种<CPUMode= ' Host-model '> <Modelfallback= ' Allow '/> </CPU>
#或者这样<CPUMode= ' Host-passthrough '> <topologySockets= ' 2 'cores= ' 2 'Threads= ' 2 '/> </CPU>
#CPU穿透, the Vcpus seen in the virtual machine will be configured in the same way as the physical machine's CPU, and the disadvantage is that if you are migrating to a virtual machine, the destination server hardware configuration of the migration must be the same as the current physical machine
If you start a virtual machine using the QEMU-KVM command line, you can simply add
-ENABLE-KVM-CPU qemu64,+vmx# set virtual machine CPU to QEMU64 model, add VMX support
Then start the virtual machine to view the configuration
#下面虚拟机CPU定义为 "Host-model"
cat /proc/cpuinfo processor 0vendor_id : Genuineintelcpu family 6 Model - model name : Intel Core i7 9xx (Nehalem Class Core i7)
... wp : yesflags vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic ...
This article from http://www.cnblogs.com/jython/p/4458807.html, reproduced please indicate the source
Reference articles
http://kashyapc.com/2012/01/14/nested-virtualization-with-kvm-intel/
http://networkstatic.net/nested-kvm-hypervisor-support/
Nested virtualization nested of KVM Virtualization