获取支持SRIOV的网络接口设备信息

1.首先 virsh nodedev-list --cap net | grep -v net_lo_00_00_00_00_00_00 可以查看当前系统现有的网络设备 如下图所示

2.但是上述只能显示设备信息,无法显示出设备的pci相关信息,也可以virsh nodedev-list --tree 以树形的结构展现 以树形结构展现 可以展现对应pci信息下的设备信息


3.virsh nodedev-list dumpxml 某个设备名字如 net_enp8s16f5_6e_36_5a_d1_e3_a3可以得到如下信息


4.可以看到该网络设备的硬件信息 如网卡名字和MAC地址等,其parent一项指定的pci信息也正好是树形结构下该设备对应的pci信息 执行 virsh nodedev-list dumpxml  pci_0000_08_10_5 可得到如下信息


5.图中描述的不再是具体的设备信息,二是设备对应的pci相关信息和对应的网卡及驱动信息,该网络设备是SRIOV环境下一个物理PF虚拟出的一个VF,所以name 一项是igbvf 
6.下面再看物理网络接口 virsh nodedev-dumpxml net_enp7s0f0_f8_0f_41_f2_ea_ee 可以得到物理网络接口设备的相关信息,MAC和接口速度等
 
7.之后对应其pci 信息 virsh nodedev-dumpxml pci_0000_07_00_0


可以看出该物理网络设备对应的网卡驱动信息,并且由于配置了其支持SRIOV可以看到其上虚拟出来的各个VF的PCI信息,每个VF PCI信息下都对应一个VF相关信息,因而可以将这些信息整合,形成一个直观的支持SRIOV的系统的网络接口设备信息,最后形式如下

代码如下:
#!/bin/bash

##
# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
# This file is part of openmano
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: nfvlabs@tid.es
##

#Get configuration of a host for using it as a compute node
####
###author wangxia ctbri wexll@sina.com
###system:CentOS Linux release 7.2.1511 (Core)
###NIC:I350 Gigabit Network Connection
###NIC driver:igb
####
function usage(){
    echo  -e "usage: $0 user ip_name [>> host.yaml]\n  Get host parameters and generated a yaml file to be used for openvim host-add"
    exit 1
}

function load_vf_driver(){
  local pf_driver=$1
  if [[ `lsmod | cut -d" " -f1 | grep $pf_driver | grep -v vf` ]] && [[ ! `lsmod | cut -d" " -f1 | grep ${pf_driver}vf` ]]
  then
    >&2 echo "$pf_driver is loaded but not ${pf_driver}vf. This is required in order to properly add SR-IOV."
    read -p "Do you want to load ${pf_driver}vf [Y/n] " load_driver
    case $load_driver in
      [nN]* ) exit 1;;
      * ) >&2 echo "Loading ${pf_driver}vf..."
          modprobe ${pf_driver}vf;
          >&2 echo "Reloading ${pf_driver}..."
          modprobe -r $pf_driver;
          modprobe $pf_driver;;
    esac
  fi
}

function remove_vf_driver(){
  local pf_dr
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值