From patchwork Thu May 21 08:13:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 474867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4258814077A for ; Thu, 21 May 2015 18:22:11 +1000 (AEST) Received: from localhost ([::1]:55868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLk1-0006Fl-DT for incoming@patchwork.ozlabs.org; Thu, 21 May 2015 04:22:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLcl-0002GF-52 for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvLcj-0002jV-D3 for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:39 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:55119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvLci-0002ig-Lz for qemu-devel@nongnu.org; Thu, 21 May 2015 04:14:37 -0400 Received: from 172.24.2.119 (EHLO szxeml433-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id COD57689; Thu, 21 May 2015 16:14:28 +0800 (CST) Received: from localhost (10.177.22.69) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.158.1; Thu, 21 May 2015 16:14:19 +0800 From: zhanghailiang To: Date: Thu, 21 May 2015 16:13:06 +0800 Message-ID: <1432196001-10352-15-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.2.msysgit.0 In-Reply-To: <1432196001-10352-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1432196001-10352-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.22.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, amit.shah@redhat.com, Lai Jiangshan , Yang Hongyang , david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH COLO-Frame v5 14/29] COLO failover: Introduce a new command to trigger a failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Li Zhijian Signed-off-by: Lai Jiangshan Signed-off-by: Yang Hongyang --- 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 index e864a6c..be3e398 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1008,6 +1008,21 @@ Set the parameter @var{parameter} 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 e17852d..f87fa37 100644 --- a/hmp.c +++ b/hmp.c @@ -1250,6 +1250,13 @@ void hmp_migrate_set_parameter(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 a158e3f..b6549f8 100644 --- a/hmp.h +++ b/hmp.h @@ -67,6 +67,7 @@ void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict); void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); void hmp_migrate_set_parameter(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 c03c391..d6eac07 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" bool colo_supported(void); 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..a8767fc --- /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 cb7bd30..50d8392 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,6 +1,6 @@ common-obj-y += migration.o tcp.o -common-obj-$(CONFIG_COLO) += colo.o common-obj-y += colo-comm.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..2bd2e16 --- /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 74590eb..ad44569 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -14,6 +14,7 @@ #include "migration/migration-colo.h" #include "trace.h" #include "qemu/error-report.h" +#include "migration/migration-failover.h" enum { COLO_CHECPOINT_READY = 0x46, diff --git a/qapi-schema.json b/qapi-schema.json index 54eb707..7562111 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -644,6 +644,15 @@ 'returns': 'MigrationParameters' } ## +# @colo-lost-heartbeat +# +# Tell COLO that heartbeat is lost +# +# Since: 2.4 +## +{ 'command': 'colo-lost-heartbeat' } + +## # @MouseInfo: # # Information about a mouse device. diff --git a/qmp-commands.hx b/qmp-commands.hx index 14e109e..3813f66 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -781,6 +781,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 45b992a..7d1fd9f 100644 --- a/stubs/migration-colo.c +++ b/stubs/migration-colo.c @@ -11,6 +11,7 @@ */ #include "migration/migration-colo.h" +#include "qmp-commands.h" bool colo_supported(void) { @@ -30,3 +31,10 @@ void *colo_process_incoming_checkpoints(void *opaque) { return NULL; } + +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"); +}