[PATCH v2 29/29] tests/qtest: Add a test for migration with direct-io and multifd

Fabiano Rosas posted 29 patches 2 years, 2 months ago
Maintainers: Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Leonardo Bras <leobras@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH v2 29/29] tests/qtest: Add a test for migration with direct-io and multifd
Posted by Fabiano Rosas 2 years, 2 months ago
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/migration-test.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index c74c911283..30e70c0e4e 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -2077,6 +2077,16 @@ static void *migrate_multifd_fixed_ram_start(QTestState *from, QTestState *to)
     return NULL;
 }
 
+static void *migrate_multifd_fixed_ram_dio_start(QTestState *from, QTestState *to)
+{
+    migrate_multifd_fixed_ram_start(from, to);
+
+    migrate_set_parameter_bool(from, "direct-io", true);
+    migrate_set_parameter_bool(to, "direct-io", true);
+
+    return NULL;
+}
+
 static void test_multifd_file_fixed_ram_live(void)
 {
     g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
@@ -2103,6 +2113,18 @@ static void test_multifd_file_fixed_ram(void)
     test_file_common(&args, false, true);
 }
 
+static void test_multifd_file_fixed_ram_dio(void)
+{
+    g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
+                                           FILE_TEST_FILENAME);
+    MigrateCommon args = {
+        .connect_uri = uri,
+        .listen_uri = "defer",
+        .start_hook = migrate_multifd_fixed_ram_dio_start,
+    };
+
+    test_file_common(&args, false, true);
+}
 
 static void test_precopy_tcp_plain(void)
 {
@@ -3182,6 +3204,9 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/multifd/file/fixed-ram/live",
                    test_multifd_file_fixed_ram_live);
 
+    qtest_add_func("/migration/multifd/file/fixed-ram/dio",
+                   test_multifd_file_fixed_ram_dio);
+
 #ifdef CONFIG_GNUTLS
     qtest_add_func("/migration/precopy/unix/tls/psk",
                    test_precopy_unix_tls_psk);
-- 
2.35.3
Re: [PATCH v2 29/29] tests/qtest: Add a test for migration with direct-io and multifd
Posted by Daniel P. Berrangé 2 years, 2 months ago
On Mon, Oct 23, 2023 at 05:36:08PM -0300, Fabiano Rosas wrote:
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>  tests/qtest/migration-test.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index c74c911283..30e70c0e4e 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -2077,6 +2077,16 @@ static void *migrate_multifd_fixed_ram_start(QTestState *from, QTestState *to)
>      return NULL;
>  }
>  
> +static void *migrate_multifd_fixed_ram_dio_start(QTestState *from, QTestState *to)
> +{
> +    migrate_multifd_fixed_ram_start(from, to);
> +
> +    migrate_set_parameter_bool(from, "direct-io", true);
> +    migrate_set_parameter_bool(to, "direct-io", true);
> +
> +    return NULL;
> +}
> +
>  static void test_multifd_file_fixed_ram_live(void)
>  {
>      g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
> @@ -2103,6 +2113,18 @@ static void test_multifd_file_fixed_ram(void)
>      test_file_common(&args, false, true);
>  }
>  
> +static void test_multifd_file_fixed_ram_dio(void)
> +{
> +    g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
> +                                           FILE_TEST_FILENAME);
> +    MigrateCommon args = {
> +        .connect_uri = uri,
> +        .listen_uri = "defer",
> +        .start_hook = migrate_multifd_fixed_ram_dio_start,
> +    };
> +
> +    test_file_common(&args, false, true);
> +}
>  
>  static void test_precopy_tcp_plain(void)
>  {
> @@ -3182,6 +3204,9 @@ int main(int argc, char **argv)
>      qtest_add_func("/migration/multifd/file/fixed-ram/live",
>                     test_multifd_file_fixed_ram_live);
>  
> +    qtest_add_func("/migration/multifd/file/fixed-ram/dio",
> +                   test_multifd_file_fixed_ram_dio);

All of the above should be put behind a #ifdef O_DIRECT check.

Also even if the platform supports O_DIRECT, we shouldn't assume
the filesystem used for QEMU build supports it. So we need to
open a tmp file at the same place as the save/restore and probe
to see if it succeeds with O_DIRECT, and skip the test if not.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|