Is it possible to setup a virtual machine inside another virtual machine

Solution 1:

Nesting VMs is something that has been done for forever on IBM Mainframe hardware. That hardware does lots of stuff to make the process very very efficient. You can have VMs nested to an arbitrary depth and it works very well.

PC hardware very recently has kinda made this barely possible. A document on VMware's web site discusses it, but the gist is that you can have VMs nested 2 deep, but only on very modern hardware that supports true hardware virtualization (VT-x or AMD-V), and the second VM depth must be running the older style BT/binary translation style virtualization. There are also severe restrictions on the virtual monitors you're able to run on the inner guest.

Needless to say, it's not supported and I'd expect it to be really flakey if you do anything even remotely weird (like Hyper-V under ESX). And performance will not be good, regardless of if it is stable.

Solution 2:

Yes you can. For example, on Linux, you may run Xen with multiple VMs running OpenVZ, VirtualServer or some other kind of VM system. It is most certainly possible and also very practical depending on your purpose.

One reason that I could think of for doing this is to run multiple servers on a single physical machine. Whether you run it as a single level of VM hierarchy or multiple ones is dependent on your resource isolation plan.


Solution 3:

If you need some specific, say legacy, system to be virtualized you can always do it in software, the nesting is not an issue then. Try qemu, I did it 2 level deep with it, but you can go deeper, the performance will probably make it useless, though. BTW, PC architecture was nomen omen made by IBM, but for totally different uses compared to what it is used for today.