---
src/vz/vz_driver.c | 21 +++++++++++++++++++++
src/vz/vz_sdk.c | 33 +++++++++++++++++++++++++++++++++
src/vz/vz_sdk.h | 1 +
src/vz/vz_utils.c | 1 +
src/vz/vz_utils.h | 2 ++
5 files changed, 58 insertions(+)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 59bfb7a..0547de5 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3883,6 +3883,26 @@ vzConnectGetAllDomainStats(virConnectPtr conn,
#undef VZ_ADD_STAT_PARAM_UUL
+static int
+vzDomainAbortJob(virDomainPtr domain)
+{
+ virDomainObjPtr dom;
+ int ret = -1;
+
+ if (!(dom = vzDomObjFromDomainRef(domain)))
+ return -1;
+
+ if (virDomainAbortJobEnsureACL(domain->conn, dom->def) < 0)
+ goto cleanup;
+
+ ret = prlsdkCancelJob(dom);
+
+ cleanup:
+ virDomainObjEndAPI(&dom);
+
+ return ret;
+}
+
static virHypervisorDriver vzHypervisorDriver = {
.name = "vz",
.connectOpen = vzConnectOpen, /* 0.10.0 */
@@ -3979,6 +3999,7 @@ static virHypervisorDriver vzHypervisorDriver = {
.domainGetJobInfo = vzDomainGetJobInfo, /* 2.2.0 */
.domainGetJobStats = vzDomainGetJobStats, /* 2.2.0 */
.connectGetAllDomainStats = vzConnectGetAllDomainStats, /* 3.1.0 */
+ .domainAbortJob = vzDomainAbortJob, /* 3.1.0 */
};
static virConnectDriver vzConnectDriver = {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 01b071c..d4d4d6d 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -243,13 +243,22 @@ waitDomainJobHelper(PRL_HANDLE job, virDomainObjPtr dom, unsigned
int timeout,
const char *filename, const char *funcname,
size_t linenr)
{
+ vzDomObjPtr pdom = dom->privateData;
PRL_RESULT ret;
+ if (pdom->job.cancelled) {
+ virReportError(VIR_ERR_OPERATION_ABORTED, "%s",
+ _("Operation cancelled by client"));
+ return PRL_ERR_FAILURE;
+ }
+
+ pdom->job.sdkJob = job;
if (dom)
virObjectUnlock(dom);
ret = waitJobHelper(job, timeout, filename, funcname, linenr);
if (dom)
virObjectLock(dom);
+ pdom->job.sdkJob = NULL;
return ret;
}
@@ -260,6 +269,30 @@ waitDomainJobHelper(PRL_HANDLE job, virDomainObjPtr dom, unsigned int
timeout,
typedef PRL_RESULT (*prlsdkParamGetterType)(PRL_HANDLE, char*, PRL_UINT32*);
+int
+prlsdkCancelJob(virDomainObjPtr dom)
+{
+ vzDomObjPtr privdom = dom->privateData;
+ PRL_RESULT pret;
+ PRL_HANDLE job;
+
+ if (!privdom->job.active) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("no job is active on the domain"));
+ return -1;
+ }
+
+ privdom->job.cancelled = true;
+ job = PrlJob_Cancel(privdom->job.sdkJob);
+
+ virObjectUnlock(dom);
+ pret = waitJobHelper(job, JOB_INFINIT_WAIT_TIMEOUT,
+ __FILE__, __FUNCTION__, __LINE__);
+ virObjectLock(dom);
+
+ return PRL_FAILED(pret) ? -1 : 0;
+}
+
static char*
prlsdkGetStringParamVar(prlsdkParamGetterType getter, PRL_HANDLE handle)
{
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index e4e46dc..65a3e68 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -89,3 +89,4 @@ prlsdkMigrate(virDomainObjPtr dom,
PRL_HANDLE
prlsdkSdkDomainLookupByName(vzDriverPtr driver, const char *name);
+int prlsdkCancelJob(virDomainObjPtr dom);
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 81429d2..a6d7b93 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -659,6 +659,7 @@ vzDomainObjEndJob(virDomainObjPtr dom)
vzDomObjPtr pdom = dom->privateData;
pdom->job.active = false;
+ pdom->job.cancelled = false;
virCondSignal(&pdom->job.cond);
}
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index 9e02fe0..ea2e2da 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -100,6 +100,8 @@ struct _vzDomainJobObj {
unsigned long long elapsed;
bool hasProgress;
int progress; /* percents */
+ PRL_HANDLE sdkJob;
+ bool cancelled;
};
typedef struct _vzDomainJobObj vzDomainJobObj;
--
1.8.3.1