File a1f38951-libxl-mig-job.patch of Package libvirt.239
commit a1f389515c7995ce0412f5b2413e5ec3dba4ef98
Author: Jim Fehlig <jfehlig@suse.com>
Date: Thu Nov 13 14:41:56 2014 -0700
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>
Index: libvirt-1.2.5/src/libxl/libxl_driver.c
===================================================================
--- libvirt-1.2.5.orig/src/libxl/libxl_driver.c
+++ libvirt-1.2.5/src/libxl/libxl_driver.c
@@ -4659,6 +4659,7 @@ libxlDomainMigrateFinish3Params(virConne
libxlDriverPrivatePtr driver = dconn->privateData;
virDomainObjPtr vm = NULL;
const char *dname = NULL;
+ virDomainPtr ret = NULL;
#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
virReportUnsupportedError();
@@ -4689,16 +4690,29 @@ libxlDomainMigrateFinish3Params(virConne
return NULL;
}
+ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) {
+ virObjectUnlock(vm);
+ return NULL;
+ }
+
if (!virDomainObjIsActive(vm)) {
/* Migration failed if domain is inactive */
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Migration failed. Domain is not running "
"on destination host"));
- virObjectUnlock(vm);
- return NULL;
+ goto endjob;
}
- 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
Index: libvirt-1.2.5/src/libxl/libxl_migration.c
===================================================================
--- libvirt-1.2.5.orig/src/libxl/libxl_migration.c
+++ libvirt-1.2.5/src/libxl/libxl_migration.c
@@ -566,8 +566,6 @@ libxlDomainMigrationFinish(virConnectPtr
cleanup:
if (event)
libxlDomainEventQueue(driver, event);
- if (vm)
- virObjectUnlock(vm);
virObjectUnref(cfg);
return dom;
}