kvm qemu pci passthough

1,  宿主机需要打开iommu特性
     验证host有没有打开iommu可以通过dmesg | grep iommu 查看
2,  通过lspci查看pci设备信息,得到pci设备的domain ,bus, slot, function信息(例如:0000.04.00.0)
3,  也可以通过virsh的命令得到pci设备信息:
     1) virsh nodedev-list --tree
 computer
|
+- net_lo_00_00_00_00_00_00
+- pci_0000_00_00_0
+- pci_0000_00_02_0
+- pci_0000_00_03_0
+- pci_0000_00_14_0
| |
| +- usb_usb2
| | |
| | +- usb_2_0_1_0
| | +- usb_2_7
| | | |
| | | +- usb_2_7_1_0
| | | +- usb_2_7_1_1
| | | 
| | +- usb_2_8
| | |
| | +- usb_2_8_1_0
| | +- usb_2_8_1_1
| | 
| +- usb_usb3

    2) virsh nodedev-dumpxml pci_0000_04_00_0
<device>
<name>pci_0000_04_00_0</name>
<path>/sys/devices/pci0000:00/0000:00:1c.2/0000:04:00.0</path>
<parent>pci_0000_00_1c_2</parent>
<driver>
<name>iwlwifi</name>
</driver>
<capability type='pci'>
<domain>0</domain>
<bus>4</bus>
<slot>0</slot>
<function>0</function>
<product id='0x08b4'>Wireless 3160</product>
<vendor id='0x8086'>Intel Corporation</vendor>
<iommuGroup number='13'>
<address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</iommuGroup>
</capability>
</device>

3, 在libvirt xml配置文件里面加入:
<hostdev mode='subsystem' type='pci' managed='yes'>
        <source>
        <address domain='0x00' bus='0x04' slot='0x00' function='0x00' />
       </source>
</hostdev>

至此再重新定义和开启虚拟机,然后lspci就可以看到穿透过来的pci设备了
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值