qemu: propagate virDomainJobObj into qemuDomainObjPreserveJob()

It does not make sense to propagate virDomainObj and get
qemuDomainObjPrivate from it, when it is already accessible in
the only function qemuDomainObjPreserveJob() is called from. That
being said, we can also propagate virDomainJobObj directly and
avoid using qemu private structure.

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:14 +02:00 committed by Michal Privoznik
parent 36435967f6
commit 4df82dbbd1
3 changed files with 15 additions and 18 deletions

View File

@ -160,28 +160,25 @@ qemuDomainEventEmitJobCompleted(virQEMUDriver *driver,
* Returns 0 on success, -1 on failure.
*/
int
qemuDomainObjPreserveJob(virDomainObj *obj,
qemuDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job)
{
qemuDomainObjPrivate *priv = obj->privateData;
memset(job, 0, sizeof(*job));
job->active = priv->job.active;
job->owner = priv->job.owner;
job->asyncJob = priv->job.asyncJob;
job->asyncOwner = priv->job.asyncOwner;
job->asyncStarted = priv->job.asyncStarted;
job->phase = priv->job.phase;
job->privateData = g_steal_pointer(&priv->job.privateData);
job->apiFlags = priv->job.apiFlags;
job->active = currJob->active;
job->owner = currJob->owner;
job->asyncJob = currJob->asyncJob;
job->asyncOwner = currJob->asyncOwner;
job->phase = currJob->phase;
job->privateData = g_steal_pointer(&currJob->privateData);
job->apiFlags = currJob->apiFlags;
if (priv->job.cb &&
!(priv->job.privateData = priv->job.cb->allocJobPrivate()))
if (currJob->cb &&
!(currJob->privateData = currJob->cb->allocJobPrivate()))
return -1;
job->cb = priv->job.cb;
job->cb = currJob->cb;
virDomainObjResetJob(&priv->job);
virDomainObjResetAsyncJob(&priv->job);
virDomainObjResetJob(currJob);
virDomainObjResetAsyncJob(currJob);
return 0;
}

View File

@ -105,7 +105,7 @@ qemuDomainObjStartJobPhase(virDomainObj *obj,
int phase);
void qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
unsigned long long allowedJobs);
int qemuDomainObjPreserveJob(virDomainObj *obj,
int qemuDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job);
void
qemuDomainObjRestoreAsyncJob(virDomainObj *vm,

View File

@ -8879,7 +8879,7 @@ qemuProcessReconnect(void *opaque)
cfg = virQEMUDriverGetConfig(driver);
priv = obj->privateData;
qemuDomainObjPreserveJob(obj, &oldjob);
qemuDomainObjPreserveJob(&priv->job, &oldjob);
if (oldjob.asyncJob == VIR_ASYNC_JOB_MIGRATION_IN)
stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
if (oldjob.asyncJob == VIR_ASYNC_JOB_BACKUP && priv->backup)