qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] colo migration cleanups
@ 2023-06-22 12:14 Lukas Straub
  2023-06-22 12:15 ` [PATCH 1/8] colo: Only support the same qemu version on source and destination Lukas Straub
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 1140 bytes --]

Hello Everyone,
Here are some cleanups around the colo migration code. Notably, we only
support the same qemu version on both sides for now. Though in this
patchset I still try to be support migration to a newer qemu version.

Lukas Straub (8):
  colo: Only support the same qemu version on source and destination
  colo: Setup ram cache in normal migration path
  colo: Replace migration_incoming_colo_enabled() with migrate_colo()
  colo: Remove ENABLE_COLO loadvm command functions
  colo: Don't send ENABLE_COLO command
  colo: Reject colo with postcopy capability enabled
  colo: Reject colo with block migration capability enabled
  ram: Remove useless colo special-casing

 docs/COLO-FT.txt         |  2 ++
 include/migration/colo.h |  3 --
 migration/colo.c         |  2 +-
 migration/migration.c    | 63 ++++++++++------------------------------
 migration/options.c      | 14 +++++++++
 migration/ram.c          | 14 ++++-----
 migration/savevm.c       | 21 +-------------
 migration/savevm.h       |  1 -
 migration/trace-events   |  1 -
 9 files changed, 41 insertions(+), 80 deletions(-)

-- 
2.39.2

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] colo: Only support the same qemu version on source and destination
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
@ 2023-06-22 12:15 ` Lukas Straub
  2023-06-22 17:17   ` Dong, Eddie
  2023-06-22 12:15 ` [PATCH 2/8] colo: Setup ram cache in normal migration path Lukas Straub
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 docs/COLO-FT.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt
index 2e760a4aee..8e64480dbd 100644
--- a/docs/COLO-FT.txt
+++ b/docs/COLO-FT.txt
@@ -148,6 +148,8 @@ in test procedure.
 Note: Here we are running both instances on the same host for testing,
 change the IP Addresses if you want to run it on two hosts. Initially
 127.0.0.1 is the Primary Host and 127.0.0.2 is the Secondary Host.
+Note: COLO is a experimental feature, so currently is should only be used
+with the same qemu version on sourcee and target.
 
 == Startup qemu ==
 1. Primary:
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/8] colo: Setup ram cache in normal migration path
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
  2023-06-22 12:15 ` [PATCH 1/8] colo: Only support the same qemu version on source and destination Lukas Straub
@ 2023-06-22 12:15 ` Lukas Straub
  2023-06-28  9:30   ` Zhang, Chen
  2023-06-22 12:15 ` [PATCH 3/8] colo: Replace migration_incoming_colo_enabled() with migrate_colo() Lukas Straub
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 1995 bytes --]

Now that x-colo capability needs to be always enabled on the
incoming side we can use that to initialize the ram cache in
the normal migration path.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/migration.c | 16 ++++++++++++----
 migration/savevm.c    | 10 +---------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index dc05c6f6ea..050bd8ffc8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -404,10 +404,6 @@ int migration_incoming_enable_colo(void)
         return -EINVAL;
     }
 
-    if (ram_block_discard_disable(true)) {
-        error_report("COLO: cannot disable RAM discard");
-        return -EBUSY;
-    }
     migration_colo_enabled = true;
     return 0;
 }
@@ -519,6 +515,18 @@ process_incoming_migration_co(void *opaque)
         goto fail;
     }
 
+    if (migrate_colo()) {
+        if (ram_block_discard_disable(true)) {
+            error_report("COLO: cannot disable RAM discard");
+            goto fail;
+        }
+
+        if (colo_init_ram_cache() < 0) {
+            error_report("Init ram cache failed");
+            goto fail;
+        }
+    }
+
     mis->largest_page_size = qemu_ram_pagesize_largest();
     postcopy_state_set(POSTCOPY_INCOMING_NONE);
     migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
