Proxmox VE PVE 進行網絡卡直通

2021-10-11 17:36:24 字數 3338 閱讀 9687

新增所需模組

新增pci裝置

驗證iommu有效

iommu中斷重對映參考

pci直通允許您在vm內部使用物理pci裝置(圖形卡,網絡卡)(僅限kvm虛擬化)。如果您「pci passthrough」裝置,該裝置將不再可用於主機。

注意:pci passthrough是proxmox ve中的一項實驗性功能

要啟用硬體直通的話先要確保硬體支援vt-d和vt-x,cpu必須支援硬體虛擬化(為了使用 kvm)和 iommu(為了使用 vga 直通)並保證主機板中相關功能的開啟

設定完之後最好重新啟動一下

reboot
lspci |

grep -i ethernet

顯示

debian gnu/linux comes with absolutely no warranty, to the extent

root@pve:~# lspci | grep -i ethernet

00:1f.6 ethernet controller: intel corporation ethernet connection (2) i219-lm

01:00.0 ethernet controller: intel corporation i350 gigabit network connection (rev 01)

01:00.1 ethernet controller: intel corporation i350 gigabit network connection (rev 01)

01:00.2 ethernet controller: intel corporation i350 gigabit network connection (rev 01)

01:00.3 ethernet controller: intel corporation i350 gigabit network connection (rev 01)

03:00.0 ethernet controller: realtek semiconductor co., ltd. rtl8111/8168/8411 pci express gigabit ethernet controller (rev 16)

root@pve:~#

修改grub

vi /etc/default/grub

找到 grub_cmdline_linux_default="quiet"

修改為 grub_cmdline_linux_default="quiet intel_iommu=on"

update-grub

dmesg | grep -e dmar -e iommu

修改grub

vi /etc/default/grub

找到 grub_cmdline_linux_default="quiet"

修改為 grub_cmdline_linux_default="quiet amd_iommu=on"

update-grub

dmesg | grep -e dmar -e iommu

修改檔案/etc/modules,加入如下的行

vi /etc/modules
vfio

vfio_iommu_type1

vfio_pci

vfio_virqfd

執行命令來更新initramfs

update-initramfs -u -k all.
開啟檔案進行手工新增

查詢網絡卡id

lspci | grep net

或者lspci

新增pci

vi /etc/pve/qemu-server/vmid.conf

hostpci0: 01:00.0

hostpci0: 01:00.0;01:00.1

hostpci0: 01:00.0

hostpci1: 01:00.1

hostpci0: 01:00

新增pcie

vi /etc/pve/qemu-server/111.conf

machine: q35

hostpci0: 01:00.0,pcie=1

硬體->新增,選擇pci裝置->選擇,完成

如需更改為pcie,可設定機器為q35

如果新增了pci裝置開啟虛擬機器正常使用那後面的就不需要看了

如果新增了pci裝置無法開啟虛擬機器的話需要允許不安全的中斷

先驗證iommu是否有效

再檢視iommu是否可以中斷重對映

後啟用中斷重對映,允許不安全的中斷

要讓pci passthrough正常工作,您需要為您的pci裝置提供專用的iommu組

find / sys / kernel / iommu_groups / -type l
輸入命令後有相關東西輸出,則表示正常

如果沒有則需要進行iommu中斷重對映,只有每個iommu都支援中斷重對映,才會啟用中斷重對映。

沒有中斷重對映就不可能使用pci passthrough。

對於kvm使用者,裝置分配將失敗,出現』failed to assign device "[device name]"的錯誤,即「無法分配裝置」[裝置名稱]「:操作不允許」錯誤,並且』未找到中斷重對映硬體,將裝置傳遞到非特權域是不安全的。

不支援中斷重對映的系統:

執行「dmesg | grep ecap」命令。

在iommu行上,「ecap」之後的十六進製制值表示是否支援中斷重對映。如果該值的最後乙個字元是8,9,a,b,c,d,e或f,則支援中斷重對映。例如,「ecap 1000」表示沒有中斷重對映支援。「ecap 10207f」表示中斷重對映支援,因為最後乙個字元是「f」。

echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
vi /etc/modprobe.d/pve-blacklist.conf

檔案裡面新增一行

options vfio_iommu_type1 allow_unsafe_interrupts=1

來啟用不安全的中斷

之後就可以通過圖形化介面執行pcie裝置的直通操作了

fiddle進行弱網測試

參考 它提供了乙個功能讓我們模擬低速網路環境.啟用方法如下 rule performances simulate modem speeds 模擬數據機的速度 具體要進行如下fiddle的設定 1 在tools options connections進行和我一樣的設定,這裡allow remote c...

Fiddler進行弱網測試

一 弱網測試點 二 fiddler模擬限速的原理 rules performances simulate modem speeds 模擬數據機的速度 三 fiddler配置 1 找到頭部的tools功能,然後點選第乙個功能options,會彈出乙個介面 2 找到connections,把port改為...

弱網測試 使用fiddler進行弱網測試

資料源於 弱網測試原理以及方法 一 一 為什麼要進行弱網測試?按照移動特性,各種網路連線協議不同,導致通訊的訊號不同,速率也不同,影響應用的載入時間 可用性 穩定性 二 什麼樣的網路屬於弱網?低於2g速率的時候都屬於弱網也可以將3g劃分為弱網 一般wifi不納入弱網測試範圍。三 如何進行弱網測試?1...