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

lxc: use job functions in lxcDomain{Suspend, Resume}

These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.
Signed-off-by: NKaterina Koukiou <k.koukiou@gmail.com>
上级 f5df98aa
...@@ -3416,17 +3416,20 @@ static int lxcDomainSuspend(virDomainPtr dom) ...@@ -3416,17 +3416,20 @@ static int lxcDomainSuspend(virDomainPtr dom)
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0) if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
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 not running")); "%s", _("Domain is not running"));
goto cleanup; goto endjob;
} }
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) { if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
if (lxcFreezeContainer(vm) < 0) { if (lxcFreezeContainer(vm) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Suspend operation failed")); "%s", _("Suspend operation failed"));
goto cleanup; goto endjob;
} }
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER); virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER);
...@@ -3436,9 +3439,12 @@ static int lxcDomainSuspend(virDomainPtr dom) ...@@ -3436,9 +3439,12 @@ static int lxcDomainSuspend(virDomainPtr dom)
} }
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto cleanup; goto endjob;
ret = 0; ret = 0;
endjob:
if (!virLXCDomainObjEndJob(driver, vm))
vm = NULL;
cleanup: cleanup:
if (event) if (event)
virObjectEventStateQueue(driver->domainEventState, event); virObjectEventStateQueue(driver->domainEventState, event);
...@@ -3465,17 +3471,20 @@ static int lxcDomainResume(virDomainPtr dom) ...@@ -3465,17 +3471,20 @@ static int lxcDomainResume(virDomainPtr dom)
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0) if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
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 not running")); "%s", _("Domain is not running"));
goto cleanup; goto endjob;
} }
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) { if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) { if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Resume operation failed")); "%s", _("Resume operation failed"));
goto cleanup; goto endjob;
} }
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
VIR_DOMAIN_RUNNING_UNPAUSED); VIR_DOMAIN_RUNNING_UNPAUSED);
...@@ -3486,9 +3495,12 @@ static int lxcDomainResume(virDomainPtr dom) ...@@ -3486,9 +3495,12 @@ static int lxcDomainResume(virDomainPtr dom)
} }
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto cleanup; goto endjob;
ret = 0; ret = 0;
endjob:
if (!virLXCDomainObjEndJob(driver, vm))
vm = NULL;
cleanup: cleanup:
if (event) if (event)
virObjectEventStateQueue(driver->domainEventState, event); virObjectEventStateQueue(driver->domainEventState, event);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册