qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 14/18] mirror: Move base to MirrorBlockJob
Date: Fri, 20 Dec 2013 16:46:52 +0100	[thread overview]
Message-ID: <1387554416-5837-15-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1387554416-5837-1-git-send-email-stefanha@redhat.com>

From: Fam Zheng <famz@redhat.com>

This allows setting the base before entering mirror_run, commit will
make use of it.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/mirror.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 5b2c119..605dda6 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;
@@ -337,8 +338,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,
@@ -543,6 +543,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
@@ -565,6 +566,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;
@@ -574,6 +581,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

  parent reply	other threads:[~2013-12-20 15:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 15:46 [Qemu-devel] [PULL 00/18] Block patches Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 01/18] sheepdog: fix dynamic grow for running qcow2 format Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 02/18] vring: create a common function to parse descriptors Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 03/18] vring: factor common code for error exits Stefan Hajnoczi
2014-01-13 10:18   ` Peter Maydell
2013-12-20 15:46 ` [Qemu-devel] [PULL 04/18] dataplane: change vring API to use VirtQueueElement Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 05/18] dataplane: replace hostmem with memory_region_find Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 06/18] qapi-schema: fix QEMU 1.8 references Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 07/18] block/iscsi: Fix compilation for libiscsi 1.4.0 (API change) Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 08/18] block: vhdx - improve error message, and .bdrv_check implementation Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 09/18] docs: updated qemu-img man page and qemu-doc to reflect VHDX support Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 10/18] vmdk: Check VMFS extent line field number Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 11/18] vmdk: Allow vmdk_create to work with protocol Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 12/18] qemu-iotests: drop duplicate virtio-blk initialization failure Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 13/18] mirror: Don't close target Stefan Hajnoczi
2013-12-20 15:46 ` Stefan Hajnoczi [this message]
2013-12-20 15:46 ` [Qemu-devel] [PULL 15/18] block: Add commit_active_start() Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 16/18] commit: Support commit active layer Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 17/18] qemu-iotests: Update test cases for commit active Stefan Hajnoczi
2013-12-20 15:46 ` [Qemu-devel] [PULL 18/18] commit: Remove unused check Stefan Hajnoczi
2014-01-10 17:29 ` [Qemu-devel] [PULL 00/18] Block patches Stefan Weil
2014-01-10 18:06   ` Paolo Bonzini
2014-01-10 18:37     ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387554416-5837-15-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).