Matryoshka and kvm: simplifying development with nested VM

On my first trip to Russia, my host’s wife insisted on taking me on a world-wind tour of the seven-sisters and of some arts and crafts fair, where she selected a matryoshka doll for me to take home. The matryoshka is, of course, a nesting doll. Each time you open it, its the same again but smaller.

Now, one of the problems of doing development of virtual environments is that they themselves have not been virtualisable. E.g. I had three choices:

  1. Get a new dedicated machine and keep wrecking it as i tried stuff
  2. Install on the normal desktop I use, and curse when I wrecked it
  3. Use a VM on the normal desktop, and curse as I watched the VM’s inside the VM run slow since they used full emulation.

Intel has a feature called VT-X (vmx as a processor flag) along w/ nested-page-tables (EPT). (see http://ark.intel.com/products/virtualizationtechnology). And, you need the VT-X in order to do high-performance virtualisation.

Recently kvm has added the feature of nested kvm, passing the ‘vmx’ flag. This means you can create a VM, and in it, run other VM’s with good performance.

This has in turn made it much easier to hack away on OpenStack.

So, if you are curious to play with OpenStack, you can run a recent copy of kvm, and in it, install a Ubuntu 13.10 64-bit server (default install options), and then run devstack.

and boom, you’ll have an OpenStack setup.

I chose an 8GB disk and 24GB of ram and 6 cores for the VM, but its reasonably forgiving of all 3.

To get the nested kvm you should check:

$ grep -E '^flags.*(vmx|svm)' /proc/cpuinfo

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
# cat /sys/module/kvm_intel/parameters/nested
Y

if you have all 3, nest away. And feel free to try my script. What have you got to lose, that VM can be destroyed and recreated with impunity!

And, you masochist you, feel free to try it in a VM inside that first VM. You can keep going until you run out of memory, just like those russian dollmakers can keep going until its a toothpick and a microscope.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *