KVM: GPU Passthrough(3)

先の記事と異なり、AMD機でopenSUSE Leap 15.1.1を使っているサーバについてとなる。Leapのバージョンを15.2にアップデートしたところ、VMの起動時にエラーメッセージが表示された。

Leap15.2 # virsh start WindowsVM
error: Failed to start domain WindowsVM
error: internal error: qemu unexpectedly closed the monitor: 2021-03-27T03:07:59.061478Z qemu-system-x86_64: warning: This family of AMD CPU doesn't support hyperthreading(2)
Please configure -smp options properly or try enabling topoext feature.
2021-03-27T03:07:59.346697Z qemu-system-x86_64: -device vfio-pci,host=0000:0b:00.3,id=hostdev0,bus=pci.7,addr=0x0: vfio 0000:0b:00.3: failed to setup container for group 4: No available IOMMU models

IOMMUの方はvfio_iommu_type1が読み込まれていないっぽい。暫定的には次のコマンドで解消する。

# modprobe vfio_iommu_type1

起動時に読み込ませたいので次設定を記載する。

# cat /etc/modules-load.d/vfio-pci.conf
vfio-pci
vfio_iommu_type1
vfio_virqfd
options kvm_amd nasted=0 avic=1 npt=1

CPUのエラーについては、hyperthreadingとか書いてあるのでintel topologyが参照されている?次当たりが怪しい。

>QEMU 3.1 から TOPOEXT cpuid フラグはデフォルトで無効になっています。

<cpu mode='host-passthrough' check='none'>
   <topology sockets='1' cores='4' threads='2'/>
   <feature policy='disable' name='hypervisor'/>
   <feature policy="require" name="invtsc"/>
   <feature policy='require' name='topoext'/>
</cpu>

topoextを有効化すれば良いっぽい。