yeahuh / rpms / qemu-kvm

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