diff mbox

[v3,34/35] postcopy/outgoing: introduce precopy_count parameter

Message ID ba6c9780174b296a364697a6612a9b14196e8871.1351582535.git.yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata Oct. 30, 2012, 8:33 a.m. UTC
Precopy with this loop number before postcopy mode.
This will be implemented by the next patch.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hmp-commands.hx      |   10 ++++++----
 hmp.c                |    2 ++
 migration-postcopy.c |    2 +-
 migration.c          |    2 ++
 migration.h          |    3 ++-
 qapi-schema.json     |    4 +++-
 qmp-commands.hx      |    2 +-
 savevm.c             |    3 ++-
 8 files changed, 19 insertions(+), 9 deletions(-)

Comments

Eric Blake Nov. 1, 2012, 9:20 p.m. UTC | #1
On 10/30/2012 02:33 AM, Isaku Yamahata wrote:
> Precopy with this loop number before postcopy mode.
> This will be implemented by the next patch.
> 
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> +++ b/qapi-schema.json
> @@ -2089,6 +2089,8 @@
>  # @detach: this argument exists only for compatibility reasons and
>  #          is ignored by QEMU
>  #
> +# @precopy_count: #optional the number of loops of precopy when postcopy
> +#

Finally, a documented addition; but still lacking (since 1.3)
designation.  Also, QMP prefers '-' over '_', so I would name it
precopy-count, if we even decide to attach it to 'migrate' instead of a
new command or enhancement to 'migrate-set-capabilities'.
diff mbox

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 942f620..957bf76 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -826,9 +826,10 @@  ETEXI
 
     {
         .name       = "migrate",
-        .args_type  = "detach:-d,blk:-b,inc:-i,postcopy:-p,movebg:-m,nobg:-n,uri:s,"
-	              "forward:i?,backward:i?",
-        .params     = "[-d] [-b] [-i] [-p [-n] [-m]] uri [forward] [backword]",
+        .args_type  = "detach:-d,blk:-b,inc:-i,postcopy:-p,movebg:-m,nobg:-n,"
+	              "uri:s,precopy_count:i?,forward:i?,backward:i?",
+        .params     = "[-d] [-b] [-i] [-p [-n] [-m]] uri "
+	              "[precopy_count] [forward] [backword]",
         .help       = "migrate to URI (using -d to not wait for completion)"
 		      "\n\t\t\t -b for migration without shared storage with"
 		      " full copy of disk\n\t\t\t -i for migration without "
@@ -837,6 +838,7 @@  ETEXI
 		      "\n\t\t\t-p for migration with postcopy mode enabled"
 		      "\n\t\t\t-m for move background transfer of postcopy mode"
 		      "\n\t\t\t-n for no background transfer of postcopy mode"
+		      "\n\t\t\tprecopy_count: loop of precopy when postcopy"
 		      "\n\t\t\tforward: the number of pages to "
 		      "forward-prefault when postcopy (default 0)"
 		      "\n\t\t\tbackward: the number of pages to "
@@ -846,7 +848,7 @@  ETEXI
 
 
 STEXI
-@item migrate [-d] [-b] [-i] [-p [-n] [-m]] @var{uri} @var{forward} @var{backward}
+@item migrate [-d] [-b] [-i] [-p [-n] [-m]] @var{uri} @var{precopy_count} @var{forward} @var{backward}
 @findex migrate
 Migrate to @var{uri} (using -d to not wait for completion).
 	-b for migration with full copy of disk
diff --git a/hmp.c b/hmp.c
index a0bd869..be88db9 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1038,6 +1038,7 @@  void hmp_migrate(Monitor *mon, const QDict *qdict)
     int postcopy = qdict_get_try_bool(qdict, "postcopy", 0);
     int movebg = qdict_get_try_bool(qdict, "movebg", 0);
     int nobg = qdict_get_try_bool(qdict, "nobg", 0);
+    int precopy_count = qdict_get_try_int(qdict, "precopy_count", 0);
     int forward = qdict_get_try_int(qdict, "forward", 0);
     int backward = qdict_get_try_int(qdict, "backward", 0);
     const char *uri = qdict_get_str(qdict, "uri");
@@ -1045,6 +1046,7 @@  void hmp_migrate(Monitor *mon, const QDict *qdict)
 
     qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false,
                 !!postcopy, postcopy, !!movebg, movebg, !!nobg, nobg,
+                !!precopy_count, precopy_count,
                 !!forward, forward, !!backward, backward,
                 &err);
     if (err) {
diff --git a/migration-postcopy.c b/migration-postcopy.c
index 9298cd4..8a43c42 100644
--- a/migration-postcopy.c
+++ b/migration-postcopy.c
@@ -319,7 +319,7 @@  int postcopy_outgoing_create_read_socket(MigrationState *s)
     return 0;
 }
 
-void postcopy_outgoing_state_begin(QEMUFile *f)
+void postcopy_outgoing_state_begin(QEMUFile *f, const MigrationParams *params)
 {
     uint64_t options = 0;
     qemu_put_ubyte(f, QEMU_VM_POSTCOPY_INIT);
diff --git a/migration.c b/migration.c
index 057ea31..84ca4b3 100644
--- a/migration.c
+++ b/migration.c
@@ -513,6 +513,7 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
                  bool has_postcopy, bool postcopy,
                  bool has_movebg, bool movebg,
                  bool has_nobg, bool nobg,
+                 bool has_precopy_count, int64_t precopy_count,
                  bool has_forward, int64_t forward,
                  bool has_backward, int64_t backward,
                  Error **errp)
@@ -527,6 +528,7 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
     params.postcopy = postcopy;
     params.nobg = nobg;
     params.movebg = movebg;
+    params.precopy_count = precopy_count,
     params.prefault_forward = 0;
     if (has_forward) {
         if (forward < 0) {
diff --git a/migration.h b/migration.h
index 2801e7e..c4d7b0a 100644
--- a/migration.h
+++ b/migration.h
@@ -27,6 +27,7 @@  struct MigrationParams {
     bool postcopy;
     bool nobg;
     bool movebg;
+    int precopy_count;
     int64_t prefault_forward;
     int64_t prefault_backward;
 };
@@ -150,7 +151,7 @@  int64_t xbzrle_cache_resize(int64_t new_size);
 
 /* For outgoing postcopy */
 int postcopy_outgoing_create_read_socket(MigrationState *s);
-void postcopy_outgoing_state_begin(QEMUFile *f);
+void postcopy_outgoing_state_begin(QEMUFile *f, const MigrationParams *params);
 void postcopy_outgoing_state_complete(
     QEMUFile *f, const uint8_t *buffer, size_t buffer_size);
 int postcopy_outgoing_ram_save_iterate(QEMUFile *f, void *opaque);
diff --git a/qapi-schema.json b/qapi-schema.json
index cf5d988..5c4d2f2 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2089,6 +2089,8 @@ 
 # @detach: this argument exists only for compatibility reasons and
 #          is ignored by QEMU
 #
+# @precopy_count: #optional the number of loops of precopy when postcopy
+#
 # Returns: nothing on success
 #
 # Since: 0.14.0
@@ -2096,7 +2098,7 @@ 
 { 'command': 'migrate',
   'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' ,
            '*postcopy': 'bool', '*movebg': 'bool', '*nobg': 'bool',
-           '*forward': 'int', '*backward': 'int'} }
+           '*precopy_count': 'int', '*forward': 'int', '*backward': 'int'} }
 
 # @xen-save-devices-state:
 #
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 7028ece..b8cf174 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -518,7 +518,7 @@  EQMP
 
     {
         .name       = "migrate",
-        .args_type  = "detach:-d,blk:-b,inc:-i,postcopy:-p,movebg:-m,nobg:-n,uri:s",
+        .args_type  = "detach:-d,blk:-b,inc:-i,postcopy:-p,movebg:-m,nobg:-n,uri:s,precopy_cout:i?",
         .mhandler.cmd_new = qmp_marshal_input_migrate,
     },
 
diff --git a/savevm.c b/savevm.c
index 8d26354..32781e1 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1650,7 +1650,7 @@  int qemu_savevm_state_begin(QEMUFile *f,
     if (params->postcopy) {
         /* tell this is postcopy */
         qemu_put_byte(f, QEMU_VM_POSTCOPY);
-        postcopy_outgoing_state_begin(f);
+        postcopy_outgoing_state_begin(f, params);
     }
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
@@ -1839,6 +1839,7 @@  static int qemu_savevm_state(QEMUFile *f)
         .blk = 0,
         .shared = 0,
         .postcopy = 0,
+        .precopy_count = 0,
         .movebg = 0,
         .nobg = 0,
     };