On Mon, Dec 15, 2025 at 07:00:03PM -0300, Fabiano Rosas wrote:
> @@ -1260,124 +1261,28 @@ bool migrate_params_check(MigrationParameters
> *params, Error **errp)
> return true;
> }
>
> -static void migrate_params_test_apply(MigrationParameters *params,
> - MigrationParameters *dest)
> +static void migrate_params_merge(MigrationParameters *dst,
> + MigrationParameters *src)
> {
> - MigrationState *s = migrate_get_current();
> -
> - QAPI_CLONE_MEMBERS(MigrationParameters, dest, &s->parameters);
> -
> - if (params->has_throttle_trigger_threshold) {
> - dest->throttle_trigger_threshold =
> params->throttle_trigger_threshold;
> - }
> -
> - if (params->has_cpu_throttle_initial) {
> - dest->cpu_throttle_initial = params->cpu_throttle_initial;
> - }
> -
> - if (params->has_cpu_throttle_increment) {
> - dest->cpu_throttle_increment = params->cpu_throttle_increment;
> + /* free memory from pointers that are about to be assigned */
> + if (src->has_block_bitmap_mapping) {
> + g_clear_pointer(&dst->block_bitmap_mapping,
> + qapi_free_BitmapMigrationNodeAliasList);
> }
>
> - if (params->has_cpu_throttle_tailslow) {
> - dest->cpu_throttle_tailslow = params->cpu_throttle_tailslow;
> + if (src->tls_creds) {
> + g_clear_pointer(&dst->tls_creds, qapi_free_StrOrNull);
> }
>
> - if (params->tls_creds) {
> - qapi_free_StrOrNull(dest->tls_creds);
> - dest->tls_creds = QAPI_CLONE(StrOrNull, params->tls_creds);
> + if (src->tls_hostname) {
> + g_clear_pointer(&dst->tls_hostname, qapi_free_StrOrNull);
> }
>
> - if (params->tls_hostname) {
> - qapi_free_StrOrNull(dest->tls_hostname);
> - dest->tls_hostname = QAPI_CLONE(StrOrNull, params->tls_hostname);
> + if (src->tls_authz) {
> + g_clear_pointer(&dst->tls_authz, qapi_free_StrOrNull);
> }
These will still be error prone when introducing new parameters that needs
explicit frees. It'll be nice if QAPI_MERGE() can free the elements when
present in dest and when to be replaced.
But this is good enough, let's land this series first..
Reviewed-by: Peter Xu <[email protected]>
--
Peter Xu