From 54109db8265198b98c0bd4c148fff442d37d53b5 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 27 Sep 2024 09:07:22 +0200 Subject: [PATCH] qemu: blockjob: Clean out disk mirror data after concluding the job The 'disk->mirrorJob' and 'disk->mirrorState' fields need to be cleared after a blockjob, but should be kept around while 'disk->mirror' is still in place. As 'disk->mirror' is cleared only after conclusion of the job in 'qemuBlockJobEventProcessConcluded()' we should be resetting them only afterwards. Move the code later, but since the job is unregistered from the disk we need to store the pointer to the disk before concluding the job. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_blockjob.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 9c56d5cb95..652b25540a 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1561,12 +1561,18 @@ qemuBlockJobEventProcess(virQEMUDriver *driver, case QEMU_BLOCKJOB_STATE_COMPLETED: case QEMU_BLOCKJOB_STATE_FAILED: case QEMU_BLOCKJOB_STATE_CANCELLED: - case QEMU_BLOCKJOB_STATE_CONCLUDED: - if (job->disk) { - job->disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; - job->disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; - } + case QEMU_BLOCKJOB_STATE_CONCLUDED: { + virDomainDiskDef *disk = job->disk; + qemuBlockJobEventProcessConcluded(job, driver, vm, asyncJob); + + /* Job was unregistered from the disk but we must ensure that the + * data is cleared */ + if (disk) { + disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; + disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; + } + } break; case QEMU_BLOCKJOB_STATE_READY: