From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlg0D-0007rd-FM for qemu-devel@nongnu.org; Mon, 12 Oct 2015 12:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlg0A-00065o-Oa for qemu-devel@nongnu.org; Mon, 12 Oct 2015 12:31:09 -0400 Date: Mon, 12 Oct 2015 17:31:03 +0100 From: Stefan Hajnoczi Message-ID: <20151012163103.GD4053@stefanha-thinkpad.redhat.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> <1443161858-20533-9-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443161858-20533-9-git-send-email-wency@cn.fujitsu.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v10 08/10] Implement new driver for block replication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: Kevin Wolf , Fam Zheng , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , "Dr. David Alan Gilbert" On Fri, Sep 25, 2015 at 02:17:36PM +0800, Wen Congyang wrote: > +static void replication_start(BlockDriverState *bs, ReplicationMode mode, > + Error **errp) > +{ > + BDRVReplicationState *s = bs->opaque; > + int64_t active_length, hidden_length, disk_length; > + AioContext *aio_context; > + Error *local_err = NULL; > + > + if (s->replication_state != BLOCK_REPLICATION_NONE) { > + error_setg(errp, "Block replication is running or done"); > + return; > + } > + > + if (s->mode != mode) { > + error_setg(errp, "The parameter mode's value is invalid, needs %d," > + " but receives %d", s->mode, mode); > + return; > + } > + > + switch (s->mode) { > + case REPLICATION_MODE_PRIMARY: > + break; > + case REPLICATION_MODE_SECONDARY: > + s->active_disk = bs->file; > + if (!bs->file->backing_hd) { > + error_setg(errp, "Active disk doesn't have backing file"); > + return; > + } > + > + s->hidden_disk = s->active_disk->backing_hd; > + if (!s->hidden_disk->backing_hd) { > + error_setg(errp, "Hidden disk doesn't have backing file"); > + return; > + } > + > + s->secondary_disk = s->hidden_disk->backing_hd; > + if (!s->secondary_disk->blk) { > + error_setg(errp, "The secondary disk doesn't have block backend"); > + return; > + } ... > + aio_context = bdrv_get_aio_context(bs); > + aio_context_acquire(aio_context); > + bdrv_set_aio_context(s->secondary_disk, aio_context); Why is this bdrv_set_aio_context() call necessary? Child BDS nodes are in the same AioContext as their parents. Other block jobs need something like this because they operate on a second BDS which is not bs' backing file chain. I think you have a different situation here so it's not needed.