Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

VFIO transparent transmission

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In the qemu-kvm virtualization environment, in order to improve the performance of the virtual machine, it is necessary to pass through the host (PCI) device to the virtual machine (vm), that is, device pass-through technology (also known as device pass-through technology), which requires the host to support Intel (VT-d) or AMD (IOMMU) hardware virtualization acceleration technology.

Prerequisite requirement

Linux kernel > 3.6qemu version > 1.4.The virtual machine system starts the host server in uefi mode and starts IOMMU host to load vfio and vfio-pci driver host CPU to support intel-vt/vd

Experimental environment

Centos7.2-AIO-3.6.0.0.1 qemu-2.2 preparation work

Server host

Modify the kernel boot parameters, restart the system, and see if IOMMU is enabled.

Dmesg | grep-e DMAR-e IOMMU [0.000000] DMAR: IOMMU enabled

Check to see if intel-vt-x/vt-d is enabled

Cat / proc/cpuinfo | grep vmx

Execute the following script to check if interrupt redirection is supported

#! / bin/shif [$(dmesg | grep ecap | wc-l)-eq 0]; then echo "No interrupt remapping support found" exit 1fifor I in $(dmesg | grep ecap | awk'{print $NF}'); do if [$((0x$i & 0xf) > > 3)-ne 1]; then echo "Interrupt remapping not supported" exit 1 fidone

If the hardware does not support interrupt remapping, you need to execute

Echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > / etc/modprobe.d/iommu_unsafe_interrupts.conf

Load vfio driver

Modprobe vfiomodprobe vfio-pci

Install OVMF boot virtual machine (OVMF supports uefi startup)

Wget http://www.kraxel.org/repos/firmware.repoyum install edk2.git-ovmf-x64.noarch transparent transmission

The device is unbound in the host

[root@localhost ~] # lspci-nn | more00:00.0 Host bridge [0600]: Intel Corporation 440BX/ZX/DX-82443BX/ZX/DX Host bridge [8086 nn 7190] (rev 01) 00nn 01.0 PCI bridge [0604]: Intel Corporation 440BX/ZX/DX-82443BX/ZX/DX AGP bridge [8086 nn 7191] (rev 01) 00nn 07.0 ISA bridge [0601]: Intel Corporation 82371AB/EB/MB PIIX4 ISA [8086 nn 7110] (rev 08) 00nn 07.1 IDE interface [0101 ]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086 VMware SVGA II Adapter 7111] (rev 01) 00Bridge 07.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI [8086 Bridge 7113] (rev 08) 00Bridge 07.7 System peripheral [0880]: VMware Virtual Machine Communication Interface [15ad:0740] (rev 10) 00:0f.0 VGA compatible controller [0300]: VMware SVGA II Adapter [15ad:0405] 00Bridge 10.0 SCSI storage controller [0100]: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion- MPT Dual Ultra320 SCSI [1000VMware PCI bridge 0030] (rev 01) 00PCI bridge 11.0 PCI bridge [0604]: VMware PCI bridge [15ad:0790] (rev 02) 00VMware PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01) 00VMware PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01) 00VMware PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01)

Find the device and unbind it.

Echo 0000VOV 07.1 > / sys/bus/pci/devices/0000\: 00\: 07.1/driver/unbind

Generate vfio Devic

Echo 8086 7111 > / sys/bus/pci/drivers/vfio-pci/new_id

At this point: / dev/vfio there will be a file named with Arabic numerals, corresponding to the vfio device group

Start the virtual machine

Plus parameter:-device vfio-pci,host=00:05:00.0 # transparent device plus parameter:-drive if=pflash,format=raw,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd # virtual machine bios/usr/libexec/qemu-kvm-M pc-i440fx-rhel7.0.0-enable-kvm-m 2048-smp 2-drive if=pflash,format=raw,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd-drive id=disk0,if=none,format=qcow2 File=test.qcow2-device virtio-blk-pci,drive=disk0,bootindex=0-drive id=cd0,if=none,format=raw,readonly,file=CentOS-7-x86_64-Minimal-1503-01.iso-device ide-cd,bus=ide.1,drive=cd0,bootindex=1-global PIIX4_PM.disable_s3=0-global isa-debugcon.iobase=0x402-debugcon file:fedora.ovmf.log-monitor stdio-device piix3-usb-uhci-device usb-tablet-netdev id=net0,type=user-device virtio-net-pci,netdev=net0,romfile=-device qxl-vga-spice port=3000 Disable-ticketing/usr/libexec/qemu-kvm-M pc-i440fx-rhel7.0.0-enable-kvm-m 2048-smp 2-drive if=pflash,format=raw,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd-drive id=disk0,if=none,format=qcow2,file=test.qcow2-device virtio-blk-pci,drive=disk0,bootindex=0-global PIIX4_PM.disable_s3=0-global isa-debugcon.iobase=0x402-debugcon file:fedora.ovmf.log-monitor stdio-device piix3-usb-uhci-device usb-tablet-netdev id=net0 Type=user-device virtio-net-pci,netdev=net0,romfile=-device qxl-vga-spice port=3000,disable-ticketing-device vfio-pci,host=00:05:00.0 client accesses spicy-h ip-p 3000

Execute inside the virtual machine

Lspci-nnlsblk

Check whether the transmission is successful.

references

Https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

Https://www.kernel.org/doc/Documentation/vfio.txt

Http://pve.proxmox.com/wiki/Pci_passthrough

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report