mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 15:05:17 +00:00
qemuDomainObjBeginNestedJob: Return -2 for temporary failures
If job queue is full or waiting for a job times out, the function returns -2 so that it can be handled in a different way by callers. The change is safe since all existing callers of qemuDomainObjBeginNestedJob check the return value to be less than zero. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
1643b158f6
commit
dca377dbd6
@ -1059,6 +1059,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
|
|||||||
unsigned long long then;
|
unsigned long long then;
|
||||||
bool nested = job == QEMU_JOB_ASYNC_NESTED;
|
bool nested = job == QEMU_JOB_ASYNC_NESTED;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
int ret;
|
||||||
|
|
||||||
VIR_DEBUG("Starting %s: %s (async=%s vm=%p name=%s)",
|
VIR_DEBUG("Starting %s: %s (async=%s vm=%p name=%s)",
|
||||||
job == QEMU_JOB_ASYNC ? "async job" : "job",
|
job == QEMU_JOB_ASYNC ? "async job" : "job",
|
||||||
@ -1135,21 +1136,25 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
|
|||||||
qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
|
qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
|
||||||
priv->job.owner, priv->job.asyncOwner);
|
priv->job.owner, priv->job.asyncOwner);
|
||||||
|
|
||||||
if (errno == ETIMEDOUT)
|
ret = -1;
|
||||||
|
if (errno == ETIMEDOUT) {
|
||||||
virReportError(VIR_ERR_OPERATION_TIMEOUT,
|
virReportError(VIR_ERR_OPERATION_TIMEOUT,
|
||||||
"%s", _("cannot acquire state change lock"));
|
"%s", _("cannot acquire state change lock"));
|
||||||
else if (cfg->maxQueuedJobs &&
|
ret = -2;
|
||||||
priv->jobs_queued > cfg->maxQueuedJobs)
|
} else if (cfg->maxQueuedJobs &&
|
||||||
|
priv->jobs_queued > cfg->maxQueuedJobs) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("cannot acquire state change lock "
|
"%s", _("cannot acquire state change lock "
|
||||||
"due to max_queued limit"));
|
"due to max_queued limit"));
|
||||||
else
|
ret = -2;
|
||||||
|
} else {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
"%s", _("cannot acquire job mutex"));
|
"%s", _("cannot acquire job mutex"));
|
||||||
|
}
|
||||||
priv->jobs_queued--;
|
priv->jobs_queued--;
|
||||||
virObjectUnref(obj);
|
virObjectUnref(obj);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1165,16 +1170,22 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr obj,
|
virDomainObjPtr obj,
|
||||||
enum qemuDomainJob job)
|
enum qemuDomainJob job)
|
||||||
{
|
{
|
||||||
return qemuDomainObjBeginJobInternal(driver, obj, job,
|
if (qemuDomainObjBeginJobInternal(driver, obj, job,
|
||||||
QEMU_ASYNC_JOB_NONE);
|
QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
|
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr obj,
|
virDomainObjPtr obj,
|
||||||
enum qemuDomainAsyncJob asyncJob)
|
enum qemuDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
return qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
|
if (qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
|
||||||
asyncJob);
|
asyncJob) < 0)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ATTRIBUTE_RETURN_CHECK
|
static int ATTRIBUTE_RETURN_CHECK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user