qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC/COLO: 2/3] Parameterise min/max/relax time


From: Dr. David Alan Gilbert (git)
Subject: [Qemu-devel] [RFC/COLO: 2/3] Parameterise min/max/relax time
Date: Tue, 4 Aug 2015 20:26:26 +0100

From: "Dr. David Alan Gilbert" <address@hidden>

Signed-off-by: Dr. David Alan Gilbert <address@hidden>

---
 hmp-commands.hx        | 15 -------------
 hmp.c                  | 31 ++++++++++++++++++++------
 hmp.h                  |  1 -
 migration/colo.c       | 32 ++++++---------------------
 migration/migration.c  | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 qapi-schema.json       | 33 ++++++++++++++--------------
 qmp-commands.hx        | 22 -------------------
 stubs/migration-colo.c |  4 ----
 8 files changed, 105 insertions(+), 92 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 9164961..410637f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1049,21 +1049,6 @@ Tell COLO that heartbeat is lost, a failover or takeover 
is needed.
 ETEXI
 
     {
-        .name       = "colo_set_checkpoint_period",
-        .args_type  = "value:i",
-        .params     = "value",
-        .help       = "set checkpoint period (in ms) for colo. "
-        "Defaults to 100ms",
-        .mhandler.cmd = hmp_colo_set_checkpoint_period,
-    },
-
-STEXI
address@hidden migrate_set_checkpoint_period @var{value}
address@hidden migrate_set_checkpoint_period
-Set checkpoint period to @var{value} (in ms) for colo.
-ETEXI
-
-    {
         .name       = "client_migrate_info",
         .args_type  = 
"protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?",
         .params     = "protocol hostname port tls-port cert-subject",
diff --git a/hmp.c b/hmp.c
index 8828756..0e92d11 100644
--- a/hmp.c
+++ b/hmp.c
@@ -298,6 +298,15 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict 
*qdict)
         monitor_printf(mon, " %s: %" PRId64,
             MigrationParameter_lookup[MIGRATION_PARAMETER_COLO_PASSIVE_TIME],
             params->colo_passive_time);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_COLO_MIN_TIME],
+            params->colo_min_time);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_COLO_MAX_TIME],
+            params->colo_max_time);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_COLO_RELAX_TIME],
+            params->colo_relax_time);
 
         monitor_printf(mon, "\n");
     }
@@ -1251,6 +1260,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict)
     bool has_colo_passive_count = false;
     bool has_colo_passive_limit = false;
     bool has_colo_passive_time = false;
+    bool has_colo_min_time = false;
+    bool has_colo_max_time = false;
+    bool has_colo_relax_time = false;
 
     int i;
 
@@ -1275,6 +1287,15 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict)
             case MIGRATION_PARAMETER_COLO_PASSIVE_TIME:
                 has_colo_passive_time = true;
                 break;
+            case MIGRATION_PARAMETER_COLO_MIN_TIME:
+                has_colo_min_time = true;
+                break;
+            case MIGRATION_PARAMETER_COLO_MAX_TIME:
+                has_colo_max_time = true;
+                break;
+            case MIGRATION_PARAMETER_COLO_RELAX_TIME:
+                has_colo_relax_time = true;
+                break;
             }
             qmp_migrate_set_parameters(has_compress_level, value,
                                        has_compress_threads, value,
@@ -1282,6 +1303,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict)
                                        has_colo_passive_count, value,
                                        has_colo_passive_limit, value,
                                        has_colo_passive_time, value,
+                                       has_colo_min_time, value,
+                                       has_colo_max_time, value,
+                                       has_colo_relax_time, value,
                                        &err);
             break;
         }
@@ -1323,13 +1347,6 @@ void hmp_colo_lost_heartbeat(Monitor *mon, const QDict 
*qdict)
     hmp_handle_error(mon, &err);
 }
 
-void hmp_colo_set_checkpoint_period(Monitor *mon, const QDict *qdict)
-{
-    int64_t value = qdict_get_int(qdict, "value");
-
-    qmp_colo_set_checkpoint_period(value, NULL);
-}
-
 void hmp_set_password(Monitor *mon, const QDict *qdict)
 {
     const char *protocol  = qdict_get_str(qdict, "protocol");
diff --git a/hmp.h b/hmp.h
index d66dc76..c36c99c 100644
--- a/hmp.h
+++ b/hmp.h
@@ -69,7 +69,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict);
 void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict);
 void hmp_client_migrate_info(Monitor *mon, const QDict *qdict);
 void hmp_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
