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: 0b66196d86ea375234cb0ee99289c486f9921820
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_driver.c | 9 +++++++++
src/qemu/qemu_hotplug.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4fd70ed300..6eca2645de 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10358,6 +10358,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;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 235e9e177a..3aa6fb8a27 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3871,6 +3871,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;
}
--
2.26.2