VFIO透传
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,在qemu-kvm虚拟化环境中,为提高虚拟机性能,需要将主机(PCI)设备直通给虚拟机(vm),即:设备透传技术(也叫设备直通技术),该技术需要主机支持Intel(VT-d) 或 AMD (IOMMU
千家信息网最后更新 2024年09月22日VFIO透传
在qemu-kvm虚拟化环境中,为提高虚拟机性能,需要将主机(PCI)设备直通给虚拟机(vm),即:设备透传技术(也叫设备直通技术),该技术需要主机支持Intel(VT-d) 或 AMD (IOMMU) 硬件虚拟化加速技术。
前提要求
linux kernel>3.6qemu 版本>1.4虚拟机系统以uefi模式启动宿主机服务器开启IOMMU宿主机加载vfio和vfio-pci驱动宿主机CPU支持intel-vt/vd
实验环境
Centos7.2-AIO-3.6.0.0.1 qemu-2.2
准备工作
服务器宿主机
修改系统内核启动参数,重启系统,查看是否开启IOMMU
dmesg | grep -e DMAR -e IOMMU[ 0.000000] DMAR: IOMMU enabled
查看是否开启intel-vt-x/vt-d
cat /proc/cpuinfo | grep vmx
执行如下脚本检查是否支持中断重定向
#!/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
如果硬件不支持interrupt remapping,需要执行
echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
加载vfio驱动
modprobe vfiomodprobe vfio-pci
安装OVMF引导虚拟机(OVMF支持uefi启动)
wget http://www.kraxel.org/repos/firmware.repoyum install edk2.git-ovmf-x64.noarch
透传
设备在主机中解绑
[root@localhost ~]# lspci -nn|more00:00.0 Host bridge [0600]: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge [8086:7190] (rev 01)00:01.0 PCI bridge [0604]: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge [8086:7191] (rev 01)00:07.0 ISA bridge [0601]: Intel Corporation 82371AB/EB/MB PIIX4 ISA [8086:7110] (rev 08)00:07.1 IDE interface [0101]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086:7111] (rev 01)00:07.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI [8086:7113] (rev 08)00: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]00:10.0 SCSI storage controller [0100]: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI [1000:0030] (rev 01)00:11.0 PCI bridge [0604]: VMware PCI bridge [15ad:0790] (rev 02)00:15.0 PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01)00:15.1 PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01)00:15.2 PCI bridge [0604]: VMware PCI Express Root Port [15ad:07a0] (rev 01)
找到设备,解绑
echo 0000:00:07.1 > /sys/bus/pci/devices/0000\:00\:07.1/driver/unbind
生成vfio设备
echo 8086 7111 > /sys/bus/pci/drivers/vfio-pci/new_id
此时:/dev/vfio下面会有个以阿拉伯数字命名的文件,对应vfio设备组
启动虚拟机
加参数:-device vfio-pci,host=00:05:00.0 #透传的设备加参数:-drive if=pflash,format=raw,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd #虚拟机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
客户端访问
spicy -h ip -p 3000
在虚拟机内部执行
lspci -nnlsblk
查看是否透传成功
参考资料
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
设备
支持
宿主
宿主机
技术
主机
参数
系统
服务器
环境
硬件
服务
驱动
成功
内核
前提
参考资料
客户
客户端
性能
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
小学网络安全领导小组及职能
数据库常见的安全问题
纳米材料合成数据库
软件开发与创新5000字论文
顺义区正规软件开发价格信息
网络技术文明是指的什么
数据库建库的数据
软件开发年底总结汇报
数据库mul是什么约束
速达5000数据库迁移
江西综合软件开发批发价格
学历中专数据库技术
大连海洋大学数据库sql
小红书数据库营销的感悟
浙江net软件开发如何收费
住建网络安全自查情况报告
服务器设置域名映射ip
数据库 主机和服务器吗
内蒙古通讯软件开发价格优惠
网络安全大会精神
数据库 上下线 分润
连接数据库用什么技术
如何做好软件开发数据分析员
妈妈好江苏网络技术
沃土 数据库
我的世界模组服务器运行内存
dcs网络安全设计
决胜高考网络技术类
相城区智能服务器价格咨询
三大数据库软件
- 上一篇
云服务器的永久免费的吗
这篇文章运用简单易懂的例子给大家介绍云服务器的永久免费的吗,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。现在很多云服务商为了吸引顾客,会有一些福利推出,比如免费试用、购买多久赠送
- 下一篇
cannot update mailbox /var/mail/root for user root. error writing messa ge: File too large
cannot update mailbox /var/mail/root for user root. error writing message: File too large1 postfix 作