diff --git a/migration/savevm.c b/migration/savevm.c
index bc284087f9..155abb0fda 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2302,15 +2302,7 @@ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis,
 
 static int loadvm_process_enable_colo(MigrationIncomingState *mis)
 {
-    int ret = migration_incoming_enable_colo();
-
-    if (!ret) {
-        ret = colo_init_ram_cache();
-        if (ret) {
-            migration_incoming_disable_colo();
-        }
-    }
-    return ret;
+    return migration_incoming_enable_colo();
 }
 
 /*
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/8] colo: Replace migration_incoming_colo_enabled() with migrate_colo()
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
  2023-06-22 12:15 ` [PATCH 1/8] colo: Only support the same qemu version on source and destination Lukas Straub
  2023-06-22 12:15 ` [PATCH 2/8] colo: Setup ram cache in normal migration path Lukas Straub
@ 2023-06-22 12:15 ` Lukas Straub
  2023-06-22 12:15 ` [PATCH 4/8] colo: Remove ENABLE_COLO loadvm command functions Lukas Straub
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 2531 bytes --]

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 include/migration/colo.h | 1 -
 migration/colo.c         | 2 +-
 migration/migration.c    | 7 +------
 migration/ram.c          | 2 +-
 4 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/include/migration/colo.h b/include/migration/colo.h
index eaac07f26d..4a1955067b 100644
--- a/include/migration/colo.h
+++ b/include/migration/colo.h
@@ -27,7 +27,6 @@ bool migration_in_colo_state(void);
 /* loadvm */
 int migration_incoming_enable_colo(void);
 void migration_incoming_disable_colo(void);
-bool migration_incoming_colo_enabled(void);
 bool migration_incoming_in_colo_state(void);
 
 COLOMode get_colo_mode(void);
diff --git a/migration/colo.c b/migration/colo.c
index 72f4f7b37e..8b0e7c9af3 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -927,7 +927,7 @@ int coroutine_fn colo_incoming_co(void)
 
     assert(qemu_mutex_iothread_locked());
 
