]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu, lxc: Warn if setting QoS on unsupported vNIC types
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 7 Jan 2015 14:52:21 +0000 (15:52 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Jan 2015 07:54:49 +0000 (08:54 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1165993

So, there are still plenty of vNIC types that we don't know how to set
bandwidth on. Let's warn explicitly in case user has requested it
instead of pretending everything was set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_driver.c
src/lxc/lxc_process.c
src/qemu/qemu_command.c
src/qemu/qemu_hotplug.c

index f503fcfb197efcbc32ae14ff8dd6190bbf980f59..07ddce36646a23901c63a4ab3e580418c7888ae6 100644 (file)
@@ -4148,6 +4148,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
     virLXCDomainObjPrivatePtr priv = vm->privateData;
     int ret = -1;
     int actualType;
+    virNetDevBandwidthPtr actualBandwidth;
     char *veth = NULL;
 
     if (!priv->initpid) {
@@ -4195,11 +4196,18 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
                        _("Network device type is not supported"));
         goto cleanup;
     }
-    /* set network bandwidth */
-    if (virNetDevSupportBandwidth(actualType) &&
-        virNetDevBandwidthSet(net->ifname,
-                              virDomainNetGetActualBandwidth(net), false) < 0)
-        goto cleanup;
+    /* Set bandwidth or warn if requested and not supported. */
+    actualBandwidth = virDomainNetGetActualBandwidth(net);
+    if (actualBandwidth) {
+        if (virNetDevSupportBandwidth(actualType)) {
+            if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
+                goto cleanup;
+        } else {
+            VIR_WARN("setting bandwidth on interfaces of "
+                     "type '%s' is not implemented yet",
+                     virDomainNetTypeToString(actualType));
+        }
+    }
 
     if (virNetDevSetNamespace(veth, priv->initpid) < 0) {
         virDomainAuditNet(vm, NULL, net, "attach", false);
index af08de9cdce4a79bfe9f5835c312ab5fc0875a36..89e9249abea717929e92b74c9ac428b67ab23133 100644 (file)
@@ -369,6 +369,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
 
     for (i = 0; i < def->nnets; i++) {
         char *veth = NULL;
+        virNetDevBandwidthPtr actualBandwidth;
         /* If appropriate, grab a physical device from the configured
          * network's pool of devices, or resolve bridge device name
          * to the one defined in the network definition.
@@ -422,11 +423,18 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
 
         }
 
-        /* set network bandwidth */
-        if (virNetDevSupportBandwidth(type) &&
-            virNetDevBandwidthSet(net->ifname,
-                                  virDomainNetGetActualBandwidth(net), false) < 0)
-            goto cleanup;
+        /* Set bandwidth or warn if requested and not supported. */
+        actualBandwidth = virDomainNetGetActualBandwidth(net);
+        if (actualBandwidth) {
+            if (virNetDevSupportBandwidth(type)) {
+                if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
+                    goto cleanup;
+            } else {
+                VIR_WARN("setting bandwidth on interfaces of "
+                         "type '%s' is not implemented yet",
+                         virDomainNetTypeToString(type));
+            }
+        }
 
         (*veths)[(*nveths)-1] = veth;
 
index 3346e95e1d4ee0847c2e7457dcb70a3e7b806566..3cafbfb6000d0864cfb9c9443f7185e475c921fb 100644 (file)
@@ -7365,6 +7365,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
     char **tapfdName = NULL;
     char **vhostfdName = NULL;
     int actualType = virDomainNetGetActualType(net);
+    virNetDevBandwidthPtr actualBandwidth;
     size_t i;
 
     if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
@@ -7415,12 +7416,18 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
             goto cleanup;
     }
 
-    /* Set Bandwidth */
-    if (virNetDevSupportBandwidth(actualType) &&
-        virNetDevBandwidthSet(net->ifname,
-                              virDomainNetGetActualBandwidth(net),
-                              false) < 0)
-        goto cleanup;
+    /* Set bandwidth or warn if requested and not supported. */
+    actualBandwidth = virDomainNetGetActualBandwidth(net);
+    if (actualBandwidth) {
+        if (virNetDevSupportBandwidth(actualType)) {
+            if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
+                goto cleanup;
+        } else {
+            VIR_WARN("setting bandwidth on interfaces of "
+                     "type '%s' is not implemented yet",
+                     virDomainNetTypeToString(actualType));
+        }
+    }
 
     if ((actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
          actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
index 1714341a61bf753af52db9e97a9085ca8740cc01..bf1f69a1ffbb366e66f1869f727d4ded9e5e4c78 100644 (file)
@@ -838,6 +838,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
     bool releaseaddr = false;
     bool iface_connected = false;
     int actualType;
+    virNetDevBandwidthPtr actualBandwidth;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     size_t i;
 
@@ -926,11 +927,18 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
     if (qemuInterfaceStartDevice(net) < 0)
         goto cleanup;
 
-    /* Set Bandwidth */
-    if (virNetDevSupportBandwidth(actualType) &&
-        virNetDevBandwidthSet(net->ifname,
-                              virDomainNetGetActualBandwidth(net), false) < 0)
-        goto cleanup;
+    /* Set bandwidth or warn if requested and not supported. */
+    actualBandwidth = virDomainNetGetActualBandwidth(net);
+    if (actualBandwidth) {
+        if (virNetDevSupportBandwidth(actualType)) {
+            if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
+                goto cleanup;
+        } else {
+            VIR_WARN("setting bandwidth on interfaces of "
+                     "type '%s' is not implemented yet",
+                     virDomainNetTypeToString(actualType));
+        }
+    }
 
     for (i = 0; i < tapfdSize; i++) {
         if (virSecurityManagerSetTapFDLabel(driver->securityManager,