]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainSetInterfaceParameters: Allow bandwidth clear out
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Mar 2014 09:50:02 +0000 (10:50 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Mar 2014 13:45:09 +0000 (14:45 +0100)
We allow translation from no_bandwidth to has_bandwidth for a vnic.
However, going in the opposite direction is not implemented. It's not
limitation of the API rather than internal implementation. The problem
is, we correctly detect that user hasn't specified any outbound (say
he wants to clear out outbound). However, this gets overwritten by
current vnic outbound settings. Then, virNetDevBandwidthSet doesn't
change anything. We need to stop overwriting the outbound if users
don't want us to. Same applies for inbound.

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

index c83021e6f54cfa4c884e578afe25f7cff55f39a0..6b96c1673a8e2aa911d0ba567668e0757785c21d 100644 (file)
@@ -9739,6 +9739,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     virNetDevBandwidthPtr bandwidth = NULL, newBandwidth = NULL;
     virQEMUDriverConfigPtr cfg = NULL;
     virCapsPtr caps = NULL;
+    bool inboundSpecified = false, outboundSpecified = false;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -9800,12 +9801,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 
         if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_AVERAGE)) {
             bandwidth->in->average = params[i].value.ui;
+            inboundSpecified = true;
         } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_PEAK)) {
             bandwidth->in->peak = params[i].value.ui;
         } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_BURST)) {
             bandwidth->in->burst = params[i].value.ui;
         } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE)) {
             bandwidth->out->average = params[i].value.ui;
+            outboundSpecified = true;
         } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_PEAK)) {
             bandwidth->out->peak = params[i].value.ui;
         } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_BURST)) {
@@ -9831,7 +9834,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
          * bandwidth parameters, so merge with old bandwidth parameters
          * here to prevent them from being lost. */
         if (bandwidth->in ||
-            (net->bandwidth && net->bandwidth->in)) {
+            (!inboundSpecified && net->bandwidth && net->bandwidth->in)) {
             if (VIR_ALLOC(newBandwidth->in) < 0)
                 goto cleanup;
 
@@ -9840,7 +9843,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
                    sizeof(*newBandwidth->in));
         }
         if (bandwidth->out ||
-            (net->bandwidth && net->bandwidth->out)) {
+            (!outboundSpecified && net->bandwidth && net->bandwidth->out)) {
             if (VIR_ALLOC(newBandwidth->out) < 0)
                 goto cleanup;
 
@@ -9857,8 +9860,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
         }
 
         virNetDevBandwidthFree(net->bandwidth);
-        net->bandwidth = newBandwidth;
-        newBandwidth = NULL;
+        if (newBandwidth->in || newBandwidth->out) {
+            net->bandwidth = newBandwidth;
+            newBandwidth = NULL;
+        } else {
+            net->bandwidth = NULL;
+        }
     }
     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
         if (!persistentNet->bandwidth) {
index fbde3da0db867048e5dfb84a8d620a0e14ca5716..cb6bf63da12204493c96b18096ccc787f106b37f 100644 (file)
@@ -2615,7 +2615,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, _("inbound format is incorrect"));
             goto cleanup;
         }
-        if (inbound.average == 0) {
+        if (inbound.average == 0 && (inbound.burst || inbound.peak)) {
             vshError(ctl, _("inbound average is mandatory"));
             goto cleanup;
         }
@@ -2643,7 +2643,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, _("outbound format is incorrect"));
             goto cleanup;
         }
-        if (outbound.average == 0) {
+        if (outbound.average == 0 && (outbound.burst || outbound.peak)) {
             vshError(ctl, _("outbound average is mandatory"));
             goto cleanup;
         }
index 5c74bb328cf69db5f2c6bd0ec86685c508bffd72..3e721e0fe5db32ebfa7b312836a4a7e80e6eff5d 100644 (file)
@@ -698,6 +698,9 @@ expressed in kilobytes per second, while I<burst> is expressed in kilobytes
 in a single burst at -I<peak> speed as described in the Network XML
 documentation at L<http://libvirt.org/formatnetwork.html#elementQoS>.
 
+To clear inbound or outbound settings, use I<--inbound> or I<--outbound>
+respectfully with average of value zero.
+
 If I<--live> is specified, affect a running guest.
 If I<--config> is specified, affect the next boot of a persistent guest.
 If I<--current> is specified, affect the current guest state.