[PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd

Prasad Pandit posted 4 patches 1 day, 14 hours ago
[PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd
Posted by Prasad Pandit 1 day, 14 hours ago
From: Prasad Pandit <pjp@fedoraproject.org>

Add a new postcopy test 'migration/postcopy/multifd'
to run postcopy migration with multifd channels enabled.
Add a boolean field 'multifd' to the MigrateCommon struct.
It helps to enable multifd channels.

Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
---
 tests/qtest/migration/framework.c      |  8 ++++++++
 tests/qtest/migration/framework.h      |  3 +++
 tests/qtest/migration/postcopy-tests.c | 10 ++++++++++
 3 files changed, 21 insertions(+)

diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index 4550cda129..7f5abd760e 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -427,6 +427,14 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,
         migrate_set_capability(to, "postcopy-preempt", true);
     }
 
+    if (args->multifd) {
+        migrate_set_capability(from, "multifd", true);
+        migrate_set_capability(to, "multifd", true);
+
+        migrate_set_parameter_int(from, "multifd-channels", 8);
+        migrate_set_parameter_int(to, "multifd-channels", 8);
+    }
+
     migrate_ensure_non_converge(from);
 
     migrate_prepare_for_dirty_mem(from);
diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
index 7991ee56b6..1b2320ebef 100644
--- a/tests/qtest/migration/framework.h
+++ b/tests/qtest/migration/framework.h
@@ -193,6 +193,9 @@ typedef struct {
      */
     bool live;
 
+    /* set multifd on */
+    bool multifd;
+
     /* Postcopy specific fields */
     void *postcopy_data;
     bool postcopy_preempt;
diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration/postcopy-tests.c
index daf7449f2c..6eada6ccbc 100644
--- a/tests/qtest/migration/postcopy-tests.c
+++ b/tests/qtest/migration/postcopy-tests.c
@@ -27,6 +27,15 @@ static void test_postcopy(void)
     test_postcopy_common(&args);
 }
 
+static void test_postcopy_multifd(void)
+{
+    MigrateCommon args = {
+        .multifd = true,
+    };
+
+    test_postcopy_common(&args);
+}
+
 static void test_postcopy_suspend(void)
 {
     MigrateCommon args = {
@@ -83,6 +92,7 @@ void migration_test_add_postcopy(MigrationTestEnv *env)
 {
     if (env->has_uffd) {
         migration_test_add("/migration/postcopy/plain", test_postcopy);
+        migration_test_add("/migration/postcopy/multifd", test_postcopy_multifd);
         migration_test_add("/migration/postcopy/recovery/plain",
                            test_postcopy_recovery);
         migration_test_add("/migration/postcopy/preempt/plain",
--
2.48.1
Re: [PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd
Posted by Peter Xu 1 day, 11 hours ago
On Tue, Jan 21, 2025 at 06:40:32PM +0530, Prasad Pandit wrote:
> From: Prasad Pandit <pjp@fedoraproject.org>
> 
> Add a new postcopy test 'migration/postcopy/multifd'
> to run postcopy migration with multifd channels enabled.
> Add a boolean field 'multifd' to the MigrateCommon struct.
> It helps to enable multifd channels.
> 
> Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
> ---
>  tests/qtest/migration/framework.c      |  8 ++++++++
>  tests/qtest/migration/framework.h      |  3 +++
>  tests/qtest/migration/postcopy-tests.c | 10 ++++++++++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
> index 4550cda129..7f5abd760e 100644
> --- a/tests/qtest/migration/framework.c
> +++ b/tests/qtest/migration/framework.c
> @@ -427,6 +427,14 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,
>          migrate_set_capability(to, "postcopy-preempt", true);
>      }
>  
> +    if (args->multifd) {
> +        migrate_set_capability(from, "multifd", true);
> +        migrate_set_capability(to, "multifd", true);
> +
> +        migrate_set_parameter_int(from, "multifd-channels", 8);
> +        migrate_set_parameter_int(to, "multifd-channels", 8);
> +    }
> +
>      migrate_ensure_non_converge(from);
>  
>      migrate_prepare_for_dirty_mem(from);
> diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
> index 7991ee56b6..1b2320ebef 100644
> --- a/tests/qtest/migration/framework.h
> +++ b/tests/qtest/migration/framework.h
> @@ -193,6 +193,9 @@ typedef struct {
>       */
>      bool live;
>  
> +    /* set multifd on */
> +    bool multifd;
> +
>      /* Postcopy specific fields */
>      void *postcopy_data;
>      bool postcopy_preempt;
> diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration/postcopy-tests.c
> index daf7449f2c..6eada6ccbc 100644
> --- a/tests/qtest/migration/postcopy-tests.c
> +++ b/tests/qtest/migration/postcopy-tests.c
> @@ -27,6 +27,15 @@ static void test_postcopy(void)
>      test_postcopy_common(&args);
>  }
>  
> +static void test_postcopy_multifd(void)
> +{
> +    MigrateCommon args = {
> +        .multifd = true,
> +    };
> +
> +    test_postcopy_common(&args);
> +}
> +
>  static void test_postcopy_suspend(void)
>  {
>      MigrateCommon args = {
> @@ -83,6 +92,7 @@ void migration_test_add_postcopy(MigrationTestEnv *env)
>  {
>      if (env->has_uffd) {
>          migration_test_add("/migration/postcopy/plain", test_postcopy);
> +        migration_test_add("/migration/postcopy/multifd", test_postcopy_multifd);
>          migration_test_add("/migration/postcopy/recovery/plain",
>                             test_postcopy_recovery);
>          migration_test_add("/migration/postcopy/preempt/plain",
> --
> 2.48.1
> 

This is only one test out of many I listed in the previous email:

https://lore.kernel.org/qemu-devel/ZykJBq7ME5jgSzCA@x1n/

Would you please add all the tests mentioned there?

Thanks,

-- 
Peter Xu
Re: [PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd
Posted by Prasad Pandit 19 hours ago
Hi,
On Tue, 21 Jan 2025 at 21:17, Peter Xu <peterx@redhat.com> wrote:
> https://lore.kernel.org/qemu-devel/ZykJBq7ME5jgSzCA@x1n/
> Would you please add all the tests mentioned there?

    /x86_64/migration/multifd/file/mapped-ram/
    /x86_64/migration/multifd/tcp/uri/plain/none
    /x86_64/migration/multifd/tcp/plain/cancel

    /x86_64/migration/postcopy/plain
    /x86_64/migration/postcopy/recovery/
    /x86_64/migration/postcopy/preempt/

* Of the tests you suggested above, I'll try to enable multifd
channels for 'postcopy/recovery' and 'postcopy/preempt' tests. For the
'multifd' tests above, how do we want to modify them? Enable
'postcopy' mode for them?

Thank you.
---
  - Prasad
Re: [PATCH v3 4/4] tests/qtest/migration: add postcopy test with multifd
Posted by Peter Xu 11 hours ago
On Wed, Jan 22, 2025 at 01:26:21PM +0530, Prasad Pandit wrote:
> Hi,
> On Tue, 21 Jan 2025 at 21:17, Peter Xu <peterx@redhat.com> wrote:
> > https://lore.kernel.org/qemu-devel/ZykJBq7ME5jgSzCA@x1n/
> > Would you please add all the tests mentioned there?
> 
>     /x86_64/migration/multifd/file/mapped-ram/
>     /x86_64/migration/multifd/tcp/uri/plain/none
>     /x86_64/migration/multifd/tcp/plain/cancel
> 
>     /x86_64/migration/postcopy/plain
>     /x86_64/migration/postcopy/recovery/
>     /x86_64/migration/postcopy/preempt/
> 
> * Of the tests you suggested above, I'll try to enable multifd
> channels for 'postcopy/recovery' and 'postcopy/preempt' tests. For the
> 'multifd' tests above, how do we want to modify them? Enable
> 'postcopy' mode for them?

Right, that implies a migration with both features enabled but finished
even before postcopy starts.

We have some tricky paths that may go differently when different feature
enabled, especially when it's relevant to postcopy and multifd.  Adding
these tests could make sure those corner cases got covered.

And btw, some of my above lines are not a single test, but a set of tests.
E.g., "/x86_64/migration/postcopy/recovery/" is not a single test but:

        # /x86_64/migration/postcopy/recovery/plain
        # /x86_64/migration/postcopy/recovery/tls/psk
        # /x86_64/migration/postcopy/recovery/double-failures/handshake
        # /x86_64/migration/postcopy/recovery/double-failures/reconnect

Let me list all the tests that is relevant to the two features to be
explicit..

        # /x86_64/migration/postcopy/plain
        # /x86_64/migration/postcopy/suspend
        # /x86_64/migration/postcopy/tls/psk
        # /x86_64/migration/postcopy/recovery/plain
        # /x86_64/migration/postcopy/recovery/tls/psk
        # /x86_64/migration/postcopy/recovery/double-failures/handshake
        # /x86_64/migration/postcopy/recovery/double-failures/reconnect
        # /x86_64/migration/postcopy/preempt/plain
        # /x86_64/migration/postcopy/preempt/tls/psk
        # /x86_64/migration/postcopy/preempt/recovery/plain
        # /x86_64/migration/postcopy/preempt/recovery/tls/psk
        # /x86_64/migration/multifd/tcp/tls/psk/match
        # /x86_64/migration/multifd/tcp/tls/psk/mismatch
        # /x86_64/migration/multifd/tcp/tls/x509/default-host
        # /x86_64/migration/multifd/tcp/tls/x509/override-host
        # /x86_64/migration/multifd/tcp/tls/x509/mismatch-host
        # /x86_64/migration/multifd/tcp/tls/x509/allow-anon-client
        # /x86_64/migration/multifd/tcp/tls/x509/reject-anon-client
        # /x86_64/migration/multifd/tcp/plain/zstd
        # /x86_64/migration/multifd/tcp/plain/zlib
        # /x86_64/migration/multifd/tcp/plain/cancel
        # /x86_64/migration/multifd/tcp/plain/zero-page/legacy
        # /x86_64/migration/multifd/tcp/plain/zero-page/none
        # /x86_64/migration/multifd/tcp/uri/plain/none
        # /x86_64/migration/multifd/tcp/channels/plain/none

(I used to reference mapped-ram for multifd, but I just remembered it can't
be enabled with postcopy, so I dropped them)

I believe many of the tests can be avoided, but still below is a list of
minimum tests that I think might still be good to add:

        # /x86_64/migration/postcopy/plain
        # /x86_64/migration/postcopy/recovery/tls/psk
        # /x86_64/migration/postcopy/preempt/plain
        # /x86_64/migration/postcopy/preempt/recovery/tls/psk
        # /x86_64/migration/multifd/tcp/tls/psk/match
        # /x86_64/migration/multifd/tcp/plain/zstd
        # /x86_64/migration/multifd/tcp/plain/cancel

I kept almost tls relevant ones because it has the most code path coverage,
and I suppose tls should also be an emphasis in the future for migration in
CoCo environments.  I removed most of the trivial test cases, like postcopy
double failures etc. which can be too hard to trigger in real life.

Feel free to comment on whether you think the list is suitable to you.  If
you want to add some more into the list I'm also ok with.

IMHO we can have a specific path "/x86_64/migration/multifd+postcopy/*" for
all above new tests, that have both features enabled.

Fabiano, you're rethinking the test infra, please comment if you have any
thoughts on above too.

Thanks,

-- 
Peter Xu