xref: /kvm-unit-tests/lib/migrate.c (revision bb8dd242c4f2bc27fdf44dc856a68f11747b9480)
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 /* static for now since we only support migrating exactly once per test. */
12 static void migrate(void)
13 {
14 	puts("Now migrate the VM, then press a key to continue...\n");
15 	(void)getchar();
16 	report_info("Migration complete");
17 }
18 
19 /*
20  * Initiate migration and wait for it to complete.
21  * If this function is called more than once, it is a no-op.
22  * Since migrate_cmd can only migrate exactly once this function can
23  * simplify the control flow, especially when skipping tests.
24  */
25 void migrate_once(void)
26 {
27 	static bool migrated;
28 
29 	if (migrated)
30 		return;
31 
32 	migrated = true;
33 	migrate();
34 }
35