]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}
authorKaterina Koukiou <k.koukiou@googlemail.com>
Mon, 16 May 2016 21:36:48 +0000 (00:36 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 19 May 2016 16:42:08 +0000 (18:42 +0200)
Creating a large domain could potentially be time consuming.  Use the
recently added job functions and unlock the virDomainObj while
the create operation is in progress.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
src/lxc/lxc_driver.c

index a2268504dd22a813bd5f84e632780e0398af6530..1e21ee436b0ee8c16e1264c2acff4ebe41b98c02 100644 (file)
@@ -1127,10 +1127,13 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom,
         goto cleanup;
     }
 
+    if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
+        goto cleanup;
+
     if (virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        "%s", _("Domain is already running"));
-        goto cleanup;
+        goto endjob;
     }
 
     ret = virLXCProcessStart(dom->conn, driver, vm,
@@ -1147,6 +1150,10 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom,
         virDomainAuditStart(vm, "booted", false);
     }
 
+ endjob:
+    if (!virLXCDomainObjEndJob(driver, vm))
+        vm = NULL;
+
  cleanup:
     if (vm)
         virObjectUnlock(vm);
@@ -1249,6 +1256,14 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
         goto cleanup;
     def = NULL;
 
+    if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
+        if (!vm->persistent) {
+            virDomainObjListRemove(driver->domains, vm);
+            vm = NULL;
+        }
+        goto cleanup;
+    }
+
     if (virLXCProcessStart(conn, driver, vm,
                            nfiles, files,
                            (flags & VIR_DOMAIN_START_AUTODESTROY),
@@ -1258,7 +1273,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
             virDomainObjListRemove(driver->domains, vm);
             vm = NULL;
         }
-        goto cleanup;
+        goto endjob;
     }
 
     event = virDomainEventLifecycleNewFromObj(vm,
@@ -1270,6 +1285,10 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
     if (dom)
         dom->id = vm->def->id;
 
+ endjob:
+    if (!virLXCDomainObjEndJob(driver, vm))
+        vm = NULL;
+
  cleanup:
     virDomainDefFree(def);
     if (vm)