Split function prlsdkDomainChangeState into
prlsdkDomainChangeStateLocked and prlsdkDomainChangeState.
So it can be used from places, where virDomainObj already
found and locked.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_sdk.c | 35 +++++++++++++++++++++--------------
src/parallels/parallels_sdk.h | 4 ++++
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 0b2478e..e677d36 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1704,22 +1704,14 @@ PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE
sdkdom)
}
int
-prlsdkDomainChangeState(virDomainPtr domain,
- prlsdkChangeStateFunc chstate)
+prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
+ virDomainObjPtr dom,
+ prlsdkChangeStateFunc chstate)
{
- parallelsConnPtr privconn = domain->conn->privateData;
- virDomainObjPtr dom;
parallelsDomObjPtr pdom;
PRL_RESULT pret;
- int ret = -1;
virErrorNumber virerr;
- dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
- if (dom == NULL) {
- parallelsDomNotFoundError(domain);
- return -1;
- }
-
pdom = dom->privateData;
pret = chstate(privconn, pdom->sdkdom);
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -1737,12 +1729,27 @@ prlsdkDomainChangeState(virDomainPtr domain,
}
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);
return ret;
}
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index cb8d3fb..780a226 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -46,6 +46,10 @@ int
prlsdkDomainChangeState(virDomainPtr domain,
prlsdkChangeStateFunc chstate);
int
+prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
+ virDomainObjPtr dom,
+ prlsdkChangeStateFunc chstate);
+int
prlsdkApplyConfig(virConnectPtr conn,
virDomainObjPtr dom,
virDomainDefPtr new);
--
2.1.0