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(a)gmail.com>
---
src/lxc/lxc_driver.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index a226850..1e21ee4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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)
--
2.7.4