From patchwork Fri Jun 3 07:52:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9152107 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 18B1E6072B for ; Fri, 3 Jun 2016 08:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 060762675C for ; Fri, 3 Jun 2016 08:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEDA628309; Fri, 3 Jun 2016 08:20:00 +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 58C2F2675C for ; Fri, 3 Jun 2016 08:20:00 +0000 (UTC) Received: from localhost ([::1]:53166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8kKl-0005OJ-Fs for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Jun 2016 04:19:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jvu-0007I3-0D for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8jvo-0004qP-Qe for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:17 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:25198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jvo-0004pI-6D for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:12 -0400 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DIE18600; Fri, 03 Jun 2016 15:53:05 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Fri, 3 Jun 2016 15:52:54 +0800 From: zhanghailiang To: , , , Date: Fri, 3 Jun 2016 15:52:15 +0800 Message-ID: <1464940366-9880-4-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1464940366-9880-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1464940366-9880-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.5751378E.0098, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 736407fa56f3166b5b2e19b39e7936b2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH COLO-Frame v17 03/34] 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, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, zhanghailiang , arei.gonglei@huawei.com, stefanha@redhat.com, zhangchen.fnst@cn.fujitsu.com, hongyang.yang@easystack.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can know if VM in destination should go into COLO mode by refer to the info that been migrated from PVM. We skip this section if colo is not enabled (i.e. migrate_set_capability colo off), so that, It not break compatibility with migration however the --enable-colo/disable-colo on the source/destination; Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian Signed-off-by: Gonglei Reviewed-by: Dr. David Alan Gilbert --- 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 | 4 +++- 4 files changed, 57 insertions(+), 1 deletion(-) 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..2d06ace --- /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 2f74fe8..1a8869e 100644 --- a/vl.c +++ b/vl.c @@ -89,6 +89,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" @@ -4372,6 +4373,8 @@ int main(int argc, char **argv, char **envp) #endif } + colo_info_init(); + if (net_init_clients() < 0) { exit(1); } @@ -4402,7 +4405,6 @@ int main(int argc, char **argv, char **envp) blk_mig_init(); ram_mig_init(); - /* If the currently selected machine wishes to override the units-per-bus * property of its default HBA interface type, do so now. */ if (machine_class->units_per_default_bus) {