mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
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: Katerina Koukiou <k.koukiou@gmail.com>
This commit is contained in:
parent
03e9077bd1
commit
c066f9eed3
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user