On Sat, Jul 06, 2019 at 01:24:22PM +0200, Ilias Stamatis wrote:
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
...
+
+ /* average or floor are mandatory, peak and burst are optional */
+ if (!bandwidth->in->average && !bandwidth->in->floor)
+ VIR_FREE(bandwidth->in);
+ if (!bandwidth->out->average)
+ VIR_FREE(bandwidth->out);
+
+ if (!net->bandwidth) {
+ VIR_STEAL_PTR(net->bandwidth, bandwidth);
+ } else {
+ if (bandwidth->in) {
+ VIR_FREE(net->bandwidth->in);
+ VIR_STEAL_PTR(net->bandwidth->in, bandwidth->in);
+ }
+ if (bandwidth->out) {
+ VIR_FREE(net->bandwidth->out);
+ VIR_STEAL_PTR(net->bandwidth->out, bandwidth->out);
+ }
+ }
Doesn't look quite right, you just lost any way of resetting the bandwidth when
in fact this should be possible simply with setting .average=0, that's why the
original QEMU code uses booleans, because then at the end, the whole
net->bandwidth structure is set to NULL if reset was requested.
Erik