[libvirt] traffic control on hypervisor
Michal Privoznik
mprivozn at redhat.com
Fri Jan 10 09:45:23 UTC 2014
On 10.01.2014 09:37, yue wrote:
> hi,all
> if we can control the bandwidth of vm at hypervisor level?
> i know linux tc command can control traffic, but it is at ISO level 3,
> vm;s network is on bridge at level 2.
>
> how libvirt implement traffic control over vm?
>
> thanks
>
I'm not sure the linux traffic shaper works on layer 3. I'd say linux
inserts a new layer (called "queuing layer") in between layers 2 and 3
just to allow traffic shaping on bridges too. Hence, there's no need for
libvirt to treat bridges differently than the rest of devices when it
comes to traffic shaping (e.g. TUN/TAP device). If your bridge is
managed by libvirt, you can insert a simple XML snippet to corresponding
network configuration, e.g.:
<bandwidth>
<inbound average='1000' peak='5000' burst='5120'/>
<outbound average='128' peak='256' burst='256'/>
</bandwidth>
http://libvirt.org/formatnetwork.html#elementQoS
Same applies for each domain's interface:
<bandwidth>
<inbound average='1000' peak='5000' floor='200' burst='1024'/>
<outbound average='128' peak='256' burst='256'/>
</bandwidth>
http://libvirt.org/formatdomain.html#elementQoS
If you're interested in implementation details I'd suggest to dive into
http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/virnetdevbandwidth.c;h=ed6a19d7faa3b564e4aa6c184418ebd85305a712;hb=HEAD#l45
Libvirt creates rather a complex tree of qdiscs (things get complicated
once a device hotplug is allowed). But there's nearly a page comment
with a picture showing what's going on.
Michal
More information about the libvir-list
mailing list