[Virtualization][qemu][kvm][virtio] 使用 QEMU/KVM 模拟网卡多队列
序:
做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 模拟网卡多队列的更多相关文章
- 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设备直接分 ...
- KVM/QEMU桥接网络设置及kvm资料
KVM/QEMU桥接网络设置 配置kvm的网络有2种方法.其一,默认方式为用户模式网络(Usermode Networking),数据包由NAT方式通过主机的接口进行传送.其二,使用桥接方式(Brid ...
- [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最高版本是 ...
- KVM :vnc 远程控制kvm创建虚拟机
一.vnc远程控制服务器 前期准备: 1.编辑/etc/hosts vi /etc/hosts 10.1.16.32 kvm 2.关闭防火墙 service iptables stop 3.关闭sel ...
- centos6.5安装KVM,并在KVM中安装虚拟6.5系统
=============================环境搭建================================================== 1.检查CPU信息 KVM 需要 ...
- CentOS 7创建自定义KVM模板(现有KVM迁移到另外一台机)
说明:创建KVM模板有个好处,不用每次都运行命令创建,并且可以为迁移做准备. 一.创建KVM模板 1.下载iso(省略) 2.创建磁盘 qemu-img create -f raw centos7.r ...
- 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 ...
- QEMU KVM Libvirt手册(10): KVM的各种限制
Overcommits KVM allows for both memory and disk space overcommit. However, hard errors resulting fro ...
- [转] KVM VirtIO paravirtualized drivers: why they matter
http://www.ilsistemista.net/index.php/virtualization/42-kvm-virtio-paravirtualized-drivers-why-they- ...
随机推荐
- Poj1131-Octal Fractions
Octal Fractions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6669 Accepted: 3641 D ...
- putty ssh连接老断
有两种方法来解决:一. 配置客户端 1 在 linux下的ssh命令:vim /etc/ssh/ssh_config 然后找到里面的ServerAliveInterval 参数,如果没有你同样自己加一 ...
- Eclipse: How to Navigating Java call stack in Eclipse
Link: http://stackoverflow.com/questions/3256369/navigating-java-call-stack-in-eclipse 解决方法: In the ...
- BZOJ4569 : [Scoi2016]萌萌哒
建立ST表,每层维护一个并查集. 每个信息可以拆成两条长度为$2$的幂次的区间相等的信息,等价于ST表里两对点的合并. 然后递归合并,一旦发现已经合并过了就退出. 因为一共只会发生$O(n\log n ...
- echarts.js 做图表的插件
<scripttype="text/javascript"src="{uiurl()}echarts/echarts.js"></script ...
- wamp 2.5 开放访问权限和设置虚拟域名
开放访问权限 D:\wamp\bin\apache\apache2.4.9\conf 里的 httpd.conf 搜索www 把 Require local 改为 Require all gra ...
- 洛谷 P1092 虫食算 Label:dfs
题目描述 所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母.来看一个简单的例子: 43#9865#045 +8468#6633 44445509678 其中# ...
- 【noiOJ】p7914(..)
08:不重复地输出数 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 输入n个数,从小到大将它们输出,重复的数只输出一次.保证不同的数不超过500个. 输入 ...
- 自己签发免费ssl证书
自己制作ssl证书:自己签发免费ssl证书,为nginx生成自签名ssl证书 这里说下Linux 系统怎么通过openssl命令生成 证书. 首先执行如下命令生成一个keyopenssl genrsa ...
- Ubuntu root密码修改
安装完Ubuntu后忽然意识到没有设置root密码,不知道密码自然就无法进入根用户下.到网上搜了一下,原来是这麽回事.Ubuntu的默认root密码是随机的,即每次开机都有一个新的root密码.我们可 ...