From: Peter Krempa Date: Mon, 26 Nov 2018 14:29:55 +0000 (+0100) Subject: qemu: blockjob: Consume new block job state in the processing function X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c257352797a8367d8f03b2901e7b9175cc907156;p=libvirt.git qemu: blockjob: Consume new block job state in the processing function 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 --- 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; + + qemuBlockJobEventProcessLegacy(priv->driver, vm, job, asyncJob); - return state; + return job->state; }