yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 1098dfcaf705697337694269c4990d2fb58347a6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Fri, 17 Jan 2014 03:07:58 +0100
9ae3a8
Subject: [PATCH 15/34] mirror: Move base to MirrorBlockJob
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1389928083-8921-14-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 56775
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 13/18] mirror: Move base to MirrorBlockJob
9ae3a8
Bugzilla: 1041301
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
This allows setting the base before entering mirror_run, commit will
9ae3a8
make use of it.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 5bc361b8134eff68e2c40916d1cf58b3523d223b)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
---
9ae3a8
 block/mirror.c | 12 ++++++++++--
9ae3a8
 1 file changed, 10 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/mirror.c |   12 ++++++++++--
9ae3a8
 1 files changed, 10 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/mirror.c b/block/mirror.c
9ae3a8
index 1e3337f..8ccde2f 100644
9ae3a8
--- a/block/mirror.c
9ae3a8
+++ b/block/mirror.c
9ae3a8
@@ -31,6 +31,7 @@ typedef struct MirrorBlockJob {
9ae3a8
     BlockJob common;
9ae3a8
     RateLimit limit;
9ae3a8
     BlockDriverState *target;
9ae3a8
+    BlockDriverState *base;
9ae3a8
     MirrorSyncMode mode;
9ae3a8
     BlockdevOnError on_source_error, on_target_error;
9ae3a8
     bool synced;
9ae3a8
@@ -334,8 +335,7 @@ static void coroutine_fn mirror_run(void *opaque)
9ae3a8
 
9ae3a8
     if (s->mode != MIRROR_SYNC_MODE_NONE) {
9ae3a8
         /* First part, loop on the sectors and initialize the dirty bitmap.  */
9ae3a8
-        BlockDriverState *base;
9ae3a8
-        base = s->mode == MIRROR_SYNC_MODE_FULL ? NULL : bs->backing_hd;
9ae3a8
+        BlockDriverState *base = s->base;
9ae3a8
         for (sector_num = 0; sector_num < end; ) {
9ae3a8
             int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
9ae3a8
             ret = bdrv_is_allocated_above(bs, base,
9ae3a8
@@ -540,6 +540,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
9ae3a8
                   void *opaque, Error **errp)
9ae3a8
 {
9ae3a8
     MirrorBlockJob *s;
9ae3a8
+    BlockDriverState *base = NULL;
9ae3a8
 
9ae3a8
     if (granularity == 0) {
9ae3a8
         /* Choose the default granularity based on the target file's cluster
9ae3a8
@@ -562,6 +563,12 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
+    if (mode == MIRROR_SYNC_MODE_TOP) {
9ae3a8
+        base = bs->backing_hd;
9ae3a8
+    } else {
9ae3a8
+        base = NULL;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     s = block_job_create(&mirror_job_driver, bs, speed, cb, opaque, errp);
9ae3a8
     if (!s) {
9ae3a8
         return;
9ae3a8
@@ -571,6 +578,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
9ae3a8
     s->on_target_error = on_target_error;
9ae3a8
     s->target = target;
9ae3a8
     s->mode = mode;
9ae3a8
+    s->base = base;
9ae3a8
     s->granularity = granularity;
9ae3a8
     s->buf_size = MAX(buf_size, granularity);
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8