The processing function modifies the job state so it should make sure
that the variable holding the new state is cleared properly and not the
caller. The caller should only deal with the job state and not the
transition that happened.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 7aaa439791..49e747ebbb 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -285,6 +285,9 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
job->state,
job->newstate);
+ if (job->newstate == -1)
+ return;
+
qemuBlockJobEmitEvents(driver, vm, disk, job->type, job->newstate);
/* If we completed a block pull or commit, then update the XML
@@ -314,6 +317,7 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
}
job->state = job->newstate;
+ job->newstate = -1;
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
VIR_WARN("Unable to save status on vm %s after block job",
vm->def->name);
@@ -346,14 +350,13 @@ qemuBlockJobUpdateDisk(virDomainObjPtr vm,
{
qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
qemuDomainObjPrivatePtr priv = vm->privateData;
- int state = job->newstate;
- if (state != -1) {
- qemuBlockJobEventProcessLegacy(priv->driver, vm, job, asyncJob);
- job->newstate = -1;
- }
+ if (job->newstate == -1)
+ return -1;
+
+ qemuBlockJobEventProcessLegacy(priv->driver, vm, job, asyncJob);
- return state;
+ return job->state;
}
--
2.19.2