xref: /kvm-unit-tests/lib/migrate.c (revision 14ea7bdac078acb46357c7943b3aa384ef5eb3f3)
1bb8dd242SNico Boehr /* SPDX-License-Identifier: GPL-2.0-only */
2bb8dd242SNico Boehr /*
3bb8dd242SNico Boehr  * Migration-related functions
4bb8dd242SNico Boehr  *
5bb8dd242SNico Boehr  * Copyright IBM Corp. 2022
6bb8dd242SNico Boehr  * Author: Nico Boehr <nrb@linux.ibm.com>
7bb8dd242SNico Boehr  */
8bb8dd242SNico Boehr #include <libcflat.h>
9bb8dd242SNico Boehr #include "migrate.h"
10bb8dd242SNico Boehr 
11*14ea7bdaSNicholas Piggin /*
12*14ea7bdaSNicholas Piggin  * Initiate migration and wait for it to complete.
13*14ea7bdaSNicholas Piggin  */
14*14ea7bdaSNicholas Piggin void migrate(void)
15bb8dd242SNico Boehr {
16bb8dd242SNico Boehr 	puts("Now migrate the VM, then press a key to continue...\n");
17bb8dd242SNico Boehr 	(void)getchar();
18bb8dd242SNico Boehr 	report_info("Migration complete");
19bb8dd242SNico Boehr }
20bb8dd242SNico Boehr 
21bb8dd242SNico Boehr /*
22bb8dd242SNico Boehr  * Initiate migration and wait for it to complete.
23bb8dd242SNico Boehr  * If this function is called more than once, it is a no-op.
24bb8dd242SNico Boehr  */
25bb8dd242SNico Boehr void migrate_once(void)
26bb8dd242SNico Boehr {
27bb8dd242SNico Boehr 	static bool migrated;
28bb8dd242SNico Boehr 
29bb8dd242SNico Boehr 	if (migrated)
30bb8dd242SNico Boehr 		return;
31bb8dd242SNico Boehr 
32bb8dd242SNico Boehr 	migrated = true;
33bb8dd242SNico Boehr 	migrate();
34bb8dd242SNico Boehr }
35