qemu: move virDomainObjCanSetJob() into hypervisor

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2022-08-03 14:43:22 +02:00 committed by Michal Privoznik
parent 7537c4d0a5
commit 54f48e033e
4 changed files with 17 additions and 12 deletions

View File

@ -234,3 +234,14 @@ virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob)
newJob == VIR_JOB_NONE ||
(jobs->mask & JOB_MASK(newJob));
}
bool
virDomainObjCanSetJob(virDomainJobObj *job,
virDomainJob newJob,
virDomainAgentJob newAgentJob)
{
return ((newJob == VIR_JOB_NONE ||
job->active == VIR_JOB_NONE) &&
(newAgentJob == VIR_AGENT_JOB_NONE ||
job->agentActive == VIR_AGENT_JOB_NONE));
}

View File

@ -224,3 +224,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virDomainJobObj, virDomainObjClearJob);
bool virDomainTrackJob(virDomainJob job);
bool virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob);
bool virDomainObjCanSetJob(virDomainJobObj *job,
virDomainJob newJob,
virDomainAgentJob newAgentJob);

View File

@ -1595,6 +1595,7 @@ virDomainJobStatusToType;
virDomainJobTypeFromString;
virDomainJobTypeToString;
virDomainNestedJobAllowed;
virDomainObjCanSetJob;
virDomainObjClearJob;
virDomainObjInitJob;
virDomainObjPreserveJob;

View File

@ -697,17 +697,6 @@ qemuDomainObjReleaseAsyncJob(virDomainObj *obj)
priv->job.asyncOwner = 0;
}
static bool
qemuDomainObjCanSetJob(virDomainJobObj *job,
virDomainJob newJob,
virDomainAgentJob newAgentJob)
{
return ((newJob == VIR_JOB_NONE ||
job->active == VIR_JOB_NONE) &&
(newAgentJob == VIR_AGENT_JOB_NONE ||
job->agentActive == VIR_AGENT_JOB_NONE));
}
/* Give up waiting for mutex after 30 seconds */
#define QEMU_JOB_WAIT_TIME (1000ull * 30)
@ -788,7 +777,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
goto error;
}
while (!qemuDomainObjCanSetJob(&priv->job, job, agentJob)) {
while (!virDomainObjCanSetJob(&priv->job, job, agentJob)) {
if (nowait)
goto cleanup;