From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSKTf-0004v9-EW for qemu-devel@nongnu.org; Fri, 12 Sep 2014 02:37:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSKTb-0007nl-67 for qemu-devel@nongnu.org; Fri, 12 Sep 2014 02:37:03 -0400 Received: from [59.151.112.132] (port=4232 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSKTa-0007nT-9I for qemu-devel@nongnu.org; Fri, 12 Sep 2014 02:36:59 -0400 Message-ID: <54129480.4060705@cn.fujitsu.com> Date: Fri, 12 Sep 2014 14:36:48 +0800 From: Hongyang Yang MIME-Version: 1.0 References: <1406125538-27992-1-git-send-email-yanghy@cn.fujitsu.com> <1406125538-27992-5-git-send-email-yanghy@cn.fujitsu.com> <20140801144321.GA2430@work-vm> In-Reply-To: <20140801144321.GA2430@work-vm> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH 04/17] COLO info: use colo info to tell migration target colo is enabled List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: kvm@vger.kernel.org, GuiJianfeng@cn.fujitsu.com, eddie.dong@intel.com, qemu-devel@nongnu.org, mrhines@linux.vnet.ibm.com =E5=9C=A8 08/01/2014 10:43 PM, Dr. David Alan Gilbert =E5=86=99=E9=81=93: > * Yang Hongyang (yanghy@cn.fujitsu.com) wrote: >> migrate colo info to migration target to tell the target colo is >> enabled. > > If I understand this correctly this means that you send a 'colo info' dev= ice > information for migrations that don't have COLO enabled; that's bad becau= se > it breaks migration unless the destination has it; I guess it's OK if you > were to guard it with a thing so it didn't do it for old machine-types. > > You could use the QEMU_VM_COMMAND sections I've created for postcopy; > ( http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg00889.html ) an= d > add a QEMU_VM_CMD_COLO to indicate you want the destination to become an = SVM, > then check the capability near the start of migration and send the com= mand. Thank you for the reference, I've read part of your Postcopy patches, but haven't into detailed implementation. I will use QEMUSizedBuffer/QEMUFile i= n next version. For QEMU_VM_COMMAND sections, can you separate it out so that= I can make use of it? Do you have a public git tree or something? > > Or perhaps there's a way to add the colo-info device on the command line = so it's > not always there. > > Dave > >> Signed-off-by: Yang Hongyang >> --- >> Makefile.objs | 1 + >> include/migration/migration-colo.h | 3 ++ >> migration-colo-comm.c | 68 ++++++++++++++++++++++++++++++= ++++++++ >> vl.c | 4 +++ >> 4 files changed, 76 insertions(+) >> create mode 100644 migration-colo-comm.c >> >> diff --git a/Makefile.objs b/Makefile.objs >> index cab5824..1836a68 100644 >> --- a/Makefile.objs >> +++ b/Makefile.objs >> @@ -50,6 +50,7 @@ common-obj-$(CONFIG_POSIX) +=3D os-posix.o >> common-obj-$(CONFIG_LINUX) +=3D fsdev/ >> >> common-obj-y +=3D migration.o migration-tcp.o >> +common-obj-y +=3D migration-colo-comm.o >> common-obj-$(CONFIG_COLO) +=3D migration-colo.o >> common-obj-y +=3D vmstate.o >> common-obj-y +=3D qemu-file.o >> diff --git a/include/migration/migration-colo.h b/include/migration/migr= ation-colo.h >> index 35b384c..e3735d8 100644 >> --- a/include/migration/migration-colo.h >> +++ b/include/migration/migration-colo.h >> @@ -12,6 +12,9 @@ >> #define QEMU_MIGRATION_COLO_H >> >> #include "qemu-common.h" >> +#include "migration/migration.h" >> + >> +void colo_info_mig_init(void); >> >> bool colo_supported(void); >> >> diff --git a/migration-colo-comm.c b/migration-colo-comm.c >> new file mode 100644 >> index 0000000..ccbc246 >> --- /dev/null >> +++ b/migration-colo-comm.c >> @@ -0,0 +1,68 @@ >> +/* >> + * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (C= OLO) >> + * (a.k.a. Fault Tolerance or Continuous Replication) >> + * >> + * Copyright (C) 2014 FUJITSU LIMITED >> + * >> + * 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 >> + >> +#define DEBUG_COLO >> + >> +#ifdef DEBUG_COLO >> +#define DPRINTF(fmt, ...) \ >> + do { fprintf(stdout, "COLO: " fmt, ## __VA_ARGS__); } while (0) >> +#else >> +#define DPRINTF(fmt, ...) \ >> + do { } while (0) >> +#endif >> + >> +static bool colo_requested; >> + >> +/* save */ >> + >> +static bool migrate_use_colo(void) >> +{ >> + MigrationState *s =3D migrate_get_current(); >> + return s->enabled_capabilities[MIGRATION_CAPABILITY_COLO]; >> +} >> + >> +static void colo_info_save(QEMUFile *f, void *opaque) >> +{ >> + qemu_put_byte(f, migrate_use_colo()); >> +} >> + >> +/* restore */ >> + >> +static int colo_info_load(QEMUFile *f, void *opaque, int version_id) >> +{ >> + int value =3D qemu_get_byte(f); >> + >> + if (value && !colo_supported()) { >> + fprintf(stderr, "COLO is not supported\n"); >> + return -EINVAL; >> + } >> + >> + if (value && !colo_requested) { >> + DPRINTF("COLO requested!\n"); >> + } >> + >> + colo_requested =3D value; >> + >> + return 0; >> +} >> + >> +static SaveVMHandlers savevm_colo_info_handlers =3D { >> + .save_state =3D colo_info_save, >> + .load_state =3D colo_info_load, >> +}; >> + >> +void colo_info_mig_init(void) >> +{ >> + register_savevm_live(NULL, "colo info", -1, 1, >> + &savevm_colo_info_handlers, NULL); >> +} >> diff --git a/vl.c b/vl.c >> index fe451aa..1a282d8 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -89,6 +89,7 @@ int main(int argc, char **argv) >> #include "sysemu/dma.h" >> #include "audio/audio.h" >> #include "migration/migration.h" >> +#include "migration/migration-colo.h" >> #include "sysemu/kvm.h" >> #include "qapi/qmp/qjson.h" >> #include "qemu/option.h" >> @@ -4339,6 +4340,9 @@ int main(int argc, char **argv, char **envp) >> >> blk_mig_init(); >> ram_mig_init(); >> + if (colo_supported()) { >> + colo_info_mig_init(); >> + } >> >> /* open the virtual block devices */ >> if (snapshot) >> -- >> 1.9.1 >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > . > --=20 Thanks, Yang.