This patch adds a new variable maxQueuedJobs into the job object as it is the last hypervisor-based part of the begin job. Since this patch, it will not be necessary to propagate driver structure into the job functions. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- src/hypervisor/domain_job.h | 1 + src/qemu/qemu_domain.c | 3 +++ src/qemu/qemu_domainjob.c | 11 +++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hypervisor/domain_job.h b/src/hypervisor/domain_job.h index 838cfd16e3..7f35d5ee85 100644 --- a/src/hypervisor/domain_job.h +++ b/src/hypervisor/domain_job.h @@ -155,6 +155,7 @@ struct _virDomainJobObj { virCond cond; /* Use to coordinate jobs */ int jobsQueued; + unsigned int maxQueuedJobs; /* The following members are for VIR_JOB_* */ virDomainJob active; /* currently running job */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 94b50420fe..7ac7c3c05a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1758,6 +1758,7 @@ static void * qemuDomainObjPrivateAlloc(void *opaque) { g_autoptr(qemuDomainObjPrivate) priv = g_new0(qemuDomainObjPrivate, 1); + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(opaque); if (virDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) { virReportSystemError(errno, "%s", @@ -1770,6 +1771,8 @@ qemuDomainObjPrivateAlloc(void *opaque) priv->blockjobs = virHashNew(virObjectUnref); + priv->job.maxQueuedJobs = cfg->maxQueuedJobs; + /* agent commands block by default, user can choose different behavior */ priv->agentTimeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 11f30de136..0e1c7210c5 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -723,7 +723,7 @@ qemuDomainObjReleaseAsyncJob(virDomainObj *obj) * -1 otherwise. */ static int ATTRIBUTE_NONNULL(1) -qemuDomainObjBeginJobInternal(virQEMUDriver *driver, +qemuDomainObjBeginJobInternal(virQEMUDriver *driver G_GNUC_UNUSED, virDomainObj *obj, virDomainJob job, virDomainAgentJob agentJob, @@ -734,7 +734,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver, unsigned long long now; unsigned long long then; bool nested = job == VIR_JOB_ASYNC_NESTED; - g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); const char *blocker = NULL; const char *agentBlocker = NULL; int ret = -1; @@ -763,8 +762,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver, retry: if (job != VIR_JOB_ASYNC && job != VIR_JOB_DESTROY && - cfg->maxQueuedJobs && - priv->job.jobsQueued > cfg->maxQueuedJobs) { + priv->job.maxQueuedJobs && + priv->job.jobsQueued > priv->job.maxQueuedJobs) { goto error; } @@ -907,8 +906,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver, _("cannot acquire state change lock")); } ret = -2; - } else if (cfg->maxQueuedJobs && - priv->job.jobsQueued > cfg->maxQueuedJobs) { + } else if (priv->job.maxQueuedJobs && + priv->job.jobsQueued > priv->job.maxQueuedJobs) { if (blocker && agentBlocker) { virReportError(VIR_ERR_OPERATION_FAILED, _("cannot acquire state change " -- 2.37.1