-void hmp_colo_set_checkpoint_period(Monitor *mon, const QDict *qdict);
 void hmp_set_password(Monitor *mon, const QDict *qdict);
 void hmp_expire_password(Monitor *mon, const QDict *qdict);
 void hmp_eject(Monitor *mon, const QDict *qdict);
diff --git a/migration/colo.c b/migration/colo.c
index 37f63f2..5c8096d 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -23,20 +23,6 @@
 #include "block/block_int.h"
 #include "trace.h"
 
-/*
-* We should not do checkpoint one after another without any time interval,
-* Because this will lead continuous 'stop' status for VM.
-* CHECKPOINT_MIN_PERIOD is the min time limit between two checkpoint action.
-*/
-#define CHECKPOINT_MIN_PERIOD 100  /* unit: ms */
-
-/*
- * force checkpoint timer: unit ms
- * this is large because COLO checkpoint will mostly depend on
- * COLO compare module.
- */
-#define CHECKPOINT_MAX_PEROID 10000
-
 /* Fix me: Convert to use QAPI */
 typedef enum COLOCommand {
     COLO_CHECPOINT_READY = 0x46,
@@ -93,8 +79,6 @@ const char * const COLOCommand_lookup[] = {
 static QEMUBH *colo_bh;
 static bool vmstate_loading;
 
-int64_t colo_checkpoint_period = CHECKPOINT_MAX_PEROID;
-
 /* colo buffer */
 #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024)
 
@@ -117,11 +101,6 @@ bool migration_incoming_in_colo_state(void)
     return (mis && (mis->state == MIGRATION_STATUS_COLO));
 }
 
-void qmp_colo_set_checkpoint_period(int64_t value, Error **errp)
-{
-    colo_checkpoint_period = value;
-}
-
 static bool colo_runstate_is_stopped(void)
 {
     return runstate_check(RUN_STATE_COLO) || !runstate_is_running();
@@ -611,9 +590,11 @@ static void *colo_thread(void *opaque)
 
             current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
             interval = current_time - checkpoint_time;
-            if (interval < CHECKPOINT_MIN_PERIOD) {
+            if (interval < s->parameters[MIGRATION_PARAMETER_COLO_MIN_TIME]) {
                 /* Limit the min time between two checkpoint */
-                g_usleep((1000*(CHECKPOINT_MIN_PERIOD - interval)));
+                g_usleep((1000 * 
+                         (s->parameters[MIGRATION_PARAMETER_COLO_MIN_TIME] -
+                          interval)));
             }
             s->checkpoint_state.proxy_discompare_count++;
             goto do_checkpoint;
@@ -621,7 +602,7 @@ static void *colo_thread(void *opaque)
 
         checkpoint_limit = passive_count ?
             s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_TIME] :
-            colo_checkpoint_period;
+            s->parameters[MIGRATION_PARAMETER_COLO_MAX_TIME];
 
         /*
          * No proxy checkpoint is request, wait for 100ms or
@@ -641,7 +622,8 @@ static void *colo_thread(void *opaque)
                 }
                 s->checkpoint_state.live_transfer_pages += ret;
             } else {
-                g_usleep(100000);
+                g_usleep(1000 *
+                         s->parameters[MIGRATION_PARAMETER_COLO_RELAX_TIME]);
             }
             continue;
         } else {
diff --git a/migration/migration.c b/migration/migration.c
index f84c676..d41914c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -56,6 +56,11 @@
 #define DEFAULT_MIGRATE_COLO_PASSIVE_LIMIT 400
 /* COLO passive mode checkpoint time (ms) */
 #define DEFAULT_MIGRATE_COLO_PASSIVE_TIME 250
+/* COLO minimum/maximum times for normal comparitive checkpoint (ms) */
+#define DEFAULT_MIGRATE_COLO_MIN_TIME 100
+#define DEFAULT_MIGRATE_COLO_MAX_TIME 10000
+/* Time after a miscompare before resuming comparison (ms) */
+#define DEFAULT_MIGRATE_COLO_RELAX_TIME 100
 
 static NotifierList migration_state_notifiers =
     NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
@@ -85,7 +90,13 @@ MigrationState *migrate_get_current(void)
         .parameters[MIGRATION_PARAMETER_COLO_PASSIVE_LIMIT] =
                 DEFAULT_MIGRATE_COLO_PASSIVE_LIMIT,
         .parameters[MIGRATION_PARAMETER_COLO_PASSIVE_TIME] =
-                DEFAULT_MIGRATE_COLO_PASSIVE_TIME
+                DEFAULT_MIGRATE_COLO_PASSIVE_TIME,
+        .parameters[MIGRATION_PARAMETER_COLO_MIN_TIME] =
+                DEFAULT_MIGRATE_COLO_MIN_TIME,
+        .parameters[MIGRATION_PARAMETER_COLO_MAX_TIME] =
+                DEFAULT_MIGRATE_COLO_MAX_TIME,
+        .parameters[MIGRATION_PARAMETER_COLO_RELAX_TIME] =
+                DEFAULT_MIGRATE_COLO_RELAX_TIME,
         .checkpoint_state.max_downtime = 0,
         .checkpoint_state.min_downtime = INT64_MAX
     };
@@ -406,6 +417,9 @@ MigrationParameters *qmp_query_migrate_parameters(Error 
**errp)
     params->colo_passive_count = 
s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_COUNT];
     params->colo_passive_limit = 
