Tuesday, September 25, 2012

Nested virtualization on Fedora for testing Convirt 2

Nested virtualization on Fedora for testing Convirt 2

I am somewhat fascinated by Convirt. I have never tried it, but I've always wondered what it is capable off. I never wanted to potentially kill my laptop by trying Convirt out on it. But there are other ways.

This one seems pretty cool: setting up a Convirt 2 installation, completely in VM's on my laptop :) Interested? Here's what to do.


I am going to assume your are running Fedora and / or EL6. If you are running another recent distribution, like Ubuntu or OpenSUSE, this should work fine. You just need a different document to install Convirt in step 4.


Please make sure you have adequate hardware. Older hardware will make this
process painful. Make sure you have Intel VT or AMD-V enabled in your BIOS.
Boot your kernel with "kvm-intel.nested=1" on the "kernel" command line. This
will enabled nested virtualization. Without this option, the setup below will
not work, because the 'vmx' flag will not be exposed to your hypervisor guests.

Step 1

Create three VM's through virt-manager. One for the Convirt console (management interface for the hypervisors) and two as hypervisors. Let's call them 'convirt', 'hyper01' and 'hyper02'.

Step 2

For the hypervisor VM's, start up 'virsh edit' on both of them and add this snippet to the XML:
<cpu match='exact'>
  <feature policy='require' name='vmx' />
This will enable the VM's to start nested VM's of their own. You can read more in this excellent article.

Step 3

Install CentOS6 or something similar on all of the VM's. An installation with just the "Base" package group will work fine for the Convirt VM, but it's recommended to install the "Virtualization Host" package group for the hypervisor VM's.

Step 4

Follow the instructions here to install Convirt on the convirt VM.

Step 5

Follow the instructions here to enable Convirt management of the hypervisor VM's. If you have not installed the "Virtualization Host" package group during install, make sure to install bridge-utils and qemu-kvm manually: the installer script will *not* install these for you and therefore fail.

Make sure to run the convirt-tool commands from a console, not over SSH. Network connection will be lost during it's execution.

Step 6

Log into the Convirt web gui with the default credentials ('admin' for both the username and the password) and add the hypervisor VM's to Convirt. You will need to click "Data Center" in the left menu bar, "Servers" in the main window and then select "Add server" in the "Actions" drop-down menu in the upper right corner of the screen.

Step 7

Create a virtual machine by following the instructions here. This is somewhat awkward, because you need to juggle with templates from the very first beginning, so follow that document. It makes stuff a lot easier.

Step 8

Start the VM and see it soar. Well, not quite, because performance will not be spectacular, but it's not that bad either and it works (at least for me) :)

I haven't tried doing a live migration yet. If you do, please leave a comment to tell how that went for you!

1 comment:

molekuul said...

I've tried this at my CentOS6.2, but it seems that CentOS6.2 doesn't support the nested parameter yet. I got this message during booting:

kvm_intel: Unknown parameter `nested'