xref: /kvm-unit-tests/lib/migrate.c (revision a8a78d758b16d4e1869aae600ee074dfd1a64135)
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  */
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  */
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  */
36 void migrate_once(void)
37 {
38 	static bool migrated;
39 
40 	if (migrated)
41 		return;
42 
43 	migrated = true;
44 	migrate();
45 }
46