Jochen
Jochen

Reputation: 1853

Qemu/Libvirt: limit total download size

We're providing VMs to people with Qemu/Libvirt. Now we'd like to make sure that users of these VMs can not download very large files (for example 1..2GB files).

Is it possible to limit this with QEMU/Libvirt? I know there's a bandwidth option with libvirt that seems to use tc shape the bandwidth, but I'm looking for a way to not throttle the bandwidth speed, but rather the amount of downloaded bytes.

Upvotes: 1

Views: 868

Answers (2)

Jochen
Jochen

Reputation: 1853

What we ended up doing was creating a daemon that monitored virsh domifstat and looked at rx_bytes. When a threshold is reached, the VM is destroyed.

Upvotes: 0

DanielB
DanielB

Reputation: 2836

There's no mechanism in either QEMU or libvirt for limiting the total cumulative network traffic downloaded by a VM. All that's possible is to set data transfer rate caps via tc, as you've already noticed.

So any solution to this would have to likely be done in your network router, based on the guest assigned MAC address / IP address.

Upvotes: 1

Related Questions