1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

qemu: Don't set migration caps when changing postcopy bandwidth

The qemuMigrationParamsApply internal API was designed to apply all
migration parameters and capabilities before we start to migrate a
domain. While migration parameters are only passed to QEMU when we
explicitly want to set a specific value, capabilities are always either
enabled or disabled.

Thus when this API is called outside migration job, e.g., via a call to
qemuDomainMigrateSetMaxSpeed with VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY
flag, we would call migrate-set-capabilities and disable all
capabilities. However, changing capabilities while migration is already
running does not make sense and our code should never be trying to do
so. In fact QEMU even reports an error if migrate-set-capabilities is
called during migration and qemuDomainMigrateSetMaxSpeed would fail
with:

    internal error: unable to execute QEMU command
    migrate-set-capabilities: There's a migration process in progress

With this patch qemuMigrationParamsApply never tries to call
migrate-set-capabilities outside of migration job. When the capabilities
bitmap is all zeros (which is its initial value after
qemuMigrationParamsNew), we just skip the command. But when any
capability bit is set to 1 by a non-migration job, we report an error to
highlight a bug in our code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jiri Denemark 2019-03-05 22:16:03 +01:00
parent f2cbb94eab
commit a1dec315c9

View File

@ -778,14 +778,23 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
if (!(caps = qemuMigrationCapsToJSON(priv->migrationCaps, migParams->caps)))
goto cleanup;
if (virJSONValueArraySize(caps) > 0) {
rc = qemuMonitorSetMigrationCapabilities(priv->mon, caps);
caps = NULL;
if (rc < 0)
if (asyncJob == QEMU_ASYNC_JOB_NONE) {
if (!virBitmapIsAllClear(migParams->caps)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Migration capabilities can only be set by "
"a migration job"));
goto cleanup;
}
} else {
if (!(caps = qemuMigrationCapsToJSON(priv->migrationCaps, migParams->caps)))
goto cleanup;
if (virJSONValueArraySize(caps) > 0) {
rc = qemuMonitorSetMigrationCapabilities(priv->mon, caps);
caps = NULL;
if (rc < 0)
goto cleanup;
}
}
/* If QEMU is too old to support xbzrle-cache-size migration parameter,