s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_LIMIT];
     params->colo_passive_time = 
s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_TIME];
+    params->colo_min_time = s->parameters[MIGRATION_PARAMETER_COLO_MIN_TIME];
+    params->colo_max_time = s->parameters[MIGRATION_PARAMETER_COLO_MAX_TIME];
+    params->colo_relax_time = 
s->parameters[MIGRATION_PARAMETER_COLO_RELAX_TIME];
 
     return params;
 }
@@ -563,6 +577,12 @@ void qmp_migrate_set_parameters(bool has_compress_level,
                                 int64_t colo_passive_limit,
                                 bool has_colo_passive_time,
                                 int64_t colo_passive_time,
+                                bool has_colo_min_time,
+                                int64_t colo_min_time,
+                                bool has_colo_max_time,
+                                int64_t colo_max_time,
+                                bool has_colo_relax_time,
+                                int64_t colo_relax_time,
                                 Error **errp)
 {
     MigrationState *s = migrate_get_current();
@@ -601,6 +621,21 @@ void qmp_migrate_set_parameters(bool has_compress_level,
                   "colo_passive_time",
                   "is invalid, it must be positive");
     }
+    if (has_colo_min_time && (colo_min_time < 0)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                  "colo_min_time",
+                  "is invalid, it must be positive");
+    }
+    if (has_colo_max_time && (colo_max_time < 0)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                  "colo_max_time",
+                  "is invalid, it must be positive");
+    }
+    if (has_colo_relax_time && (colo_relax_time < 0)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                  "colo_relax_time",
+                  "is invalid, it must be positive");
+    }
 
     if (has_compress_level) {
         s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level;
@@ -624,6 +659,18 @@ void qmp_migrate_set_parameters(bool has_compress_level,
         s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_TIME] =
                                                     colo_passive_time;
     }
+    if (has_colo_min_time) {
+        s->parameters[MIGRATION_PARAMETER_COLO_MIN_TIME] =
+                                                    colo_min_time;
+    }
+    if (has_colo_max_time) {
+        s->parameters[MIGRATION_PARAMETER_COLO_MAX_TIME] =
+                                                    colo_max_time;
+    }
+    if (has_colo_relax_time) {
+        s->parameters[MIGRATION_PARAMETER_COLO_RELAX_TIME] =
+                                                    colo_relax_time;
+    }
 }
 
 /* shared migration helpers */
@@ -746,7 +793,12 @@ static MigrationState *migrate_init(const MigrationParams 
*params)
                             MIGRATION_PARAMETER_COLO_PASSIVE_LIMIT];
     int colo_passive_time = s->parameters[
                             MIGRATION_PARAMETER_COLO_PASSIVE_TIME];
-
+    int64_t colo_min_time = s->parameters[
+                            MIGRATION_PARAMETER_COLO_MIN_TIME];
+    int64_t colo_max_time = s->parameters[
+                            MIGRATION_PARAMETER_COLO_MAX_TIME];
+    int64_t colo_relax_time = s->parameters[
+                            MIGRATION_PARAMETER_COLO_RELAX_TIME];
 
     memcpy(enabled_capabilities, s->enabled_capabilities,
            sizeof(enabled_capabilities));
@@ -766,6 +818,9 @@ static MigrationState *migrate_init(const MigrationParams 
*params)
     s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_LIMIT] =
                   colo_passive_limit;
     s->parameters[MIGRATION_PARAMETER_COLO_PASSIVE_TIME] = colo_passive_time;
