Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 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 | |
Nicholas Piggin | 14ea7bd | 2024-02-21 13:27:53 +1000 | [diff] [blame] | 11 | /* |
| 12 | * Initiate migration and wait for it to complete. |
| 13 | */ |
| 14 | void migrate(void) |
Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 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 | /* |
Nicholas Piggin | 71e3516 | 2024-02-21 13:27:55 +1000 | [diff] [blame] | 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 | /* |
Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 33 | * Initiate migration and wait for it to complete. |
| 34 | * If this function is called more than once, it is a no-op. |
Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 35 | */ |
| 36 | void migrate_once(void) |
| 37 | { |
| 38 | static bool migrated; |
| 39 | |
| 40 | if (migrated) |
| 41 | return; |
Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 42 | migrated = true; |
Nicholas Piggin | fa8914b | 2024-04-05 18:35:04 +1000 | [diff] [blame] | 43 | |
Nico Boehr | bb8dd24 | 2022-12-12 12:17:28 +0100 | [diff] [blame] | 44 | migrate(); |
| 45 | } |
Nicholas Piggin | fa8914b | 2024-04-05 18:35:04 +1000 | [diff] [blame] | 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 | */ |
| 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 | } |
Nicholas Piggin | 956004a | 2024-04-05 18:35:06 +1000 | [diff] [blame] | 63 | |
| 64 | void migrate_begin_continuous(void) |
| 65 | { |
| 66 | puts("Begin continuous migration\n"); |
| 67 | (void)getchar(); |
| 68 | } |
| 69 | |
| 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 | } |