cryptospore / rpms / qemu-kvm

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