How To Enable Nested Virtualization In KVM

Hi, I followed this instruction to enable nested virtualization but when I start my Ubuntu guest and run egrep --color -i "svm|vmx" /proc/cpuinfo I get nothing and I also cannot use virtualbox.
what is wrong?

What about all the previous steps?
Run this command on your host system and it should highlight these very same things since the configuration was done by copying the host CPU configuration.

That is because you don’t have virtualization enabled on your machine, that could either mean that you’re CPU doesn’t support it (must be a pretty old CPU), or that your CPU does support it, but it is not enabled from your BIOS. So you first have to enable it from your BIOS configuration.

So restart your computer, and press ESC, F2, F3, F9 (the key may vary based on your pc manufacturer, and you have to press it within 4 seconds, if you miss, restart and try again). After that, the usual way to enable it is BIOS Configuration > Advanced Settings > CPU Configuration > Virtualization Technology and enable. (The interface may vary based on your computer manufacturer). After that, the command egrep --color -i "svm|vmx" /proc/cpuinfo should work and you’d get some text highlighting.

Edit: Don’t know why the tutorial put that command at the end, it should have been on the top, not upside-down.

All the previous steps are okay, my CPU supports virtualization and also it supports nested virtualization, I load proper kernel module, nested virtualization is enabled and so on.
but I don’t know why in the guest the last command does not show anything which means something is wrong.
there’s one thing, I’ve selected the Copy host CPU configuration check box in the CPU configuration window but when I start my guest machine its checkbox gone and when I shutdown the guest it’s selected again. is that okay?

actually my CPU is not very old and it supports virtualization but there problem is with nested virtualization. should I active something in my BIOS for nested virtualization?

I never paid attention to that, but now that you mentioned it I looked and: it’s the same for me.
Is it ok?
I have to assume it is - since it works (for me). :wink:

This should at least give the desired output on the host system.
Does it?

and this - again, on the host:
cat /sys/module/kvm_intel/parameters/nested
should return a “Y” or a “1”
Does it?

yes I see the egrep --color -i "svm|vmx" /proc/cpuinfo ouput in my host. and cat /sys/module/kvm_amd/parameters/nested output is “1”
but I just realized a thing, I stared my guest and executed virsh # dumpxml ubuntu and see the output

 <cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>EPYC-Rome</model>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='stibp'/>
<feature policy='require' name='arch-capabilities'/>
<feature policy='require' name='ssbd'/>
<feature policy='require' name='xsaves'/>
<feature policy='require' name='cmp_legacy'/>
<feature policy='require' name='amd-ssbd'/>
<feature policy='require' name='virt-ssbd'/>
<feature policy='require' name='rdctl-no'/>
<feature policy='require' name='skip-l1dfl-vmentry'/>
<feature policy='require' name='mds-no'/>
<feature policy='require' name='pschange-mc-no'/>
**<feature policy='disable' name='svm'/>**
<feature policy='require' name='topoext'/>
<feature policy='disable' name='npt'/>
<feature policy='disable' name='nrip-save'/>

why svm is disabled?

Yes, u have to do that, whether you have KVM enabled or not, you have to manually enable virtualization in order to use it

I have no idea what that is - and I don’t know how to use virsh - I just use the GUI.
What I did notice is this - the first line of your xml output:

<cpu mode='custom' match='exact' check='full'>

It should probably be:

<cpu mode="host-model" ...
since you wanted to copy the host’s cpu configuration
for me it is:

  <cpu mode="host-model" check="partial"/>

I said: “and I don’t know how to use virsh”
now I do :wink:
I just forgot to use sudo and thus had no machines …

it is enable.

yes it is, actually before staring the guest it’s <cpu mode="host-model" ... and after starting the guest it’s <cpu mode='custom' match='exact' check='full'>

Whats that warning about?

s3 is a sleep mode (energy saving)