]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: fail on attempt to set 'floor' if interface type is not 'network'
authorPavel Mores <pmores@redhat.com>
Fri, 14 Feb 2020 16:26:21 +0000 (17:26 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Feb 2020 16:25:59 +0000 (17:25 +0100)
QoS 'floor' setting is documented to be only supported for interfaces of
type 'network'.  Fail with an error message on attempt to set 'floor' on
an interface of any other type.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index 2813f084cd3d069453de812428d077de1949762c..f686b858cf9796d9998743bc1564454e6098a5d3 100644 (file)
@@ -11672,9 +11672,21 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
                    sizeof(*newBandwidth->out));
         }
 
-        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
-            virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
-            goto endjob;
+        if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
+            if (virDomainNetBandwidthUpdate(net, newBandwidth) < 0)
+                goto endjob;
+        } else {
+            if (virNetDevBandwidthHasFloor(bandwidth)) {
+                char ifmac[VIR_MAC_STRING_BUFLEN];
+
+                virMacAddrFormat(&net->mac, ifmac);
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                               _("Invalid use of 'floor' on interface with MAC address %s "
+                               "- 'floor' is only supported for interface type 'network' with forward type 'nat', 'route', 'open' or none"),
+                               ifmac);
+                goto endjob;
+            }
+        }
 
         if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
                                   !virDomainNetTypeSharesHostView(net)) < 0) {