master
c 121 lines 3.51 KB
Raw
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(char *name, MigrateCommon *args)
24 {
25 test_postcopy_common(args);
26 }
27
28 static void test_postcopy_suspend(char *name, MigrateCommon *args)
29 {
30 args->start.suspend_me = true;
31
32 test_postcopy_common(args);
33 }
34
35 static void test_postcopy_preempt(char *name, MigrateCommon *args)
36 {
37 args->start.caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true;
38
39 test_postcopy_common(args);
40 }
41
42 static void test_postcopy_recovery(char *name, MigrateCommon *args)
43 {
44 test_postcopy_recovery_common(args, POSTCOPY_FAIL_NONE);
45 }
46
47 static void test_postcopy_recovery_fail_handshake(char *name,
48 MigrateCommon *args)
49 {
50 test_postcopy_recovery_common(args, POSTCOPY_FAIL_RECOVERY);
51 }
52
53 static void test_postcopy_recovery_fail_reconnect(char *name,
54 MigrateCommon *args)
55 {
56 test_postcopy_recovery_common(args, POSTCOPY_FAIL_CHANNEL_ESTABLISH);
57 }
58
59 static void test_postcopy_preempt_recovery(char *name, MigrateCommon *args)
60 {
61 args->start.caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true;
62
63 test_postcopy_recovery_common(args, POSTCOPY_FAIL_NONE);
64 }
65
66 static void migration_test_add_postcopy_smoke(MigrationTestEnv *env)
67 {
68 if (env->has_uffd) {
69 migration_test_add("/migration/postcopy/plain", test_postcopy);
70 migration_test_add("/migration/postcopy/recovery/plain",
71 test_postcopy_recovery);
72 migration_test_add("/migration/postcopy/preempt/plain",
73 test_postcopy_preempt);
74 }
75 }
76
77 static void test_multifd_postcopy(char *name, MigrateCommon *args)
78 {
79 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
80
81 test_postcopy_common(args);
82 }
83
84 static void test_multifd_postcopy_preempt(char *name, MigrateCommon *args)
85 {
86 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
87 args->start.caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT] = true;
88
89 test_postcopy_common(args);
90 }
91
92 void migration_test_add_postcopy(MigrationTestEnv *env)
93 {
94 migration_test_add_postcopy_smoke(env);
95
96 if (!env->full_set) {
97 return;
98 }
99
100 if (env->has_uffd) {
101 migration_test_add("/migration/postcopy/preempt/recovery/plain",
102 test_postcopy_preempt_recovery);
103
104 migration_test_add(
105 "/migration/postcopy/recovery/double-failures/handshake",
106 test_postcopy_recovery_fail_handshake);
107
108 migration_test_add(
109 "/migration/postcopy/recovery/double-failures/reconnect",
110 test_postcopy_recovery_fail_reconnect);
111
112 migration_test_add("/migration/multifd+postcopy/plain",
113 test_multifd_postcopy);
114 migration_test_add("/migration/multifd+postcopy/preempt/plain",
115 test_multifd_postcopy_preempt);
116 if (env->is_x86) {
117 migration_test_add("/migration/postcopy/suspend",
118 test_postcopy_suspend);
119 }
120 }
121 }