]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Restore default root qdisc when QoS is cleared out
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Dec 2020 11:50:58 +0000 (12:50 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 6 Jan 2021 12:29:52 +0000 (13:29 +0100)
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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_hotplug.c

index 88324945ef361ae7b44a778f568636730b0dba0a..26c6e9b2e171adcae8be10a5cd9b4a6f0635c0cf 100644 (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;
index e5848d7de453af2d9bfd220dcca9744e121135a8..ec5c5220001fc4643840c2cb8dcaa30bc3fd4949 100644 (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;
     }