On 2/7/19 10:11 AM, Jiri Denemark wrote: > This flag tells virDomainMigrateSetMaxSpeed and > virDomainMigrateGetMaxSpeed APIs to work on post-copy migration > bandwidth. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > > Notes: > Version 2: > - if (postcopy) branch from qemuDomainMigrateGetMaxSpeed separated > into a helper function [...] > + > +static int > +qemuDomainMigrationGetPostcopyBandwidth(virQEMUDriverPtr driver, > + virDomainObjPtr vm, > + unsigned long *bandwidth) > +{ > + VIR_AUTOPTR(qemuMigrationParams) migParams = NULL; > + unsigned long long bw; > + int rc; > + int ret = -1; > + > + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) > + return -1; > + > + if (virDomainObjCheckActive(vm) < 0) > + goto cleanup; > + > + if (qemuMigrationParamsFetch(driver, vm, QEMU_ASYNC_JOB_NONE, > + &migParams) < 0) > + goto cleanup; > + > + if ((rc = qemuMigrationParamsGetULL(migParams, > + QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH, > + &bw)) < 0) > + goto cleanup; > + > + if (rc == 1) { > + virReportError(VIR_ERR_OPERATION_INVALID, "%s", > + _("querying maximum post-copy migration speed is " > + "not supported by QEMU binary")); > + goto cleanup; > + } > + > + /* QEMU reports B/s while we use MiB/s */ > + bw /= 1024 * 1024; > + > + if (bw > ULONG_MAX) { FWIW: Coverity generates a complaint here: 1) Event result_independent_of_operands: "bw > 18446744073709551615ULL /* 9223372036854775807L * 2UL + 1UL */" is always false regardless of the values of its operands. This occurs as the logical operand of "if". John > + virReportError(VIR_ERR_OVERFLOW, > + _("bandwidth %llu is greater than %lu which is the " > + "maximum value supported by this API"), > + bw, ULONG_MAX); > + goto cleanup; > + } > + > + *bandwidth = bw; > + ret = 0; > + > + cleanup: > + qemuDomainObjEndJob(driver, vm); > + return ret; > +} > + > + [...]