[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

HOWTO: Configure nested virtualization on CentOS 6

1. Introduction

In some situations you would like to test or prove a Virtualization set-up before rolling it out on bare metal. In these cases the ideal scenario would be to set up your Hypervisor hosts as Virtual Machines and then run Virtual Machines on them. This scenario where you run VM's inside a VM is called nested virtualization.

Nested virtualization is a feature that can be enabled using a kernel parameter. Unfortunately, the current CentOS kernel does not support this parameter.

2. Before you begin

You may verify if your system supports the nested parameter by checking for the file: /sys/module/kvm_intel/parameters/nested

On a default CentOS 6 system this file will not exist. Fortunately, we have the xen-c6 project (http://dev.centos.org/centos/6/xen-c6/) that features a kernel that supports the nested parameter!

3. Step 1: add the xen-c6 repo to your system

  1. su -
  2. cd /etc/yum.repos.d
  3. wget http://dev.centos.org/centos/6/xen-c6/xen-c6.repo

  4. yum repolist
  5. [optional] vi xen-c6.repo : change to "enabled=0" to not take the repo enabled by default

4. Step 2: install the new kernel

  1. su -
  2. yum --enablerepo xen-c6 install kernel kernel-firmware
  3. vi /boot/grub/grub.conf : add "kvm-intel.nested=1" to the end of the kernel line
  4. reboot
  5. verify proper operation: "cat /sys/module/kvm_intel/parameters/nested" will output "Y"

5. Step 3: Configure the Hypervisor Virtual Machine

For the setup to work, we need the "vmx" flag in the virtual cpu inside the VM.

I will use virt-manager for this HOWTO. Obviously, one can use XML files and virsh to get the same result.

  1. virt-manager
  2. open the hypervisor virtual machine, go to Details > Processor

  3. unfold the "Configuration"
  4. press the "Copy host CPU configuration" button
  5. unfold the "CPU Features"
  6. verify the "vmx" feature is set to "require"
  7. press Apply

Boot the hypervisor virtual machine, and lo and behold! libvirtd is up and running inside the VM!

(source: http://technotes.nocoffee.nl)

2023-09-11 07:22