[PATCH v2 3/4] test_driver: Implement virDomainAbortJob

Luke Yue posted 4 patches 4 years, 5 months ago
There is a newer version of this series
[PATCH v2 3/4] test_driver: Implement virDomainAbortJob
Posted by Luke Yue 4 years, 5 months ago
As we are using jobState to store dummy job type, so just change it to
VIR_DOMAIN_JOB_CANCELLED when try to abort a job.

Signed-off-by: Luke Yue <lukedyue@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 93aeec7105..5043c57fe2 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2874,6 +2874,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->jobState == VIR_DOMAIN_JOB_NONE) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("no job is active on the domain"));
+    } else {
+        priv->jobState = VIR_DOMAIN_JOB_CANCELLED;
+        ret = 0;
+    }
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 static int
 testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED,
                                 virTypedParameterPtr *params G_GNUC_UNUSED,
@@ -9777,6 +9805,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainSetLifecycleAction = testDomainSetLifecycleAction, /* 5.7.0 */
     .domainGetJobInfo = testDomainGetJobInfo, /* 7.7.0 */
     .domainGetJobStats = testDomainGetJobStats, /* 7.7.0 */
+    .domainAbortJob = testDomainAbortJob, /* 7.7.0 */
 
     .domainSnapshotNum = testDomainSnapshotNum, /* 1.1.4 */
     .domainSnapshotListNames = testDomainSnapshotListNames, /* 1.1.4 */
-- 
2.32.0

Re: [PATCH v2 3/4] test_driver: Implement virDomainAbortJob
Posted by Martin Kletzander 4 years, 5 months ago
On Mon, Aug 16, 2021 at 07:13:36PM +0800, Luke Yue wrote:
>As we are using jobState to store dummy job type, so just change it to
>VIR_DOMAIN_JOB_CANCELLED when try to abort a job.
>
>Signed-off-by: Luke Yue <lukedyue@gmail.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>