qemu_migration_params: Refactor qemuMigrationParamsReset

Because qemuMigrationParamsReset used to call qemuMigrationParamsApply
for resetting migration capabilities and parameters, it did not work
well since commit v5.1.0-83-ga1dec315c9 which only allowed capabilities
to be set from an async job. However, when reconnecting to running
domains after daemon restart we do not have an async job. Thus the
capabilities were not properly reset in case the daemon was restarted
during an ongoing migration. We need to avoid calling
qemuMigrationParamsApply to make sure both parameters and capabilities
can be reset by a normal job.

https://bugzilla.redhat.com/show_bug.cgi?id=2107892

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2022-07-21 16:49:09 +02:00
parent c0824fd038
commit c47f1abb81

View File

@ -1290,6 +1290,7 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
unsigned long apiFlags)
{
virErrorPtr err;
g_autoptr(virBitmap) clearCaps = NULL;
virErrorPreserveLast(&err);
@ -1299,13 +1300,16 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
if (!virDomainObjIsActive(vm) || !origParams)
goto cleanup;
/* Do not pass apiFlags to qemuMigrationParamsApply here to make sure all
* parameters and capabilities are reset. */
if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams, 0) < 0)
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup;
qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
/* We don't reset 'block-bitmap-mapping' as it can't be unset */
clearCaps = virBitmapNew(0);
if (qemuMigrationParamsApplyCaps(vm, clearCaps) == 0 &&
qemuMigrationParamsApplyValues(vm, origParams, false) == 0)
qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
qemuDomainObjExitMonitor(vm);
cleanup:
virErrorRestore(&err);