本文共 5281 字,大约阅读时间需要 17 分钟。
Frist, you need an Intel host support Vt-d, and enabled nested virtualization.
By default, nested virtualization is disabled:[root@kvm-hypervisor ~]# cat /sys/module/kvm_intel/parameters/nestedN
[root@kvm-hypervisor ~]# vi /etc/modprobe.d/kvm-nested.confoptions kvm-intel nested=1options kvm-intel enable_shadow_vmcs=1options kvm-intel enable_apicv=1options kvm-intel ept=1
Save & exit the file
[root@kvm-hypervisor ~]# modprobe -r kvm_intel[root@kvm-hypervisor ~]# modprobe -a kvm_intel
Now verify whether nested virtualization feature enabled or not.
[root@kvm-hypervisor ~]# cat /sys/module/kvm_intel/parameters/nestedY
host should enable Vt-d and "iommu=pt intel_iommu=on" in kernel cmdline.
...... hvm ............ ...... ...... ... 1 ...
# vim /etc/default/grub (apend "intel_iommu=on" to GRUB_CMDLINE_LINUX)
if you use seabios:
# grub2-mkconfig -o /boot/grub2//grub.cfg
if you use OVMF:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Reboot the L1 guest, then on L1 guest check if the env is ok:
1). the kvm device is there, otherwise, check the 'enable nested virtualization' step(step 1)# ls -al /dev/kvmcrw-rw-rw-. 1 root kvm 10, 232 Jul 3 14:30 /dev/kvm
# lscpuArchitecture: x86_64CPU op-mode(s): 32-bit, 64-bitByte Order: Little EndianCPU(s): 10On-line CPU(s) list: 0-9Thread(s) per core: 1Core(s) per socket: 1Socket(s): 10NUMA node(s): 1Vendor ID: GenuineIntelCPU family: 6Model: 63Model name: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHzStepping: 2CPU MHz: 2397.222BogoMIPS: 4794.44Virtualization: VT-xHypervisor vendor: KVMVirtualization type: full......
2). Checkpoint for vIOMMU enable
# dmesg | grep -i DMAR[ 0.000000] ACPI: DMAR 0x000000007FFE2541 000048 (v01 BOCHS BXPCDMAR 00000001 BXPC 00000001)[ 0.000000] DMAR: IOMMU enabled[ 0.203737] DMAR: Host address width 39[ 0.203739] DMAR: DRHD base: 0x000000fed90000 flags: 0x1[ 0.203776] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap 12008c22260206 ecap f02[ 2.910862] DMAR: No RMRR found[ 2.910863] DMAR: No ATSR found[ 2.914870] DMAR: dmar0: Using Queued invalidation[ 2.914924] DMAR: Setting RMRR:[ 2.914926] DMAR: Prepare 0-16MiB unity mapping for LPC[ 2.915039] DMAR: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff][ 2.915140] DMAR: Intel(R) Virtualization Technology for Directed I/O
Make sure the "DMAR: Intel(R) Virtualization Technology for Directed I/O" is there – if that’s missing something went wrong – don’t be mislead by the earlier “DMAR: IOMMU enabled” line which merely says the kernel saw the “intel_iommu=on” command line option.
3). The IOMMU should also have registered the PCI devices into various groups
# dmesg | grep -i iommu |grep device[ 2.915212] iommu: Adding device 0000:00:00.0 to group 0[ 2.915226] iommu: Adding device 0000:00:01.0 to group 1...snip...[ 5.588723] iommu: Adding device 0000:b5:00.0 to group 14[ 5.588737] iommu: Adding device 0000:b6:00.0 to group 15[ 5.588751] iommu: Adding device 0000:b7:00.0 to group 16
Now you can assgin the 3 interfaces to L2 guest.
Above steps expected to works well, but in fact, some devices share the same iommu group. How to make the devices into separated iommu group?
Reference:
转载于:https://blog.51cto.com/11527071/2135675