qemu: move virDomainNestedJobAllowed 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:21 +02:00 committed by Michal Privoznik
parent 6260204c7f
commit 7537c4d0a5
4 changed files with 14 additions and 11 deletions

View File

@ -226,3 +226,11 @@ virDomainTrackJob(virDomainJob job)
{ {
return (VIR_DOMAIN_TRACK_JOBS & JOB_MASK(job)) != 0; return (VIR_DOMAIN_TRACK_JOBS & JOB_MASK(job)) != 0;
} }
bool
virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob)
{
return !jobs->asyncJob ||
newJob == VIR_JOB_NONE ||
(jobs->mask & JOB_MASK(newJob));
}

View File

@ -222,3 +222,5 @@ void virDomainObjClearJob(virDomainJobObj *job);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virDomainJobObj, virDomainObjClearJob); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virDomainJobObj, virDomainObjClearJob);
bool virDomainTrackJob(virDomainJob job); bool virDomainTrackJob(virDomainJob job);
bool virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob);

View File

@ -1594,6 +1594,7 @@ virDomainJobDataInit;
virDomainJobStatusToType; virDomainJobStatusToType;
virDomainJobTypeFromString; virDomainJobTypeFromString;
virDomainJobTypeToString; virDomainJobTypeToString;
virDomainNestedJobAllowed;
virDomainObjClearJob; virDomainObjClearJob;
virDomainObjInitJob; virDomainObjInitJob;
virDomainObjPreserveJob; virDomainObjPreserveJob;

View File

@ -697,14 +697,6 @@ qemuDomainObjReleaseAsyncJob(virDomainObj *obj)
priv->job.asyncOwner = 0; priv->job.asyncOwner = 0;
} }
static bool
qemuDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob)
{
return !jobs->asyncJob ||
newJob == VIR_JOB_NONE ||
(jobs->mask & JOB_MASK(newJob)) != 0;
}
static bool static bool
qemuDomainObjCanSetJob(virDomainJobObj *job, qemuDomainObjCanSetJob(virDomainJobObj *job,
virDomainJob newJob, virDomainJob newJob,
@ -787,7 +779,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
goto error; goto error;
} }
while (!nested && !qemuDomainNestedJobAllowed(&priv->job, job)) { while (!nested && !virDomainNestedJobAllowed(&priv->job, job)) {
if (nowait) if (nowait)
goto cleanup; goto cleanup;
@ -807,7 +799,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
/* No job is active but a new async job could have been started while obj /* No job is active but a new async job could have been started while obj
* was unlocked, so we need to recheck it. */ * was unlocked, so we need to recheck it. */
if (!nested && !qemuDomainNestedJobAllowed(&priv->job, job)) if (!nested && !virDomainNestedJobAllowed(&priv->job, job))
goto retry; goto retry;
if (obj->removing) { if (obj->removing) {
@ -896,7 +888,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
duration / 1000, agentDuration / 1000, asyncDuration / 1000); duration / 1000, agentDuration / 1000, asyncDuration / 1000);
if (job) { if (job) {
if (nested || qemuDomainNestedJobAllowed(&priv->job, job)) if (nested || virDomainNestedJobAllowed(&priv->job, job))
blocker = priv->job.ownerAPI; blocker = priv->job.ownerAPI;
else else
blocker = priv->job.asyncOwnerAPI; blocker = priv->job.asyncOwnerAPI;