Re: [PATCH v2 7/8] qemu: Implement VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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

[...]


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux