[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- ...
随机推荐
- C# 词法分析器(六)构造词法分析器
系列导航 (一)词法分析介绍 (二)输入缓冲和代码定位 (三)正则表达式 (四)构造 NFA (五)转换 DFA (六)构造词法分析器 (七)总结 现在最核心的 DFA 已经成功构造出来了,最后一步就 ...
- dl dt dd定义
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- tomcat与HTML命令提示符
在tomcatwebapps目录下建立一个新文件夹 命名为my 把第一个学习的HTML文件放到my文件夹内 通过tomcat服务器远程访问该网页 把localhost换成自己的IP地址 先查看自己的I ...
- Codeforces Round #196 (Div. 2) B. Routine Problem
screen 尺寸为a:b video 尺寸为 c:d 如果a == c 则 面积比为 cd/ab=ad/cb (ad < cb) 如果b == d 则 面积比为 cd/ab=cb/ad (c ...
- jQuery实现竖排菜单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- [题解+总结]NOIP2015模拟题2
// 此博文为迁移而来,写于2015年7月22日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102w72i.html 1.总 ...
- win8.1上wamp环境中利用apache自带ab压力测试工具使用超简单讲解
2015.10.4apache自带ab压力测试工具使用:本地环境:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一 ...
- window下 配置gitlab ssh非端口22端口
git config --global user.name "jack" git config --global user.email "jackluo@xxx.com& ...
- windows2008 IIS下配置FTP服务
一.服务器管理器 1.2008的系统使用服务器管理器,选择角色,因为我之前已经开启了IIS服务器角色,所以我现在只要添加角色服务即可,如果你没有开启过的话,直接添加角色即可. 2.选择WEB服务器,打 ...
- [CareerCup] 18.13 Largest Rectangle of Letters
18.13 Given a list of millions of words, design an algorithm to create the largest possible rectangl ...