Message ID | 1441183880-26993-12-git-send-email-wency@cn.fujitsu.com |
---|---|
State | New |
Headers | show |
On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Signed-off-by: Gonglei <arei.gonglei@huawei.com> > Cc: Luiz Capitulino <lcapitulino@redhat.com> > Cc: Michael Roth <mdroth@linux.vnet.ibm.com> > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> > --- > block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > include/block/block.h | 5 +++++ > include/block/block_int.h | 14 ++++++++++++++ > qapi/block-core.json | 15 +++++++++++++++ > 4 files changed, 77 insertions(+) > Just an interface review for now: > +++ b/qapi/block-core.json > @@ -1810,6 +1810,21 @@ > 'data': { '*export': 'str' } } > > ## > +# @ReplicationMode > +# > +# An enumeration of replication modes. > +# > +# @unprotected: Replication is not started or after failover. Maybe: Replication is either not started, or has experienced failover. > +# > +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. > +# > +# @secondary: Secondary mode, receive the vm's state from primary QEMU. > +# > +# Since: 2.4 You've missed 2.4; this should be 2.5. > +## > +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } Where is 'unprotected' in this list?
On 09/03/2015 12:33 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Signed-off-by: Gonglei <arei.gonglei@huawei.com> >> Cc: Luiz Capitulino <lcapitulino@redhat.com> >> Cc: Michael Roth <mdroth@linux.vnet.ibm.com> >> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> >> --- >> block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >> include/block/block.h | 5 +++++ >> include/block/block_int.h | 14 ++++++++++++++ >> qapi/block-core.json | 15 +++++++++++++++ >> 4 files changed, 77 insertions(+) >> > > Just an interface review for now: > >> +++ b/qapi/block-core.json >> @@ -1810,6 +1810,21 @@ >> 'data': { '*export': 'str' } } >> >> ## >> +# @ReplicationMode >> +# >> +# An enumeration of replication modes. >> +# >> +# @unprotected: Replication is not started or after failover. > > Maybe: > > Replication is either not started, or has experienced failover. OK > >> +# >> +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. >> +# >> +# @secondary: Secondary mode, receive the vm's state from primary QEMU. >> +# >> +# Since: 2.4 > > You've missed 2.4; this should be 2.5. Yes, I forgot to update it. I will check all patches. > >> +## >> +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } > > Where is 'unprotected' in this list? > I don't know when it is removed. I will check it and fix it in the next version. Thanks Wen Congyang
On 09/03/2015 12:33 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Signed-off-by: Gonglei <arei.gonglei@huawei.com> >> Cc: Luiz Capitulino <lcapitulino@redhat.com> >> Cc: Michael Roth <mdroth@linux.vnet.ibm.com> >> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> >> --- >> block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >> include/block/block.h | 5 +++++ >> include/block/block_int.h | 14 ++++++++++++++ >> qapi/block-core.json | 15 +++++++++++++++ >> 4 files changed, 77 insertions(+) >> > > Just an interface review for now: > >> +++ b/qapi/block-core.json >> @@ -1810,6 +1810,21 @@ >> 'data': { '*export': 'str' } } >> >> ## >> +# @ReplicationMode >> +# >> +# An enumeration of replication modes. >> +# >> +# @unprotected: Replication is not started or after failover. > > Maybe: > > Replication is either not started, or has experienced failover. This is internal state, and this mode is used to tell qemu that it is on which side. Thanks Wen Congyang > >> +# >> +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. >> +# >> +# @secondary: Secondary mode, receive the vm's state from primary QEMU. >> +# >> +# Since: 2.4 > > You've missed 2.4; this should be 2.5. > >> +## >> +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } > > Where is 'unprotected' in this list? >
diff --git a/block.c b/block.c index 5119e1e..c7670d2 100644 --- a/block.c +++ b/block.c @@ -4390,3 +4390,46 @@ void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs, bs->drv->bdrv_del_child(bs, child_bs, errp); } + +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_start_replication) { + drv->bdrv_start_replication(bs, mode, errp); + } else if (bs->file) { + bdrv_start_replication(bs->file, mode, errp); + } else { + error_setg(errp, "The BDS %s doesn't support starting block" + " replication", bs->filename); + } +} + +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_do_checkpoint) { + drv->bdrv_do_checkpoint(bs, errp); + } else if (bs->file) { + bdrv_do_checkpoint(bs->file, errp); + } else { + error_setg(errp, "The BDS %s doesn't support block checkpoint", + bs->filename); + } +} + +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_stop_replication) { + drv->bdrv_stop_replication(bs, failover, errp); + } else if (bs->file) { + bdrv_stop_replication(bs->file, failover, errp); + } else { + error_setg(errp, "The BDS %s doesn't support stopping block" + " replication", bs->filename); + } +} diff --git a/include/block/block.h b/include/block/block.h index 98c8509..192a066 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -626,4 +626,9 @@ void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp); void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child, Error **errp); +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp); +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp); +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index b6f2905..1c2d310 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -293,6 +293,20 @@ struct BlockDriver { void (*bdrv_del_child)(BlockDriverState *bs, BlockDriverState *child, Error **errp); + void (*bdrv_start_replication)(BlockDriverState *bs, ReplicationMode mode, + Error **errp); + /* Drop Disk buffer when doing checkpoint. */ + void (*bdrv_do_checkpoint)(BlockDriverState *bs, Error **errp); + /* + * After failover, we should flush Disk buffer into secondary disk + * and stop block replication. + * + * If the guest is shutdown, we should drop Disk buffer and stop + * block representation. + */ + void (*bdrv_stop_replication)(BlockDriverState *bs, bool failover, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; diff --git a/qapi/block-core.json b/qapi/block-core.json index 24099ef..96f0530 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1810,6 +1810,21 @@ 'data': { '*export': 'str' } } ## +# @ReplicationMode +# +# An enumeration of replication modes. +# +# @unprotected: Replication is not started or after failover. +# +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. +# +# @secondary: Secondary mode, receive the vm's state from primary QEMU. +# +# Since: 2.4 +## +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } + +## # @BlockdevOptions # # Options for creating a block device.