mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
vz: support virDomainAbortJob
This commit is contained in:
parent
3ac97c2ded
commit
48317abbf7
@ -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 = {
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -89,3 +89,4 @@ prlsdkMigrate(virDomainObjPtr dom,
|
||||
|
||||
PRL_HANDLE
|
||||
prlsdkSdkDomainLookupByName(vzDriverPtr driver, const char *name);
|
||||
int prlsdkCancelJob(virDomainObjPtr dom);
|
||||
|
@ -659,6 +659,7 @@ vzDomainObjEndJob(virDomainObjPtr dom)
|
||||
vzDomObjPtr pdom = dom->privateData;
|
||||
|
||||
pdom->job.active = false;
|
||||
pdom->job.cancelled = false;
|
||||
virCondSignal(&pdom->job.cond);
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,8 @@ struct _vzDomainJobObj {
|
||||
unsigned long long elapsed;
|
||||
bool hasProgress;
|
||||
int progress; /* percents */
|
||||
PRL_HANDLE sdkJob;
|
||||
bool cancelled;
|
||||
};
|
||||
|
||||
typedef struct _vzDomainJobObj vzDomainJobObj;
|
||||
|
Loading…
Reference in New Issue
Block a user