From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yakm2-0008MG-1x for qemu-devel@nongnu.org; Wed, 25 Mar 2015 08:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yakm1-0000FF-2C for qemu-devel@nongnu.org; Wed, 25 Mar 2015 08:51:06 -0400 Sender: Paolo Bonzini Message-ID: <5512AF2E.2070206@redhat.com> Date: Wed, 25 Mar 2015 13:50:54 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1427276174-9130-1-git-send-email-wency@cn.fujitsu.com> <1427276174-9130-7-git-send-email-wency@cn.fujitsu.com> In-Reply-To: <1427276174-9130-7-git-send-email-wency@cn.fujitsu.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH COLO v2 06/13] NBD client: implement block driver interfaces for block replication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz Cc: Kevin Wolf , Lai Jiangshan , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang On 25/03/2015 10:36, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > block/nbd.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > > diff --git a/block/nbd.c b/block/nbd.c > index 3faf865..753b322 100644 > --- a/block/nbd.c > +++ b/block/nbd.c > @@ -458,6 +458,52 @@ static void nbd_refresh_filename(BlockDriverState *bs) > bs->full_open_options = opts; > } > > +static void nbd_start_replication(BlockDriverState *bs, COLOMode mode, > + Error **errp) > +{ > + BDRVNBDState *s = bs->opaque; > + > + /* > + * TODO: support COLO_SECONDARY_MODE if we allow secondary > + * QEMU becoming primary QEMU. > + */ > + if (mode != COLO_MODE_PRIMARY) { > + error_set(errp, QERR_INVALID_PARAMETER, "mode"); > + return; > + } > + > + if (s->connected) { > + error_setg(errp, "The connection is established"); > + return; > + } > + > + /* TODO: NBD client should be one child of quorum, how to verify it? */ > + nbd_connect_server(bs, errp); > +} > + > +static void nbd_do_checkpoint(BlockDriverState *bs, Error **errp) > +{ > + BDRVNBDState *s = bs->opaque; > + > + if (!s->connected) { > + error_setg(errp, "The connection is not established"); > + return; > + } > +} > + > +static void nbd_stop_replication(BlockDriverState *bs, Error **errp) > +{ > + BDRVNBDState *s = bs->opaque; > + > + if (!s->connected) { > + error_setg(errp, "The connection is not established"); > + return; > + } > + > + nbd_client_close(bs); > + s->connected = false; > +} > + > static BlockDriver bdrv_nbd = { > .format_name = "nbd", > .protocol_name = "nbd", > @@ -527,6 +573,9 @@ static BlockDriver bdrv_nbd_colo = { > .bdrv_detach_aio_context = nbd_detach_aio_context, > .bdrv_attach_aio_context = nbd_attach_aio_context, > .bdrv_refresh_filename = nbd_refresh_filename, > + .bdrv_start_replication = nbd_start_replication, > + .bdrv_do_checkpoint = nbd_do_checkpoint, > + .bdrv_stop_replication = nbd_stop_replication, > > .has_variable_length = true, > }; > Reviewed-by: Paolo Bonzini