Hi all, I try to understand why the network bandwidth limits are not applied to my ubuntu 16.04.2 VM (qemu-kvm driver) and I would need some insights. I create my VM network with virsh and when I issue a dumpxml on my network, I can see that bandwidth limits are set: virsh # net-dumpxml nat_limit <network> <name>nat_limit</name> <uuid>4b5e128d-9ad0-4ccc-9424-dee60b71861a</uuid> <forward mode='nat'> <nat> <port start='1024' end='65535'/> </nat> </forward> <bridge name='virbr1' stp='on' delay='0'/> <mac address='52:54:00:af:99:73'/> <bandwidth> <inbound average='10' peak='50' burst='10'/> <outbound average='128' peak='256' burst='256'/> </bandwidth> <ip address='192.168.123.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.123.2' end='192.168.123.254'/> </dhcp> </ip> </network> And the net info is: virsh # net-info nat_limit Name: nat_limit UUID: 4b5e128d-9ad0-4ccc-9424-dee60b71861a Active: yes Persistent: yes Autostart: yes Bridge: virbr1 Then, I create my VM, and the source of interface is the network, like this: virsh # dumpxml virt20 ... <interface type='network'> <mac address='52:54:00:a2:5b:10'/> <source network='nat_limit' bridge='virbr1'/> <target dev='vnet2'/> <model type='rtl8139'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> ... However when I send a big file with netper I don't see any limits applied to the transfer rate. I've checked the domain log and I didn't see any qemu command line argument related to bandwidth limits. Could you tell me why the network bandwidth limits can not work? Do network limits are managed in another way? Thanks. Below some information about my hypervisor: root@ubuntu-04:~# virsh -V Virsh command line tool of libvirt 1.3.1 See web site at http://libvirt.org/ Compiled with support for: Hypervisors: QEMU/KVM LXC UML Xen LibXL OpenVZ VMWare VirtualBox ESX Test Networking: Remote Network Bridging Interface netcf Nwfilter VirtualPort Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM RBD Sheepdog ZFS Miscellaneous: Daemon Nodedev AppArmor Secrets Debug Readline Modular qemu version: 2.5.0 Thanks, Netsurfed
Michal Privoznik
2017-Jun-16 08:29 UTC
Re: [libvirt-users] [qemu-kvm] Network bandwidth limits via libvirt
On 06/15/2017 07:56 AM, 卓浩凡 wrote:> Hi all, > > I try to understand why the network bandwidth limits are not applied to my ubuntu 16.04.2 VM (qemu-kvm driver) and I would need some insights. > I create my VM network with virsh and when I issue a dumpxml on my network, I can see that bandwidth limits are set: > > virsh # net-dumpxml nat_limit > <network> > <name>nat_limit</name> > <uuid>4b5e128d-9ad0-4ccc-9424-dee60b71861a</uuid> > <forward mode='nat'> > <nat> > <port start='1024' end='65535'/> > </nat> > </forward> > <bridge name='virbr1' stp='on' delay='0'/> > <mac address='52:54:00:af:99:73'/> > <bandwidth> > <inbound average='10' peak='50' burst='10'/> > <outbound average='128' peak='256' burst='256'/> > </bandwidth> > <ip address='192.168.123.1' netmask='255.255.255.0'> > <dhcp> > <range start='192.168.123.2' end='192.168.123.254'/> > </dhcp> > </ip> > > </network>Have you restarted network after editing? virsh net-destroy nat_limit && virsh net-start nat_limit;> > > And the net info is: > virsh # net-info nat_limit > Name: nat_limit > UUID: 4b5e128d-9ad0-4ccc-9424-dee60b71861a > Active: yes > Persistent: yes > Autostart: yes > Bridge: virbr1 > Then, I create my VM, and the source of interface is the network, like this: > virsh # dumpxml virt20 > ... > <interface type='network'> > <mac address='52:54:00:a2:5b:10'/> > <source network='nat_limit' bridge='virbr1'/> > <target dev='vnet2'/> > <model type='rtl8139'/> > <alias name='net0'/> > <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> > </interface> > ... > > > However when I send a big file with netper I don't see any limits applied to the transfer rate.Where are you sending the file from? If it is the host then the limits should be applied. If it is from another virtual machine, then unfortunately limits are set, but since kernel takes some shortcuts and the packets don't travel through bridge but are copied from one vNIC to another one. In that case you might want to use <bandwidth/> for your <interface/> directly. The golden rule here is follow the packets. In case of network, the limiting is applied on the bridge, so packets must go through bridge in order for limits to apply. In case of <interface/> the limits are applied there. Michal
Apparently Analagous Threads
- CentOS 7 host with guests as bridge cannot access host
- How to disable dnsmasq from starting automatically with libvirtd
- Re: guest A from virbr0 can talk to guest B in virbr1 but not vice versa
- unable to ping from guests in virbr0 to guests in virbr1 network
- Inconsistent iptables forwarding rules for virtual networks?