[GSoC][PATCH v3 4/8] qemu_domainjob: callback functions added to access `jobs_queued`

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

 



Since the attribute `jobs_queued` was required to be accessed
by jobs, callback functions: `getJobsQueued`, `increaseJobsQueued`
and `decreaseJobsQueued` were added to access them.

Signed-off-by: Prathamesh Chavan <pc44800@xxxxxxxxx>
---
 src/qemu/qemu_domain.c    | 24 ++++++++++++++++++++++++
 src/qemu/qemu_domainjob.c | 14 +++++++-------
 src/qemu/qemu_domainjob.h |  6 ++++++
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ea740bcf60..8deac9d21e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -775,6 +775,27 @@ qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt,
     return 0;
 }
 
+static int
+qemuDomainGetJobsQueued(virDomainObjPtr vm)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    return priv->jobs_queued;
+}
+
+
+static void
+qemuDomainIncreaseJobsQueued(virDomainObjPtr vm)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    priv->jobs_queued++;
+}
+
+static void
+qemuDomainDecreaseJobsQueued(virDomainObjPtr vm)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    priv->jobs_queued--;
+}
 
 static qemuDomainObjPrivateJobCallbacks qemuPrivateJobCallbacks = {
     .allocJobPrivate = qemuJobAllocPrivate,
@@ -784,6 +805,9 @@ static qemuDomainObjPrivateJobCallbacks qemuPrivateJobCallbacks = {
     .parseJob = qemuDomainParseJobPrivate,
     .setJobInfoOperation = qemuDomainJobInfoSetOperation,
     .currentJobInfoInit = qemuDomainCurrentJobInfoInit,
+    .getJobsQueued = qemuDomainGetJobsQueued,
+    .increaseJobsQueued = qemuDomainIncreaseJobsQueued,
+    .decreaseJobsQueued = qemuDomainDecreaseJobsQueued,
 };
 
 /**
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 60b834a5cb..e15619b792 100644
--- a/src/qemu/qemu_domainjob.c
+++ b/src/qemu/qemu_domainjob.c
@@ -365,13 +365,13 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
     if (virTimeMillisNow(&now) < 0)
         return -1;
 
-    priv->jobs_queued++;
+    priv->job.cb->increaseJobsQueued(obj);
     then = now + QEMU_JOB_WAIT_TIME;
 
  retry:
     if ((!async && job != QEMU_JOB_DESTROY) &&
         cfg->maxQueuedJobs &&
-        priv->jobs_queued > cfg->maxQueuedJobs) {
+        priv->job.cb->getJobsQueued(obj) > cfg->maxQueuedJobs) {
         goto error;
     }
 
@@ -502,7 +502,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
         }
         ret = -2;
     } else if (cfg->maxQueuedJobs &&
-               priv->jobs_queued > cfg->maxQueuedJobs) {
+               priv->job.cb->getJobsQueued(obj) > cfg->maxQueuedJobs) {
         if (blocker && agentBlocker) {
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("cannot acquire state change "
@@ -532,7 +532,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
     }
 
  cleanup:
-    priv->jobs_queued--;
+    priv->job.cb->decreaseJobsQueued(obj);
     return ret;
 }
 
@@ -653,7 +653,7 @@ qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
     qemuDomainObjPrivatePtr priv = obj->privateData;
     qemuDomainJob job = priv->job.active;
 
-    priv->jobs_queued--;
+    priv->job.cb->decreaseJobsQueued(obj);
 
     VIR_DEBUG("Stopping job: %s (async=%s vm=%p name=%s)",
               qemuDomainJobTypeToString(job),
@@ -674,7 +674,7 @@ qemuDomainObjEndAgentJob(virDomainObjPtr obj)
     qemuDomainObjPrivatePtr priv = obj->privateData;
     qemuDomainAgentJob agentJob = priv->job.agentActive;
 
-    priv->jobs_queued--;
+    priv->job.cb->decreaseJobsQueued(obj);
 
     VIR_DEBUG("Stopping agent job: %s (async=%s vm=%p name=%s)",
               qemuDomainAgentJobTypeToString(agentJob),
@@ -692,7 +692,7 @@ qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
 {
     qemuDomainObjPrivatePtr priv = obj->privateData;
 
-    priv->jobs_queued--;
+    priv->job.cb->decreaseJobsQueued(obj);
 
     VIR_DEBUG("Stopping async job: %s (vm=%p name=%s)",
               qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h
index c1c68719a6..d3bc59cbcb 100644
--- a/src/qemu/qemu_domainjob.h
+++ b/src/qemu/qemu_domainjob.h
@@ -113,6 +113,9 @@ typedef void (*qemuDomainObjJobInfoSetOperation)(qemuDomainJobObjPtr,
                                                  virDomainJobOperation);
 typedef void (*qemuDomainObjCurrentJobInfoInit)(qemuDomainJobObjPtr,
                                                 unsigned long long);
+typedef int (*qemuDomainObjGetJobsQueued)(virDomainObjPtr);
+typedef void (*qemuDomainObjIncreaseJobsQueued)(virDomainObjPtr);
+typedef void (*qemuDomainObjDecreaseJobsQueued)(virDomainObjPtr);
 
 typedef struct _qemuDomainObjPrivateJobCallbacks qemuDomainObjPrivateJobCallbacks;
 typedef qemuDomainObjPrivateJobCallbacks *qemuDomainObjPrivateJobCallbacksPtr;
@@ -124,6 +127,9 @@ struct _qemuDomainObjPrivateJobCallbacks {
    qemuDomainObjPrivateJobParse parseJob;
    qemuDomainObjJobInfoSetOperation setJobInfoOperation;
    qemuDomainObjCurrentJobInfoInit currentJobInfoInit;
+   qemuDomainObjGetJobsQueued getJobsQueued;
+   qemuDomainObjIncreaseJobsQueued increaseJobsQueued;
+   qemuDomainObjDecreaseJobsQueued decreaseJobsQueued;
 };
 
 struct _qemuDomainJobObj {
-- 
2.25.1




[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