KVM in 2013 years or so in the company at that time as a production environment in use, the habit, in their normal test environment also no longer use VMware Workstation and exsi. Recently, however, we are learning about the Rhel 7 version of the RHCE course. Get a set of RHCE environment after decompression found to be VMDK format. After conversion through the Qemu-img tool, the KVM is imported and the environment is started successfully. Compared to the pit dad was in the virtual machine, which opened three KVM virtual machines---classroom, server, and desktop. The CPU of a KVM-enabled guest host is not supported by default, so it is not as successful as KVM guest to turn on the KVM, and then nested successfully run the virtual machine in the virtual machine by opening the VMX.
First, VMware turn Qcow2
After extracting the compressed package, the contents are as follows:
You can see that the main data file in the two VMDK files, first view two VMDK files by qemu-img the following information:
[Root@361way rhel7.0_server]# qemu-img Info rhel7_server.vmdk
Image:RHEL7_Server.vmdk
File format:vmdk
Virtual size:200g (214748364800 bytes)
Disk size:9.7g
cluster_size:65536
Format Specific information:
cid:1940791077
Parent cid:4294967295
Create Type:monolithicsparse
Extents:
[0]:
Virtual size:214748364800
Filename:RHEL7_Server.vmdk
Cluster size:65536
Format
[Root@361way rhel7.0_server]# qemu-img Info rhel7_server-000002.vmdk
Image:rhel7_server-000002.vmdk
File format:vmdk
Virtual size:200g (214748364800 bytes)
Disk size:36m
cluster_size:65536
backing FILE:RHEL7_SERVER.VMDK
Format Specific information:
cid:2122094490
Parent cid:1940791077---> Father cid for RHEL7_SERVER.VMDK
Create Type:monolithicsparse
Extents:
[0]:
Virtual size:214748364800
Filename:rhel7_server-000002.vmdk
Cluster size:65536
Format
Next, convert the vmdk file to the Qcow2 file:
# qemu-img convert-f vmkd-o qcow2 rhel7_server.vmdk jiaoshiji.img
After the conversion is complete, refer to the KVM Virtualization summary (vi) Libguestfs-tools to view the contents of the mirrored file. This step confirms that I only need to use the RHEL7_SERVER.VMDK file here, the RHEL7_SERVER-000002.VMDK file is not required, here is no longer converted.
Second, start the virtual machine
After copying a jiaoshiji.xml template from the currently existing KVM guest host, and changing the relevant information, it was found that the Kai was unsuccessful through Virsh Define/xxxx/jiaoshiji.xml and Virsh start Jiaoshi. Here for the direct use of KVM command to try:
#/usr/libexec/qemu-kvm-m 4096-drive File=jiaoshiji.qcow2-vnc 0.0.0.0:20
After the VNC client is connected, it is possible to boot into the system normally.
However, an error occurred while booting the three hosts:
Error:faild to start domain classroom
Error:unsupported Configuration:domain requires KVM, but it is not available. Check that virtualization are enabled in the host BIOS, and host configuration are setup to load the KVM modules.
Rht-vmctl
The CPU of the KVM guest host was found to not support the VMX feature via Cat/proc/cpuinfo. By looking at the-CPU parameters of the physical machine, the results are as follows:
[Root@361way rhel7.0_server]#/USR/LIBEXEC/QEMU-KVM-CPU Help
x86 qemu64 QEMU Virtual CPU version 1.5.3
x86 phenom AMD Phenom (tm) 9550 Quad-core Processor
x86 Core2duo Intel (R) Core (TM) 2 Duo CPU T7700 @ 2.40GHz
x86 kvm64 Common KVM processor
x86 qemu32 QEMU Virtual CPU version 1.5.3
x86 kvm32 Common 32-bit KVM processor
x86 Coreduo Genuine Intel (R) CPU T2600 @ 2.16GHz
x86 486
x86 Pentium
x86 pentium2
x86 pentium3
x86 Athlon QEMU Virtual CPU version 1.5.3
x86 n270 Intel (R) Atom (TM) CPU N270 @ 1.60GHz
x86 cpu64-rhel6 QEMU Virtual CPU version (CPU64-RHEL6)
x86 Conroe Intel celeron_4x0 (conroe/merom Class Core 2)
x86 Penryn Intel Core 2 Duo p9xxx (Penryn Class Core 2)
x86 Nehalem Intel Core i7 9xx (Nehalem Class Core i7)
x86 Westmere Westmere e56xx/l56xx/x56xx (nehalem-c)
x86 Sandybridge Intel Xeon e312xx (Sandy Bridge)
x86 Haswell Intel Core Processor (Haswell)
x86 Broadwell Intel Core Processor (Broadwell)
x86 opteron_g1 AMD Opteron (Gen 1 Class Opteron)
x86 opteron_g2 AMD Opteron 22xx (Gen 2 Class Opteron)
x86 opteron_g3 AMD Opteron 23xx (Gen 3 Class Opteron)
x86 opteron_g4 AMD Opteron 62xx class CPU
x86 opteron_g5 AMD Opteron 63xx class CPU
x86 host KVM processor with all supported host features (only available in KVM mode)
Recognized CPUID flags:
PBE IA64 TM HT SS SSE2 SSE FXSR MMX ACPI DS clflush PN PSE36 Pat Cmov MCA PGE MTRR Sep APIC cx8 MCE pae MSR TSC PSE de VME Fpu
hypervisor rdrand f16c AVX osxsave xsave AES Tsc-deadline popcnt movbe x2apic sse4.2|sse4_2 sse4.1|sse4_1 DCA pcid PDCM xt PR cx16 FMA cid ssse3 tm2 est smx vmx ds_cpl monitor Dtes64 pclmulqdq|pclmuldq pni|sse3
SMAP ADX rdseed RTM invpcid erms bmi2 smep avx2 hle bmi1
3DNow 3dnowext lm|i64 rdtscp pdpe1gb fxsr_opt|ffxsr mmxext nx|xd syscall
PERFCTR_NB perfctr_core topoext TBM Nodeid_msr tce fma4 LWP WDT skinit xop IBS osvw 3dnowprefetch misalignsse sse4a ABM CR 8legacy extapic SVM cmp_legacy lahf_lm
Pmm-en pmm phe-en PHE ace2-en ace2 xcrypt-en xcrypt xstore-en xstore
Kvm_pv_unhalt kvm_pv_eoi kvm_steal_time kvm_asyncpf kvmclock kvm_mmu kvm_nopiodelay kvmclock
Pfthreshold pause_filter decodeassists flushbyasid vmcb_clean tsc_scale nrip_save svm_lock lbrv NPT
By attempting to use a variety of CPUs at startup,-cpu Nehalem, and so on, found that the virtual machine that started was unable to support VMX. By looking at the CPU-defined default profile/usr/share/libvirt/cpu_map.xml, it is found that several types of CPUs that are defined by default do not contain VMX items (the Fedora system's KVM CPU definition file is/usr/share/ qemu-kvm/cpu-model/cpu-x86_64.conf). I was going to try to make the CPU default support for the VMX feature by modifying the file, but I found the nested virtual nested technology when I checked the relevant data.
Three, nested type virtual nested
Nested virtual nested is a feature that can be enabled through kernel parameters. It enables a virtual machine to have physical computer CPU characteristics, support VMX or SVM (AMD) hardware virtualization. A specific introduction to nested can be seen here. This feature requires the kernel to upgrade to the Linux 3.X version, so it is necessary to upgrade the kernel under CENTOS6, and the feature is supported by default in Centos7, but is not enabled by default and needs to be supported by modifying parameters.
1, confirm whether the host support nested
The following file is found or can be grep to the attribute value in the module feature to prove that the current kernel supports nested, and the following is supported but not opened:
#查看当前系统是否支持nested
Systool-m Kvm_intel-v | Grep-i nested
nested = "N"
#或者这样查看
cat/sys/module/kvm_intel/parameters/nested
N
2, boot up the nested
There are two ways to boot from this feature:
At the end of the kernel line, add "kvm-intel.nested=1."
Or
# echo "Options Kvm-intel nested=1" >>/etc/modprobe.d/kvm-intel.conf
Do not reboot the host can also be supported by reloading the module:
# Rmmod Kvm_intel
# modprobe Kvm-intel nested=1
# cat/sys/module/kvm_intel/parameters/nested
Y
3, recommend VMX support virtual machine
By virsh the specified XML file to start the virtual machine, you can use the following three methods in XML to support
<cpu mode= ' custom ' match= ' exact ' >
<model fallback= ' Allow ' >core2duo</model>
<feature policy= ' require ' name= ' vmx '/>
</cpu>
#这种方式为虚拟机定义需要模拟的CPU类型 "Core2duo" and add "vmx" attributes to the virtual machine
#也可以使用这种
<cpu mode= ' Host-model ' >
<model fallback= ' Allow '/>
</cpu>
#或者这样
<cpu mode= ' Host-passthrough ' >
<topology sockets= ' 2 ' cores= ' 2 ' threads= ' 2 '/>
</cpu>
#CPU穿透, the vcpu seen in the virtual machine will be configured with the same CPU as the physical machine, in the same way that if you are migrating to a virtual machine, the destination server hardware configuration for the migration must be the same as the current physical machine
When you start with the QEMU-KVM command, you can support it with the following parameters:
Iv. successful running of RHCE virtual machine
The following is the focus of this nested virtual machine
Start the Jiaoshiji virtual machine by using the following methods:
/usr/libexec/qemu-kvm-m 8096-cpu qemu64,+vmx-smp 4,sockets=4,cores=1,threads=1-drive file=jiaoshiji.qcow2-vnc 0.0.0 .0:20
After VNC connection, view support VMX features via Cat/proc/cpuinfo:
This is the environment through the operation of the RHCE environment, if you think each time the jump to VNC operation is uncomfortable, can also be solved by the following three kinds of simple:
Method 1: The-serial parameter (serial port function) of QEMU-KVM, can start mapping physical machine port through-serial tcp:192.168.0.2:4444, and turn on Jiaoshiji serial port connection-----------------------on kernel This is in the previous KVM summary. When reconnecting, it can be connected through SCRT;
Method 2: The Jiaoshiji virtual machine configuration A bridge network, and the physical machine in the same network segment, jump to the Jiaoshiji and then through SSH to jump another three host;
Method 3: Copy the three host qcow2 mirrors and XML files in the Jiaoshiji, and add them to the physical machine directly clay.