mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjIsActive(vm)) {
|
if (virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("Domain is already running"));
|
"%s", _("Domain is already running"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virLXCProcessStart(dom->conn, driver, vm,
|
ret = virLXCProcessStart(dom->conn, driver, vm,
|
||||||
@ -1147,6 +1150,10 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom,
|
|||||||
virDomainAuditStart(vm, "booted", false);
|
virDomainAuditStart(vm, "booted", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!virLXCDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
@ -1249,6 +1256,14 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
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,
|
if (virLXCProcessStart(conn, driver, vm,
|
||||||
nfiles, files,
|
nfiles, files,
|
||||||
(flags & VIR_DOMAIN_START_AUTODESTROY),
|
(flags & VIR_DOMAIN_START_AUTODESTROY),
|
||||||
@ -1258,7 +1273,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||||||
virDomainObjListRemove(driver->domains, vm);
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
}
|
}
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
event = virDomainEventLifecycleNewFromObj(vm,
|
event = virDomainEventLifecycleNewFromObj(vm,
|
||||||
@ -1270,6 +1285,10 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||||||
if (dom)
|
if (dom)
|
||||||
dom->id = vm->def->id;
|
dom->id = vm->def->id;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!virLXCDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
if (vm)
|
if (vm)
|
||||||
|
Loading…
Reference in New Issue
Block a user