[PATCH 1/4] test_driver: Implement virDomainGetJobInfo

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

 



As in testDomainGetControlInfo, a background job should be running
between 0-10000 seconds, so make the testDomainGetJobInfo consistent
with it.

Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
---
 src/test/test_driver.c | 51 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 892dc978f2..29b19d80f0 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2604,6 +2604,56 @@ testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED)
     return ret;
 }
 
+static int
+testDomainGetJobInfoImpl(virDomainObj *dom,
+                         virDomainJobInfoPtr info)
+{
+    testDomainObjPrivate *priv = dom->privateData;
+
+    memset(info, 0, sizeof(*info));
+
+    if (priv->seconds < 10000) {
+        info->type = VIR_DOMAIN_JOB_BOUNDED;
+        info->dataTotal = 10000;
+        info->dataProcessed = priv->seconds;
+        info->dataRemaining = 10000 - priv->seconds;
+        info->timeElapsed = priv->seconds;
+        info->timeRemaining = 10000 - priv->seconds;
+        info->memTotal = 1048576;
+        info->memProcessed = 1048576 - priv->seconds;
+        info->memRemaining = priv->seconds;
+        info->fileTotal = 2097152;
+        info->fileProcessed = 2097152 - priv->seconds;
+        info->fileRemaining = priv->seconds;
+    } else if (priv->seconds < 30000 && priv->seconds >= 10000) {
+        info->type = VIR_DOMAIN_JOB_COMPLETED;
+    } else {
+        info->type = VIR_DOMAIN_JOB_NONE;
+    }
+
+    return 0;
+}
+
+static int
+testDomainGetJobInfo(virDomainPtr dom,
+                     virDomainJobInfoPtr info)
+{
+    virDomainObj *vm;
+    int ret = -1;
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        goto cleanup;
+
+    if (virDomainObjCheckActive(vm) < 0)
+        goto cleanup;
+
+    ret = testDomainGetJobInfoImpl(vm, info);
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 
 static int
 testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED,
@@ -9484,6 +9534,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainMemoryPeek = testDomainMemoryPeek, /* 5.4.0 */
     .domainGetBlockInfo = testDomainGetBlockInfo, /* 5.7.0 */
     .domainSetLifecycleAction = testDomainSetLifecycleAction, /* 5.7.0 */
+    .domainGetJobInfo = testDomainGetJobInfo, /* 7.6.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