aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--migration/savevm.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/migration/savevm.c b/migration/savevm.c
index b024ee3b22..f202c3de3a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1376,7 +1376,8 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis);
* *might* happen - it might be skipped if precopy transferred everything
* quickly.
*/
-static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis)
+static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis,
+ uint16_t len)
{
PostcopyState ps = postcopy_state_set(POSTCOPY_INCOMING_ADVISE);
uint64_t remote_pagesize_summary, local_pagesize_summary, remote_tps;
@@ -1387,8 +1388,22 @@ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis)
return -1;
}
- if (!migrate_postcopy_ram()) {
+ switch (len) {
+ case 0:
+ if (migrate_postcopy_ram()) {
+ error_report("RAM postcopy is enabled but have 0 byte advise");
+ return -EINVAL;
+ }
return 0;
+ case 8 + 8:
+ if (!migrate_postcopy_ram()) {
+ error_report("RAM postcopy is disabled but have 16 byte advise");
+ return -EINVAL;
+ }
+ break;
+ default:
+ error_report("CMD_POSTCOPY_ADVISE invalid length (%d)", len);
+ return -EINVAL;
}
if (!postcopy_ram_supported_by_host(mis)) {
@@ -1807,7 +1822,7 @@ static int loadvm_process_command(QEMUFile *f)
return loadvm_handle_cmd_packaged(mis);
case MIG_CMD_POSTCOPY_ADVISE:
- return loadvm_postcopy_handle_advise(mis);
+ return loadvm_postcopy_handle_advise(mis, len);
case MIG_CMD_POSTCOPY_LISTEN:
return loadvm_postcopy_handle_listen(mis);