]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainSetInterfaceParameters: Explicitly reject unsupported net types
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Oct 2017 10:42:41 +0000 (12:42 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Oct 2017 12:59:29 +0000 (14:59 +0200)
For instance, NET_TYPE_MCAST doesn't support setting QoS. Instead
of claiming success and doing nothing, we should be explicit
about that and report an error.

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

index 74fdfdb0f08acdbef3c38d8943dd3b1318b7e3fd..1dff53441b418fa36b15ad00af041e30a38a90be 100644 (file)
 #include "virnuma.h"
 #include "dirname.h"
 #include "network/bridge_driver.h"
+#include "netdev_bandwidth_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -11107,6 +11108,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     virNetDevBandwidthPtr bandwidth = NULL, newBandwidth = NULL;
     virQEMUDriverConfigPtr cfg = NULL;
     bool inboundSpecified = false, outboundSpecified = false;
+    int actualType;
+    bool qosSupported = true;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -11150,6 +11153,24 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
         !(persistentNet = virDomainNetFind(persistentDef, device)))
         goto endjob;
 
+    if (net) {
+        actualType = virDomainNetGetActualType(net);
+        qosSupported = virNetDevSupportBandwidth(actualType);
+    }
+
+    if (qosSupported && persistentNet) {
+        actualType = virDomainNetGetActualType(persistentNet);
+        qosSupported = virNetDevSupportBandwidth(actualType);
+    }
+
+    if (!qosSupported) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("setting bandwidth on interfaces of "
+                         "type '%s' is not implemented yet"),
+                       virDomainNetTypeToString(actualType));
+        goto endjob;
+    }
+
     if ((VIR_ALLOC(bandwidth) < 0) ||
         (VIR_ALLOC(bandwidth->in) < 0) ||
         (VIR_ALLOC(bandwidth->out) < 0))