From patchwork Thu Sep 29 08:46:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9355973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA1E76077A for ; Thu, 29 Sep 2016 08:57:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B40029904 for ; Thu, 29 Sep 2016 08:57:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FB0D29922; Thu, 29 Sep 2016 08:57:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB55129904 for ; Thu, 29 Sep 2016 08:57:35 +0000 (UTC) Received: from localhost ([::1]:35689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpX9q-0004rx-IC for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Sep 2016 04:57:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpX0j-0004yC-RW for qemu-devel@nongnu.org; Thu, 29 Sep 2016 04:48:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpX0f-00033s-KG for qemu-devel@nongnu.org; Thu, 29 Sep 2016 04:48:09 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:27303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpX0e-0002yR-Fz for qemu-devel@nongnu.org; Thu, 29 Sep 2016 04:48:05 -0400 Received: from 172.24.1.137 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIP11599; Thu, 29 Sep 2016 16:47:59 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Thu, 29 Sep 2016 16:46:52 +0800 From: zhanghailiang To: , Date: Thu, 29 Sep 2016 16:46:22 +0800 Message-ID: <1475138797-9908-3-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1475138797-9908-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1475138797-9908-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Subject: [Qemu-devel] [PATCH COLO-Frame (Base) v20 02/17] COLO: migrate COLO related info to secondary node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiecl.fnst@cn.fujitsu.com, lizhijian@cn.fujitsu.com, zhangchen.fnst@cn.fujitsu.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Gonglei , zhanghailiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can determine whether or not VM in destination should go into COLO mode by referring to the info that was migrated. We skip this section if COLO is not enabled (i.e. migrate_set_capability colo off), so that, It doesn't break compatibility with migration no matter whether users configure the --enable-colo/disable-colo on the source/destination side or not; Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian Signed-off-by: Gonglei Reviewed-by: Dr. David Alan Gilbert --- v19: - fix title and comment v16: - Fix compile broken due to missing osdep.h v14: - Adjust the place of calling colo_info_init() v11: - Add Reviewed-by tag v10: - Use VMSTATE_BOOL instead of VMSTATE_UNIT32 for 'colo_requested' (Dave's suggestion) --- include/migration/colo.h | 2 ++ migration/Makefile.objs | 1 + migration/colo-comm.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ vl.c | 3 +++ 4 files changed, 57 insertions(+) create mode 100644 migration/colo-comm.c diff --git a/include/migration/colo.h b/include/migration/colo.h index 59a632a..1c899a0 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -14,7 +14,9 @@ #define QEMU_COLO_H #include "qemu-common.h" +#include "migration/migration.h" bool colo_supported(void); +void colo_info_init(void); #endif diff --git a/migration/Makefile.objs b/migration/Makefile.objs index cff96f0..4bbe9ab 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,6 +1,7 @@ common-obj-y += migration.o socket.o fd.o exec.o common-obj-y += tls.o common-obj-$(CONFIG_COLO) += colo.o +common-obj-y += colo-comm.o common-obj-y += vmstate.o common-obj-y += qemu-file.o common-obj-y += qemu-file-channel.o diff --git a/migration/colo-comm.c b/migration/colo-comm.c new file mode 100644 index 0000000..a2d5185 --- /dev/null +++ b/migration/colo-comm.c @@ -0,0 +1,51 @@ +/* + * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO) + * (a.k.a. Fault Tolerance or Continuous Replication) + * + * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. + * Copyright (c) 2016 FUJITSU LIMITED + * Copyright (c) 2016 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 "qemu/osdep.h" +#include +#include "trace.h" + +typedef struct { + bool colo_requested; +} COLOInfo; + +static COLOInfo colo_info; + +static void colo_info_pre_save(void *opaque) +{ + COLOInfo *s = opaque; + + s->colo_requested = migrate_colo_enabled(); +} + +static bool colo_info_need(void *opaque) +{ + return migrate_colo_enabled(); +} + +static const VMStateDescription colo_state = { + .name = "COLOState", + .version_id = 1, + .minimum_version_id = 1, + .pre_save = colo_info_pre_save, + .needed = colo_info_need, + .fields = (VMStateField[]) { + VMSTATE_BOOL(colo_requested, COLOInfo), + VMSTATE_END_OF_LIST() + }, +}; + +void colo_info_init(void) +{ + vmstate_register(NULL, 0, &colo_state, &colo_info); +} diff --git a/vl.c b/vl.c index ab0349b..403ea55 100644 --- a/vl.c +++ b/vl.c @@ -90,6 +90,7 @@ int main(int argc, char **argv) #include "audio/audio.h" #include "migration/migration.h" #include "sysemu/cpus.h" +#include "migration/colo.h" #include "sysemu/kvm.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" @@ -4415,6 +4416,8 @@ int main(int argc, char **argv, char **envp) #endif } + colo_info_init(); + if (net_init_clients() < 0) { exit(1); }