Create a nested virtual machine on Intel

To create an L2 nested virtual machine (VM) on an Intel host, you must enable and configure nested virtualization capabilities on both the L0 host and the L1 VM.

Before you begin

  • An L0 RHEL 10 host running an L1 VM.
  • The hypervisor CPU must support nested virtualization. To verify, use the cat /proc/cpuinfo command on the L0 hypervisor. If the output of the command includes the vmx and ept flags, creating L2 VMs is possible. This is generally the case on Intel Xeon v3 cores and later.
  • Ensure that nested virtualization is enabled on the L0 host:
    # cat /sys/module/kvm_intel/parameters/nested
    • If the command returns 1 or Y, the feature is enabled. Skip the remaining prerequisite steps, and continue with the Procedure section.
    • If the command returns 0 or N but your system supports nested virtualization, use the following steps to enable the feature.
      1. Unload the kvm_intel module:
        # modprobe -r kvm_intel
      2. Activate the nesting feature:
        # modprobe kvm_intel nested=1
      3. The nesting feature is now enabled, but only until the next reboot of the L0 host. To enable it permanently, add the following line to the /etc/modprobe.d/kvm.conf file:
        options kvm_intel nested=1

About this task

Warning

In most environments, nested virtualization is only available as a Technology Preview in RHEL 10.

For detailed descriptions of the supported and unsupported environments, see Support limitations for nested virtualization.

Procedure

  1. Configure your L1 VM for nested virtualization.
    1. Open the XML configuration of the VM. The following example opens the configuration of the Intel-L1 VM:
      # virsh edit Intel-L1
    2. Configure the VM to use host-passthrough CPU mode by editing the <cpu> element:
      <cpu mode='host-passthrough'/>

      If you require the VM to use a specific CPU model, configure the VM to use custom CPU mode. Inside the <cpu> element, add a <feature policy='require' name='vmx'/> element and a <model> element with the CPU model specified inside. For example:

      <cpu mode ='custom' match ='exact' check='partial'>
        <model fallback='allow'>Haswell-noTSX</model>
        <feature policy='require' name='vmx'/>
        ...
      </cpu>
  2. Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the L1 VM.