From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlBSp-0004af-Vb for qemu-devel@nongnu.org; Tue, 26 Nov 2013 00:45:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlBSj-00026r-5F for qemu-devel@nongnu.org; Tue, 26 Nov 2013 00:45:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlBSi-00026l-R1 for qemu-devel@nongnu.org; Tue, 26 Nov 2013 00:45:29 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAQ5jSNu032395 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Nov 2013 00:45:28 -0500 From: Fam Zheng Date: Tue, 26 Nov 2013 13:45:04 +0800 Message-Id: <1385444708-19439-3-git-send-email-famz@redhat.com> In-Reply-To: <1385444708-19439-1-git-send-email-famz@redhat.com> References: <1385444708-19439-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v6 2/6] mirror: move base to MirrorBlockJob List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, jcody@redhat.com, stefanha@redhat.com This allows setting the base before entering mirror_run, commit will make use of it. Signed-off-by: Fam Zheng --- block/mirror.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 01a795a..cbdcc21 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -31,6 +31,7 @@ typedef struct MirrorBlockJob { BlockJob common; RateLimit limit; BlockDriverState *target; + BlockDriverState *base; MirrorSyncMode mode; BlockdevOnError on_source_error, on_target_error; bool synced; @@ -334,8 +335,7 @@ static void coroutine_fn mirror_run(void *opaque) if (s->mode != MIRROR_SYNC_MODE_NONE) { /* First part, loop on the sectors and initialize the dirty bitmap. */ - BlockDriverState *base; - base = s->mode == MIRROR_SYNC_MODE_FULL ? NULL : bs->backing_hd; + BlockDriverState *base = s->base; for (sector_num = 0; sector_num < end; ) { int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1; ret = bdrv_is_allocated_above(bs, base, @@ -540,6 +540,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, void *opaque, Error **errp) { MirrorBlockJob *s; + BlockDriverState *base = NULL; if (granularity == 0) { /* Choose the default granularity based on the target file's cluster @@ -562,6 +563,12 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, return; } + if (mode == MIRROR_SYNC_MODE_TOP) { + base = bs->backing_hd; + } else { + base = NULL; + } + s = block_job_create(&mirror_job_driver, bs, speed, cb, opaque, errp); if (!s) { return; @@ -571,6 +578,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, s->on_target_error = on_target_error; s->target = target; s->mode = mode; + s->base = base; s->granularity = granularity; s->buf_size = MAX(buf_size, granularity); -- 1.8.4.2