On Mon, Dec 15, 2025 at 07:00:25PM -0300, Fabiano Rosas wrote:
> Split the TLS x509 hooks by moving out of them any code that doesn't
> need to access the QTestState.
> 
> Aside from making the code harder to follow for no practical reason,
> having extra code in the hooks will soon get in the way of converting
> the tests to use a new API that, unlike
> migrate_set_parameters|capabilities, doesn't require the QEMU instance
> to be already live.
> 
> Move the QTestState-independent code into a normal function and leave
> the hooks only for operations that need the guest machine.
> 
> Signed-off-by: Fabiano Rosas <[email protected]>

I think I see what you want to do, this looks ok,

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

One trivial thing to mention below,

> ---
>  tests/qtest/migration/tls-tests.c | 155 +++++++++++++++---------------
>  1 file changed, 75 insertions(+), 80 deletions(-)
> 
> diff --git a/tests/qtest/migration/tls-tests.c 
> b/tests/qtest/migration/tls-tests.c
> index 8da95dc92a..6a858b766f 100644
> --- a/tests/qtest/migration/tls-tests.c
> +++ b/tests/qtest/migration/tls-tests.c
> @@ -210,15 +210,57 @@ migrate_hook_start_tls_x509_common(QTestState *from,
>                                     void *opaque)
>  {
>      TestMigrateTLSX509 *args = opaque;
> -    TestMigrateTLSX509Data *data = g_new0(TestMigrateTLSX509Data, 1);
> +    const char *workdir = g_strdup_printf("%s/tlscredsx5090", tmpfs);

This introduces a string duplicate with the init() function.

Quick change is we can at least make it a macro so use it in both places
just to be clear that they must match.

Logically we can also make the opaque to be TestMigrateTLSX509Data*
instead, which can add a pointer pointing to TestMigrateTLSX509 (the "Data"
struct is per-test, "non-Data" is a setup, which can be shared).

Either way (the latter will need separate patch), or keep it as-is, you can
keep my R-b.

-- 
Peter Xu


Reply via email to