From a437bfcdaad8e387709506ccaa992895f76afa8e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 20 Aug 2014 16:40:10 +0200 Subject: [PATCH 3/7] mirror: Go through ready -> complete process for 0 len image Message-id: <1408552814-23031-4-git-send-email-eblake@redhat.com> Patchwork-id: 60645 O-Subject: [qemu-kvm-rhev 7.0.z PATCH 3/7] mirror: Go through ready -> complete process for 0 len image Bugzilla: 1132806 RH-Acked-by: Paolo Bonzini RH-Acked-by: Fam Zheng RH-Acked-by: Stefan Hajnoczi From: Fam Zheng When mirroring or active committing a zero length image, BLOCK_JOB_READY is not reported now, instead the job completes because we short circuit the mirror job loop. This is inconsistent with non-zero length images, and only confuses management software. Let's do the same thing when seeing a 0-length image: report ready immediately; wait for block-job-cancel or block-job-complete; clear the cancel flag as existing non-zero image synced case (cancelled after ready); then jump to the exit. Reported-by: Eric Blake Signed-off-by: Fam Zheng Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit 9e48b025400b2d284e17860862b0a4aa02c6032d) Conflicts: block/mirror.c - no backport of qapi events Signed-off-by: Eric Blake Signed-off-by: Miroslav Rezanina --- block/mirror.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 9b3e229..cdc0268 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -306,9 +306,18 @@ static void coroutine_fn mirror_run(void *opaque) } s->common.len = bdrv_getlength(bs); - if (s->common.len <= 0) { + if (s->common.len < 0) { ret = s->common.len; goto immediate_exit; + } else if (s->common.len == 0) { + /* Report BLOCK_JOB_READY and wait for complete. */ + block_job_ready(&s->common); + s->synced = true; + while (!block_job_is_cancelled(&s->common) && !s->should_complete) { + block_job_yield(&s->common); + } + s->common.cancelled = false; + goto immediate_exit; } length = (bdrv_getlength(bs) + s->granularity - 1) / s->granularity; -- 1.7.1