xref: /kvm-unit-tests/lib/migrate.c (revision 956004acda727b12b14ef0b5283984754ee7616d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Migration-related functions
4  *
5  * Copyright IBM Corp. 2022
6  * Author: Nico Boehr <nrb@linux.ibm.com>
7  */
8 #include <libcflat.h>
9 #include "migrate.h"
10 
11 /*
12  * Initiate migration and wait for it to complete.
13  */
migrate(void)14 void migrate(void)
15 {
16 	puts("Now migrate the VM, then press a key to continue...\n");
17 	(void)getchar();
18 	report_info("Migration complete");
19 }
20 
21 /*
22  * Like migrate() but suppress output and logs, useful for intensive
23  * migration stress testing without polluting logs. Test cases should
24  * provide relevant information about migration in failure reports.
25  */
migrate_quiet(void)26 void migrate_quiet(void)
27 {
28 	puts("Now migrate the VM (quiet)\n");
29 	(void)getchar();
30 }
31 
32 /*
33  * Initiate migration and wait for it to complete.
34  * If this function is called more than once, it is a no-op.
35  */
migrate_once(void)36 void migrate_once(void)
37 {
38 	static bool migrated;
39 
40 	if (migrated)
41 		return;
42 	migrated = true;
43 
44 	migrate();
45 }
46 
47 /*
48  * When the test has been started in migration mode, but the test case is
49  * skipped and no migration point is reached, this can be used to tell the
50  * harness not to mark it as a failure to migrate.
51  */
migrate_skip(void)52 void migrate_skip(void)
53 {
54 	static bool did_migrate_skip;
55 
56 	if (did_migrate_skip)
57 		return;
58 	did_migrate_skip = true;
59 
60 	puts("Skipped VM migration (quiet)\n");
61 	(void)getchar();
62 }
63 
migrate_begin_continuous(void)64 void migrate_begin_continuous(void)
65 {
66 	puts("Begin continuous migration\n");
67 	(void)getchar();
68 }
69 
migrate_end_continuous(void)70 void migrate_end_continuous(void)
71 {
72 	/*
73 	 * Migration can split this output between source and dest QEMU
74 	 * output files, print twice and match once to always cope with
75 	 * a split.
76 	 */
77 	puts("End continuous migration\n");
78 	puts("End continuous migration (quiet)\n");
79 	(void)getchar();
80 }
81