Message ID | 1423711034-5340-15-git-send-email-zhang.zhanghailiang@huawei.com |
---|---|
State | New |
Headers | show |
On 02/11/2015 08:17 PM, zhanghailiang wrote: > We leave users to use whatever heartbeat solution they want, if the heartbeat > is lost, or other errors they detect, they can use command > 'colo_lost_heartbeat' to tell COLO to do failover, COLO will do operations > accordingly. > > For example, > If send the command to PVM, Primary will exit COLO mode, and takeover, > if to Secondary, Secondary will do failover work and at last takeover server. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> > Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> > Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com> > --- > hmp-commands.hx | 15 ++++++++++++++ > hmp.c | 7 +++++++ > hmp.h | 1 + > include/migration/migration-colo.h | 1 + > include/migration/migration-failover.h | 20 ++++++++++++++++++ > migration/Makefile.objs | 2 +- > migration/colo-failover.c | 38 ++++++++++++++++++++++++++++++++++ > migration/colo.c | 1 + > qapi-schema.json | 9 ++++++++ > qmp-commands.hx | 19 +++++++++++++++++ > stubs/migration-colo.c | 8 +++++++ > 11 files changed, 120 insertions(+), 1 deletion(-) > create mode 100644 include/migration/migration-failover.h > create mode 100644 migration/colo-failover.c > > diff --git a/hmp-commands.hx b/hmp-commands.hx > +++ b/qapi-schema.json > @@ -543,6 +543,15 @@ > { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} > > ## > +# @colo-lost-heartbeat > +# > +# Tell COLO that heartbeat is lost > +# > +# Since: 2.3 > +## > +{ 'command': 'colo-lost-heartbeat' } Okay... > + > +## > # @MouseInfo: > # > # Information about a mouse device. > diff --git a/qmp-commands.hx b/qmp-commands.hx > index a85d847..1b4a5ca 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -753,6 +753,25 @@ Example: > EQMP > > { > + .name = "colo_lost_heartbeat", ...but documented incorrectly (this should use '-' to match the command name in the .json file, not '_') > + .args_type = "", > + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, > + }, > + > +SQMP > +colo_lost_heartbeat > +-------------------- > + > +Tell COLO that heartbeat is lost, a failover or takeover is needed. > + > +Example: > + > +-> { "execute": "colo_lost_heartbeat" } > +<- { "return": {} } This example won't work unless you fix the spelling.
On 2015/2/17 7:47, Eric Blake wrote: > On 02/11/2015 08:17 PM, zhanghailiang wrote: >> We leave users to use whatever heartbeat solution they want, if the heartbeat >> is lost, or other errors they detect, they can use command >> 'colo_lost_heartbeat' to tell COLO to do failover, COLO will do operations >> accordingly. >> >> For example, >> If send the command to PVM, Primary will exit COLO mode, and takeover, >> if to Secondary, Secondary will do failover work and at last takeover server. >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> >> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> >> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com> >> --- >> hmp-commands.hx | 15 ++++++++++++++ >> hmp.c | 7 +++++++ >> hmp.h | 1 + >> include/migration/migration-colo.h | 1 + >> include/migration/migration-failover.h | 20 ++++++++++++++++++ >> migration/Makefile.objs | 2 +- >> migration/colo-failover.c | 38 ++++++++++++++++++++++++++++++++++ >> migration/colo.c | 1 + >> qapi-schema.json | 9 ++++++++ >> qmp-commands.hx | 19 +++++++++++++++++ >> stubs/migration-colo.c | 8 +++++++ >> 11 files changed, 120 insertions(+), 1 deletion(-) >> create mode 100644 include/migration/migration-failover.h >> create mode 100644 migration/colo-failover.c >> >> diff --git a/hmp-commands.hx b/hmp-commands.hx > >> +++ b/qapi-schema.json >> @@ -543,6 +543,15 @@ >> { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} >> >> ## >> +# @colo-lost-heartbeat >> +# >> +# Tell COLO that heartbeat is lost >> +# >> +# Since: 2.3 >> +## >> +{ 'command': 'colo-lost-heartbeat' } > > Okay... > >> + >> +## >> # @MouseInfo: >> # >> # Information about a mouse device. >> diff --git a/qmp-commands.hx b/qmp-commands.hx >> index a85d847..1b4a5ca 100644 >> --- a/qmp-commands.hx >> +++ b/qmp-commands.hx >> @@ -753,6 +753,25 @@ Example: >> EQMP >> >> { >> + .name = "colo_lost_heartbeat", > > ...but documented incorrectly (this should use '-' to match the command > name in the .json file, not '_') > Er, yes, you are right, here it should be 'colo-lost-heartbeat' in qmp-commands.hx, but 'colo_lost_heartbeat' in hmp-commands.hx, it is a little confused for me, why it should be like this? i will fix it. >> + .args_type = "", >> + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, >> + }, >> + >> +SQMP >> +colo_lost_heartbeat >> +-------------------- >> + >> +Tell COLO that heartbeat is lost, a failover or takeover is needed. >> + >> +Example: >> + >> +-> { "execute": "colo_lost_heartbeat" } >> +<- { "return": {} } > > This example won't work unless you fix the spelling. > Should here also be changed to 'colo-lost-heartbeat' ? Thanks, zhanghailiang
在 02/25/2015 03:04 PM, zhanghailiang 写道: > On 2015/2/17 7:47, Eric Blake wrote: >> On 02/11/2015 08:17 PM, zhanghailiang wrote: >>> We leave users to use whatever heartbeat solution they want, if the heartbeat >>> is lost, or other errors they detect, they can use command >>> 'colo_lost_heartbeat' to tell COLO to do failover, COLO will do operations >>> accordingly. >>> >>> For example, >>> If send the command to PVM, Primary will exit COLO mode, and takeover, >>> if to Secondary, Secondary will do failover work and at last takeover server. >>> >>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> >>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> >>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com> >>> --- >>> hmp-commands.hx | 15 ++++++++++++++ >>> hmp.c | 7 +++++++ >>> hmp.h | 1 + >>> include/migration/migration-colo.h | 1 + >>> include/migration/migration-failover.h | 20 ++++++++++++++++++ >>> migration/Makefile.objs | 2 +- >>> migration/colo-failover.c | 38 ++++++++++++++++++++++++++++++++++ >>> migration/colo.c | 1 + >>> qapi-schema.json | 9 ++++++++ >>> qmp-commands.hx | 19 +++++++++++++++++ >>> stubs/migration-colo.c | 8 +++++++ >>> 11 files changed, 120 insertions(+), 1 deletion(-) >>> create mode 100644 include/migration/migration-failover.h >>> create mode 100644 migration/colo-failover.c >>> >>> diff --git a/hmp-commands.hx b/hmp-commands.hx >> >>> +++ b/qapi-schema.json >>> @@ -543,6 +543,15 @@ >>> { 'command': 'query-migrate-capabilities', 'returns': >>> ['MigrationCapabilityStatus']} >>> >>> ## >>> +# @colo-lost-heartbeat >>> +# >>> +# Tell COLO that heartbeat is lost >>> +# >>> +# Since: 2.3 >>> +## >>> +{ 'command': 'colo-lost-heartbeat' } >> >> Okay... >> >>> + >>> +## >>> # @MouseInfo: >>> # >>> # Information about a mouse device. >>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>> index a85d847..1b4a5ca 100644 >>> --- a/qmp-commands.hx >>> +++ b/qmp-commands.hx >>> @@ -753,6 +753,25 @@ Example: >>> EQMP >>> >>> { >>> + .name = "colo_lost_heartbeat", >> >> ...but documented incorrectly (this should use '-' to match the command >> name in the .json file, not '_') >> > > Er, yes, you are right, here it should be 'colo-lost-heartbeat' in qmp-commands.hx, > but 'colo_lost_heartbeat' in hmp-commands.hx, it is a little confused for me, > why it should be like this? > > i will fix it. > >>> + .args_type = "", >>> + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, >>> + }, >>> + >>> +SQMP >>> +colo_lost_heartbeat >>> +-------------------- >>> + >>> +Tell COLO that heartbeat is lost, a failover or takeover is needed. >>> + >>> +Example: >>> + >>> +-> { "execute": "colo_lost_heartbeat" } >>> +<- { "return": {} } >> >> This example won't work unless you fix the spelling. >> > > Should here also be changed to 'colo-lost-heartbeat' ? No... > > Thanks, > zhanghailiang > > > . >
On 02/25/2015 03:04 PM, zhanghailiang wrote: > On 2015/2/17 7:47, Eric Blake wrote: >> On 02/11/2015 08:17 PM, zhanghailiang wrote: >>> We leave users to use whatever heartbeat solution they want, if the heartbeat >>> is lost, or other errors they detect, they can use command >>> 'colo_lost_heartbeat' to tell COLO to do failover, COLO will do operations >>> accordingly. >>> >>> For example, >>> If send the command to PVM, Primary will exit COLO mode, and takeover, >>> if to Secondary, Secondary will do failover work and at last takeover server. >>> >>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> >>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> >>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com> >>> --- >>> hmp-commands.hx | 15 ++++++++++++++ >>> hmp.c | 7 +++++++ >>> hmp.h | 1 + >>> include/migration/migration-colo.h | 1 + >>> include/migration/migration-failover.h | 20 ++++++++++++++++++ >>> migration/Makefile.objs | 2 +- >>> migration/colo-failover.c | 38 ++++++++++++++++++++++++++++++++++ >>> migration/colo.c | 1 + >>> qapi-schema.json | 9 ++++++++ >>> qmp-commands.hx | 19 +++++++++++++++++ >>> stubs/migration-colo.c | 8 +++++++ >>> 11 files changed, 120 insertions(+), 1 deletion(-) >>> create mode 100644 include/migration/migration-failover.h >>> create mode 100644 migration/colo-failover.c >>> >>> diff --git a/hmp-commands.hx b/hmp-commands.hx >> >>> +++ b/qapi-schema.json >>> @@ -543,6 +543,15 @@ >>> { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} >>> >>> ## >>> +# @colo-lost-heartbeat >>> +# >>> +# Tell COLO that heartbeat is lost >>> +# >>> +# Since: 2.3 >>> +## >>> +{ 'command': 'colo-lost-heartbeat' } >> >> Okay... >> >>> + >>> +## >>> # @MouseInfo: >>> # >>> # Information about a mouse device. >>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>> index a85d847..1b4a5ca 100644 >>> --- a/qmp-commands.hx >>> +++ b/qmp-commands.hx >>> @@ -753,6 +753,25 @@ Example: >>> EQMP >>> >>> { >>> + .name = "colo_lost_heartbeat", >> >> ...but documented incorrectly (this should use '-' to match the command >> name in the .json file, not '_') >> > > Er, yes, you are right, here it should be 'colo-lost-heartbeat' in qmp-commands.hx, > but 'colo_lost_heartbeat' in hmp-commands.hx, it is a little confused for me, > why it should be like this? > > i will fix it. > >>> + .args_type = "", >>> + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, >>> + }, >>> + >>> +SQMP >>> +colo_lost_heartbeat same here >>> +-------------------- >>> + >>> +Tell COLO that heartbeat is lost, a failover or takeover is needed. >>> + >>> +Example: >>> + >>> +-> { "execute": "colo_lost_heartbeat" } >>> +<- { "return": {} } >> >> This example won't work unless you fix the spelling. >> > > Should here also be changed to 'colo-lost-heartbeat' ? Yes. Thanks Wen Congyang > > Thanks, > zhanghailiang > > > > . >
On 02/25/2015 12:04 AM, zhanghailiang wrote: >>> +++ b/qmp-commands.hx >>> @@ -753,6 +753,25 @@ Example: >>> EQMP >>> >>> { >>> + .name = "colo_lost_heartbeat", >> >> ...but documented incorrectly (this should use '-' to match the command >> name in the .json file, not '_') >> > > Er, yes, you are right, here it should be 'colo-lost-heartbeat' in > qmp-commands.hx, > but 'colo_lost_heartbeat' in hmp-commands.hx, it is a little confused > for me, > why it should be like this? Historical madness. HMP has traditionally used '_' (and relied on tab-completion to allow users to skip having to use the shift key), while QMP has traditionally used '-' (in all but the oldest interfaces). > > i will fix it. > >>> + .args_type = "", >>> + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, >>> + }, >>> + >>> +SQMP >>> +colo_lost_heartbeat >>> +-------------------- >>> + >>> +Tell COLO that heartbeat is lost, a failover or takeover is needed. >>> + >>> +Example: >>> + >>> +-> { "execute": "colo_lost_heartbeat" } >>> +<- { "return": {} } >> >> This example won't work unless you fix the spelling. >> > > Should here also be changed to 'colo-lost-heartbeat' ? Yes.
On 2015/3/7 0:10, Eric Blake wrote: > On 02/25/2015 12:04 AM, zhanghailiang wrote: > >>>> +++ b/qmp-commands.hx >>>> @@ -753,6 +753,25 @@ Example: >>>> EQMP >>>> >>>> { >>>> + .name = "colo_lost_heartbeat", >>> >>> ...but documented incorrectly (this should use '-' to match the command >>> name in the .json file, not '_') >>> >> >> Er, yes, you are right, here it should be 'colo-lost-heartbeat' in >> qmp-commands.hx, >> but 'colo_lost_heartbeat' in hmp-commands.hx, it is a little confused >> for me, >> why it should be like this? > > Historical madness. HMP has traditionally used '_' (and relied on > tab-completion to allow users to skip having to use the shift key), > while QMP has traditionally used '-' (in all but the oldest interfaces). > Got it. >> >> i will fix it. >> >>>> + .args_type = "", >>>> + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, >>>> + }, >>>> + >>>> +SQMP >>>> +colo_lost_heartbeat >>>> +-------------------- >>>> + >>>> +Tell COLO that heartbeat is lost, a failover or takeover is needed. >>>> + >>>> +Example: >>>> + >>>> +-> { "execute": "colo_lost_heartbeat" } >>>> +<- { "return": {} } >>> >>> This example won't work unless you fix the spelling. >>> >> >> Should here also be changed to 'colo-lost-heartbeat' ? > > Yes. > OK, thanks.
diff --git a/hmp-commands.hx b/hmp-commands.hx index e37bc8b..b05e4da 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -985,6 +985,21 @@ Enable/Disable the usage of a capability @var{capability} for migration. ETEXI { + .name = "colo_lost_heartbeat", + .args_type = "", + .params = "", + .help = "Tell COLO that heartbeat is lost,\n\t\t\t" + "a failover or takeover is needed.", + .mhandler.cmd = hmp_colo_lost_heartbeat, + }, + +STEXI +@item colo_lost_heartbeat +@findex colo_lost_heartbeat +Tell COLO that heartbeat is lost, a failover or takeover is needed. +ETEXI + + { .name = "client_migrate_info", .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", .params = "protocol hostname port tls-port cert-subject", diff --git a/hmp.c b/hmp.c index b47f331..aa99616 100644 --- a/hmp.c +++ b/hmp.c @@ -1140,6 +1140,13 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) } } +void hmp_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + qmp_colo_lost_heartbeat(&err); + hmp_handle_error(mon, &err); +} + void hmp_set_password(Monitor *mon, const QDict *qdict) { const char *protocol = qdict_get_str(qdict, "protocol"); diff --git a/hmp.h b/hmp.h index 4bb5dca..a67fbf0 100644 --- a/hmp.h +++ b/hmp.h @@ -64,6 +64,7 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict); void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict); void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict); +void hmp_colo_lost_heartbeat(Monitor *mon, const QDict *qdict); void hmp_set_password(Monitor *mon, const QDict *qdict); void hmp_expire_password(Monitor *mon, const QDict *qdict); void hmp_eject(Monitor *mon, const QDict *qdict); diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h index 2084fe2..27a515a 100644 --- a/include/migration/migration-colo.h +++ b/include/migration/migration-colo.h @@ -17,6 +17,7 @@ #include "migration/migration.h" #include "block/coroutine.h" #include "qemu/thread.h" +#include "qemu/main-loop.h" void colo_info_mig_init(void); diff --git a/include/migration/migration-failover.h b/include/migration/migration-failover.h new file mode 100644 index 0000000..5fd376a --- /dev/null +++ b/include/migration/migration-failover.h @@ -0,0 +1,20 @@ +/* + * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO) + * (a.k.a. Fault Tolerance or Continuous Replication) + * + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + * Copyright (C) 2015 FUJITSU LIMITED + * Copyright (c) 2015 Intel Corporation + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#ifndef MIGRATION_FAILOVER_H +#define MIGRATION_FAILOVER_H + +#include "qemu-common.h" + +void failover_request_set(void); + +#endif diff --git a/migration/Makefile.objs b/migration/Makefile.objs index 895583e..50d8392 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,6 +1,6 @@ common-obj-y += migration.o tcp.o common-obj-y += colo-comm.o -common-obj-$(CONFIG_COLO) += colo.o +common-obj-$(CONFIG_COLO) += colo.o colo-failover.o common-obj-y += vmstate.o common-obj-y += qemu-file.o qemu-file-buf.o qemu-file-unix.o qemu-file-stdio.o common-obj-y += xbzrle.o diff --git a/migration/colo-failover.c b/migration/colo-failover.c new file mode 100644 index 0000000..af78054 --- /dev/null +++ b/migration/colo-failover.c @@ -0,0 +1,38 @@ +/* + * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO) + * (a.k.a. Fault Tolerance or Continuous Replication) + * + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + * Copyright (c) 2015 FUJITSU LIMITED + * Copyright (c) 2015 Intel Corporation + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#include "migration/migration-colo.h" +#include "migration/migration-failover.h" +#include "qmp-commands.h" + +static bool failover_request; + +static QEMUBH *failover_bh; + +static void colo_failover_bh(void *opaque) +{ + qemu_bh_delete(failover_bh); + failover_bh = NULL; + /*TODO: Do failover work */ +} + +void failover_request_set(void) +{ + failover_request = true; + failover_bh = qemu_bh_new(colo_failover_bh, NULL); + qemu_bh_schedule(failover_bh); +} + +void qmp_colo_lost_heartbeat(Error **errp) +{ + failover_request_set(); +} diff --git a/migration/colo.c b/migration/colo.c index 5ff2ee8..cd84e4d 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -13,6 +13,7 @@ #include "sysemu/sysemu.h" #include "migration/migration-colo.h" #include "qemu/error-report.h" +#include "migration/migration-failover.h" /* #define DEBUG_COLO */ diff --git a/qapi-schema.json b/qapi-schema.json index 0e7e21e..4873561 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -543,6 +543,15 @@ { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} ## +# @colo-lost-heartbeat +# +# Tell COLO that heartbeat is lost +# +# Since: 2.3 +## +{ 'command': 'colo-lost-heartbeat' } + +## # @MouseInfo: # # Information about a mouse device. diff --git a/qmp-commands.hx b/qmp-commands.hx index a85d847..1b4a5ca 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -753,6 +753,25 @@ Example: EQMP { + .name = "colo_lost_heartbeat", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_colo_lost_heartbeat, + }, + +SQMP +colo_lost_heartbeat +-------------------- + +Tell COLO that heartbeat is lost, a failover or takeover is needed. + +Example: + +-> { "execute": "colo_lost_heartbeat" } +<- { "return": {} } + +EQMP + + { .name = "client_migrate_info", .args_type = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?", .params = "protocol hostname port tls-port cert-subject", diff --git a/stubs/migration-colo.c b/stubs/migration-colo.c index 274dfcf..a690b04 100644 --- a/stubs/migration-colo.c +++ b/stubs/migration-colo.c @@ -11,6 +11,7 @@ */ #include "migration/migration-colo.h" +#include "qmp-commands.h" void colo_init_checkpointer(MigrationState *s) { @@ -25,3 +26,10 @@ bool migrate_in_colo_state(void) { return false; } + +void qmp_colo_lost_heartbeat(Error **errp) +{ + error_setg(errp, "COLO is not supported, please rerun configure" + " with --enable-colo option in order to support" + " COLO feature"); +}