On Tue, Sep 29, 2026 at 08:23:24PM +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]>

Reviewed-by: Peter Xu <[email protected]>

One thing to mention below..

> ---
>  tests/qtest/migration/cpr-tests.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/tests/qtest/migration/cpr-tests.c 
> b/tests/qtest/migration/cpr-tests.c
> index 0bec753b4ab..2be0fc8c07e 100644
> --- a/tests/qtest/migration/cpr-tests.c
> +++ b/tests/qtest/migration/cpr-tests.c
> @@ -290,6 +290,40 @@ 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"));

What it looks like is it tries one more time with normal mode then a
snapshot should be correctly taken.  In reality, behavior with current
qtest_init():

{"return": "Error: no block device can store vmstate for snapshot\r\n"}

So yes, the check is working, but slightly obscure on what is expected to
happen.  Maybe worth a comment if there's a repost.  It also answers why
there's no "snap" snapshot leftover not cleaned up.

> +    g_free(out);
> +
> +    qtest_quit(vm);
> +}
> +
>  void migration_test_add_cpr(MigrationTestEnv *env)
>  {
>      tmpfs = env->tmpfs;
> @@ -300,6 +334,8 @@ void migration_test_add_cpr(MigrationTestEnv *env)
>          return;
>      }
>  
> +    migration_test_add("/migration/mode/no-snapshot", test_mode_no_snapshot);
> +
>      /*
>       * Our CI system has problems with shared memory.
>       * Don't run this test until we find a workaround.
> 
> -- 
> 2.47.1
> 

-- 
Peter Xu


Reply via email to