diff mbox

[COLO-Frame,v6,03/31] COLO: migrate colo related info to slave

Message ID 1434617935-6924-4-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang June 18, 2015, 8:58 a.m. UTC
We can know if VM in destination should go into COLO mode by refer to
the info that has been migrated from PVM.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 include/migration/migration-colo.h |  2 ++
 migration/Makefile.objs            |  1 +
 migration/colo-comm.c              | 47 ++++++++++++++++++++++++++++++++++++++
 trace-events                       |  3 +++
 vl.c                               |  5 +++-
 5 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 migration/colo-comm.c

Comments

Dr. David Alan Gilbert July 3, 2015, 6:03 p.m. UTC | #1
* zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
> We can know if VM in destination should go into COLO mode by refer to
> the info that has been migrated from PVM.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  include/migration/migration-colo.h |  2 ++
>  migration/Makefile.objs            |  1 +
>  migration/colo-comm.c              | 47 ++++++++++++++++++++++++++++++++++++++
>  trace-events                       |  3 +++
>  vl.c                               |  5 +++-
>  5 files changed, 57 insertions(+), 1 deletion(-)
>  create mode 100644 migration/colo-comm.c
> 
> diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h
> index c6d0c51..e20a0c1 100644
> --- a/include/migration/migration-colo.h
> +++ b/include/migration/migration-colo.h
> @@ -14,7 +14,9 @@
>  #define QEMU_MIGRATION_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..0b76eb4
> --- /dev/null
> +++ b/migration/colo-comm.c
> @@ -0,0 +1,47 @@
> +/*
> + * 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 <migration/migration-colo.h>
> +#include "trace.h"
> +
> +static bool colo_requested;
> +
> +/* save */
> +static void colo_info_save(QEMUFile *f, void *opaque)
> +{
> +    qemu_put_byte(f, migrate_enable_colo());
> +}
> +
> +/* restore */
> +static int colo_info_load(QEMUFile *f, void *opaque, int version_id)
> +{
> +    int value = qemu_get_byte(f);
> +
> +    if (value && !colo_requested) {
> +        trace_colo_info_load("COLO request!");
> +    }
> +    colo_requested = value;
> +
> +    return 0;
> +}
> +
> +static SaveVMHandlers savevm_colo_info_handlers = {
> +    .save_state = colo_info_save,
> +    .load_state = colo_info_load,
> +};
> +
> +void colo_info_mig_init(void)
> +{
> +    register_savevm_live(NULL, "colo", -1, 1,
> +                         &savevm_colo_info_handlers, NULL);
> +}
> diff --git a/trace-events b/trace-events
> index 52b7efa..3f63019 100644
> --- a/trace-events
> +++ b/trace-events
> @@ -1466,6 +1466,9 @@ rdma_start_incoming_migration_after_rdma_listen(void) ""
>  rdma_start_outgoing_migration_after_rdma_connect(void) ""
>  rdma_start_outgoing_migration_after_rdma_source_init(void) ""
>  
> +# migration/colo-comm.c
> +colo_info_load(const char *msg) "%s"
> +
>  # kvm-all.c
>  kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
>  kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
> diff --git a/vl.c b/vl.c
> index 2201e27..988567a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -90,6 +90,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"
> @@ -4261,7 +4262,9 @@ int main(int argc, char **argv, char **envp)
>  
>      blk_mig_init();
>      ram_mig_init();
> -
> +#ifdef CONFIG_COLO
> +    colo_info_mig_init();
> +#endif

Does't this still break migration compatibility?  I wouldn't
want to have to have two QEMU builds on a system, one built with COLO
and one built without COLO.   You need to arrange for the
section to only be sent if COLO is enabled (i.e. migrate_set_capability colo on).
One way to do that would be to use the new QEMU optional sections
that Juan added recently.

Dave

