All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [PATCH 1/5] migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply
Date: Thu, 15 Jan 2026 11:26:53 -0300	[thread overview]
Message-ID: <87v7h3lzo2.fsf@suse.de> (raw)
In-Reply-To: <87h5sonkdu.fsf@suse.de>

Fabiano Rosas <farosas@suse.de> writes:

> Peter Xu <peterx@redhat.com> writes:
>
>> On Wed, Jan 14, 2026 at 10:23:05AM -0300, Fabiano Rosas wrote:
>>> Use QAPI_CLONE_MEMBERS instead of making an assignment. The QAPI
>>> method makes the handling of the TLS strings more intuitive because it
>>> clones them as well.
>>
>> The cover letter said this patch didn't change, but it has changed at least
>> somewhere.. anyway, I'm re-reviewing every line here.
>>
>
> Sorry, I forgot I had already addressed your review comments from the
> other series in this patch.
>
>>> 
>>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>>> ---
>>>  migration/options.c | 32 ++++++++++++++++++--------------
>>>  1 file changed, 18 insertions(+), 14 deletions(-)
>>> 
>>> diff --git a/migration/options.c b/migration/options.c
>>> index 9a5a39c886..994e1cc5ac 100644
>>> --- a/migration/options.c
>>> +++ b/migration/options.c
>>> @@ -1264,9 +1264,9 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)
>>>  static void migrate_params_test_apply(MigrationParameters *params,
>>>                                        MigrationParameters *dest)
>>>  {
>>> -    *dest = migrate_get_current()->parameters;
>>> +    MigrationState *s = migrate_get_current();
>>>  
>>> -    /* TODO use QAPI_CLONE() instead of duplicating it inline */
>>> +    QAPI_CLONE_MEMBERS(MigrationParameters, dest, &s->parameters);
>>>  
>>>      if (params->has_throttle_trigger_threshold) {
>>>          dest->throttle_trigger_threshold = params->throttle_trigger_threshold;
>>> @@ -1285,24 +1285,18 @@ static void migrate_params_test_apply(MigrationParameters *params,
>>>      }
>>>  
>>>      if (params->tls_creds) {
>>> +        qapi_free_StrOrNull(dest->tls_creds);
>>>          dest->tls_creds = QAPI_CLONE(StrOrNull, params->tls_creds);
>>> -    } else {
>>> -        /* clear the reference, it's owned by s->parameters */
>>> -        dest->tls_creds = NULL;
>>>      }
>>>  
>>>      if (params->tls_hostname) {
>>> +        qapi_free_StrOrNull(dest->tls_hostname);
>>>          dest->tls_hostname = QAPI_CLONE(StrOrNull, params->tls_hostname);
>>> -    } else {
>>> -        /* clear the reference, it's owned by s->parameters */
>>> -        dest->tls_hostname = NULL;
>>>      }
>>>  
>>>      if (params->tls_authz) {
>>> +        qapi_free_StrOrNull(dest->tls_authz);
>>>          dest->tls_authz = QAPI_CLONE(StrOrNull, params->tls_authz);
>>> -    } else {
>>> -        /* clear the reference, it's owned by s->parameters */
>>> -        dest->tls_authz = NULL;
>>>      }
>>>  
>>>      if (params->has_max_bandwidth) {
>>> @@ -1359,8 +1353,9 @@ static void migrate_params_test_apply(MigrationParameters *params,
>>>      }
>>>  
>>>      if (params->has_block_bitmap_mapping) {
>>> -        dest->has_block_bitmap_mapping = true;
>>> -        dest->block_bitmap_mapping = params->block_bitmap_mapping;
>>> +        qapi_free_BitmapMigrationNodeAliasList(dest->block_bitmap_mapping);
>>> +        dest->block_bitmap_mapping = QAPI_CLONE(BitmapMigrationNodeAliasList,
>>> +                                                params->block_bitmap_mapping);
>>>      }
>>>  
>>>      if (params->has_x_vcpu_dirty_limit_period) {
>>> @@ -1384,7 +1379,8 @@ static void migrate_params_test_apply(MigrationParameters *params,
>>>      }
>>>  
>>>      if (params->has_cpr_exec_command) {
>>> -        dest->cpr_exec_command = params->cpr_exec_command;
>>> +        qapi_free_strList(dest->cpr_exec_command);
>>> +        dest->cpr_exec_command = QAPI_CLONE(strList, params->cpr_exec_command);
>>>      }
>>>  }
>>
>> So we have 5 special cases here, (1-3) for tls, (4) for block bitmap, (5)
>> for cpr-exec-cmd.  All good.
>>
>>>  
>>> @@ -1535,6 +1531,14 @@ void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
>>>      migrate_params_test_apply(params, &tmp);
>>>  
>>>      if (migrate_params_check(&tmp, errp)) {
>>> +        /*
>>> +         * Mark block_bitmap_mapping as present now while we have the
>>> +         * params structure with the user input around.
>>> +         */
>>> +        if (params->has_block_bitmap_mapping) {
>>> +            migrate_get_current()->has_block_bitmap_mapping = true;
>>> +        }
>>
>> Now I'm looking at the lastest master branch, we have:
>>
>> migrate_params_apply():
>>     if (params->has_block_bitmap_mapping) {
>>         qapi_free_BitmapMigrationNodeAliasList(
>>             s->parameters.block_bitmap_mapping);
>>
>>         s->has_block_bitmap_mapping = true;
>>         s->parameters.block_bitmap_mapping =
>>             QAPI_CLONE(BitmapMigrationNodeAliasList,
>>                        params->block_bitmap_mapping);
>>     }
>>
>> Do we really need above change?
>>
>
> It should be in the next patch.
>
>>> +
>>>          migrate_params_apply(params);
>>>          migrate_post_update_params(params, errp);
>>>      }
>>
>> The other thing is, when reaching here, after we have all 5 special cases
>> dynamically allocated, do we need to always free it?
>>
>> We used to do it for the initial (1-3) for tls (in migrate_tls_opts_free()).
>> I think we should also free (4,5) now from &tmp?
>>
>
> Yes!
>

Although, for CPR, the ASAN, valgrind, etc tools will never catch the
leak because of the execvp(). It took me a while to figure that one.

>>> -- 
>>> 2.51.0
>>> 


  reply	other threads:[~2026-01-15 14:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 13:23 [PATCH 0/5] qapi: Use visitors for migration parameters handling Fabiano Rosas
2026-01-14 13:23 ` [PATCH 1/5] migration: Use QAPI_CLONE_MEMBERS in migrate_params_test_apply Fabiano Rosas
2026-01-14 15:10   ` Peter Xu
2026-01-14 18:01     ` Fabiano Rosas
2026-01-15 14:26       ` Fabiano Rosas [this message]
2026-01-14 13:23 ` [PATCH 2/5] migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply Fabiano Rosas
2026-01-21 12:00   ` Prasad Pandit
2026-01-21 12:42     ` Fabiano Rosas
2026-01-22 12:37       ` Prasad Pandit
2026-01-22 14:16         ` Fabiano Rosas
2026-01-21 12:20   ` Prasad Pandit
2026-01-21 21:05     ` Fabiano Rosas
2026-01-22  8:14       ` Prasad Pandit
2026-01-22 14:17         ` Fabiano Rosas
2026-01-14 13:23 ` [PATCH 3/5] qapi: Implement qapi_dealloc_present_visitor Fabiano Rosas
2026-01-14 13:23 ` [PATCH 4/5] qapi: Add QAPI_MERGE Fabiano Rosas
2026-01-14 13:23 ` [PATCH 5/5] migration/options: Use QAPI_MERGE in migrate_params_test_apply Fabiano Rosas
2026-01-21 12:56   ` Prasad Pandit
2026-01-21 22:11     ` Fabiano Rosas
2026-01-22  9:24       ` Prasad Pandit
2026-01-22 14:21         ` Fabiano Rosas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v7h3lzo2.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.