KVM – Nested virtualization

Ever wondered about the possibility of running VMs inside VMs ? If so then you’ll want to read further.

In my particular case I have because (might have mentioned this before on my blog) I’m constantly “playing” with stuff for testing and proof of concept reasons.

The HOW TO part:

1. Enable the settings for nested KVM

edit /etc/modprobe.d/kvm-nested.conf file and add
options kvm_intel nested=1
(or kvm_amd if using AMD cpu)
line to it
then reboot the node or reload the module then confirm by running
cat /sys/module/kvm_intel/parameters/nested
you should get a “Y” as the output

2. Adjust configuration of a VM which should be able to run VMs

edit the configuration of one of the VMs you want to be able to run VMs and change cpu mode like so

cpu mode=’host-passthrough’

This should work on any Linux distro which has the KVM modules compiled. One can enable the nested option using the kernel line as well (in the boot loader). If you’re a maniac like me you might have decided to simply build KVM as builtin modules in which case the kernel line will be your friend.

Enjoy! (if not already)


Posted

in

,

by

Tags: