1 /* 2 * QTest testcases for postcopy migration 3 * 4 * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates 5 * based on the vhost-user-test.c that is: 6 * Copyright (c) 2014 Virtual Open Systems Sarl. 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2 or later. 9 * See the COPYING file in the top-level directory. 10 * 11 */ 12 13 #include "qemu/osdep.h" 14 #include "libqtest.h" 15 #include "migration/framework.h" 16 #include "migration/migration-util.h" 17 #include "qobject/qlist.h" 18 #include "qemu/module.h" 19 #include "qemu/option.h" 20 #include "qemu/range.h" 21 #include "qemu/sockets.h" 22 23 static void test_postcopy(void) 24 { 25 MigrateCommon args = { }; 26 27 test_postcopy_common(&args); 28 } 29 30 static void test_postcopy_suspend(void) 31 { 32 MigrateCommon args = { 33 .start.suspend_me = true, 34 }; 35 36 test_postcopy_common(&args); 37 } 38 39 static void test_postcopy_preempt(void) 40 { 41 MigrateCommon args = { 42 .start = { 43 .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true, 44 }, 45 }; 46 47 test_postcopy_common(&args); 48 } 49 50 static void test_postcopy_recovery(void) 51 { 52 MigrateCommon args = { }; 53 54 test_postcopy_recovery_common(&args); 55 } 56 57 static void test_postcopy_recovery_fail_handshake(void) 58 { 59 MigrateCommon args = { 60 .postcopy_recovery_fail_stage = POSTCOPY_FAIL_RECOVERY, 61 }; 62 63 test_postcopy_recovery_common(&args); 64 } 65 66 static void test_postcopy_recovery_fail_reconnect(void) 67 { 68 MigrateCommon args = { 69 .postcopy_recovery_fail_stage = POSTCOPY_FAIL_CHANNEL_ESTABLISH, 70 }; 71 72 test_postcopy_recovery_common(&args); 73 } 74 75 static void test_postcopy_preempt_recovery(void) 76 { 77 MigrateCommon args = { 78 .start = { 79 .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true, 80 }, 81 }; 82 83 test_postcopy_recovery_common(&args); 84 } 85 86 static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) 87 { 88 if (env->has_uffd) { 89 migration_test_add("/migration/postcopy/plain", test_postcopy); 90 migration_test_add("/migration/postcopy/recovery/plain", 91 test_postcopy_recovery); 92 migration_test_add("/migration/postcopy/preempt/plain", 93 test_postcopy_preempt); 94 } 95 } 96 97 static void test_multifd_postcopy(void) 98 { 99 MigrateCommon args = { 100 .start = { 101 .caps[MIGRATION_CAPABILITY_MULTIFD] = true, 102 }, 103 }; 104 105 test_postcopy_common(&args); 106 } 107 108 static void test_multifd_postcopy_preempt(void) 109 { 110 MigrateCommon args = { 111 .start = { 112 .caps[MIGRATION_CAPABILITY_MULTIFD] = true, 113 .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true, 114 }, 115 }; 116 117 test_postcopy_common(&args); 118 } 119 120 void migration_test_add_postcopy(MigrationTestEnv *env) 121 { 122 migration_test_add_postcopy_smoke(env); 123 124 if (!env->full_set) { 125 return; 126 } 127 128 if (env->has_uffd) { 129 migration_test_add("/migration/postcopy/preempt/recovery/plain", 130 test_postcopy_preempt_recovery); 131 132 migration_test_add( 133 "/migration/postcopy/recovery/double-failures/handshake", 134 test_postcopy_recovery_fail_handshake); 135 136 migration_test_add( 137 "/migration/postcopy/recovery/double-failures/reconnect", 138 test_postcopy_recovery_fail_reconnect); 139 140 migration_test_add("/migration/multifd+postcopy/plain", 141 test_multifd_postcopy); 142 migration_test_add("/migration/multifd+postcopy/preempt/plain", 143 test_multifd_postcopy_preempt); 144 if (env->is_x86) { 145 migration_test_add("/migration/postcopy/suspend", 146 test_postcopy_suspend); 147 } 148 } 149 } 150