[PATCH V2 2/4] libxl: acquire job in migration finish phase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---

V2:
- Unlock virDomainObj in libxlDomainMigrateFinish3Params instead of callee

 src/libxl/libxl_driver.c    | 20 +++++++++++++++++---
 src/libxl/libxl_migration.c |  1 -
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d2c077c..651d4eb 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4654,6 +4654,7 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
     libxlDriverPrivatePtr driver = dconn->privateData;
     virDomainObjPtr vm = NULL;
     const char *dname = NULL;
+    virDomainPtr ret = NULL;
 
 #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
     virReportUnsupportedError();
@@ -4684,16 +4685,29 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
         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
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index c728fa2..fa80a0c 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -573,7 +573,6 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
  cleanup:
     if (event)
         libxlDomainEventQueue(driver, event);
-    virObjectUnlock(vm);
     virObjectUnref(cfg);
     return dom;
 }
-- 
1.8.4.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]