>      /* 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.7.12.4
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Zhanghailiang July 6, 2015, 7:26 a.m. UTC | #2
On 2015/7/4 2:03, 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 has been migrated from PVM.
>>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>   include/migration/migration-colo.h |  2 ++
>>   migration/Makefile.objs            |  1 +
>>   migration/colo-comm.c              | 47 ++++++++++++++++++++++++++++++++++++++
>>   trace-events                       |  3 +++
>>   vl.c                               |  5 +++-
>>   5 files changed, 57 insertions(+), 1 deletion(-)
>>   create mode 100644 migration/colo-comm.c
>>
>> diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h
>> index c6d0c51..e20a0c1 100644
>> --- a/include/migration/migration-colo.h
>> +++ b/include/migration/migration-colo.h
>> @@ -14,7 +14,9 @@
>>   #define QEMU_MIGRATION_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..0b76eb4
>> --- /dev/null
>> +++ b/migration/colo-comm.c
>> @@ -0,0 +1,47 @@
>> +/*
>> + * 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 <migration/migration-colo.h>
>> +#include "trace.h"
>> +
>> +static bool colo_requested;
>> +
>> +/* save */
>> +static void colo_info_save(QEMUFile *f, void *opaque)
>> +{
>> +    qemu_put_byte(f, migrate_enable_colo());
>> +}
>> +
>> +/* restore */
>> +static int colo_info_load(QEMUFile *f, void *opaque, int version_id)
>> +{
>> +    int value = qemu_get_byte(f);
>> +
>> +    if (value && !colo_requested) {
>> +        trace_colo_info_load("COLO request!");
>> +    }
>> +    colo_requested = value;
>> +
>> +    return 0;
>> +}
>> +
>> +static SaveVMHandlers savevm_colo_info_handlers = {
>> +    .save_state = colo_info_save,
>> +    .load_state = colo_info_load,
>> +};
>> +
>> +void colo_info_mig_init(void)
>> +{
>> +    register_savevm_live(NULL, "colo", -1, 1,
>> +                         &savevm_colo_info_handlers, NULL);
>> +}
>> diff --git a/trace-events b/trace-events
>> index 52b7efa..3f63019 100644
>> --- a/trace-events
>> +++ b/trace-events
>> @@ -1466,6 +1466,9 @@ rdma_start_incoming_migration_after_rdma_listen(void) ""
>>   rdma_start_outgoing_migration_after_rdma_connect(void) ""
>>   rdma_start_outgoing_migration_after_rdma_source_init(void) ""
>>
>> +# migration/colo-comm.c
>> +colo_info_load(const char *msg) "%s"
>> +
>>   # kvm-all.c
>>   kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
>>   kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
>> diff --git a/vl.c b/vl.c
>> index 2201e27..988567a 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -90,6 +90,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"
>> @@ -4261,7 +4262,9 @@ int main(int argc, char **argv, char **envp)
>>
>>       blk_mig_init();
>>       ram_mig_init();
>> -
>> +#ifdef CONFIG_COLO
>> +    colo_info_mig_init();
>> +#endif
>
> Does't this still break migration compatibility?  I wouldn't

Yes, it will break migration if the QEMU in destination and source not enable/disable (configure) this
feature together, also not compatible with old version on migration.

> want to have to have two QEMU builds on a system, one built with COLO
> and one built without COLO.   You need to arrange for the
> section to only be sent if COLO is enabled (i.e. migrate_set_capability colo on).
> One way to do that would be to use the new QEMU optional sections
> that Juan added recently.
>

Hmm, his method can address the above problems, (though, we will still fail when we configure
with --enable-colo in source side and --disable-colo in destination, but that is what
we want, we should not go into colo mode if secondary host is not enable this feature).
I will look into his patch, and fix that in next version, thanks,

zhanghailiang

> Dave
>
>>       /* 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.7.12.4
>>
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
> .
>
Dr. David Alan Gilbert July 6, 2015, 8:29 a.m. UTC | #3
* zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
> On 2015/7/4 2:03, 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 has been migrated from PVM.
> >>
> >>Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> >>Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> >>Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> >>Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> >>---
> >>  include/migration/migration-colo.h |  2 ++
> >>  migration/Makefile.objs            |  1 +
> >>  migration/colo-comm.c              | 47 ++++++++++++++++++++++++++++++++++++++
> >>  trace-events                       |  3 +++
> >>  vl.c                               |  5 +++-
> >>  5 files changed, 57 insertions(+), 1 deletion(-)
> >>  create mode 100644 migration/colo-comm.c
> >>
> >>diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h
> >>index c6d0c51..e20a0c1 100644
> >>--- a/include/migration/migration-colo.h
> >>+++ b/include/migration/migration-colo.h
> >>@@ -14,7 +14,9 @@
> >>  #define QEMU_MIGRATION_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..0b76eb4
> >>--- /dev/null
> >>+++ b/migration/colo-comm.c
> >>@@ -0,0 +1,47 @@
> >>+/*
> >>+ * 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 <migration/migration-colo.h>
> >>+#include "trace.h"
> >>+
> >>+static bool colo_requested;
> >>+
> >>+/* save */
> >>+static void colo_info_save(QEMUFile *f, void *opaque)
> >>+{
> >>+    qemu_put_byte(f, migrate_enable_colo());
> >>+}
> >>+
> >>+/* restore */
> >>+static int colo_info_load(QEMUFile *f, void *opaque, int version_id)
> >>+{
> >>+    int value = qemu_get_byte(f);
> >>+
> >>+    if (value && !colo_requested) {
> >>+        trace_colo_info_load("COLO request!");
> >>+    }
> >>+    colo_requested = value;
> >>+
> >>+    return 0;
> >>+}
> >>+
> >>+static SaveVMHandlers savevm_colo_info_handlers = {
> >>+    .save_state = colo_info_save,
> >>+    .load_state = colo_info_load,
> >>+};
> >>+
> >>+void colo_info_mig_init(void)
> >>+{
> >>+    register_savevm_live(NULL, "colo", -1, 1,
> >>+                         &savevm_colo_info_handlers, NULL);
> >>+}
> >>diff --git a/trace-events b/trace-events
> >>index 52b7efa..3f63019 100644
> >>--- a/trace-events
> >>+++ b/trace-events
> >>@@ -1466,6 +1466,9 @@ rdma_start_incoming_migration_after_rdma_listen(void) ""
> >>  rdma_start_outgoing_migration_after_rdma_connect(void) ""
> >>  rdma_start_outgoing_migration_after_rdma_source_init(void) ""
> >>
> >>+# migration/colo-comm.c
> >>+colo_info_load(const char *msg) "%s"
> >>+
> >>  # kvm-all.c
> >>  kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
> >>  kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
> >>diff --git a/vl.c b/vl.c
> >>index 2201e27..988567a 100644
> >>--- a/vl.c
> >>+++ b/vl.c
> >>@@ -90,6 +90,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"
> >>@@ -4261,7 +4262,9 @@ int main(int argc, char **argv, char **envp)
> >>
> >>      blk_mig_init();
> >>      ram_mig_init();
> >>-
> >>+#ifdef CONFIG_COLO
> >>+    colo_info_mig_init();
> >>+#endif
> >
> >Does't this still break migration compatibility?  I wouldn't
> 
> Yes, it will break migration if the QEMU in destination and source not enable/disable (configure) this
> feature together, also not compatible with old version on migration.
> 
> >want to have to have two QEMU builds on a system, one built with COLO
> >and one built without COLO.   You need to arrange for the
> >section to only be sent if COLO is enabled (i.e. migrate_set_capability colo on).
> >One way to do that would be to use the new QEMU optional sections
> >that Juan added recently.
> >
> 
> Hmm, his method can address the above problems, (though, we will still fail when we configure
> with --enable-colo in source side and --disable-colo in destination, but that is what
> we want, we should not go into colo mode if secondary host is not enable this feature).
> I will look into his patch, and fix that in next version, thanks,

