mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 00:01:55 +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;
|
||||
bool nested = job == QEMU_JOB_ASYNC_NESTED;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
int ret;
|
||||
|
||||
VIR_DEBUG("Starting %s: %s (async=%s vm=%p name=%s)",
|
||||
job == QEMU_JOB_ASYNC ? "async job" : "job",
|
||||
@ -1135,21 +1136,25 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
|
||||
qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
|
||||
priv->job.owner, priv->job.asyncOwner);
|
||||
|
||||
if (errno == ETIMEDOUT)
|
||||
ret = -1;
|
||||
if (errno == ETIMEDOUT) {
|
||||
virReportError(VIR_ERR_OPERATION_TIMEOUT,
|
||||
"%s", _("cannot acquire state change lock"));
|
||||
else if (cfg->maxQueuedJobs &&
|
||||
priv->jobs_queued > cfg->maxQueuedJobs)
|
||||
ret = -2;
|
||||
} else if (cfg->maxQueuedJobs &&
|
||||
priv->jobs_queued > cfg->maxQueuedJobs) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("cannot acquire state change lock "
|
||||
"due to max_queued limit"));
|
||||
else
|
||||
ret = -2;
|
||||
} else {
|
||||
virReportSystemError(errno,
|
||||
"%s", _("cannot acquire job mutex"));
|
||||
}
|
||||
priv->jobs_queued--;
|
||||
virObjectUnref(obj);
|
||||
virObjectUnref(cfg);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1165,16 +1170,22 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr obj,
|
||||
enum qemuDomainJob job)
|
||||
{
|
||||
return qemuDomainObjBeginJobInternal(driver, obj, job,
|
||||
QEMU_ASYNC_JOB_NONE);
|
||||
if (qemuDomainObjBeginJobInternal(driver, obj, job,
|
||||
QEMU_ASYNC_JOB_NONE) < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr obj,
|
||||
enum qemuDomainAsyncJob asyncJob)
|
||||
{
|
||||
return qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
|
||||
asyncJob);
|
||||
if (qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
|
||||
asyncJob) < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ATTRIBUTE_RETURN_CHECK
|
||||
|
Loading…
x
Reference in New Issue
Block a user