提交 c066f9ee 编写于 作者: K Katerina Koukiou 提交者: Michal Privoznik

lxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}

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: NKaterina Koukiou <k.koukiou@gmail.com>
上级 03e9077b
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册