序:

做DPDK例子的时候,发现一些例子需要多队列,而我当前所使用的虚拟机并不是多队列的。关于我当前虚拟机的状态,可以见前文。

所以,我的需求就是,让虚拟机里的网卡,有多队列!

参考:

http://www.linux-kvm.org/page/Multiqueue

https://gist.github.com/sibiaoluo/11133723

原理上没大看懂,半懂不懂的。目的优先。

查看:

  如何查看网卡是否支持多队列: 红色的行就代表支持了。 MSI-X就是支持多队列的意思,MSI是什么意思,我也不知道。

  Count=64 代表支持64个队列。

[root@C4 ]# lspci |grep
:00.0 Ethernet controller: Intel Corporation 82599ES -Gigabit SFI/SFP+ Network Connection (rev )
:00.1 Ethernet controller: Intel Corporation 82599ES -Gigabit SFI/SFP+ Network Connection (rev )
[root@C4 ]# lspci -vv -s :00.0 |grep MSI
Capabilities: [] MSI: Enable- Count=/ Maskable+ 64bit+
Capabilities: [70] MSI-X: Enable+ Count=64 Masked-
Capabilities: [a0] Express (v2) Endpoint, MSI
[root@C4 ]#

  再查看: 队列分了四种,RX,TX,Other,Combined。 63代表 combined可以设置的最大值是63. 24代表当前的队列设置是24

[root@C4 ]# ethtool -l eth4
Channel parameters for eth4:
Pre-set maximums:
RX:
TX:
Other:
Combined:
Current hardware settings:
RX:
TX:
Other:
Combined: [root@C4 ]#

  当然这个值是可以该的,比如将24 改为 25:

[root@dpdk ~]# ethtool -L eth1 combined 

  再查看:中断

[root@C4 ]# ls /sys/bus/pci/devices/\:\:00.0/msi_irqs/

[root@C4 ]# 

  还可以:

[root@C4 ]# cat /proc/interrupts |grep eth4 |awk -F ' ' '{print $27}'
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4-TxRx-
eth4
[root@C4 ]# ll /sys/

开始:

当前配置:

/home/tong/VM/dpdk [tong@T7] [:]
> cat start.sh
sudo qemu-system-x86_64 -nographic -vnc 127.0.0.1: -enable-kvm \
-m 2G -cpu Nehalem -smp cores=,threads=,sockets= \
-numa node,mem=1G,cpus=-,nodeid= \
-numa node,mem=1G,cpus=-,nodeid= \
-drive file=disk.img,if=virtio \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:00' \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:01' \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:02' \
-net tap,vlan=,ifname=tap-dpdk-ctrl \
-net tap,vlan=,ifname=tap-dpdk-,script=no,downscript=no \
-net tap,vlan=,ifname=tap-dpdk-,script=no,downscript=no &
# -device vfio-pci,host='0000:00:19.0' \
#ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio /home/tong/VM/dpdk [tong@T7] [:]
>

改完之后:红色部分为关键性修改。

vectors=32 修改了lspci中打印的那个count
mq=on 的修改可以在“ip link”中被查看到,关键字 pfifo_fast 变成了 mq
-netdev 和 -net 是有区别的。-net中包含vlan参数,即使没有显示指定它依然与queues参数相冲突。
vhost=on 并不知道有什么用。不加的话好像也是可以的。
queues=16 会在使用ethtool -l时查看到max为16
/home/tong/VM/dpdk [tong@T7] [:]
> cat start-multiqueue.sh
sudo qemu-system-x86_64 -nographic -vnc 127.0.0.1: -enable-kvm \
-m 2G -cpu Nehalem -smp cores=,threads=,sockets= \
-numa node,mem=1G,cpus=-,nodeid= \
-numa node,mem=1G,cpus=-,nodeid= \
-drive file=disk.img,if=virtio \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:00' \
-device virtio-net-pci,netdev=dev1,mac='00:00:00:01:00:01',vectors=32,mq=on \
-device virtio-net-pci,netdev=dev2,mac='00:00:00:01:00:02',vectors=32,mq=on \
-net tap,vlan=,ifname=tap-dpdk-ctrl \
-netdev tap,ifname=tap-dpdk-,script=no,downscript=no,vhost=on,queues=16,id=dev1 \
-netdev tap,ifname=tap-dpdk-,script=no,downscript=no,vhost=on,queues=16,id=dev2 &
# -device vfio-pci,host='0000:00:19.0' \
#ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio

  启动之后,生效的queue依然只有1,需要用ethtool修改之。

