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 .postcopy_preempt = true, 43 }; 44 45 test_postcopy_common(&args); 46 } 47 48 static void test_postcopy_recovery(void) 49 { 50 MigrateCommon args = { }; 51 52 test_postcopy_recovery_common(&args); 53 } 54 55 static void test_postcopy_recovery_fail_handshake(void) 56 { 57 MigrateCommon args = { 58 .postcopy_recovery_fail_stage = POSTCOPY_FAIL_RECOVERY, 59 }; 60 61 test_postcopy_recovery_common(&args); 62 } 63 64 static void test_postcopy_recovery_fail_reconnect(void) 65 { 66 MigrateCommon args = { 67 .postcopy_recovery_fail_stage = POSTCOPY_FAIL_CHANNEL_ESTABLISH, 68 }; 69 70 test_postcopy_recovery_common(&args); 71 } 72 73 static void test_postcopy_preempt_recovery(void) 74 { 75 MigrateCommon args = { 76 .postcopy_preempt = true, 77 }; 78 79 test_postcopy_recovery_common(&args); 80 } 81 82 static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) 83 { 84 if (env->has_uffd) { 85 migration_test_add("/migration/postcopy/plain", test_postcopy); 86 migration_test_add("/migration/postcopy/recovery/plain", 87 test_postcopy_recovery); 88 migration_test_add("/migration/postcopy/preempt/plain", 89 test_postcopy_preempt); 90 } 91 } 92 93 void migration_test_add_postcopy(MigrationTestEnv *env) 94 { 95 migration_test_add_postcopy_smoke(env); 96 97 if (!env->full_set) { 98 return; 99 } 100 101 if (env->has_uffd) { 102 migration_test_add("/migration/postcopy/preempt/recovery/plain", 103 test_postcopy_preempt_recovery); 104 105 migration_test_add( 106 "/migration/postcopy/recovery/double-failures/handshake", 107 test_postcopy_recovery_fail_handshake); 108 109 migration_test_add( 110 "/migration/postcopy/recovery/double-failures/reconnect", 111 test_postcopy_recovery_fail_reconnect); 112 113 if (env->is_x86) { 114 migration_test_add("/migration/postcopy/suspend", 115 test_postcopy_suspend); 116 } 117 } 118 } 119