+    s->parameters[MIGRATION_PARAMETER_COLO_MIN_TIME] = colo_min_time;
+    s->parameters[MIGRATION_PARAMETER_COLO_MAX_TIME] = colo_max_time;
+    s->parameters[MIGRATION_PARAMETER_COLO_RELAX_TIME] = colo_relax_time;
 
     s->bandwidth_limit = bandwidth_limit;
     migrate_set_state(&s->state, MIGRATION_STATUS_NONE, 
MIGRATION_STATUS_SETUP);
diff --git a/qapi-schema.json b/qapi-schema.json
index 9d2b6d4..30113fc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -633,12 +633,16 @@
 # @colo-passive-count: Time (in ms) for a COLO passive mode checkpoint
 # @colo-passive-limit: Time (in ms) below which we switch into passive mode
 # @colo-passive-time: Time (in ms) for a COLO passive mode checkpoint
+# @colo-min-time: Minimum Time (in ms) for a COLO comparative checkpoint
+# @colo-max-time: Maximum Time (in ms) for a COLO comparative checkpoint
+# @colo-relax-time: Time (in ms) after a miscompare before starting a new COLO 
checkpoint
 #
 # Since: 2.4
 ##
 { 'enum': 'MigrationParameter',
   'data': ['compress-level', 'compress-threads', 'decompress-threads',
-           'colo-passive-count', 'colo-passive-limit', 'colo-passive-time'] }
+           'colo-passive-count', 'colo-passive-limit', 'colo-passive-time',
+           'colo-min-time', 'colo-max-time', 'colo-relax-time' ] }
 
 #
 # @migrate-set-parameters
@@ -654,6 +658,9 @@
 # @colo-passive-count: Time (in ms) for a COLO passive mode checkpoint
 # @colo-passive-limit: Time (in ms) below which we switch into passive mode
 # @colo-passive-time: Time (in ms) for a COLO passive mode checkpoint
+# @colo-min-time: Minimum Time (in ms) for a COLO comparative checkpoint
+# @colo-max-time: Maximum Time (in ms) for a COLO comparative checkpoint
+# @colo-relax-time: Time (in ms) after a miscompare before starting a new COLO 
checkpoint
 #
 # Since: 2.4
 ##
@@ -663,7 +670,11 @@
             '*decompress-threads': 'int',
             '*colo-passive-count': 'int',
             '*colo-passive-limit': 'int',
-            '*colo-passive-time': 'int' } }
+            '*colo-passive-time': 'int',
+            '*colo-min-time': 'int',
+            '*colo-max-time': 'int',
+            '*colo-relax-time': 'int'
+          } }
 
 #
 # @MigrationParameters
@@ -682,7 +693,10 @@
             'decompress-threads': 'int',
             'colo-passive-count': 'int',
             'colo-passive-limit': 'int',
-            'colo-passive-time': 'int' } }
+            'colo-passive-time': 'int',
+            'colo-min-time': 'int',
+            'colo-max-time': 'int',
+            'colo-relax-time': 'int' } }
 
 ##
 # @query-migrate-parameters
@@ -741,19 +755,6 @@
 { 'command': 'colo-lost-heartbeat' }
 
 ##
-# @colo-set-checkpoint-period
-#
-# Set colo checkpoint period
-#
-# @value: period of colo checkpoint in ms
-#
-# Returns: nothing on success
-#
-# Since: 2.4
-##
-{ 'command': 'colo-set-checkpoint-period', 'data': {'value': 'int'} }
-
-##
 # @MouseInfo:
 #
 # Information about a mouse device.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index a809710..7dd67cf 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -800,28 +800,6 @@ Example:
 EQMP
 
     {
-         .name       = "colo-set-checkpoint-period",
-         .args_type  = "value:i",
-         .mhandler.cmd_new = qmp_marshal_input_colo_set_checkpoint_period,
-    },
-
-SQMP
-colo-set-checkpoint-period
---------------------------
-
-set checkpoint period
-
-Arguments:
-- "value": checkpoint period
-
-Example:
-
--> { "execute": "colo-set-checkpoint-period", "arguments": { "value": "1000" } 
}
-<- { "return": {} }
-
-EQMP
-
-    {
         .name       = "client_migrate_info",
         .args_type  = 
"protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?",
         .params     = "protocol hostname port tls-port cert-subject",
diff --git a/stubs/migration-colo.c b/stubs/migration-colo.c
index 9d3b9e7..0edc59c 100644
--- a/stubs/migration-colo.c
+++ b/stubs/migration-colo.c
@@ -52,7 +52,3 @@ void qmp_colo_lost_heartbeat(Error **errp)
                      " with --enable-colo option in order to support"
                      " COLO feature");
 }
-
-void qmp_colo_set_checkpoint_period(int64_t value, Error **errp)
-{
-}
-- 
2.4.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]