Virtual-Machine

即使啟用了 Intel IOMMU,virt-manager PCI passthrough 也會給出錯誤“No IOMMU Found”

  • September 3, 2018

我正在嘗試在 virt-manager 中設置 PCI 直通,以授予我的 Debian Wheezy 來賓 VM 訪問筆記型電腦的 Intel Centrino N 無線網卡的權限。

Debian 預設核心啟用了 Intel IOMMU,我已intel_iommu=on在啟動時傳遞給核心(通過編輯/etc/default/grub和設置GRUB_CMDLINE_LINUX="intel_iommu=on",然後執行grub-update)…

查看 dmesg 以驗證 IOMMU 確實已啟用,我看到:[ 0.000000] Intel-IOMMU: enabled

我嘗試按照此處的說明進行操作,並在將 PCI 設備添加到 VM(即virsh nodedev-detach pci_0000_01_00_0)之前使用 virsh 將其分離,以確保確定。

但是,在為該無線網卡啟用 PCI 直通的情況下,我根本無法啟動來賓 VM,並且我收到以下錯誤(來自/var/log/libvirt/libvirtd.log):

2014-09-22 04:45:19.325+0000: 2990: error : qemuMonitorOpenUnix:305 : failed to connect to monitor socket: No such process
2014-09-22 04:45:19.325+0000: 2990: error : qemuProcessWaitForMonitor:1593 : internal error process exited while connecting to monitor: char device redirected to /dev/pts/1
**No IOMMU found.  Unable to assign device "hostdev0"
kvm: -device pci-assign,host=01:00.0,id=hostdev0,configfd=22,bus=pci.0,addr=0x7: Device 'pci-assign' could not be initialized**

這是來自的完整輸出/var/log/libvirt/qemu/

2014-09-22 04:10:47.002+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin HOME=/ QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-1.1 -cpu Nehalem,+rdtscp,+avx,+osxsave,+xsave,+tsc-deadline,+x2apic,+pdcm,+xtpr,+tm2,+est,+vmx,+ds_cpl,+monitor,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -enable-kvm -m 2500 -smp 4,sockets=4,cores=1,threads=1 -name DebianStableSandbox -uuid c18e2808-c98a-2b4d-54f1-00977d3ec1d2 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/DebianStableSandbox.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/DebianNET.img,if=none,id=drive-virtio-disk0,format=raw -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=21,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:c5:4a:a9,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device pci-assign,host=01:00.0,id=hostdev0,configfd=22,bus=pci.0,addr=0x7 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
char device redirected to /dev/pts/1
No IOMMU found.  Unable to assign device "hostdev0"
kvm: -device pci-assign,host=01:00.0,id=hostdev0,configfd=22,bus=pci.0,addr=0x7: Device 'pci-assign' could not be initialized
2014-09-22 04:10:47.610+0000: shutting down

我認為“無法連接到監視器”消息在某種程度上是相關的。如果我使用 virt-manager 將無線網卡添加為 PCI 設備,而沒有先將其分離virsh nodedev-detach(如上所述),那麼我會從 virt-manager 收到一條錯誤消息:

Error starting domain: Unable to read from monitor: Connection reset by peer

Traceback (most recent call last):
 File "/usr/share/virt-manager/virtManager/asyncjob.py", line 45, in cb_wrapper
   callback(asyncjob, *args, **kwargs)
 File "/usr/share/virt-manager/virtManager/asyncjob.py", line 66, in tmpcb
   callback(*args, **kwargs)
 File "/usr/share/virt-manager/virtManager/domain.py", line 1114, in startup
   self._backend.create()
 File "/usr/lib/python2.7/dist-packages/libvirt.py", line 620, in create
   if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: Unable to read from monitor: Connection reset by peer

/var/log/libvirt/libvirtd.log在這種情況下出現的所有內容是:2014-09-22 04:48:26.387+0000: 2985: error : qemuMonitorIORead:523 : Unable to read from monitor: Connection reset by peer

如果有幫助,這裡是一些相關的輸出lspci -v

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
   Subsystem: Dell Device 04d8
   Flags: bus master, fast devsel, latency 0
   Capabilities: [e0] Vendor Specific Information: Len=0c <?>
   Kernel driver in use: agpgart-intel

00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b5) (prog-if 00 [Normal decode])
   Flags: bus master, fast devsel, latency 0
   Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
   Memory behind bridge: d1600000-d16fffff
   Capabilities: [40] Express Root Port (Slot+), MSI 00
   Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit-
   Capabilities: [90] Subsystem: Dell Device 04d8
   Capabilities: [a0] Power Management version 2
   Kernel driver in use: pcieport

01:00.0 Network controller: Intel Corporation Centrino Wireless-N 1030 [Rainbow Peak] (rev 34)
   Subsystem: Intel Corporation Centrino Wireless-N 1030 BGN
   Flags: fast devsel, IRQ 16
   Memory at d1600000 (64-bit, non-prefetchable) [size=8K]
   Capabilities: [c8] Power Management version 3
   Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
   Capabilities: [e0] Express Endpoint, MSI 00
   Capabilities: [100] Advanced Error Reporting
   Capabilities: [140] Device Serial Number bc-77-37-ff-ff-0d-3f-90
   Kernel driver in use: pci-stub

另外,為了清楚起見,在將無線網卡添加為 PCI 直通設備之前,我能夠很好地啟動到這個虛擬機,一旦我通過 virt-manager 刪除它,一切都會恢復正常工作。

有誰知道如何解決這個問題?謝謝!

其實我剛發現這個處理器支持VT-x但不支持VT-d,所以不能做IOMMU。

引用自:https://unix.stackexchange.com/questions/156755