From patchwork Wed Aug 3 12:25:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 655413 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 3s4CvN3FkNz9ryT for ; Wed, 3 Aug 2016 23:04:16 +1000 (AEST) Received: from localhost ([::1]:34361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvqI-0006c5-G6 for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2016 09:04:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvGP-0000mD-L7 for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUvGO-0006e5-1M for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:09 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:52211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvGL-0006by-Om for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:07 -0400 Received: from 172.24.1.137 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DLE25533; Wed, 03 Aug 2016 20:26:34 +0800 (CST) Received: from localhost (10.177.24.212) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Wed, 3 Aug 2016 20:26:25 +0800 From: zhanghailiang To: Date: Wed, 3 Aug 2016 20:25:41 +0800 Message-ID: <1470227172-13704-4-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1470227172-13704-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1470227172-13704-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.0A0B0205.57A1E2FC.0050, 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: 8def69160d4fd9b7c2e7a5f5cac27eac 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 v18 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, quintela@redhat.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, Gonglei , amit.shah@redhat.com, zhangchen.fnst@cn.fujitsu.com, zhanghailiang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 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..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 e7c2c62..097295d 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" @@ -4354,6 +4355,8 @@ int main(int argc, char **argv, char **envp) #endif } + colo_info_init(); + if (net_init_clients() < 0) { exit(1); }