qemu: Restore default root qdisc when QoS is cleared out

When an interface has some bandwidth limitation set (it's root
qdisc is htb in that case) but this gets cleared out via public
API call (virDomainSetInterfaceParameters() or
virDomainUpdateDeviceFlags()) then virNetDevBandwidthSet() clears
out whatever qdiscs were set on the interface and kernel places
the default qdisc at the root. What we need to do next is to
replace the root qdisc with the one we want.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329644
Fixes: 0b66196d86
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2020-12-04 12:50:58 +01:00
parent abb1554a2d
commit d53b092353
2 changed files with 18 additions and 0 deletions

View File

@ -10339,6 +10339,15 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
goto endjob;
}
/* If the old bandwidth was cleared out, restore qdisc. */
if (virDomainNetTypeSharesHostView(net)) {
if (!newBandwidth->out || newBandwidth->out->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, net);
} else {
if (!newBandwidth->in || newBandwidth->in->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, net);
}
virNetDevBandwidthFree(net->bandwidth);
if (newBandwidth->in || newBandwidth->out) {
net->bandwidth = newBandwidth;

View File

@ -3881,6 +3881,15 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
*/
virNetDevBandwidthClear(newdev->ifname);
}
/* If the old bandwidth was cleared out, restore qdisc. */
if (virDomainNetTypeSharesHostView(newdev)) {
if (!newb->out || newb->out->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, newdev);
} else {
if (!newb->in || newb->in->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, newdev);
}
needReplaceDevDef = true;
}