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

[GSoC][PATCH v2 2/6] qemu_domainjob: jobs_queued parameter added to `qemuDomainJobPrivate`



Since the attribute `jobs_queued` was specific to jobs,
we decided to move this from `qemuDomainObjPrivate`
to `qemuDomainJobObj` structure.

Signed-off-by: Prathamesh Chavan <pc44800 gmail com>
---
 src/qemu/qemu_domain.h    |  2 --
 src/qemu/qemu_domainjob.c | 14 +++++++-------
 src/qemu/qemu_domainjob.h |  2 ++
 src/qemu/qemu_process.c   |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 386ae17272..507f710200 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -161,8 +161,6 @@ struct _qemuDomainObjPrivate {
     bool pausedShutdown;
     virTristateBool allowReboot;
 
-    int jobs_queued;
-
     unsigned long migMaxBandwidth;
     char *origname;
     int nbdPort; /* Port used for migration with NBD */
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 503a87bb12..7cd1aabd9e 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.jobs_queued++;
     then = now + QEMU_JOB_WAIT_TIME;
 
  retry:
     if ((!async && job != QEMU_JOB_DESTROY) &&
         cfg->maxQueuedJobs &&
-        priv->jobs_queued > cfg->maxQueuedJobs) {
+        priv->job.jobs_queued > cfg->maxQueuedJobs) {
         goto error;
     }
 
@@ -502,7 +502,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
         }
         ret = -2;
     } else if (cfg->maxQueuedJobs &&
-               priv->jobs_queued > cfg->maxQueuedJobs) {
+               priv->job.jobs_queued > 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.jobs_queued--;
     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.jobs_queued--;
 
     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.jobs_queued--;
 
     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.jobs_queued--;
 
     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 88051d099a..0696b79fe3 100644
--- a/src/qemu/qemu_domainjob.h
+++ b/src/qemu/qemu_domainjob.h
@@ -152,6 +152,8 @@ struct _qemuDomainJobObj {
     char *error;                        /* job event completion error */
     unsigned long apiFlags; /* flags passed to the API which started the async job */
 
+    int jobs_queued;
+
     void *privateData;                  /* job specific collection of data */
     qemuDomainObjPrivateJobCallbacksPtr cb;
 };
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 652d217b5c..e114e4c4ce 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3644,7 +3644,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver,
         ignore_value(virTimeMillisNow(&now));
 
         /* Restore the config of the async job which is not persisted */
-        priv->jobs_queued++;
+        priv->job.jobs_queued++;
         priv->job.asyncJob = QEMU_ASYNC_JOB_BACKUP;
         priv->job.asyncOwnerAPI = virThreadJobGet();
         priv->job.asyncStarted = now;
-- 
2.25.1


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