Signed-off-by: Luke Yue <lukedyue(a)gmail.com>
---
src/test/test_driver.c | 90 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 29b19d80f0..4af8ce42f2 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2654,6 +2654,95 @@ testDomainGetJobInfo(virDomainPtr dom,
return ret;
}
+static int
+testDomainJobInfoToParams(virDomainJobInfoPtr info,
+ int *type,
+ virTypedParameterPtr *params,
+ int *nparams)
+{
+ virTypedParameterPtr par = NULL;
+ int maxpar = 0;
+ int npar = 0;
+
+ if (virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DATA_TOTAL,
+ info->dataTotal) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DATA_PROCESSED,
+ info->dataProcessed) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DATA_REMAINING,
+ info->dataRemaining) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_TIME_ELAPSED,
+ info->timeElapsed) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_TIME_REMAINING,
+ info->timeRemaining) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_MEMORY_TOTAL,
+ info->memTotal) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_MEMORY_PROCESSED,
+ info->memProcessed) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_MEMORY_REMAINING,
+ info->memRemaining) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DISK_TOTAL,
+ info->fileTotal) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DISK_PROCESSED,
+ info->fileProcessed) < 0 ||
+ virTypedParamsAddULLong(&par, &npar, &maxpar,
+ VIR_DOMAIN_JOB_DISK_REMAINING,
+ info->fileRemaining) < 0)
+ goto error;
+
+ *type = info->type;
+ *params = par;
+ *nparams = npar;
+ return 0;
+
+ error:
+ virTypedParamsFree(par, npar);
+ return -1;
+}
+
+static int
+testDomainGetJobStats(virDomainPtr domain,
+ int *type,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags)
+{
+ virDomainJobInfo jobInfo;
+ virDomainObj *dom;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(dom = testDomObjFromDomain(domain)))
+ return -1;
+
+ if (testDomainGetJobInfoImpl(dom, &jobInfo) < 0)
+ goto cleanup;
+
+ if (jobInfo.type == VIR_DOMAIN_JOB_NONE) {
+ *type = VIR_DOMAIN_JOB_NONE;
+ *params = NULL;
+ *nparams = 0;
+ ret = 0;
+ goto cleanup;
+ }
+
+ ret = testDomainJobInfoToParams(&jobInfo, type, params, nparams);
+
+ cleanup:
+ virDomainObjEndAPI(&dom);
+
+ return ret;
+}
static int
testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED,
@@ -9535,6 +9624,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainGetBlockInfo = testDomainGetBlockInfo, /* 5.7.0 */
.domainSetLifecycleAction = testDomainSetLifecycleAction, /* 5.7.0 */
.domainGetJobInfo = testDomainGetJobInfo, /* 7.6.0 */
+ .domainGetJobStats = testDomainGetJobStats, /* 7.6.0 */
.domainSnapshotNum = testDomainSnapshotNum, /* 1.1.4 */
.domainSnapshotListNames = testDomainSnapshotListNames, /* 1.1.4 */
--
2.32.0