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);
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)) {
* 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;
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;
}
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) {
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;
}
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;
}
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.