[PATCH 3/4] test_driver: Implement virDomainAbortJob

Luke Yue lukedyue at gmail.com
Thu Jul 22 07:13:24 UTC 2021


As the job should be running between 0-10000 seconds, so if the API is
triggered between 0-10000 seconds, it will set time to 10000, so that
the job status will be completed. Otherwise, there is no job active and
report error.

Signed-off-by: Luke Yue <lukedyue at gmail.com>
---
 src/test/test_driver.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4af8ce42f2..b31ab95101 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2744,6 +2744,34 @@ testDomainGetJobStats(virDomainPtr domain,
     return ret;
 }
 
+static int
+testDomainAbortJob(virDomainPtr dom)
+{
+    virDomainObj *vm;
+    int ret = -1;
+    testDomainObjPrivate *priv;
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        goto cleanup;
+
+    if (virDomainObjCheckActive(vm) < 0)
+        goto cleanup;
+
+    priv = vm->privateData;
+
+    if (priv->seconds >= 10000) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("no job is active on the domain"));
+    } else {
+        priv->seconds = 10000;
+        ret = 0;
+    }
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 static int
 testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED,
                                 virTypedParameterPtr *params G_GNUC_UNUSED,
@@ -9625,6 +9653,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainSetLifecycleAction = testDomainSetLifecycleAction, /* 5.7.0 */
     .domainGetJobInfo = testDomainGetJobInfo, /* 7.6.0 */
     .domainGetJobStats = testDomainGetJobStats, /* 7.6.0 */
+    .domainAbortJob = testDomainAbortJob, /* 7.6.0 */
 
     .domainSnapshotNum = testDomainSnapshotNum, /* 1.1.4 */
     .domainSnapshotListNames = testDomainSnapshotListNames, /* 1.1.4 */
-- 
2.32.0




More information about the libvir-list mailing list