mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 16:45:20 +00:00
qemu: Refactor qemuDomainObjSetJobPhase
We will want to update migration phase without affecting job ownership. Either in the thread that already owns the job or from an event handler which only changes the phase (of a job no-one owns) without assuming it. Let's move the ownership change to a new qemuDomainObjStartJobPhase helper and let qemuDomainObjSetJobPhase set the phase without touching ownership. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
69d9f54c66
commit
2b163ca301
@ -717,6 +717,10 @@ qemuDomainJobDataToParams(virDomainJobData *jobData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the job phase without changing the job owner. The owner is supposed to
|
||||||
|
* be 0 or the current thread, a warning is issued otherwise.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
qemuDomainObjSetJobPhase(virDomainObj *obj,
|
qemuDomainObjSetJobPhase(virDomainObj *obj,
|
||||||
int phase)
|
int phase)
|
||||||
@ -731,19 +735,51 @@ qemuDomainObjSetJobPhase(virDomainObj *obj,
|
|||||||
virDomainAsyncJobTypeToString(priv->job.asyncJob),
|
virDomainAsyncJobTypeToString(priv->job.asyncJob),
|
||||||
qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase));
|
qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase));
|
||||||
|
|
||||||
if (priv->job.asyncOwner == 0) {
|
if (priv->job.asyncOwner != 0 &&
|
||||||
priv->job.asyncOwnerAPI = g_strdup(virThreadJobGet());
|
priv->job.asyncOwner != me) {
|
||||||
} else if (me != priv->job.asyncOwner) {
|
VIR_WARN("'%s' async job is owned by thread %llu, API '%s'",
|
||||||
VIR_WARN("'%s' async job is owned by thread %llu",
|
|
||||||
virDomainAsyncJobTypeToString(priv->job.asyncJob),
|
virDomainAsyncJobTypeToString(priv->job.asyncJob),
|
||||||
priv->job.asyncOwner);
|
priv->job.asyncOwner,
|
||||||
|
NULLSTR(priv->job.asyncOwnerAPI));
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->job.phase = phase;
|
priv->job.phase = phase;
|
||||||
priv->job.asyncOwner = me;
|
|
||||||
qemuDomainSaveStatus(obj);
|
qemuDomainSaveStatus(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Changes the job owner and sets the job phase. The current owner is supposed
|
||||||
|
* to be 0 or the current thread, a warning is issued otherwise.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
qemuDomainObjStartJobPhase(virDomainObj *obj,
|
||||||
|
int phase)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivate *priv = obj->privateData;
|
||||||
|
unsigned long long me = virThreadSelfID();
|
||||||
|
|
||||||
|
if (!priv->job.asyncJob)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VIR_DEBUG("Starting phase '%s' of '%s' job",
|
||||||
|
qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase),
|
||||||
|
virDomainAsyncJobTypeToString(priv->job.asyncJob));
|
||||||
|
|
||||||
|
if (priv->job.asyncOwner == 0) {
|
||||||
|
priv->job.asyncOwnerAPI = g_strdup(virThreadJobGet());
|
||||||
|
} else if (me != priv->job.asyncOwner) {
|
||||||
|
VIR_WARN("'%s' async job is owned by thread %llu, API '%s'",
|
||||||
|
virDomainAsyncJobTypeToString(priv->job.asyncJob),
|
||||||
|
priv->job.asyncOwner,
|
||||||
|
NULLSTR(priv->job.asyncOwnerAPI));
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->job.asyncOwner = me;
|
||||||
|
qemuDomainObjSetJobPhase(obj, phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
|
qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
|
||||||
unsigned long long allowedJobs)
|
unsigned long long allowedJobs)
|
||||||
|
@ -156,6 +156,9 @@ void qemuDomainObjEndAsyncJob(virDomainObj *obj);
|
|||||||
void qemuDomainObjAbortAsyncJob(virDomainObj *obj);
|
void qemuDomainObjAbortAsyncJob(virDomainObj *obj);
|
||||||
void qemuDomainObjSetJobPhase(virDomainObj *obj,
|
void qemuDomainObjSetJobPhase(virDomainObj *obj,
|
||||||
int phase);
|
int phase);
|
||||||
|
void
|
||||||
|
qemuDomainObjStartJobPhase(virDomainObj *obj,
|
||||||
|
int phase);
|
||||||
void qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
|
void qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
|
||||||
unsigned long long allowedJobs);
|
unsigned long long allowedJobs);
|
||||||
int qemuDomainObjPreserveJob(virDomainObj *obj,
|
int qemuDomainObjPreserveJob(virDomainObj *obj,
|
||||||
|
@ -165,7 +165,7 @@ qemuMigrationJobSetPhase(virDomainObj *vm,
|
|||||||
if (qemuMigrationCheckPhase(vm, phase) < 0)
|
if (qemuMigrationCheckPhase(vm, phase) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuDomainObjSetJobPhase(vm, phase);
|
qemuDomainObjStartJobPhase(vm, phase);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user