From patchwork Mon Feb 22 02:39:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 8370361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 79C089F314 for ; Mon, 22 Feb 2016 02:41:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFF722034C for ; Mon, 22 Feb 2016 02:41:35 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 771F7202F8 for ; Mon, 22 Feb 2016 02:41:34 +0000 (UTC) Received: from localhost ([::1]:46042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgRI-0000mB-Qq for patchwork-qemu-devel@patchwork.kernel.org; Sun, 21 Feb 2016 21:41:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgR9-0000iq-Rr for qemu-devel@nongnu.org; Sun, 21 Feb 2016 21:41:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXgR7-0007PH-1J for qemu-devel@nongnu.org; Sun, 21 Feb 2016 21:41:23 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:13160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgR6-0007LF-FC for qemu-devel@nongnu.org; Sun, 21 Feb 2016 21:41:20 -0500 Received: from 172.24.1.50 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.50]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BWL15689; Mon, 22 Feb 2016 10:40:54 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Mon, 22 Feb 2016 10:40:47 +0800 From: zhanghailiang To: Date: Mon, 22 Feb 2016 10:39:57 +0800 Message-ID: <1456108832-24212-4-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1456108832-24212-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1456108832-24212-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.0A020203.56CA7537.0084, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: df6e001d6116cc61f21c11ce38c8ba26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: xiecl.fnst@cn.fujitsu.com, lizhijian@cn.fujitsu.com, quintela@redhat.com, armbru@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, zhangchen.fnst@cn.fujitsu.com, hongyang.yang@easystack.cn Subject: [Qemu-devel] [PATCH COLO-Frame v15 03/38] COLO: migrate colo related info to secondary node 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 --- 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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ vl.c | 4 +++- 4 files changed, 56 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 65ecc35..81b5713 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,5 +1,6 @@ common-obj-y += migration.o tcp.o common-obj-$(CONFIG_COLO) += colo.o +common-obj-y += colo-comm.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 postcopy-ram.o diff --git a/migration/colo-comm.c b/migration/colo-comm.c new file mode 100644 index 0000000..723d86d --- /dev/null +++ b/migration/colo-comm.c @@ -0,0 +1,50 @@ +/* + * 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 +#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 b87e292..f35703f 100644 --- a/vl.c +++ b/vl.c @@ -85,6 +85,7 @@ int main(int argc, char **argv) #include "sysemu/dma.h" #include "audio/audio.h" #include "migration/migration.h" +#include "migration/colo.h" #include "sysemu/kvm.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" @@ -4394,6 +4395,8 @@ int main(int argc, char **argv, char **envp) /* clean up network at qemu process termination */ atexit(&net_cleanup); + colo_info_init(); + if (net_init_clients() < 0) { exit(1); } @@ -4425,7 +4428,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) {