Finally, I made it work ! Nested virtualization.
I am actually running the following hardware :
- Antsle one XD - 4 Cores
- edgeLinux version 2.0.0
- antMan 3.4.3
The CPUs in my Antsle are : Intel® Xeon Processor D-1518 (Intel Code name : Broadwell) [cpu family 6 - model 86]
On my Antsle, I need to do the Pre-condition checks.
Verify in Antsle BIOS if Intel Virtualization Technology is enabled.
I should have the following option enabled
Intel Virtualization Technology [enabled]
Once BIOS option is enabled, I logged in my Antsle with ssh as root.
To support nested virtualization it requires Intel VT-x vmx feature. To check if this is available I did a grep (-c for count) on /proc/cpuinfo. The count return will be either 0 if not supported or the number of cores if supported. I ran the following command.
cat /proc/cpuinfo | grep -c vmx
8
So in my case I have 8 core supporting virtualization.
Having verified that virtualization is supported I need to check if nested virtualization is enabled. I ran the following command.
cat /sys/module/kvm_intel/parameters/nested
N
In my case it's not enabled, so I have created a file in /etc/modprobe.d to enable nested virtualisation with this : options kvm_intel nested=1
If you look at the file, you should now see.
cat /etc/modprobe.d/kvm.conf
options kvm_intel nested=1
Then I rebooted my Antsle and ssh again with root once booted.
I checked now if nested virtualisation is enabled. I ran the following command.
cat /sys/module/kvm_intel/parameters/nested
Y
Good, nested virtualization is available and enabled.
After, I did a verification of my machine to see if all is set up correctly. I ran the following command.
virt-host-validate
You should have result similar to this
QEMU: Checking for hardware virtualization : PASS
QEMU: Checking if device /dev/kvm exists : PASS
QEMU: Checking if device /dev/kvm is accessible : PASS
QEMU: Checking if device /dev/vhost-net exists : PASS
QEMU: Checking if device /dev/net/tun exists : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'memory' controller mount-point : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpu' controller mount-point : PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller mount-point : PASS
QEMU: Checking for cgroup 'cpuset' controller support : PASS
QEMU: Checking for cgroup 'cpuset' controller mount-point : PASS
QEMU: Checking for cgroup 'devices' controller support : PASS
QEMU: Checking for cgroup 'devices' controller mount-point : PASS
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for cgroup 'blkio' controller mount-point : PASS
QEMU: Checking for device assignment IOMMU support : PASS
QEMU: Checking if IOMMU is enabled by kernel : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)
LXC: Checking for Linux >= 2.6.26 : PASS
LXC: Checking for namespace ipc : PASS
LXC: Checking for namespace mnt : PASS
LXC: Checking for namespace pid : PASS
LXC: Checking for namespace uts : PASS
LXC: Checking for namespace net : PASS
LXC: Checking for namespace user : PASS
LXC: Checking for cgroup 'memory' controller support : PASS
LXC: Checking for cgroup 'memory' controller mount-point : PASS
LXC: Checking for cgroup 'cpu' controller support : PASS
LXC: Checking for cgroup 'cpu' controller mount-point : PASS
LXC: Checking for cgroup 'cpuacct' controller support : PASS
LXC: Checking for cgroup 'cpuacct' controller mount-point : PASS
LXC: Checking for cgroup 'cpuset' controller support : PASS
LXC: Checking for cgroup 'cpuset' controller mount-point : PASS
LXC: Checking for cgroup 'devices' controller support : PASS
LXC: Checking for cgroup 'devices' controller mount-point : PASS
LXC: Checking for cgroup 'blkio' controller support : PASS
LXC: Checking for cgroup 'blkio' controller mount-point : PASS
LXC: Checking if device /sys/fs/fuse/connections exists : FAIL (Load the 'fuse' module to enable /proc/ overrides)
Now, I need to verify if nested virtualization is available on my antlet.
I logged in my antlet with ssh
I verified if nested virtualization is available on the Guest OS antlet. I ran the following command.
sudo cat /proc/cpuinfo | grep -c vmx
0
We can see that it's not available, otherwise we would have a value greater than 0.
I took a look at the CPU my antlet is configured with. I ran the following command.
sudo cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 44
model name : Westmere E56xx/L56xx/X56xx (Nehalem-C)
In my case, my antlet is running with an Intel Westmere CPU model.
Now I shut down my antlet gest OS
Back on my Antsle
I have edited my antlet virtual configuration with the following command.
virsh edit "my antlet name"
And changed the following two lines
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Westmere</model>
For the following one
<cpu mode='host-passthrough'>
The I restarted my antlet
Once fully booted, I logged in my antlet with ssh.
And then verified if nested virtualization is available on the Guest OS antlet. I ran the following command
sudo cat /proc/cpuinfo | grep -c vmx
16
I now have nested virtualization available since returned value is greater than 0.
Took a look now at the CPU my antlet is configured with. It should be the same as my Antsle. I ran the following command.
sudo cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 86
model name : Intel(R) Xeon(R) CPU D-1518 @ 2.20GHz
In my case, the antlet is now running with an Intel Xeon CPU model, same as my Antsle.
I also need to verify if nested virtualization is enabled in my antlet (Linux only). I executed the following command.
cat /sys/module/kvm_intel/parameters/nested
N
We see that it's not enabled, so I have created a file in /etc/modprobe.d to enable nested virtualisation with this : options kvm_intel nested=1
If you look at the file, you should now see.
cat /etc/modprobe.d/kvm.conf
options kvm_intel nested=1
Then rebooted my antlet.
A last check, I ran the following command
cat /sys/module/kvm_intel/parameters/nested
Y
Et voilà ! Nested virtualization is fully functional
Here are the references I have used to come up with a working solution :
https://blog.wikichoon.com/2016/01/using-cpu-host-passthrough-with-virt.html
https://libvirt.org/formatdomain.html#cpu-model-and-topology
https://tips.graphica.com.au/nested-kvm/