Platform
- Dom0: Opensuse 13.1
- Host/Guest Hypervisor: KVM
- Guest OS: CentOS
Enable Nested in Host KVM
- Check if nested is enabled in host hypervisor
1
| cat /sys/module/kvm_intel/parameters/nested
|
if the result is Y
. Nested virgualization in your host is open. Ohterwise you need to complete the followings
- `Modify /etc/default/grub
GRUB_CMDLINE_LINX = “kvm-intel.nested=1 ”
- Update grub
1
| grub2-mkconfig -o /boot/grub2/grub.cfg
|
- Reboot and check again
Install the guest Hypervisor
I use the raw disk as the VM partition
1
| virt-install --name=centos5.6 --os-variant=RHEL5 --ram=1024 --vcpus=1 --disk path=/dev/sda4,format=raw,bus=virtio --accelerate --cdrom /Your DVD / --vnc --vncport=5910 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole
|
Configure the Guest Hypervisor
- Disable cache on guest disk
In xml file, do
1
| <driver name='qemu' type='raw' cache='none'/>
|
- Enable VMX in guest CPU
In xml file, do
1
2
3
4
| <cpu match='exact'>
<model>core2duo</model>
<feature policy='require' name='vmx'/>
</cpu>
|
- Check guest CPU feature in host
In host OS
- Disable SELinux
In SELinux
1
2
3
4
| service NetworkManager stop
chkconfig NetworkManager off
chkconfig network on
yum install bridge-utils
|
eth0:
1
2
3
4
5
| DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BRIDGE=br0
|
br0
1
2
3
4
5
| DEVICE=br0
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=dhcp
|
reboot your computer
1
2
3
| ./configure
make
make install
|
- Install libvirt and management tool
1
| yum install libvirt-client virt-viewer guestfish libguestfs-tools virt-top libvrt python-virtinst
|
1
2
| service libvirtd start
chkconfig libvirtd on
|
- Check if libvirtd is turned on
Virsh Command
1
| virsh start domain name
|
1
2
| virsh destroy domain name
virsh undefine domain name
|
1
| virt-viewer -c qemu:///system domain name
|
1
2
| virsh destroy domain name
virsh undefine domain name
|
1
2
| virsh shutdown domain Name
virsh edit domain name
|
do this
1
2
| edit <vcpu placement='static'>4</vcpu>
virsh create /etc/libvirt/qemu/yourconfig.xml
|
- Solve the CPU incompatibility problems
In host, run virsh commands to check CPU compatibility.
1
| virsh capabilities | virsh cpu-baseline /dev/stdin
|
Copy past the display in your VM XML file
For example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| <cpu match='exact'>
<model>Penryn</model>
<vendor>Intel</vendor>
<feature policy='require' name='dca'/>
<feature policy='require' name='xtpr'/>
<feature policy='require' name='tm2'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='ds_cpl'/>
<feature policy='require' name='monitor'/>
<feature policy='require' name='pbe'/>
<feature policy='require' name='tm'/>
<feature policy='require' name='ht'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='acpi'/>
<feature policy='require' name='ds'/>
<feature policy='require' name='vme'/>
</cpu>
|