It must not break compatibility with migration however the --enable-colo/disable-colo on the
source destination; it should only break if the migrate_set_capability colo on   is set on
one and not the other.
I think with Juan's conditional section then you should be able to do it.

Dave

> zhanghailiang
> 
> >Dave
> >
> >>      /* 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.7.12.4
> >>
> >>
> >--
> >Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> >
> >.
> >
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Zhanghailiang July 6, 2015, 8:54 a.m. UTC | #4
On 2015/7/6 16:29, Dr. David Alan Gilbert wrote:
> * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
>> On 2015/7/4 2:03, 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 has been migrated from PVM.
>>>>
>>>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>>>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
>>>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
>>>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>>>> ---
>>>>   include/migration/migration-colo.h |  2 ++
>>>>   migration/Makefile.objs            |  1 +
>>>>   migration/colo-comm.c              | 47 ++++++++++++++++++++++++++++++++++++++
>>>>   trace-events                       |  3 +++
>>>>   vl.c                               |  5 +++-
>>>>   5 files changed, 57 insertions(+), 1 deletion(-)
>>>>   create mode 100644 migration/colo-comm.c
>>>>
>>>> diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h
>>>> index c6d0c51..e20a0c1 100644
>>>> --- a/include/migration/migration-colo.h
>>>> +++ b/include/migration/migration-colo.h
>>>> @@ -14,7 +14,9 @@
>>>>   #define QEMU_MIGRATION_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..0b76eb4
>>>> --- /dev/null
>>>> +++ b/migration/colo-comm.c
>>>> @@ -0,0 +1,47 @@
>>>> +/*
>>>> + * 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 <migration/migration-colo.h>
>>>> +#include "trace.h"
>>>> +
>>>> +static bool colo_requested;
>>>> +
>>>> +/* save */
>>>> +static void colo_info_save(QEMUFile *f, void *opaque)
>>>> +{
>>>> +    qemu_put_byte(f, migrate_enable_colo());
>>>> +}
>>>> +
>>>> +/* restore */
>>>> +static int colo_info_load(QEMUFile *f, void *opaque, int version_id)
>>>> +{
>>>> +    int value = qemu_get_byte(f);
>>>> +
>>>> +    if (value && !colo_requested) {
>>>> +        trace_colo_info_load("COLO request!");
>>>> +    }
>>>> +    colo_requested = value;
>>>> +
>>>> +    return 0;
>>>> +}
>>>> +
>>>> +static SaveVMHandlers savevm_colo_info_handlers = {
>>>> +    .save_state = colo_info_save,
>>>> +    .load_state = colo_info_load,
>>>> +};
>>>> +
>>>> +void colo_info_mig_init(void)
>>>> +{
>>>> +    register_savevm_live(NULL, "colo", -1, 1,
>>>> +                         &savevm_colo_info_handlers, NULL);
>>>> +}
>>>> diff --git a/trace-events b/trace-events
>>>> index 52b7efa..3f63019 100644
>>>> --- a/trace-events
>>>> +++ b/trace-events
>>>> @@ -1466,6 +1466,9 @@ rdma_start_incoming_migration_after_rdma_listen(void) ""
>>>>   rdma_start_outgoing_migration_after_rdma_connect(void) ""
>>>>   rdma_start_outgoing_migration_after_rdma_source_init(void) ""
>>>>
>>>> +# migration/colo-comm.c
>>>> +colo_info_load(const char *msg) "%s"
>>>> +
>>>>   # kvm-all.c
>>>>   kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
>>>>   kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
>>>> diff --git a/vl.c b/vl.c
>>>> index 2201e27..988567a 100644
>>>> --- a/vl.c
>>>> +++ b/vl.c
>>>> @@ -90,6 +90,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"
>>>> @@ -4261,7 +4262,9 @@ int main(int argc, char **argv, char **envp)
>>>>
>>>>       blk_mig_init();
>>>>       ram_mig_init();
>>>> -
>>>> +#ifdef CONFIG_COLO
>>>> +    colo_info_mig_init();
>>>> +#endif
>>>
>>> Does't this still break migration compatibility?  I wouldn't
>>
>> Yes, it will break migration if the QEMU in destination and source not enable/disable (configure) this
>> feature together, also not compatible with old version on migration.
>>
>>> want to have to have two QEMU builds on a system, one built with COLO
>>> and one built without COLO.   You need to arrange for the
>>> section to only be sent if COLO is enabled (i.e. migrate_set_capability colo on).
>>> One way to do that would be to use the new QEMU optional sections
>>> that Juan added recently.
>>>
>>
>> Hmm, his method can address the above problems, (though, we will still fail when we configure
>> with --enable-colo in source side and --disable-colo in destination, but that is what
>> we want, we should not go into colo mode if secondary host is not enable this feature).
>> I will look into his patch, and fix that in next version, thanks,
>
> It must not break compatibility with migration however the --enable-colo/disable-colo on the
> source destination; it should only break if the migrate_set_capability colo on   is set on
> one and not the other.

