序:

做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. bug提交模板

    简述所属版本所属模块严重等级优先级分配给[网络情况][前置条件][详情描述] 1. 2. 3.[预期结果][实际结果][历史版本][备注][是否补充用例] 另外: 1.若和界面有关的bug尽量提供对应 ...

  2. git 学习笔记4--.gitignore

    很多时候,我们都不希望非源码的文件加入到repository管理. 这时,.gitignore文件就上场了. ignore规则 所有空行或者以注释符号 # 开头的行都会被 Git 忽略. 可以使用标准 ...

  3. 关于listView 中的聚焦问题

    我在使用listView+adapter 中,遇到一个问题,就是item项添加了若干个可以被监听的控件后 在listView中的setOnItemClickListener失效了 原因是焦点已经在it ...

  4. ggplot2包--R可视化

    1.ggplot2发展历程 ggplot2是Hadley在爱荷华州立大学博士期间的作品,也是他博士论文的主题之一,实际上ggplot2还有个前身ggplot,但后来废弃了,某种程度上这也是Hadley ...

  5. 【原】iOS多线程之NSThread、NSOperationQueue、NSObject和GCD的区别

    区别: Thread: 是这几种方式里面相对轻量级的,但也是使用起来最负责的,你需要自己管理thread的生命周期,线程之间的同步.线程共享同一应用程序的部分内存空间, 它们拥有对数据相同的访问权限. ...

  6. django 数据库交互

    修改配置文件 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'USER':'root', 'PASSWORD':'1 ...

  7. 【BZOJ】1115: [POI2009]石子游戏Kam

    http://www.lydsy.com/JudgeOnline/problem.php?id=1115 题意:n堆石子,个数是从左到右单增.每一次可以从任意堆取出任意石子,但要保持单增这个性质.问先 ...

  8. Find和FirstOrDefault()有什么区别?

    Find方法和FirstOrDefault方法效果相同,都是返回满足条件的第一个元素,如果没有该元素,则返回null. 那么这两个扩展方法有什么不同? 1)Find方法是.netFramework2. ...

  9. jquery.autocomplete在火狐下的BUG解决

    该插件在火狐下使用拼音输入法输入,回车后无法即使响应事件,需要再输入别的字母才会响应事件     主要原因:   该插件响应主要监听了keydown事件   其他浏览器在打开中文输入法的情况下输入的拼 ...

  10. [iOS-UI]点击清空按钮,却会有提交的感觉

    一,问题分析 1.感觉像是点击清空按钮时调用了添加按钮的事件. 2.插入断电后,还真是这样. 3.仔细想想,才发现,原来是我复制了添加按钮,变成为添加按钮,进而点击清空时,不仅清空了所有内容,还把最新 ...