Arm场景将8张昇腾AI处理器直通给虚拟机后使用npu-smi工具只能查询到5张昇腾AI处理器。
通过执行命令dmesg | grep “BAR 4”查询,显示如下则表示为PCIe地址空间不足导致。
根因:默认的开源QEMU配置中,将PCIe域配置的地址空间限制在512G,而每张昇腾AI处理器所需要的BAR4资源为64G,结合虚拟机本身已使用的地址资源,最终无法在申请出足够的地址空间,导致分配失败。
chmod +x ./qemu-4.1.0.tar.xz
tar -xf ./qemu-4.1.0.tar.xz
cd qemu-4.1.0/
修改extended_memmap数组定义,加粗字体由512修改至1024后保存。
static MemMapEntry extended_memmap[] = { /* Additional 64 MB redist region (can contain up to 512 redistributors) */ [VIRT_HIGH_GIC_REDIST2] = { 0x0, 64 * MiB }, [VIRT_HIGH_PCIE_ECAM] = { 0x0, 256 * MiB }, /* Second PCIe window */ [VIRT_HIGH_PCIE_MMIO] = { 0x0, 1024 * GiB },
vi ./configure
修改如下加粗字体的参数取值为“yes”并保存。
qom_cast_debug="yes" trace_backends="log" trace_file="trace" spice="yes" rbd="" smartcard="" libusb="" usb_redir="" opengl="" opengl_dmabuf="no" cpuid_h="no" avx2_opt=""
Redirecting to /bin/systemctl restart libvirtd.service
systemctl disable apparmor
若系统环境为openEuler 22.03 LTS/openEuler 20.03 LTS/Kylin V10 SP2/Kylin V10/UOS V20(1050e)/CULinux 3.0/Tlinux3.1/UOS V20(1050u2e)/Kylin V10 SP3/Debian11.8/BC Linux 8.2/Debian10.13/veLinux 1.2系统,可跳过此步骤。
若系统环境为openEuler 22.03 LTS/openEuler 20.03 LTS/Kylin V10 SP2/Kylin V10/UOS V20(1050e)/CULinux 3.0/Tlinux3.1/UOS V20(1050u2e)/Kylin V10 SP3/BC Linux 8.2系统,可跳过此步骤。
Compiled against library: libvirt 6.0.0 Using library: libvirt 6.0.0 Using API: QEMU 6.0.0 Running hypervisor: QEMU 4.1.0