[libvirt] [PATCH 7/8] qemu: Implement VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY flag
Ján Tomko
jtomko at redhat.com
Thu Feb 7 14:06:20 UTC 2019
On Tue, Feb 05, 2019 at 04:23:10PM +0100, Jiri Denemark wrote:
>This flag tells virDomainMigrateSetMaxSpeed and
>virDomainMigrateGetMaxSpeed APIs to work on post-copy migration
>bandwidth.
>
>Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
>---
> src/qemu/qemu_driver.c | 91 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 78 insertions(+), 13 deletions(-)
>
>@@ -14344,7 +14369,47 @@ qemuDomainMigrateGetMaxSpeed(virDomainPtr dom,
> if (virDomainMigrateGetMaxSpeedEnsureACL(dom->conn, vm->def) < 0)
> goto cleanup;
>
>- *bandwidth = priv->migMaxBandwidth;
>+ if (postcopy) {
This whole branch looks like a good candidate for a helper function.
>+ VIR_AUTOPTR(qemuMigrationParams) migParams = NULL;
>+ unsigned long long bw;
>+ int rc = -1;
>+
>+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
>+ goto cleanup;
>+
>+ if (virDomainObjCheckActive(vm) == 0 &&
>+ qemuMigrationParamsFetch(driver, vm, QEMU_ASYNC_JOB_NONE,
>+ &migParams) == 0) {
>+ rc = qemuMigrationParamsGetULL(migParams,
>+ QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH,
>+ &bw);
>+
>+ /* QEMU reports B/s while we use MiB/s */
>+ bw /= 1024 * 1024;
>+ }
You coould put an 'endjob' label here.
>+
>+ qemuDomainObjEndJob(driver, vm);
>+
>+ if (rc < 0) {
>+ goto cleanup;
>+ } else if (rc == 1) {
No need for 'else' after goto.
>+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>+ _("querying maximum post-copy migration speed is "
>+ "not supported by QEMU binary"));
>+ goto cleanup;
>+ } if (bw > ULONG_MAX) {
Missing newline.
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190207/dbe7d5f2/attachment-0001.sig>
More information about the libvir-list
mailing list