加载中…
个人资料
sqlora
sqlora
  • 博客等级:
  • 博客积分:0
  • 博客访问:6,500
  • 关注人气:8
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

kvm直通模式pci

(2016-07-08 13:44:46)
分类: linux

 

[root@localhost ~]# lspci |grep NVIDIA

02:00.0 VGA compatible controller: NVIDIA Corporation GK107GL [Quadro K600] (rev a1)

02:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)

03:00.0 VGA compatible controller: NVIDIA Corporation GF110GL [Tesla C2050 / C2075] (rev a1)

检查通道:

[root@localhost ~]# virsh

Welcome to virsh, the virtualization interactive terminal.

 

Type:  'help' for help with commands

       'quit' to quit

 

virsh # nodedev-list  --tree

computer

  |

  +- net_lo_00_00_00_00_00_00

  +- net_macvtap0_52_54_00_8d_88_f4

  +- net_virbr0_nic_52_54_00_65_3e_c5

  +- pci_0000_00_00_0

  +- pci_0000_00_01_0

  +- pci_0000_00_02_0

   |

   +- pci_0000_02_00_0

   +- pci_0000_02_00_1

    

  +- pci_0000_00_03_0

   |

   +- pci_0000_03_00_0

    

  +- pci_0000_00_04_0

  +- pci_0000_00_04_1

  +- pci_0000_00_04_2

  +- pci_0000_00_04_3

  +- pci_0000_00_04_4

  +- pci_0000_00_04_5

  +- pci_0000_00_04_6

  +- pci_0000_00_04_7

  +- pci_0000_00_05_0

  +- pci_0000_00_05_1

  +- pci_0000_00_05_2

  +- pci_0000_00_05_4

  +- pci_0000_00_11_0

  +- pci_0000_00_11_4

   |

   +- scsi_host0

    |

    +- scsi_target0_0_0

        |

        +- scsi_0_0_0_0

            |

            +- block_sda_WDC_WD2000FYYZ_03UL1B2_WD_WMC1P0D358EY

            +- scsi_generic_sg0

             

   +- scsi_host1

   +- scsi_host2

   +- scsi_host3

    

  +- pci_0000_00_14_0

   |

   +- usb_usb1

    |

    +- usb_1_0_1_0

    +- usb_1_12

     |

     +- usb_1_12_1_0

      

    +- usb_1_3

        |

        +- usb_1_3_1_0

         

   +- usb_usb2

       |

       +- usb_2_0_1_0

        

  +- pci_0000_00_1a_0

   |

   +- usb_usb3

       |

       +- usb_3_0_1_0

       +- usb_3_1

           |

           +- usb_3_1_1_0

            

  +- pci_0000_00_1b_0

  +- pci_0000_00_1c_0

  +- pci_0000_00_1c_2

   |

   +- pci_0000_05_00_0

       |

       +- net_enp5s0_0c_c4_7a_33_74_b4

        

  +- pci_0000_00_1c_3

   |

   +- pci_0000_06_00_0

       |

       +- net_enp6s0_0c_c4_7a_33_74_b5

        

  +- pci_0000_00_1c_4

  +- pci_0000_00_1d_0

   |

   +- usb_usb4

       |

       +- usb_4_0_1_0

       +- usb_4_1

           |

           +- usb_4_1_1_0

            

  +- pci_0000_00_1f_0

  +- pci_0000_00_1f_2

   |

   +- scsi_host4

   +- scsi_host5

   +- scsi_host6

   +- scsi_host7

   +- scsi_host8

   +- scsi_host9

       |

       +- scsi_target9_0_0

           |

           +- scsi_9_0_0_0

               |

               +- block_sr0_TSSTcorp_CDDVDW_SH_224DB_R96268EFA005BH

               +- scsi_generic_sg1

                

  +- pci_0000_00_1f_3

  +- pci_0000_7f_08_0

  +- pci_0000_7f_08_2

  +- pci_0000_7f_08_3

  +- pci_0000_7f_0b_0

  +- pci_0000_7f_0b_1

  +- pci_0000_7f_0b_2

  +- pci_0000_7f_0c_0

  +- pci_0000_7f_0c_1

  +- pci_0000_7f_0c_2

  +- pci_0000_7f_0c_3

  +- pci_0000_7f_0c_4

  +- pci_0000_7f_0c_5

  +- pci_0000_7f_0f_0

  +- pci_0000_7f_0f_1

  +- pci_0000_7f_0f_4

  +- pci_0000_7f_0f_5

  +- pci_0000_7f_0f_6

  +- pci_0000_7f_10_0

  +- pci_0000_7f_10_1

  +- pci_0000_7f_10_5

  +- pci_0000_7f_10_6

  +- pci_0000_7f_10_7

  +- pci_0000_7f_12_0

  +- pci_0000_7f_12_1

  +- pci_0000_7f_13_0

  +- pci_0000_7f_13_1

  +- pci_0000_7f_13_2

  +- pci_0000_7f_13_3

  +- pci_0000_7f_13_4

  +- pci_0000_7f_13_5

  +- pci_0000_7f_13_6

  +- pci_0000_7f_13_7

  +- pci_0000_7f_14_0

  +- pci_0000_7f_14_1

  +- pci_0000_7f_14_2

  +- pci_0000_7f_14_3

  +- pci_0000_7f_14_6

  +- pci_0000_7f_14_7

  +- pci_0000_7f_15_0

  +- pci_0000_7f_15_1

  +- pci_0000_7f_15_2

  +- pci_0000_7f_15_3

  +- pci_0000_7f_16_0

  +- pci_0000_7f_16_6

  +- pci_0000_7f_16_7

  +- pci_0000_7f_17_0

  +- pci_0000_7f_17_4

  +- pci_0000_7f_17_5

  +- pci_0000_7f_17_6

  +- pci_0000_7f_17_7

  +- pci_0000_7f_1e_0

  +- pci_0000_7f_1e_1

  +- pci_0000_7f_1e_2

  +- pci_0000_7f_1e_3

  +- pci_0000_7f_1e_4

  +- pci_0000_7f_1f_0

  +- pci_0000_7f_1f_2

  +- pci_0000_80_04_0

  +- pci_0000_80_04_1

  +- pci_0000_80_04_2

  +- pci_0000_80_04_3

  +- pci_0000_80_04_4

  +- pci_0000_80_04_5

  +- pci_0000_80_04_6

  +- pci_0000_80_04_7

  +- pci_0000_80_05_0

  +- pci_0000_80_05_1

  +- pci_0000_80_05_2

  +- pci_0000_80_05_4

  +- pci_0000_ff_08_0

  +- pci_0000_ff_08_2

  +- pci_0000_ff_08_3

  +- pci_0000_ff_0b_0

  +- pci_0000_ff_0b_1

  +- pci_0000_ff_0b_2

  +- pci_0000_ff_0c_0

  +- pci_0000_ff_0c_1

  +- pci_0000_ff_0c_2

  +- pci_0000_ff_0c_3

  +- pci_0000_ff_0c_4

  +- pci_0000_ff_0c_5

  +- pci_0000_ff_0f_0

  +- pci_0000_ff_0f_1

  +- pci_0000_ff_0f_4

  +- pci_0000_ff_0f_5

  +- pci_0000_ff_0f_6

  +- pci_0000_ff_10_0

  +- pci_0000_ff_10_1

  +- pci_0000_ff_10_5

  +- pci_0000_ff_10_6

  +- pci_0000_ff_10_7

  +- pci_0000_ff_12_0

  +- pci_0000_ff_12_1

  +- pci_0000_ff_13_0

  +- pci_0000_ff_13_1

  +- pci_0000_ff_13_2

  +- pci_0000_ff_13_3

  +- pci_0000_ff_13_4

  +- pci_0000_ff_13_5

  +- pci_0000_ff_13_6

  +- pci_0000_ff_13_7

  +- pci_0000_ff_14_0

  +- pci_0000_ff_14_1

  +- pci_0000_ff_14_2

  +- pci_0000_ff_14_3

  +- pci_0000_ff_14_6

  +- pci_0000_ff_14_7

  +- pci_0000_ff_15_0

  +- pci_0000_ff_15_1

  +- pci_0000_ff_15_2

  +- pci_0000_ff_15_3

  +- pci_0000_ff_16_0

  +- pci_0000_ff_16_6

  +- pci_0000_ff_16_7

  +- pci_0000_ff_17_0

  +- pci_0000_ff_17_4

  +- pci_0000_ff_17_5

  +- pci_0000_ff_17_6

  +- pci_0000_ff_17_7

  +- pci_0000_ff_1e_0

  +- pci_0000_ff_1e_1

  +- pci_0000_ff_1e_2

  +- pci_0000_ff_1e_3

  +- pci_0000_ff_1e_4

  +- pci_0000_ff_1f_0

  +- pci_0000_ff_1f_2

 

