From c257352797a8367d8f03b2901e7b9175cc907156 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 26 Nov 2018 15:29:55 +0100 Subject: [PATCH] qemu: blockjob: Consume new block job state in the processing function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- 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 7b98056413..f26e1bdd57 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -286,6 +286,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 @@ -315,6 +318,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); @@ -347,14 +351,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; - return state; + qemuBlockJobEventProcessLegacy(priv->driver, vm, job, asyncJob); + + return job->state; }