[PATCH v2 3/4] test_driver: Implement virDomainAbortJob

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux