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.