[PATCH 0/2] qemu: migration: Don't use stale block job state when migrating disks

Peter Krempa (2): qemuMigrationSrcNBDStorageCopyReady: Use ready-state of mirror from qemuBlockJobData qemuBlockJobEventProcess: Always clear 'mirrorState' when a job finishes src/qemu/qemu_blockjob.c | 4 ++++ src/qemu/qemu_migration.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) -- 2.29.2

Use the per-job state to determine when the non-shared-storage mirror is complete rather than the per-disk definition one. The qemuBlockJobData is a newer approach and is always cleared after the blockjob is terminated while the 'mirrorState' variable in the definition of the disk may be left over. In such case the disk mirror would be considered complete prematurely. https://bugzilla.redhat.com/show_bug.cgi?id=1889131 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_migration.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c5108e55a0..5353c7ee01 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -591,10 +591,10 @@ qemuMigrationSrcNBDStorageCopyReady(virDomainObjPtr vm, return -1; } - virObjectUnref(job); - - if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) + if (job->state != VIR_DOMAIN_BLOCK_JOB_READY) notReady++; + + virObjectUnref(job); } if (notReady) { -- 2.29.2

When a block job is terminated we should clear the 'mirrorState' and 'mirrorJob' variables so that stale values are not present prior to a new job. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_blockjob.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 2a5a5e66f4..0d00dbc947 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1691,6 +1691,10 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver, 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; + } qemuBlockJobEventProcessConcluded(job, driver, vm, asyncJob); break; -- 2.29.2

On a Monday in 2021, Peter Krempa wrote:
Peter Krempa (2): qemuMigrationSrcNBDStorageCopyReady: Use ready-state of mirror from qemuBlockJobData qemuBlockJobEventProcess: Always clear 'mirrorState' when a job finishes
src/qemu/qemu_blockjob.c | 4 ++++ src/qemu/qemu_migration.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa