Leonardo Brás <leob...@redhat.com> wrote:

...

>> @@ -712,6 +726,7 @@ static void *multifd_send_thread(void *opaque)
>>              qemu_mutex_lock(&p->mutex);
>>              p->num_packets++;
>>              p->total_normal_pages += p->normal_num;
>> +            p->total_zero_pages += p->zero_num;
>
> I can see it getting declared, incremented and used. But where is it 
> initialized
> in zero? I mean, should it not have 'p->total_normal_pages = 0;' somewhere in
> setup?

int multifd_save_setup(Error **errp)
{
    ....

    thread_count = migrate_multifd_channels();
    multifd_send_state = g_malloc0(sizeof(*multifd_send_state));
    multifd_send_state->params = g_new0(MultiFDSendParams, thread_count);

You can see here, that we setup everything to zero.  We only need to
initialize explicitely whatever is not zero.


> (I understand multifd_save_setup() allocates a multifd_send_state->params with
> g_new0(),but other variables are zeroed there, like p->pending_job and 
> p->write_flags, so why not?)   

Humm, I think that it is better to do it the other way around.  Remove
the initilazations that are not zero.  That way we only put whatever is
not zero.


Thanks, Juan.


Reply via email to