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

2023-06-28 Thread Zhang, Chen



> -Original Message-
> From: Lukas Straub 
> Sent: Thursday, June 22, 2023 8:15 PM
> To: qemu-devel 
> Cc: Zhang, Hailiang ; Juan Quintela
> ; Peter Xu ; Leonardo Bras
> ; Zhang, Chen 
> 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 
> ---
>  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(>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




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

2023-06-22 Thread Lukas Straub
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 
---
 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(>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



pgpdfT0wpZtDw.pgp
Description: OpenPGP digital signature