cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-mirror-Go-through-ready-complete-process-for-0-len-i.patch

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