-    if (!migration_incoming_colo_enabled()) {
+    if (!migrate_colo()) {
         return 0;
     }
 
diff --git a/migration/migration.c b/migration/migration.c
index 050bd8ffc8..2506fd63f7 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -379,11 +379,6 @@ int migrate_send_rp_req_pages(MigrationIncomingState *mis,
 }
 
 static bool migration_colo_enabled;
-bool migration_incoming_colo_enabled(void)
-{
-    return migration_colo_enabled;
-}
-
 void migration_incoming_disable_colo(void)
 {
     ram_block_discard_disable(false);
@@ -484,7 +479,7 @@ static void process_incoming_migration_bh(void *opaque)
         } else {
             runstate_set(RUN_STATE_PAUSED);
         }
-    } else if (migration_incoming_colo_enabled()) {
+    } else if (migrate_colo()) {
         migration_incoming_disable_colo();
         vm_start();
     } else {
diff --git a/migration/ram.c b/migration/ram.c
index 5283a75f02..e3eadd08cd 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3892,7 +3892,7 @@ static int ram_load_precopy(QEMUFile *f)
              * speed of the migration, but it obviously reduce the downtime of
              * back-up all SVM'S memory in COLO preparing stage.
              */
-            if (migration_incoming_colo_enabled()) {
+            if (migrate_colo()) {
                 if (migration_incoming_in_colo_state()) {
                     /* In COLO stage, put all pages into cache temporarily */
                     host = colo_cache_from_block_offset(block, addr, true);
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/8] colo: Remove ENABLE_COLO loadvm command functions
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
                   ` (2 preceding siblings ...)
  2023-06-22 12:15 ` [PATCH 3/8] colo: Replace migration_incoming_colo_enabled() with migrate_colo() Lukas Straub
@ 2023-06-22 12:15 ` Lukas Straub
  2023-06-22 12:15 ` [PATCH 5/8] colo: Don't send ENABLE_COLO command Lukas Straub
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 3004 bytes --]

No need for it anymore now that x-colo capability is required
on incoming side. Still accept the command as noop, for
compatibility with older qemu.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 include/migration/colo.h |  2 --
 migration/migration.c    | 26 --------------------------
 migration/savevm.c       |  7 +------
 3 files changed, 1 insertion(+), 34 deletions(-)

diff --git a/include/migration/colo.h b/include/migration/colo.h
index 4a1955067b..addbc24fcf 100644
--- a/include/migration/colo.h
+++ b/include/migration/colo.h
@@ -25,8 +25,6 @@ void migrate_start_colo_process(MigrationState *s);
 bool migration_in_colo_state(void);
 
 /* loadvm */
-int migration_incoming_enable_colo(void);
-void migration_incoming_disable_colo(void);
 bool migration_incoming_in_colo_state(void);
 
 COLOMode get_colo_mode(void);
diff --git a/migration/migration.c b/migration/migration.c
index 2506fd63f7..1d347533f9 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -378,31 +378,6 @@ int migrate_send_rp_req_pages(MigrationIncomingState *mis,
     return migrate_send_rp_message_req_pages(mis, rb, start);
 }
 
-static bool migration_colo_enabled;
-void migration_incoming_disable_colo(void)
-{
-    ram_block_discard_disable(false);
-    migration_colo_enabled = false;
-}
-
-int migration_incoming_enable_colo(void)
-{
-#ifndef CONFIG_REPLICATION
-    error_report("ENABLE_COLO command come in migration stream, but COLO "
-                 "module is not built in");
-    return -ENOTSUP;
-#endif
-
-    if (!migrate_colo()) {
-        error_report("ENABLE_COLO command come in migration stream, but c-colo "
-                     "capability is not set");
-        return -EINVAL;
-    }
-
-    migration_colo_enabled = true;
-    return 0;
-}
-
 void migrate_add_address(SocketAddress *address)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
@@ -480,7 +455,6 @@ static void process_incoming_migration_bh(void *opaque)
             runstate_set(RUN_STATE_PAUSED);
         }
     } else if (migrate_colo()) {
-        migration_incoming_disable_colo();
         vm_start();
     } else {
         runstate_set(global_state_get_runstate());
diff --git a/migration/savevm.c b/migration/savevm.c
index 155abb0fda..3a1de15bd0 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2300,11 +2300,6 @@ static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis,
     return 0;
 }
 
-static int loadvm_process_enable_colo(MigrationIncomingState *mis)
-{
-    return migration_incoming_enable_colo();
-}
-
 /*
  * Process an incoming 'QEMU_VM_COMMAND'
  * 0           just a normal return
@@ -2387,7 +2382,7 @@ static int loadvm_process_command(QEMUFile *f)
         return loadvm_handle_recv_bitmap(mis, len);
 
     case MIG_CMD_ENABLE_COLO:
-        return loadvm_process_enable_colo(mis);
+        return 0;
     }
 
     return 0;
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/8] colo: Don't send ENABLE_COLO command
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
                   ` (3 preceding siblings ...)
  2023-06-22 12:15 ` [PATCH 4/8] colo: Remove ENABLE_COLO loadvm command functions Lukas Straub
@ 2023-06-22 12:15 ` Lukas Straub
  2023-06-22 12:16 ` [PATCH 6/8] colo: Reject colo with postcopy capability enabled Lukas Straub
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]

We should only migrate to qemu with newer version, and there it's
not needed anymore.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/migration.c  | 5 -----
 migration/savevm.c     | 6 ------
 migration/savevm.h     | 1 -
 migration/trace-events | 1 -
 4 files changed, 13 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 1d347533f9..a954ff4f7d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2929,11 +2929,6 @@ static void *migration_thread(void *opaque)
         qemu_savevm_send_postcopy_advise(s->to_dst_file);
     }
 
-    if (migrate_colo()) {
-        /* Notify migration destination that we enable COLO */
-        qemu_savevm_send_colo_enable(s->to_dst_file);
-    }
-
     qemu_savevm_state_setup(s->to_dst_file);
 
     qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
diff --git a/migration/savevm.c b/migration/savevm.c
index 3a1de15bd0..5986f852b2 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1035,12 +1035,6 @@ static void qemu_savevm_command_send(QEMUFile *f,
     qemu_fflush(f);
 }
 
-void qemu_savevm_send_colo_enable(QEMUFile *f)
-{
-    trace_savevm_send_colo_enable();
-    qemu_savevm_command_send(f, MIG_CMD_ENABLE_COLO, 0, NULL);
-}
-
 void qemu_savevm_send_ping(QEMUFile *f, uint32_t value)
 {
     uint32_t buf;
diff --git a/migration/savevm.h b/migration/savevm.h
index fb636735f0..cb3318e9e2 100644
--- a/migration/savevm.h
+++ b/migration/savevm.h
@@ -57,7 +57,6 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
                                            uint16_t len,
                                            uint64_t *start_list,
                                            uint64_t *length_list);
-void qemu_savevm_send_colo_enable(QEMUFile *f);
 void qemu_savevm_live_state(QEMUFile *f);
 int qemu_save_device_state(QEMUFile *f);
 
diff --git a/migration/trace-events b/migration/trace-events
index cdaef7a1ea..bd3ec40e31 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -36,7 +36,6 @@ savevm_send_ping(uint32_t val) "0x%x"
 savevm_send_postcopy_listen(void) ""
 savevm_send_postcopy_run(void) ""
 savevm_send_postcopy_resume(void) ""
-savevm_send_colo_enable(void) ""
 savevm_send_recv_bitmap(char *name) "%s"
 savevm_state_setup(void) ""
 savevm_state_resume_prepare(void) ""
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/8] colo: Reject colo with postcopy capability enabled
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
                   ` (4 preceding siblings ...)
  2023-06-22 12:15 ` [PATCH 5/8] colo: Don't send ENABLE_COLO command Lukas Straub
@ 2023-06-22 12:16 ` Lukas Straub
  2023-06-22 12:16 ` [PATCH 7/8] colo: Reject colo with block migration " Lukas Straub
  2023-06-22 12:16 ` [PATCH 8/8] ram: Remove useless colo special-casing Lukas Straub
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/migration.c | 5 +++--
 migration/options.c   | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index a954ff4f7d..9860f960f2 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2333,9 +2333,10 @@ static void migration_completion(MigrationState *s)
         goto fail;
     }
 
-    if (migrate_colo() && s->state == MIGRATION_STATUS_ACTIVE) {
+    if (migrate_colo()) {
         /* COLO does not support postcopy */
-        migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
+        assert(s->state != MIGRATION_STATUS_POSTCOPY_ACTIVE);
+        migrate_set_state(&s->state, current_active_state,
                           MIGRATION_STATUS_COLO);
     } else {
         migrate_set_state(&s->state, current_active_state,
diff --git a/migration/options.c b/migration/options.c
index b62ab30cd5..d3d4525d40 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -445,8 +445,17 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
         error_append_hint(errp, "Please enable replication before COLO.\n");
         return false;
     }
+#else
+    if (new_caps[MIGRATION_CAPABILITY_X_COLO]) {
+        if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
+            error_setg(errp, "COLO is not compatible with postcopy");
+            return false;
+        }
+    }
 #endif
 
+
+
     if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) {
         /* This check is reasonably expensive, so only when it's being
          * set the first time, also it's only the destination that needs
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/8] colo: Reject colo with block migration capability enabled
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
                   ` (5 preceding siblings ...)
  2023-06-22 12:16 ` [PATCH 6/8] colo: Reject colo with postcopy capability enabled Lukas Straub
@ 2023-06-22 12:16 ` Lukas Straub
  2023-06-22 12:16 ` [PATCH 8/8] ram: Remove useless colo special-casing Lukas Straub
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/migration.c | 4 ----
 migration/options.c   | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 9860f960f2..270130579f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1571,10 +1571,6 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc,
     }
 
     if (blk || blk_inc) {
-        if (migrate_colo()) {
-            error_setg(errp, "No disk migration is required in COLO mode");
-            return false;
-        }
         if (migrate_block() || migrate_block_incremental()) {
             error_setg(errp, "Command options are incompatible with "
                        "current migration capabilities");
diff --git a/migration/options.c b/migration/options.c
index d3d4525d40..1e9659fcb3 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -451,6 +451,11 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
             error_setg(errp, "COLO is not compatible with postcopy");
             return false;
         }
+
+        if (new_caps[MIGRATION_CAPABILITY_BLOCK]) {
+            error_setg(errp, "COLO is not compatible with block migration");
+            return false;
+        }
     }
 #endif
 
-- 
2.39.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/8] ram: Remove useless colo special-casing
  2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
                   ` (6 preceding siblings ...)
  2023-06-22 12:16 ` [PATCH 7/8] colo: Reject colo with block migration " Lukas Straub
@ 2023-06-22 12:16 ` Lukas Straub
  7 siblings, 0 replies; 12+ messages in thread
