From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk51X-00069i-89 for qemu-devel@nongnu.org; Thu, 08 Oct 2015 02:49:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zk51U-00040f-0b for qemu-devel@nongnu.org; Thu, 08 Oct 2015 02:49:55 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:44723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk51R-0003w1-Q9 for qemu-devel@nongnu.org; Thu, 08 Oct 2015 02:49:51 -0400 References: <1441182199-8328-1-git-send-email-zhang.zhanghailiang@huawei.com> <1441182199-8328-4-git-send-email-zhang.zhanghailiang@huawei.com> <20151002184552.GC8601@work-vm> From: zhanghailiang Message-ID: <561611D1.60101@huawei.com> Date: Thu, 8 Oct 2015 14:48:49 +0800 MIME-Version: 1.0 In-Reply-To: <20151002184552.GC8601@work-vm> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH COLO-Frame v9 03/32] COLO: migrate colo related info to slave List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, yanghy@cn.fujitsu.com On 2015/10/3 2:45, Dr. David Alan Gilbert wrote: > * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: >> 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: Yang Hongyang >> Signed-off-by: Gonglei >> --- >> include/migration/colo.h | 2 ++ >> migration/Makefile.objs | 1 + >> migration/colo-comm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ >> vl.c | 3 ++- >> 4 files changed, 59 insertions(+), 1 deletion(-) >> create mode 100644 migration/colo-comm.c >> >> diff --git a/include/migration/colo.h b/include/migration/colo.h >> index c60a590..9b6662d 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_mig_init(void); >> >> #endif >> diff --git a/migration/Makefile.objs b/migration/Makefile.objs >> index 5a25d39..cb7bd30 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 >> diff --git a/migration/colo-comm.c b/migration/colo-comm.c >> new file mode 100644 >> index 0000000..4330bd8 >> --- /dev/null >> +++ b/migration/colo-comm.c >> @@ -0,0 +1,54 @@ >> +/* >> + * 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 >> +#include "trace.h" >> + >> +typedef struct { >> + uint32_t colo_requested; >> +} COLOInfo; >> + >> +static COLOInfo colo_info; >> + >> +static void colo_info_pre_save(void *opaque) >> +{ >> + COLOInfo *s = opaque; >> + >> + if (migrate_enable_colo()) { >> + s->colo_requested = 1; >> + } else { >> + s->colo_requested = 0; >> + } >> +} >> + >> +static bool colo_info_need(void *opaque) >> +{ >> + return migrate_enable_colo(); >> +} >> + >> +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_UINT32(colo_requested, COLOInfo), > > Any reason not to do it as a bool, and use VMSTATE_BOOL? > (That would also simplify the pre_save). > No special reason, use VMSTATE_BOOL is a good idea, will fix in next version, thanks. zhanghailiang > (Oddly you don't actually need the state at all - just > the presence of the section is enough, but I don't worry > about that). > > Dave > >> + VMSTATE_END_OF_LIST() >> + }, >> +}; >> + >> +void colo_info_mig_init(void) >> +{ >> + vmstate_register(NULL, 0, &colo_state, &colo_info); >> +} >> diff --git a/vl.c b/vl.c >> index aee931a..571347a 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -92,6 +92,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" >> @@ -4446,7 +4447,7 @@ int main(int argc, char **argv, char **envp) >> >> blk_mig_init(); >> ram_mig_init(); >> - >> + colo_info_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) { >> -- >> 1.8.3.1 >> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > . >