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(a)redhat.com>
---
src/qemu/qemu_domainjob.c | 31 ++++++++++++++-----------------
src/qemu/qemu_domainjob.h | 2 +-
src/qemu/qemu_process.c | 2 +-
3 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 132f2a0025..260717aa88 100644
--- a/src/qemu/qemu_domainjob.c
+++ b/src/qemu/qemu_domainjob.c
@@ -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;
-
- if (priv->job.cb &&
- !(priv->job.privateData = priv->job.cb->allocJobPrivate()))
+ 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 (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;
}
diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h
index 36747154c6..a0cd79c705 100644
--- a/src/qemu/qemu_domainjob.h
+++ b/src/qemu/qemu_domainjob.h
@@ -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,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d29da63242..fc42434a0d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8874,7 +8874,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)
--
2.37.1