From: Lukas Straub @ 2023-06-22 12:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Hailiang Zhang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

This is not needed, as colo primary side everything is more or less
a new migration for every checkpoint.

Also, we only enter colo mode after the precopy migration is finished
so this if is always taken. Still add an assert just in case.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
 migration/ram.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index e3eadd08cd..e5c1146360 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2994,17 +2994,17 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
     RAMBlock *block;
     int ret;
 
+    assert(!migration_in_colo_state());
+
     if (compress_threads_save_setup()) {
         return -1;
     }
 
-    /* migration has already setup the bitmap, reuse it. */
-    if (!migration_in_colo_state()) {
-        if (ram_init_all(rsp) != 0) {
-            compress_threads_save_cleanup();
-            return -1;
-        }
+    if (ram_init_all(rsp) != 0) {
+        compress_threads_save_cleanup();
+        return -1;
     }
+
     (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel = f;
 
     WITH_RCU_READ_LOCK_GUARD() {
-- 
2.39.2

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/8] colo: Only support the same qemu version on source and destination
  2023-06-22 12:15 ` [PATCH 1/8] colo: Only support the same qemu version on source and destination Lukas Straub
@ 2023-06-22 17:17   ` Dong, Eddie
  2023-06-27  9:59     ` Zhang, Chen
  0 siblings, 1 reply; 12+ messages in thread
From: Dong, Eddie @ 2023-06-22 17:17 UTC (permalink / raw)
  To: Lukas Straub, qemu-devel
  Cc: Zhang, Hailiang, Juan Quintela, Peter Xu, Leonardo Bras,
	Zhang, Chen



> -----Original Message-----
> From: qemu-devel-bounces+eddie.dong=intel.com@nongnu.org <qemu-
> devel-bounces+eddie.dong=intel.com@nongnu.org> On Behalf Of Lukas
> Straub
> Sent: Thursday, June 22, 2023 5:15 AM
> To: qemu-devel <qemu-devel@nongnu.org>
> Cc: Zhang, Hailiang <zhanghailiang@xfusion.com>; Juan Quintela
> <quintela@redhat.com>; Peter Xu <peterx@redhat.com>; Leonardo Bras
> <leobras@redhat.com>; Zhang, Chen <chen.zhang@intel.com>
> Subject: [PATCH 1/8] colo: Only support the same qemu version on source
> and destination
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
> ---
>  docs/COLO-FT.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt index
> 2e760a4aee..8e64480dbd 100644
> --- a/docs/COLO-FT.txt
> +++ b/docs/COLO-FT.txt
> @@ -148,6 +148,8 @@ in test procedure.
>  Note: Here we are running both instances on the same host for testing,
> change the IP Addresses if you want to run it on two hosts. Initially
>  127.0.0.1 is the Primary Host and 127.0.0.2 is the Secondary Host.
> +Note: COLO is a experimental feature, 
an experimental feature

>so currently is should only be
it should ...

> +used with the same qemu version on sourcee and target.
> 
>  == Startup qemu ==
>  1. Primary:
> --
> 2.39.2



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/8] colo: Only support the same qemu version on source and destination
  2023-06-22 17:17   ` Dong, Eddie
@ 2023-06-27  9:59     ` Zhang, Chen
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Chen @ 2023-06-27  9:59 UTC (permalink / raw)
  To: Dong, Eddie, Lukas Straub, qemu-devel
  Cc: Zhang, Hailiang, Juan Quintela, Peter Xu, Leonardo Bras



> -----Original Message-----
> From: Dong, Eddie <eddie.dong@intel.com>
> Sent: Friday, June 23, 2023 1:17 AM
> To: Lukas Straub <lukasstraub2@web.de>; qemu-devel <qemu-
> devel@nongnu.org>
> Cc: Zhang, Hailiang <zhanghailiang@xfusion.com>; Juan Quintela
> <quintela@redhat.com>; Peter Xu <peterx@redhat.com>; Leonardo Bras
> <leobras@redhat.com>; Zhang, Chen <chen.zhang@intel.com>
> Subject: RE: [PATCH 1/8] colo: Only support the same qemu version on
> source and destination
> 
> 
> 
> > -----Original Message-----
> > From: qemu-devel-bounces+eddie.dong=intel.com@nongnu.org <qemu-
> > devel-bounces+eddie.dong=intel.com@nongnu.org> On Behalf Of Lukas
> > Straub
> > Sent: Thursday, June 22, 2023 5:15 AM
> > To: qemu-devel <qemu-devel@nongnu.org>
> > Cc: Zhang, Hailiang <zhanghailiang@xfusion.com>; Juan Quintela
> > <quintela@redhat.com>; Peter Xu <peterx@redhat.com>; Leonardo Bras
> > <leobras@redhat.com>; Zhang, Chen <chen.zhang@intel.com>
> > Subject: [PATCH 1/8] colo: Only support the same qemu version on
> > source and destination
> >
> > Signed-off-by: Lukas Straub <lukasstraub2@web.de>
> > ---
> >  docs/COLO-FT.txt | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt index
> > 2e760a4aee..8e64480dbd 100644
> > --- a/docs/COLO-FT.txt
> > +++ b/docs/COLO-FT.txt
> > @@ -148,6 +148,8 @@ in test procedure.
> >  Note: Here we are running both instances on the same host for
> > testing, change the IP Addresses if you want to run it on two hosts.
> > Initially
> >  127.0.0.1 is the Primary Host and 127.0.0.2 is the Secondary Host.
> > +Note: COLO is a experimental feature,
> an experimental feature
> 
> >so currently is should only be
> it should ...
> 
> > +used with the same qemu version on sourcee and target.

S/sourcee/source

Thanks
Chen

> >
> >  == Startup qemu ==
> >  1. Primary:
> > --
> > 2.39.2



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 2/8] colo: Setup ram cache in normal migration path
  2023-06-22 12:15 ` [PATCH 2/8] colo: Setup ram cache in normal migration path Lukas Straub
@ 2023-06-28  9:30   ` Zhang, Chen
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Chen @ 2023-06-28  9:30 UTC (permalink / raw)
  To: Lukas Straub, qemu-devel
  Cc: Zhang, Hailiang, Juan Quintela, Peter Xu, Leonardo Bras



> -----Original Message-----
> From: Lukas Straub <lukasstraub2@web.de>
> Sent: Thursday, June 22, 2023 8:15 PM
> To: qemu-devel <qemu-devel@nongnu.org>
> Cc: Zhang, Hailiang <zhanghailiang@xfusion.com>; Juan Quintela
> <quintela@redhat.com>; Peter Xu <peterx@redhat.com>; Leonardo Bras
> <leobras@redhat.com>; Zhang, Chen <chen.zhang@intel.com>
> Subject: [PATCH 2/8] colo: Setup ram cache in normal migration path
> 
> Now that x-colo capability needs to be always enabled on the incoming side
> we can use that to initialize the ram cache in the normal migration path.
> 
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
> ---
>  migration/migration.c | 16 ++++++++++++----
>  migration/savevm.c    | 10 +---------
>  2 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c index
> dc05c6f6ea..050bd8ffc8 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -404,10 +404,6 @@ int migration_incoming_enable_colo(void)
>          return -EINVAL;
>      }
> 
> -    if (ram_block_discard_disable(true)) {
> -        error_report("COLO: cannot disable RAM discard");
> -        return -EBUSY;
> -    }

COLO may call here when occur each checkpoint to pin the guest memory, in the Colo_incoming_process_checkpoint().
Is it still working after move to the "process_incoming_migration_co()" ?


>      migration_colo_enabled = true;
>      return 0;
>  }
> @@ -519,6 +515,18 @@ process_incoming_migration_co(void *opaque)
>          goto fail;
>      }
> 
> +    if (migrate_colo()) {
> +        if (ram_block_discard_disable(true)) {
> +            error_report("COLO: cannot disable RAM discard");
> +            goto fail;
> +        }
> +
> +        if (colo_init_ram_cache() < 0) {
> +            error_report("Init ram cache failed");

Change the code path to here need to add COLO tag to the error:
error_report("Init COLO ram cache failed");

It looks here removed the original  migration_incoming_disable_colo(),
But maybe it's OK for goto fail directly.

Thanks
Chen

> +            goto fail;
> +        }
> +    }
> +
>      mis->largest_page_size = qemu_ram_pagesize_largest();
>      postcopy_state_set(POSTCOPY_INCOMING_NONE);
>      migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, diff --git
> a/migration/savevm.c b/migration/savevm.c index bc284087f9..155abb0fda
> 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2302,15 +2302,7 @@ static int
> loadvm_handle_recv_bitmap(MigrationIncomingState *mis,
> 
>  static int loadvm_process_enable_colo(MigrationIncomingState *mis)  {
> -    int ret = migration_incoming_enable_colo();
> -
> -    if (!ret) {
> -        ret = colo_init_ram_cache();
> -        if (ret) {
> -            migration_incoming_disable_colo();
> -        }
> -    }
> -    return ret;
> +    return migration_incoming_enable_colo();
>  }
> 
>  /*
> --
> 2.39.2



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-28  9:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-22 12:14 [PATCH 0/8] colo migration cleanups Lukas Straub
2023-06-22 12:15 ` [PATCH 1/8] colo: Only support the same qemu version on source and destination Lukas Straub
2023-06-22 17:17   ` Dong, Eddie
2023-06-27  9:59     ` Zhang, Chen
2023-06-22 12:15 ` [PATCH 2/8] colo: Setup ram cache in normal migration path Lukas Straub
2023-06-28  9:30   ` Zhang, Chen
2023-06-22 12:15 ` [PATCH 3/8] colo: Replace migration_incoming_colo_enabled() with migrate_colo() Lukas Straub
2023-06-22 12:15 ` [PATCH 4/8] colo: Remove ENABLE_COLO loadvm command functions Lukas Straub
2023-06-22 12:15 ` [PATCH 5/8] colo: Don't send ENABLE_COLO command Lukas Straub
2023-06-22 12:16 ` [PATCH 6/8] colo: Reject colo with postcopy capability enabled Lukas Straub
2023-06-22 12:16 ` [PATCH 7/8] colo: Reject colo with block migration " Lukas Straub
2023-06-22 12:16 ` [PATCH 8/8] ram: Remove useless colo special-casing Lukas Straub

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).