[libvirt-users] [qemu-kvm] Network bandwidth limits via libvirt

Michal Privoznik mprivozn at redhat.com
Fri Jun 16 08:29:10 UTC 2017


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




More information about the libvirt-users mailing list