[root@dpdk ~]# ethtool -L eth2 combined
[root@dpdk ~]# ethtool -l eth2
Channel parameters for eth2:
Pre-set maximums:
RX:
TX:
Other:
Combined:
Current hardware settings:
RX:
TX:
Other:
Combined:

  但是在查看中断的时候,并没有变多,而是叫 virtio2-virtqueues 统一由一个中断队列处理。

[root@dpdk ~]# ll /sys/bus/pci/devices/\:\:05.0/msi_irqs/
total
-r--r--r--. root root Dec :
-r--r--r--. root root Dec :
[root@dpdk ~]# cat /proc/interrupts |egrep "31|32"
: PCI-MSI-edge virtio3-req.
: PCI-MSI-edge virtio2-config
: PCI-MSI-edge virtio2-virtqueues
[root@dpdk ~]#

  为啥没变多? 因为写的不太对,查看前文参考的红帽文档可以看见如下内容:

qemu-kvm -netdev tap,id=hn0,queues=M -device virtio-net-pci,netdev=hn0,vectors=2M+

  然后把前文的 vectors=32 改成 vectors=34. 在guest中可以看见中断,一共33 个。

[root@dpdk ~]# cat /proc/interrupts |grep virtio2
: PCI-MSI-edge virtio2-config
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.
: PCI-MSI-edge virtio2-input.
: PCI-MSI-edge virtio2-output.15
[root@dpdk ~]# ls /sys/bus/pci/devices/0000\:00\:05.0/msi_irqs/ |wc -l  
33
[root@dpdk ~]#

  最终,QEMU启动命令脚本如下:

/home/tong/VM/dpdk [tong@T7] [:]
> cat start-multiqueue.sh
sudo qemu-system-x86_64 -nographic -vnc 127.0.0.1: -enable-kvm \
-m 2G -cpu Nehalem -smp cores=,threads=,sockets= \
-numa node,mem=1G,cpus=-,nodeid= \
-numa node,mem=1G,cpus=-,nodeid= \
-drive file=disk.img,if=virtio \
-net nic,vlan=,model=virtio,macaddr='00:00:00:01:00:00' \
-device virtio-net-pci,netdev=dev1,mac='00:00:00:01:00:01',vectors=,mq=on \
-device virtio-net-pci,netdev=dev2,mac='00:00:00:01:00:02',vectors=,mq=on \
-net tap,vlan=,ifname=tap-dpdk-ctrl \
-netdev tap,ifname=tap-dpdk-,script=no,downscript=no,vhost=on,queues=,id=dev1 \
-netdev tap,ifname=tap-dpdk-,script=no,downscript=no,vhost=on,queues=,id=dev2 &
# -device vfio-pci,host='0000:00:19.0' \
#ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio /home/tong/VM/dpdk [tong@T7] [:]
>

