Re: [PATCH v5 5/5] tests/qtest/migration: consolidate set capabilities

2025-02-07 Thread Fabiano Rosas
Prasad Pandit  writes:

> From: Prasad Pandit 
>
> Migration capabilities are set in multiple '.start_hook'
> functions for various tests. Instead, consolidate setting
> capabilities in 'set_migration_capabilities()' function
> which is called from various 'test_*_common()' functions.
> While simplifying the capabilities setting, it helps
> to declutter the test sources.
>
> Suggested-by: Fabiano Rosas 
> Signed-off-by: Prasad Pandit 
> ---
>  tests/qtest/migration/compression-tests.c |  7 +--
>  tests/qtest/migration/cpr-tests.c |  4 +-
>  tests/qtest/migration/file-tests.c| 44 +---
>  tests/qtest/migration/framework.c | 63 ---
>  tests/qtest/migration/framework.h |  8 ++-
>  tests/qtest/migration/postcopy-tests.c| 10 ++--
>  tests/qtest/migration/precopy-tests.c | 19 +++

Isn't there a 16 channel multifd setup in this file? I don't see it in
this patch.

>  tests/qtest/migration/tls-tests.c | 11 ++--
>  8 files changed, 79 insertions(+), 87 deletions(-)
>
> diff --git a/tests/qtest/migration/compression-tests.c 
> b/tests/qtest/migration/compression-tests.c
> index 3252ba2f73..13a2b2d74f 100644
> --- a/tests/qtest/migration/compression-tests.c
> +++ b/tests/qtest/migration/compression-tests.c
> @@ -43,7 +43,7 @@ static void test_multifd_tcp_zstd(void)
>  static void test_multifd_postcopy_tcp_zstd(void)
>  {
>  MigrateCommon args = {
> -.postcopy_ram = true,
> +.caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] = true,
>  .listen_uri = "defer",
>  .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd,
>  };
> @@ -114,10 +114,6 @@ migrate_hook_start_xbzrle(QTestState *from,
>QTestState *to)
>  {
>  migrate_set_parameter_int(from, "xbzrle-cache-size", 33554432);
> -
> -migrate_set_capability(from, "xbzrle", true);
> -migrate_set_capability(to, "xbzrle", true);
> -
>  return NULL;
>  }
>  
> @@ -129,6 +125,7 @@ static void test_precopy_unix_xbzrle(void)
>  .listen_uri = uri,
>  .start_hook = migrate_hook_start_xbzrle,
>  .iterations = 2,
> +.caps[MIGRATION_CAPABILITY_XBZRLE] = true,
>  /*
>   * XBZRLE needs pages to be modified when doing the 2nd+ round
>   * iteration to have real data pushed to the stream.
> diff --git a/tests/qtest/migration/cpr-tests.c 
> b/tests/qtest/migration/cpr-tests.c
> index 44ce89aa5b..818fa95133 100644
> --- a/tests/qtest/migration/cpr-tests.c
> +++ b/tests/qtest/migration/cpr-tests.c
> @@ -24,9 +24,6 @@ static void *migrate_hook_start_mode_reboot(QTestState 
> *from, QTestState *to)
>  migrate_set_parameter_str(from, "mode", "cpr-reboot");
>  migrate_set_parameter_str(to, "mode", "cpr-reboot");
>  
> -migrate_set_capability(from, "x-ignore-shared", true);
> -migrate_set_capability(to, "x-ignore-shared", true);
> -
>  return NULL;
>  }
>  
> @@ -39,6 +36,7 @@ static void test_mode_reboot(void)
>  .connect_uri = uri,
>  .listen_uri = "defer",
>  .start_hook = migrate_hook_start_mode_reboot,
> +.caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true,
>  };
>  
>  test_file_common(&args, true);
> diff --git a/tests/qtest/migration/file-tests.c 
> b/tests/qtest/migration/file-tests.c
> index 84225c8c33..bc551949f9 100644
> --- a/tests/qtest/migration/file-tests.c
> +++ b/tests/qtest/migration/file-tests.c
> @@ -107,15 +107,6 @@ static void test_precopy_file_offset_bad(void)
>  test_file_common(&args, false);
>  }
>  
> -static void *migrate_hook_start_mapped_ram(QTestState *from,
> -   QTestState *to)
> -{
> -migrate_set_capability(from, "mapped-ram", true);
> -migrate_set_capability(to, "mapped-ram", true);
> -
> -return NULL;
> -}
> -
>  static void test_precopy_file_mapped_ram_live(void)
>  {
>  g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
> @@ -123,7 +114,7 @@ static void test_precopy_file_mapped_ram_live(void)
>  MigrateCommon args = {
>  .connect_uri = uri,
>  .listen_uri = "defer",
> -.start_hook = migrate_hook_start_mapped_ram,
> +.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true,
>  };
>  
>  test_file_common(&args, false);
> @@ -136,26 +127,12 @@ static void test_precopy_file_mapped_ram(void)
>  MigrateCommon args = {
>  .connect_uri = uri,
>  .listen_uri = "defer",
> -.start_hook = migrate_hook_start_mapped_ram,
> +.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true,
>  };
>  
>  test_file_common(&args, true);
>  }
>  
> -static void *migrate_hook_start_multifd_mapped_ram(QTestState *from,
> -   QTestState *to)
> -{
> -migrate_hook_start_mapped_ram(from, to);
> -
> -migrate_set_parameter_int(from, "multifd-channels", 4);
> -migrate_set_parameter_int(to, "multifd-channels", 4);
> -
> -migrate

Re: [PATCH v5 5/5] tests/qtest/migration: consolidate set capabilities

2025-02-07 Thread Prasad Pandit
On Fri, 7 Feb 2025 at 04:14, Peter Xu  wrote:
> Would you mind reorder the two test patches, to avoid removing the lines
> added by previous patch?

* Both ways they are the same in the end, no? Anyway, will do.

Thank you.
---
  - Prasad




Re: [PATCH v5 5/5] tests/qtest/migration: consolidate set capabilities

2025-02-06 Thread Peter Xu
On Wed, Feb 05, 2025 at 05:57:12PM +0530, Prasad Pandit wrote:
> From: Prasad Pandit 
> 
> Migration capabilities are set in multiple '.start_hook'
> functions for various tests. Instead, consolidate setting
> capabilities in 'set_migration_capabilities()' function
> which is called from various 'test_*_common()' functions.
> While simplifying the capabilities setting, it helps
> to declutter the test sources.
> 
> Suggested-by: Fabiano Rosas 
> Signed-off-by: Prasad Pandit 

Would you mind reorder the two test patches, to avoid removing the lines
added by previous patch?

Thanks,

-- 
Peter Xu