qemu_migration_params: Avoid deadlock in qemuMigrationParamsReset

In my recent comnmit v8.5.0-188-gc47f1abb81 I accidentally moved
qemuMigrationParamsResetTLS after qemuDomainObjEnterMonitorAsync not
noticing qemuMigrationParamsResetTLS will try to enter the monitor
again. The second call will time out and return with a domain object
locked. But we're still in monitor section and the object should be
unlocked which means qemuDomainObjExitMonitor will deadlock trying to
lock it again.

Fixes: c47f1abb81
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2022-07-28 15:35:45 +02:00
parent 640d185f01
commit 8cb19a9b9a

View File

@ -1291,6 +1291,7 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
{
virErrorPtr err;
g_autoptr(virBitmap) clearCaps = NULL;
int rc;
virErrorPreserveLast(&err);
@ -1305,11 +1306,16 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
clearCaps = virBitmapNew(0);
if (qemuMigrationParamsApplyCaps(vm, clearCaps) == 0 &&
qemuMigrationParamsApplyValues(vm, origParams, false) == 0)
qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
rc = 0;
if (qemuMigrationParamsApplyCaps(vm, clearCaps) < 0 ||
qemuMigrationParamsApplyValues(vm, origParams, false) < 0)
rc = -1;
qemuDomainObjExitMonitor(vm);
if (rc < 0)
goto cleanup;
qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
cleanup:
virErrorRestore(&err);