提交 233b799d 编写于 作者: D Dmitry Guryanov 提交者: Michal Privoznik

parallels: split prlsdkDomainChangeState function

Split function prlsdkDomainChangeState into
prlsdkDomainChangeStateLocked and prlsdkDomainChangeState.
So it can be used from places, where virDomainObj already
found and locked.
Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
上级 18558ae8
...@@ -1721,22 +1721,14 @@ PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom) ...@@ -1721,22 +1721,14 @@ PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
} }
int int
prlsdkDomainChangeState(virDomainPtr domain, prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
prlsdkChangeStateFunc chstate) virDomainObjPtr dom,
prlsdkChangeStateFunc chstate)
{ {
parallelsConnPtr privconn = domain->conn->privateData;
virDomainObjPtr dom;
parallelsDomObjPtr pdom; parallelsDomObjPtr pdom;
PRL_RESULT pret; PRL_RESULT pret;
int ret = -1;
virErrorNumber virerr; virErrorNumber virerr;
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
if (dom == NULL) {
parallelsDomNotFoundError(domain);
return -1;
}
pdom = dom->privateData; pdom = dom->privateData;
pret = chstate(privconn, pdom->sdkdom); pret = chstate(privconn, pdom->sdkdom);
if (PRL_FAILED(pret)) { if (PRL_FAILED(pret)) {
...@@ -1752,12 +1744,27 @@ prlsdkDomainChangeState(virDomainPtr domain, ...@@ -1752,12 +1744,27 @@ prlsdkDomainChangeState(virDomainPtr domain,
} }
virReportError(virerr, "%s", _("Can't change domain state.")); virReportError(virerr, "%s", _("Can't change domain state."));
goto cleanup; return -1;
} }
ret = prlsdkUpdateDomain(privconn, dom); return prlsdkUpdateDomain(privconn, dom);
}
cleanup: int
prlsdkDomainChangeState(virDomainPtr domain,
prlsdkChangeStateFunc chstate)
{
parallelsConnPtr privconn = domain->conn->privateData;
virDomainObjPtr dom;
int ret = -1;
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
if (dom == NULL) {
parallelsDomNotFoundError(domain);
return -1;
}
ret = prlsdkDomainChangeStateLocked(privconn, dom, chstate);
virObjectUnlock(dom); virObjectUnlock(dom);
return ret; return ret;
} }
......
...@@ -46,6 +46,10 @@ int ...@@ -46,6 +46,10 @@ int
prlsdkDomainChangeState(virDomainPtr domain, prlsdkDomainChangeState(virDomainPtr domain,
prlsdkChangeStateFunc chstate); prlsdkChangeStateFunc chstate);
int int
prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
virDomainObjPtr dom,
prlsdkChangeStateFunc chstate);
int
prlsdkApplyConfig(virConnectPtr conn, prlsdkApplyConfig(virConnectPtr conn,
virDomainObjPtr dom, virDomainObjPtr dom,
virDomainDefPtr new); virDomainDefPtr new);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册