[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- ...
随机推荐
- three.js 场景入门
<!DOCTYPE html> <html> <head> <title>Example 01.02 - First Scene</title&g ...
- 编写unit test以及自动化测试WebDriver
http://msdn.microsoft.com/en-us/library/hh694602.aspx#BKMK_Quick_starts http://www.seleniumhq.org/ ...
- 移动H5前端性能优化指南(转载)
移动H5前端性能优化指南 概述 1. PC优化手段在Mobile侧同样适用2. 在Mobile侧我们提出三秒种渲染完成首屏指标3. 基于第二点,首屏加载3秒完成或使用Loading4. 基于联通3G网 ...
- NOIp 2014 #4 无线网络发射器选址 Label:模拟
题目描述 随着智能手机的日益普及,人们对无线网的需求日益增大.某城市决定对城市内的公共场所覆盖无线网. 假设该城市的布局为由严格平行的129 条东西向街道和129 条南北向街道所形成的网格状,并且相邻 ...
- Code[VS] 1022 覆盖 题解
Code[VS] 1022 覆盖 题解 Hungary Algorithm 题目传送门:Code[VS] 1022 题目描述 Description 有一个N×M的单位方格中,其中有些方格是水塘,其 ...
- javascript 时间操作
javascript时间函数 javascript提供了Date对象来进行时间和日期的计算.Date对象有多种构造函数: 1.dateObj=new Date() //当前时间 2.dateObj=n ...
- css圆角边框
一.CSS3圆角的优点 传统的圆角生成方案,必须使用多张图片作为背景图案.CSS3的出现,使得我们再也不必浪费时间去制作这些图片了,而且还有其他多个优点: * 减少维护的工作量.图片文件的生成.更新. ...
- [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 ...
- [CareerCup] 16.5 Semphore 信号旗
16.5 Suppose we have the following code:public class Foo { public Foo() { . . . } public void first( ...
- jsp...九九乘法表,三角形,菱形
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...