virsh # nodedev-dumpxml pci_0000_03_00_0

 

  pci_0000_03_00_0

  /sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0

  pci_0000_00_03_0

 

    vfio-pci

 

 

    0

    3

    0

    0

    GF110GL [Tesla C2050 / C2075]

    NVIDIA Corporation

   

     

   

   

   

     

     

   

 

 

 

 

virsh # nodedev-dumpxml pci_0000_00_03_0

 

  pci_0000_00_03_0

  /sys/devices/pci0000:00/0000:00:03.0

  computer

 

    pcieport

 

 

    0

    0

    3

    0

    Xeon E7 v3/Xeon E5 v3/Core i7 PCI Express Root Port 3

    Intel Corporation

   

     

   

   

   

     

     

   

 

 

 

 

virsh # exit

 

[root@localhost ~]# lspci -n -s 00:03.0

00:03.0 0604: 8086:2f08 (rev 02)

[root@localhost ~]# lspci -n -s 03:00.0

03:00.0 0300: 10de:1096 (rev a1)

 

 

 

[root@localhost ~]# cat /etc/grub.d/40_custom

#!/bin/sh

exec tail -n +3 $0

# This file provides an easy way to add custom menu entries.  Simply type the

# menu entries you want to add after this comment.  Be careful not to change

# the 'exec tail' line above.

menuentry 'CentOS Linux KVM' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-53576c45-9497-4257-ad38-7f72d5f14195' {

        load_video

        set gfxpayload=keep

        insmod gzio

        insmod part_msdos

        insmod xfs

        set root='hd0,msdos1'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  736bd1e0-bba1-4db6-a0a1-c4422451ccbc

        else

          search --no-floppy --fs-uuid --set=root 736bd1e0-bba1-4db6-a0a1-c4422451ccbc

        fi

        linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on pci-stub.ids=10de:1096 LANG=en_US.UTF-8

        initrd16 /initramfs-3.10.0-327.el7.x86_64.img

}

[root@localhost boot]# cat /boot/grub2/grubenv

# GRUB Environment Block

#saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)

saved_entry=CentOS Linux KVM

 

[root@localhost ~]# grub2-mkconfig -o /etc/grub2.cfg

 

[root@localhost ~]# reboot 重启系统

 

[root@localhost ~]# dmesg | grep pci-stub

   0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on pci-stub.ids=10de:1096 LANG=en_US.UTF-8

   0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on pci-stub.ids=10de:1096 LANG=en_US.UTF-8

   9.288982] pci-stub: add 10DE:1096 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000

   9.288994] pci-stub 0000:03:00.0: claimed by stub

[ 1003.753257] pci-stub 0000:03:00.0: claimed by stub

[root@localhost ~]# dmesg | grep -i IOMMU

   0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on pci-stub.ids=10de:1096 LANG=en_US.UTF-8

   0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on pci-stub.ids=10de:1096 LANG=en_US.UTF-8

   0.000000] Intel-IOMMU: enabled

   0.057837] dmar: IOMMU 0: reg_base_addr fbffc000 ver 1:0 cap d2078c106f0466 ecap f020df

   0.057843] dmar: IOMMU 1: reg_base_addr f7ffc000 ver 1:0 cap d2078c106f0466 ecap f020df

   0.057965] IOAPIC id 10 under DRHD base  0xfbffc000 IOMMU 0

   0.057966] IOAPIC id 8 under DRHD base  0xf7ffc000 IOMMU 1

   0.057967] IOAPIC id 9 under DRHD base  0xf7ffc000 IOMMU 1

   9.250140] IOMMU 0 0xfbffc000: using Queued invalidation

   9.250142] IOMMU 1 0xf7ffc000: using Queued invalidation

   9.250149] IOMMU: Setting RMRR:

   9.250163] IOMMU: Setting identity map for device 0000:00:14.0 [0x7b818000 - 0x7b826fff]

   9.250181] IOMMU: Setting identity map for device 0000:00:1a.0 [0x7b818000 - 0x7b826fff]

   9.250198] IOMMU: Setting identity map for device 0000:00:1d.0 [0x7b818000 - 0x7b826fff]

   9.250212] IOMMU: Prepare 0-16MiB unity mapping for LPC

   9.250221] IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]

[root@localhost ~]# lspci -vv -s 03:00.0

03:00.0 VGA compatible controller: NVIDIA Corporation GF110GL [Tesla C2050 / C2075] (rev a1) (prog-if 00 [VGA controller])

        Subsystem: Hewlett-Packard Company Device 0910

        Physical Slot: 3

        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+

        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR-

        Latency: 0, Cache Line Size: 64 bytes

        Interrupt: pin A routed to IRQ 28

        Region 0: Memory at f3000000 (32-bit, non-prefetchable) [size=16M]

        Region 1: Memory at 383fe8000000 (64-bit, prefetchable) [size=128M]

        Region 3: Memory at 383ff0000000 (64-bit, prefetchable) [size=32M]

        Region 5: I/O ports at 5000 [size=128]

        Expansion ROM at f4000000 [disabled] [size=512K]

        Capabilities: [60] Power Management version 3

                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)

                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-

        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+

                Address: 0000000000000000  Data: 0000

        Capabilities: [78] Express (v1) Endpoint, MSI 00

                DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <4us, L1 <64us

                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-

                DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported-

                        RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+

                        MaxPayload 128 bytes, MaxReadReq 512 bytes

                DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-

                LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <256ns, L1 <4us

                        ClockPM+ Surprise- LLActRep- BwNot-

                LnkCtl: ASPM L1 Enabled; RCB 128 bytes Disabled- CommClk+

                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-

                LnkSta: Speed 2.5GT/s, Width x16, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-

        Capabilities: [b4] Vendor Specific Information: Len=14

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有