[Virtualization][qemu][kvm][virtio] 使用 QEMU/KVM 模拟网卡多队列的更多相关文章

  1. KVM 介绍(3):I/O 全虚拟化和准虚拟化 [KVM I/O QEMU Full-Virtualizaiton Para-virtualization]

    学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...

  2. KVM/QEMU桥接网络设置及kvm资料

    KVM/QEMU桥接网络设置 配置kvm的网络有2种方法.其一,默认方式为用户模式网络(Usermode Networking),数据包由NAT方式通过主机的接口进行传送.其二,使用桥接方式(Brid ...

  3. [qemu][cloud][centos][ovs][sdn] centos7安装高版本的qemu 以及 virtio/vhost/vhost-user咋回事

    因为要搭建ovs-dpdk,所以需要vhost-user的qemu centos默认的qemu与qemu-kvm都不支持vhost-user,qemu最高版本是2.0.0, qemu-kvm最高版本是 ...

  4. KVM :vnc 远程控制kvm创建虚拟机

    一.vnc远程控制服务器 前期准备: 1.编辑/etc/hosts vi /etc/hosts 10.1.16.32 kvm 2.关闭防火墙 service iptables stop 3.关闭sel ...

  5. centos6.5安装KVM,并在KVM中安装虚拟6.5系统

    =============================环境搭建================================================== 1.检查CPU信息 KVM 需要 ...

  6. CentOS 7创建自定义KVM模板(现有KVM迁移到另外一台机)

    说明:创建KVM模板有个好处,不用每次都运行命令创建,并且可以为迁移做准备. 一.创建KVM模板 1.下载iso(省略) 2.创建磁盘 qemu-img create -f raw centos7.r ...

  7. qemu 出现Could not access KVM kernel module: No such file or directory failed to initialize KVM: No such file or directory

    使用qemu命令 qemu-system-x86_64 -hda image/ubuntu-test.img -cdrom ubuntu-16.04.2-server-amd64.iso -m 102 ...

  8. QEMU KVM Libvirt手册(10): KVM的各种限制

    Overcommits KVM allows for both memory and disk space overcommit. However, hard errors resulting fro ...

  9. [转] KVM VirtIO paravirtualized drivers: why they matter

    http://www.ilsistemista.net/index.php/virtualization/42-kvm-virtio-paravirtualized-drivers-why-they- ...

随机推荐

  1. mysql 如何判断 "字符串" 是否为 "数字"

    这个问题有点怪 ,但很多时候我们会以字符串的形式存储数字 , 反过来我们用字符串进行数学运算时, 好像也不会出错 . 除非 , 用作数学运算的字符串不能转换成数字 .但是我们改如何判断字符串是否能转换 ...

  2. 4D时间管理

    时间管理的4D原则   时间矩阵:每个人,每天要做的事情大致分为四类:一类:必须做的,不做会产生不良后果的二类:需要做的,为将来或者今后阶段做准备工作的三类:可以不做,但又不得不做的,例如通过简约形式 ...

  3. Ferry Loading III[HDU1146]

    Ferry Loading IIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. [译]使用Continuous painting mode来分析页面的绘制状态

    Chrome Canary(Chrome “金丝雀版本”)目前已经支持Continuous painting mode,用于分析页面性能.这篇文章将会介绍怎么才能页面在绘制过程中找到问题和怎么利用这个 ...

  5. UVA 10791 - Minimum Sum LCM(坑)

    题目链接 不知道为什么,我用cin,cout就是过不了...改成scanf过了... 还是我居然理解错题意了,已经不能用看错了...至少两个数字,我理解成两个数字了,还写了个爆搜... #includ ...

  6. Tomcat_启动多个tomcat时,会报StandardServer.await: Invalid command '' received错误

    解决方案如下:将tomcat下的server.xml文件中的端口有问题,修改规则按以下标准显示“http的端口修改为6000 to 6800之间,shutdown的端口修改为3000 to 3300之 ...

  7. Hive_DDL与DML

    DDL(数据定义语言) create.drop.alter.truncate.show.describe DML(数据控制语言) load.insert.update.delete.import/ex ...

  8. PLSQL Developer注册码

    Product Code:4t46t6vydkvsxekkvf3fjnpzy5wbuhphqzserial Number:601769password:xs374ca

  9. thinkphp添加空数据的解决办法

    thinkphp真是个麻烦的东西,各种小问题,其中字段映射的表单名不能与数据库的字段名称相同,否则会添加空数据! 还有自动完成的名称要与字段映射后的名称相同,否则自动完成不会起作用! 还有自动验证的字 ...

  10. super()和this()的区别

    1)调用super()必须写在子类构造方法的第一行,否则编译不通过.每个子类构造方法的第一条语句,都是隐含地调用super(),如果父类没有这种形式的构造函数,那么在编译的时候就会报错. 2)supe ...