我使用的是 ubuntu 22.04 LTS 最小服务器。我的主机服务器设置了 kvm,运行良好。运行时所有测试均通过virt-host-validate
。
当我创建虚拟机时,我希望它也支持 kvm,并且我试图virt-host-validate
在虚拟机上运行时通过所有检查,即 laso ubuntu 22.04 LTS
我在 VM 上的 grub 上更新了以下几行
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"
GRUB_CMDLINE_LINUX="cgroup_memory=1 cgroup_enable=memory swapaccount=1 systemd.unified_cgroup_hierarchy=0 intel_iommu=on"
运行sudo update-grub
并重新启动虚拟机。我仍然收到警告
QEMU: Checking for device assignment IOMMU support : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)
我需要通过这个才能正确使用 KubeVirt。
在我的主机/硬件上
$ sudo dmesg | grep -e DMAR -e IOMMU
[ 0.025208] ACPI: DMAR 0x000000007B7E6000 000364 (v01 INTEL INTEL ID 00000001 ? 00000001)
[ 0.025303] ACPI: Reserving DMAR table memory at [mem 0x7b7e6000-0x7b7e6363]
[ 1.958464] DMAR: IOMMU enabled
[ 3.615052] DMAR: Host address width 46
[ 3.615056] DMAR: DRHD base: 0x000000fbffc000 flags: 0x0
[ 3.615070] DMAR: dmar0: reg_base_addr fbffc000 ver 1:0 cap 8d2078c106f0466 ecap f020de
[ 3.615079] DMAR: DRHD base: 0x000000c7ffc000 flags: 0x1
[ 3.615093] DMAR: dmar1: reg_base_addr c7ffc000 ver 1:0 cap 8d2078c106f0466 ecap f020de
[ 3.615100] DMAR: RMRR base: 0x00000079170000 end: 0x00000079172fff
[ 3.615107] DMAR: RMRR base: 0x000000791f4000 end: 0x000000791f7fff
[ 3.615113] DMAR: RMRR base: 0x000000791de000 end: 0x000000791f3fff
[ 3.615118] DMAR: RMRR base: 0x000000791cb000 end: 0x000000791dbfff
[ 3.615123] DMAR: RMRR base: 0x000000791dc000 end: 0x000000791ddfff
[ 3.615128] DMAR: RMRR base: 0x0000005a62f000 end: 0x0000005a69efff
[ 3.615136] DMAR: ATSR flags: 0x0
[ 3.615141] DMAR: ATSR flags: 0x0
[ 3.615148] DMAR-IR: IOAPIC id 10 under DRHD base 0xfbffc000 IOMMU 0
[ 3.615155] DMAR-IR: IOAPIC id 8 under DRHD base 0xc7ffc000 IOMMU 1
[ 3.615160] DMAR-IR: IOAPIC id 9 under DRHD base 0xc7ffc000 IOMMU 1
[ 3.615166] DMAR-IR: HPET id 0 under DRHD base 0xc7ffc000
[ 3.615171] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping.
[ 3.616770] DMAR-IR: Enabled IRQ remapping in x2apic mode
[ 4.937442] DMAR: No SATC found
[ 4.937451] DMAR: dmar0: Using Queued invalidation
[ 4.937474] DMAR: dmar1: Using Queued invalidation
[ 4.968865] DMAR: Intel(R) Virtualization Technology for Directed I/O
在我的第一个虚拟机上
$ sudo dmesg | grep -e DMAR -e IOMMU
[ 1.982119] DMAR: IOMMU enabled
答案1
如果您不打算在嵌套的 VM 中使用PCI passtrough
或,那么您可以放心地忽略这些警告。SR-IOV
这些技术用于向虚拟机公开物理设备,例如视频卡或网卡 PCI 虚拟功能。
对于主机 VM(外部 VM),请确保使用 启用 vIOMMU -device intel-iommu,intremap=on
。另请参阅:https://wiki.qemu.org/Features/VT-d
对于 virtlib,请参阅:https://libvirt.org/formatdomain.html#iommu-devices 你将需要类似以下内容的内容:
<features>
<ioapic driver='qemu'/>
</features>
<!-- ... ->
<devices>
<iommu model='intel'>
<driver intremap='on' caching_mode='on'/>
</iommu>
</devices>
要编辑配置:
# List all instances (including stopped ones):
virsh list --all
# Backup current config
virsh dumpxml <VM_Name> > virsh_dumpxml_VMname-$(date +%F_%H%M%S).txt
# Shutdown, gracefully, the instance:
virsh shutdown <VM_Name>
# Edit the config:
virsh edit <VM_Name>
# Start the VM:
virsh start <VM_Name>