diff mbox

[COLO-Frame,v16,16/35] COLO: synchronize PVM's state to SVM periodically

Message ID 1460096797-14916-17-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang April 8, 2016, 6:26 a.m. UTC
Do checkpoint periodically, the default interval is 200ms.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
v12:
- Add Reviewed-by tag
v11:
- Fix wrong sleep time for checkpoint period. (Dave's comment)
---
 migration/colo.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Li Zhijian April 12, 2016, 3:02 a.m. UTC | #1
On 04/08/2016 02:26 PM, zhanghailiang wrote:
> Do checkpoint periodically, the default interval is 200ms.
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> v12:
> - Add Reviewed-by tag
> v11:
> - Fix wrong sleep time for checkpoint period. (Dave's comment)
> ---
>   migration/colo.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/migration/colo.c b/migration/colo.c
> index 4dae069..4e3b39f 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -11,6 +11,7 @@
>    */
>
>   #include "qemu/osdep.h"
> +#include "qemu/timer.h"
>   #include "sysemu/sysemu.h"
>   #include "migration/colo.h"
>   #include "trace.h"
> @@ -231,6 +232,7 @@ out:
>   static void colo_process_checkpoint(MigrationState *s)
>   {
>       QEMUSizedBuffer *buffer = NULL;
> +    int64_t current_time, checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
>       Error *local_err = NULL;
>       int ret;
>
> @@ -262,11 +264,21 @@ static void colo_process_checkpoint(MigrationState *s)
>       trace_colo_vm_state_change("stop", "run");
>
>       while (s->state == MIGRATION_STATUS_COLO) {
> +        current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
> +        if (current_time - checkpoint_time <
> +            s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY]) {
> +            int64_t delay_ms;
> +
> +            delay_ms = s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY] -
> +                       (current_time - checkpoint_time);
> +            g_usleep(delay_ms * 1000);

Once a large value(e.g. 1000000) is set to s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY],
that means here will sleep 1000 seconds and people can't revert this operation.
Can we let this sleep operation more flexible ?

Thanks
Li Zhijian

> +        }
>           /* start a colo checkpoint */
>           ret = colo_do_checkpoint_transaction(s, buffer);
>           if (ret < 0) {
>               goto out;
>           }
> +        checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
>       }
>
>   out:
>
diff mbox

Patch

diff --git a/migration/colo.c b/migration/colo.c
index 4dae069..4e3b39f 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -11,6 +11,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "migration/colo.h"
 #include "trace.h"
@@ -231,6 +232,7 @@  out:
 static void colo_process_checkpoint(MigrationState *s)
 {
     QEMUSizedBuffer *buffer = NULL;
+    int64_t current_time, checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
     Error *local_err = NULL;
     int ret;
 
@@ -262,11 +264,21 @@  static void colo_process_checkpoint(MigrationState *s)
     trace_colo_vm_state_change("stop", "run");
 
     while (s->state == MIGRATION_STATUS_COLO) {
+        current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
+        if (current_time - checkpoint_time <
+            s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY]) {
+            int64_t delay_ms;
+
+            delay_ms = s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY] -
+                       (current_time - checkpoint_time);
+            g_usleep(delay_ms * 1000);
+        }
         /* start a colo checkpoint */
         ret = colo_do_checkpoint_transaction(s, buffer);
         if (ret < 0) {
             goto out;
         }
+        checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
     }
 
 out: