On Fri, Sep 18, 2026 at 04:46:55PM +0300, Andrey Drobyshev wrote:
> Snapshots are refused whenever a CPR migration mode is set. Add a test
> which sets each of the CPR modes in turn and checks that 'savevm' and
> 'loadvm' fail with the corresponding error, then switches back to
> 'normal' mode and checks that the error is gone.
>
> Signed-off-by: Andrey Drobyshev <[email protected]>
> ---
> tests/qtest/migration/cpr-tests.c | 36 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qtest/migration/cpr-tests.c
> b/tests/qtest/migration/cpr-tests.c
> index 0bec753b4ab..a5255193101 100644
> --- a/tests/qtest/migration/cpr-tests.c
> +++ b/tests/qtest/migration/cpr-tests.c
> @@ -290,11 +290,45 @@ static void test_mode_exec(char *name, MigrateCommon
> *args)
> test_cpr_exec(args);
> }
>
> +/* Snapshots must be refused while a CPR migration mode is set */
> +static void test_mode_no_snapshot(char *name, MigrateCommon *args)
> +{
> + static const char *const modes[] = {
> + "cpr-reboot", "cpr-transfer", "cpr-exec",
> + };
> + QTestState *vm = qtest_init("-nodefaults");
> + char *out;
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(modes); i++) {
> + g_autofree char *expected = g_strdup_printf(
> + "Snapshots are not compatible with migration mode %s", modes[i]);
> +
> + migrate_set_parameter_str(vm, "mode", modes[i]);
> +
> + out = qtest_hmp(vm, "savevm snap");
> + g_assert_nonnull(strstr(out, expected));
> + g_free(out);
> +
> + out = qtest_hmp(vm, "loadvm snap");
> + g_assert_nonnull(strstr(out, expected));
> + g_free(out);
> + }
> +
> + /* Back in normal mode the mode check no longer fires */
> + migrate_set_parameter_str(vm, "mode", "normal");
> + out = qtest_hmp(vm, "savevm snap");
> + g_assert_null(strstr(out, "not compatible with migration mode"));
> + g_free(out);
> +
> + qtest_quit(vm);
> +}
> +
> void migration_test_add_cpr(MigrationTestEnv *env)
> {
> tmpfs = env->tmpfs;
>
> - /* no tests in the smoke set for now */
> + migration_test_add("/migration/mode/no-snapshot", test_mode_no_snapshot);
We should justify each test to be added into default set because it bloats
the test matrix.
This is a negative test, I think it should be only for --full. Note that
this will be covered by each PULL as long as when KVM enabled (IIUC when
top maintainers collect PRs these will be covered), and we also run --full
at least when preparing migration pulls.
Thanks,
>
> if (!env->full_set) {
> return;
>
> --
> 2.47.1
>
--
Peter Xu