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;
}
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);
bool virDomainTrackJob(virDomainJob job);
bool virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob);

View File

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

View File

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