Create a nested virtual machine on AMD

To create an L2 nested virtual machine (VM) on an AMD 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 virtual machine (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 svm and npt flags, creating L2 VMs is possible. This is generally the case on AMD EPYC cores and later.
  • Ensure that nested virtualization is enabled on the L0 host:
    # cat /sys/module/kvm_amd/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, use the following steps to enable the feature.
      1. Stop all running VMs on the L0 host.
      2. Unload the kvm_amd module:
        # modprobe -r kvm_amd
      3. Activate the nesting feature:
        # modprobe kvm_amd nested=1
      4. The nesting feature is now enabled, but only until the next reboot of the L0 host. To enable it permanently, add the following to the /etc/modprobe.d/kvm.conf file:
        options kvm_amd 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 AMD-L1 VM:
      # virsh edit AMD-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='svm'/> element and a <model> element with the CPU model specified inside. For example:

      <cpu mode="custom" match="exact" check="none">
        <model fallback="allow">EPYC-IBPB</model>
        <feature policy="require" name="svm"/>
        ...
      </cpu>
  2. Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the L1 VM.