diff mbox series

[2/8] colo: Setup ram cache in normal migration path

Message ID dcc6c36a6225cb883c9d58697351a316b8b285e3.1687429356.git.lukasstraub2@web.de (mailing list archive)
State New, archived
Headers show
Series colo migration cleanups | expand

Commit Message

Lukas Straub June 22, 2023, 12:15 p.m. UTC
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(-)

Comments

Zhang, Chen June 28, 2023, 9:30 a.m. UTC | #1
> -----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
diff mbox series

Patch

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();
 }
 
 /*