mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
virnetdevbandwidth: Only clear qdisc for defined directions
When virNetDevBandwidthSet is called for a macvtap device in
qemu_command and qemu_hotplug, qemuDomainInterfaceSetDefaultQDisc has
been called already, setting the iface qdisc to 'noqueue'. If the
interface has an inbound-only bandwidth limit, the outgoing qdisc
on the device will be reset to the system default.
<interface type="direct">
...
<bandwidth>
<inbound average='3125000' peak='3125000'/>
</bandwidth>
</interface>
This only clears the qdisc on an interface before a bandwidth limit is
actually set.
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/875
Signed-off-by: Wesley Hershberger <wesley.hershberger@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
1 parent
0d906d8a14
commit
124c53169e
2 files changed
+14
-10
No files matched your search
@@ -287,13 +287,13 @@ virNetDevBandwidthSet(const char *ifname,
|
||||
tx = bandwidth->out;
|
||||
}
|
||||
|
||||
/* Only if the caller requests, clear everything including root
|
||||
* qdisc and all filters before adding everything.
|
||||
*/
|
||||
if (flags & VIR_NETDEV_BANDWIDTH_SET_CLEAR_ALL)
|
||||
virNetDevBandwidthClear(ifname);
|
||||
|
||||
if (tx && tx->average) {
|
||||
/* Only if the caller requests, clear the root qdisc and all filters
|
||||
* before adding everything.
|
||||
*/
|
||||
if (flags & VIR_NETDEV_BANDWIDTH_SET_CLEAR_ALL)
|
||||
virNetDevBandwidthClearRoot(ifname);
|
||||
|
||||
average = g_strdup_printf("%llukbps", tx->average);
|
||||
if (tx->peak)
|
||||
peak = g_strdup_printf("%llukbps", tx->peak);
|
||||
@@ -417,6 +417,12 @@ virNetDevBandwidthSet(const char *ifname,
|
||||
}
|
||||
|
||||
if (rx) {
|
||||
/* Only if the caller requests, clear the ingress qdisc and all
|
||||
* filters before adding everything.
|
||||
*/
|
||||
if (flags & VIR_NETDEV_BANDWIDTH_SET_CLEAR_ALL)
|
||||
virNetDevBandwidthClearIngress(ifname);
|
||||
|
||||
average = g_strdup_printf("%llukbps", rx->average);
|
||||
|
||||
if (rx->burst) {
|
||||
|
||||
@@ -146,7 +146,6 @@ mymain(void)
|
||||
" <inbound average='1024'/>"
|
||||
"</bandwidth>",
|
||||
"tc qdisc del dev eth0 root\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc show dev eth0 handle 1:\n"
|
||||
"tc qdisc add dev eth0 root handle 1: htb default 1\n"
|
||||
"tc class add dev eth0 parent 1: classid 1:1 htb rate 1024kbps quantum 87\n"
|
||||
@@ -163,7 +162,6 @@ mymain(void)
|
||||
DO_TEST_SET("<bandwidth>"
|
||||
" <outbound average='1024'/>"
|
||||
"</bandwidth>",
|
||||
"tc qdisc del dev eth0 root\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc add dev eth0 ingress\n"
|
||||
"tc filter add dev eth0 parent ffff: protocol all u32 match u32 0 0"
|
||||
@@ -177,12 +175,12 @@ mymain(void)
|
||||
" <outbound average='5' peak='6' burst='7'/>"
|
||||
"</bandwidth>",
|
||||
"tc qdisc del dev eth0 root\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc show dev eth0 handle 1:\n"
|
||||
"tc qdisc add dev eth0 root handle 1: htb default 1\n"
|
||||
"tc class add dev eth0 parent 1: classid 1:1 htb rate 1kbps ceil 2kbps burst 4kb quantum 1\n"
|
||||
"tc qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
|
||||
"tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 1 fw flowid 1\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc add dev eth0 ingress\n"
|
||||
"tc filter add dev eth0 parent ffff: protocol all u32 match u32 0 0"
|
||||
" police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n",
|
||||
@@ -200,12 +198,12 @@ mymain(void)
|
||||
" <outbound average='4294967295'/>"
|
||||
"</bandwidth>",
|
||||
"tc qdisc del dev eth0 root\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc show dev eth0 handle 1:\n"
|
||||
"tc qdisc add dev eth0 root handle 1: htb default 1\n"
|
||||
"tc class add dev eth0 parent 1: classid 1:1 htb rate 4294967295kbps quantum 366503875\n"
|
||||
"tc qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
|
||||
"tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 1 fw flowid 1\n"
|
||||
"tc qdisc del dev eth0 ingress\n"
|
||||
"tc qdisc add dev eth0 ingress\n"
|
||||
"tc filter add dev eth0 parent ffff: protocol all u32 match"
|
||||
" u32 0 0 police rate 4294967295kbps burst 4194303kb mtu 64kb"
|
||||
|
||||
Reference in new issue
Block a user