Re: [PATCH v2 1/4] test_driver: Implement virDomainGetJobInfo

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

 



On Mon, Aug 16, 2021 at 07:13:34PM +0800, Luke Yue wrote:
priv-jobState is used to store dummy job type, and priv->jobOperation is
used to store dummy job operation, they are initialized to
VIR_DOMAIN_JOB_NONE and VIR_DOMAIN_JOB_OPERATION_UNKNOWN, we can
just change them in other job related APIs as there is no real job in test
driver.

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

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 00cc13511a..9306f0e104 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -380,6 +380,10 @@ struct _testDomainObjPrivate {
    /* used by get/set time APIs */
    long long seconds;
    unsigned int nseconds;
+
+    /* used by Job Info APIs */
+    unsigned int jobState;
+    unsigned int jobOperation;
};


@@ -396,6 +400,9 @@ testDomainObjPrivateAlloc(void *opaque)
    priv->seconds = 627319920;
    priv->nseconds = 0;

+    priv->jobState = VIR_DOMAIN_JOB_NONE;
+    priv->jobOperation = VIR_DOMAIN_JOB_OPERATION_UNKNOWN;
+
    return priv;
}

@@ -2681,6 +2688,87 @@ testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED)
    return ret;
}

+static int
+testDomainGetJobInfoImpl(virDomainObj *dom,
+                         virDomainJobInfoPtr info)
+{
+    testDomainObjPrivate *priv = dom->privateData;
+
+    memset(info, 0, sizeof(*info));
+
+    info->type = priv->jobState;
+
+    switch (priv->jobState) {
+    case VIR_DOMAIN_JOB_NONE:
+        break;
+
+    case VIR_DOMAIN_JOB_BOUNDED:
+        info->dataTotal = 30 * 1024;
+        info->dataProcessed = 10 * 1024;
+        info->dataRemaining = 20 * 1024;
+        info->timeRemaining = 6000;
+        info->timeElapsed = 4000;
+        info->memTotal = 3 * 1024 * 1024;
+        info->memProcessed = 1024 * 1024;
+        info->memRemaining = 2 * 1024 * 1024;
+        info->fileTotal = 2 * 1024 * 1024;
+        info->fileProcessed = 1024 * 1024 / 2;
+        info->fileRemaining = 3 * 1024 * 1024 / 2;
+        break;
+
+    case VIR_DOMAIN_JOB_UNBOUNDED:
+        info->dataTotal = 30 * 1024;
+        info->dataProcessed = 10 * 1024;
+        info->dataRemaining = 20 * 1024;
+        info->timeElapsed = 4000;
+        info->memTotal = 3 * 1024 * 1024;
+        info->memProcessed = 1024 * 1024;
+        info->memRemaining = 2 * 1024 * 1024;
+        info->fileTotal = 2 * 1024 * 1024;
+        info->fileProcessed = 1024 * 1024 / 2;
+        info->fileRemaining = 3 * 1024 * 1024 / 2;
+        break;
+
+    case VIR_DOMAIN_JOB_COMPLETED:
+        info->timeElapsed = 10000;
+        info->dataTotal = 30 * 1024;
+        info->dataProcessed = 30 * 1024;
+        info->memTotal = 3 * 1024 * 1024;
+        info->memProcessed = 3 * 1024 * 1024;
+        info->fileTotal = 2 * 1024 * 1024;
+        info->fileProcessed = 2 * 1024 * 1024;
+        break;
+

This could be cleared up with some constants and branch fallthroughs,
but that's a minor details, for now this is fine as it is.

Reviewed-by: Martin Kletzander <mkletzan@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature


[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