Yes, i agree, my above description is not clear :) Thanks.

> I think with Juan's conditional section then you should be able to do it.
>
> Dave
>
>> zhanghailiang
>>
>>> Dave
>>>
>>>>       /* 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.7.12.4
>>>>
>>>>
>>> --
>>> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>>>
>>> .
>>>
>>
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
> .
>
diff mbox

Patch

diff --git a/include/migration/migration-colo.h b/include/migration/migration-colo.h
index c6d0c51..e20a0c1 100644
--- a/include/migration/migration-colo.h
+++ b/include/migration/migration-colo.h
@@ -14,7 +14,9 @@ 
 #define QEMU_MIGRATION_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..0b76eb4
--- /dev/null
+++ b/migration/colo-comm.c
@@ -0,0 +1,47 @@ 
+/*
+ * 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 <migration/migration-colo.h>
+#include "trace.h"
+
+static bool colo_requested;
+
+/* save */
+static void colo_info_save(QEMUFile *f, void *opaque)
+{
+    qemu_put_byte(f, migrate_enable_colo());
+}
+
+/* restore */
+static int colo_info_load(QEMUFile *f, void *opaque, int version_id)
+{
+    int value = qemu_get_byte(f);
+
+    if (value && !colo_requested) {
+        trace_colo_info_load("COLO request!");
+    }
+    colo_requested = value;
+
+    return 0;
+}
+
+static SaveVMHandlers savevm_colo_info_handlers = {
+    .save_state = colo_info_save,
+    .load_state = colo_info_load,
+};
+
+void colo_info_mig_init(void)
+{
+    register_savevm_live(NULL, "colo", -1, 1,
+                         &savevm_colo_info_handlers, NULL);
+}
diff --git a/trace-events b/trace-events
index 52b7efa..3f63019 100644
--- a/trace-events
+++ b/trace-events
@@ -1466,6 +1466,9 @@  rdma_start_incoming_migration_after_rdma_listen(void) ""
 rdma_start_outgoing_migration_after_rdma_connect(void) ""
 rdma_start_outgoing_migration_after_rdma_source_init(void) ""
 
+# migration/colo-comm.c
+colo_info_load(const char *msg) "%s"
+
 # kvm-all.c
 kvm_ioctl(int type, void *arg) "type 0x%x, arg %p"
 kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p"
diff --git a/vl.c b/vl.c
index 2201e27..988567a 100644
--- a/vl.c
+++ b/vl.c
@@ -90,6 +90,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"
@@ -4261,7 +4262,9 @@  int main(int argc, char **argv, char **envp)
 
     blk_mig_init();
     ram_mig_init();
-
+#ifdef CONFIG_COLO
+    colo_info_mig_init();
+#endif
     /* 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) {