diff mbox series

[2/2] qtest/migration: Add dirty ring tests

Message ID 20240620094714.871727-3-cosocaf@gmail.com (mailing list archive)
State New, archived
Headers show
Series Implement dirty ring for pre-copy migration | expand

Commit Message

Shota Imamura June 20, 2024, 9:47 a.m. UTC
This commit adds tests for migration using the dirty ring. To avoid
confusion with KVM's dirty ring, use_dirty_ring has been changed to
use_kvm_dirty_ring, and use_qemu_dirty_ring has been added.

Signed-off-by: Shota Imamura <cosocaf@gmail.com>
---
 tests/qtest/migration-test.c | 78 ++++++++++++++++++++++++++++++++----
 1 file changed, 70 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 0dccb4beff..a8151b9470 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -556,7 +556,8 @@  typedef struct {
     /* only launch the target process */
     bool only_target;
     /* Use dirty ring if true; dirty logging otherwise */
-    bool use_dirty_ring;
+    bool use_kvm_dirty_ring;
+    bool use_qemu_dirty_ring;
     const char *opts_source;
     const char *opts_target;
     /* suspend the src before migrating to dest. */
@@ -675,6 +676,7 @@  static int test_migrate_start(QTestState **from, QTestState **to,
     g_autofree char *shmem_opts = NULL;
     g_autofree char *shmem_path = NULL;
     const char *kvm_opts = NULL;
+    const char *migration_ops = NULL;
     const char *arch = qtest_get_arch();
     const char *memory_size;
     const char *machine_alias, *machine_opts = "";
@@ -754,10 +756,16 @@  static int test_migrate_start(QTestState **from, QTestState **to,
             memory_size, shmem_path);
     }
 
-    if (args->use_dirty_ring) {
+    if (args->use_kvm_dirty_ring) {
         kvm_opts = ",dirty-ring-size=4096";
     }
 
+    if (args->use_qemu_dirty_ring) {
+        migration_ops = "dirty-logging=ring,dirty-ring-size=32768";
+    } else {
+        migration_ops = "dirty-logging=bitmap";
+    }
+
     if (!qtest_has_machine(machine_alias)) {
         g_autofree char *msg = g_strdup_printf("machine %s not supported", machine_alias);
         g_test_skip(msg);
@@ -774,10 +782,12 @@  static int test_migrate_start(QTestState **from, QTestState **to,
                                  "-name source,debug-threads=on "
                                  "-m %s "
                                  "-serial file:%s/src_serial "
+                                 "-migration %s "
                                  "%s %s %s %s %s",
                                  kvm_opts ? kvm_opts : "",
                                  machine, machine_opts,
                                  memory_size, tmpfs,
+                                 migration_ops,
                                  arch_opts ? arch_opts : "",
                                  arch_source ? arch_source : "",
                                  shmem_opts ? shmem_opts : "",
@@ -1796,12 +1806,27 @@  static void test_precopy_unix_suspend_notlive(void)
     test_precopy_common(&args);
 }
 
-static void test_precopy_unix_dirty_ring(void)
+static void test_precopy_unix_qemu_dirty_ring(void)
 {
     g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
     MigrateCommon args = {
         .start = {
-            .use_dirty_ring = true,
+            .use_qemu_dirty_ring = true,
+        },
+        .listen_uri = uri,
+        .connect_uri = uri,
+        .live = true,
+    };
+
+    test_precopy_common(&args);
+}
+
+static void test_precopy_unix_kvm_dirty_ring(void)
+{
+    g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+    MigrateCommon args = {
+        .start = {
+            .use_kvm_dirty_ring = true,
         },
         .listen_uri = uri,
         .connect_uri = uri,
@@ -1815,6 +1840,22 @@  static void test_precopy_unix_dirty_ring(void)
     test_precopy_common(&args);
 }
 
+static void test_precopy_unix_kvm_and_qemu_dirty_ring(void)
+{
+    g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+    MigrateCommon args = {
+        .start = {
+            .use_kvm_dirty_ring = true,
+            .use_qemu_dirty_ring = true,
+        },
+        .listen_uri = uri,
+        .connect_uri = uri,
+        .live = true,
+    };
+
+    test_precopy_common(&args);
+}
+
 #ifdef CONFIG_GNUTLS
 static void test_precopy_unix_tls_psk(void)
 {
@@ -1942,6 +1983,21 @@  static void test_precopy_file(void)
     test_file_common(&args, true);
 }
 
+static void test_precopy_file_dirty_ring(void)
+{
+    g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
+                                           FILE_TEST_FILENAME);
+    MigrateCommon args = {
+        .start = {
+            .use_qemu_dirty_ring = true,
+        },
+        .connect_uri = uri,
+        .listen_uri = "defer",
+    };
+
+    test_file_common(&args, true);
+}
+
 static void file_offset_finish_hook(QTestState *from, QTestState *to,
                                     void *opaque)
 {
@@ -3298,7 +3354,7 @@  static void test_migrate_dirty_limit(void)
     MigrateCommon args = {
         .start = {
             .hide_stderr = true,
-            .use_dirty_ring = true,
+            .use_kvm_dirty_ring = true,
         },
         .listen_uri = uri,
         .connect_uri = uri,
@@ -3342,7 +3398,7 @@  static void test_migrate_dirty_limit(void)
     args = (MigrateCommon) {
         .start = {
             .only_target = true,
-            .use_dirty_ring = true,
+            .use_kvm_dirty_ring = true,
         },
         .listen_uri = uri,
         .connect_uri = uri,
@@ -3504,10 +3560,14 @@  int main(int argc, char **argv)
 
     migration_test_add("/migration/precopy/unix/plain",
                        test_precopy_unix_plain);
+    migration_test_add("/migration/precopy/unix/dirty_ring",
+                       test_precopy_unix_qemu_dirty_ring);
     migration_test_add("/migration/precopy/unix/xbzrle",
                        test_precopy_unix_xbzrle);
     migration_test_add("/migration/precopy/file",
                        test_precopy_file);
+    migration_test_add("/migration/precopy/file/dirty_ring",
+                       test_precopy_file_dirty_ring);
     migration_test_add("/migration/precopy/file/offset",
                        test_precopy_file_offset);
     migration_test_add("/migration/precopy/file/offset/bad",
@@ -3660,8 +3720,10 @@  int main(int argc, char **argv)
 #endif /* CONFIG_GNUTLS */
 
     if (g_str_equal(arch, "x86_64") && has_kvm && kvm_dirty_ring_supported()) {
-        migration_test_add("/migration/dirty_ring",
-                           test_precopy_unix_dirty_ring);
+        migration_test_add("/migration/precopy/unix/kvm_dirty_ring",
+                           test_precopy_unix_kvm_dirty_ring);
+        migration_test_add("/migration/precopy/unix/kvm_and_qemu_dirty_ring",
+                           test_precopy_unix_kvm_and_qemu_dirty_ring);
         migration_test_add("/migration/vcpu_dirty_limit",
                            test_vcpu_dirty_limit);
     }