mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: acquire job in migration finish phase
Moving data reception of the perform phase of migration to a thread introduces a race with the finish phase, where checking if the domain is active races with the thread finishing the perform phase. The race is easily solved by acquiring a job in the finish phase, which must wait for the perform phase job to complete. While wrapping the finish phase in a job, noticed the virDomainObj was being unlocked in a callee - libxlDomainMigrationFinish. Move the unlocking to libxlDomainMigrateFinish3Params, where the lock is acquired. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
cb88d4333a
commit
a1f389515c
@ -4650,6 +4650,7 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
|
|||||||
libxlDriverPrivatePtr driver = dconn->privateData;
|
libxlDriverPrivatePtr driver = dconn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
const char *dname = NULL;
|
const char *dname = NULL;
|
||||||
|
virDomainPtr ret = NULL;
|
||||||
|
|
||||||
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
|
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
|
||||||
virReportUnsupportedError();
|
virReportUnsupportedError();
|
||||||
@ -4680,16 +4681,29 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) {
|
||||||
|
virObjectUnlock(vm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
/* Migration failed if domain is inactive */
|
/* Migration failed if domain is inactive */
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("Migration failed. Domain is not running "
|
"%s", _("Migration failed. Domain is not running "
|
||||||
"on destination host"));
|
"on destination host"));
|
||||||
virObjectUnlock(vm);
|
goto endjob;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return libxlDomainMigrationFinish(dconn, vm, flags, cancelled);
|
ret = libxlDomainMigrationFinish(dconn, vm, flags, cancelled);
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!libxlDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
|
if (vm)
|
||||||
|
virObjectUnlock(vm);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -573,7 +573,6 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (event)
|
if (event)
|
||||||
libxlDomainEventQueue(driver, event);
|
libxlDomainEventQueue(driver, event);
|
||||||
virObjectUnlock(vm);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user