qemuDomainSetInterfaceParameters: Allow bandwidth clear out

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>
This commit is contained in:
Michal Privoznik 2014-03-18 10:50:02 +01:00
parent 11c5c9a930
commit 149733821d
3 changed files with 16 additions and 6 deletions

View 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) {

View 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;
}

View 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.