Nested virtualization and the network issue.

Nested virtualization [1] is a nice feature where it’s able to run a virtual machine within another. KVM [2] has support to nested virtualization [3]┬ásince 2010 (if I’m not wrong) and you can use it to test virtualization features and/or aspects in a different Linux distribution, or even Windows system. I use this sometimes when I need test some Kimchi [4] patch I’m working in different distros to make sure the solution will work.

However, when you start up a VM using NAT configuration on top of the main hosts system (let’s call them VM-master and host-master) the network interface of the VM will get an IP in the range of 192.168.122.2 and 192.168.254. This is the default configuration of libvirt+qemu on the most of the distros and when you start up a nested VM (let’s call VM-guest) it will start with the same configuration (because of the default configuration on VM-master) and you will not able to connect getting this error:

 libvirt: error : internal error: Network is already in use by interface eth0

The solution is quite simple. You only need edit the /etc/libvirt/qemu/networks/default.xml file on the VM-master and change the IP configuration that the VM-guest will work on:


$ sudo vi/etc/libvirt/qemu/networks/default.xml

%s/192.168.122/10.0.0/g
:wq

$ sudo systemctl restart libvirtd.service

After this, start up your VM-guest and you will be able to connect now.

References:

  1. https://en.wikipedia.org/wiki/Virtualization#Nested_virtualization
  2. http://www.linux-kvm.org/
  3. http://www.linux-kvm.org/images/3/33/02×03-NestedVirtualization.pdf
  4. http://kimchi-project.github.io/kimchi/