mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
migration/multifd: Add an explicit MultiFDSendData destructor
This way if there are fields there that needs explicit disposal (like, for example, some attached buffers) they will be handled appropriately. Add a related assert to multifd_set_payload_type() in order to make sure that this function is only used to fill a previously empty MultiFDSendData with some payload, not the other way around. Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> Link: https://lore.kernel.org/qemu-devel/6755205f2b95abbed251f87061feee1c0e410836.1741124640.git.maciej.szmigiero@oracle.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
d19cc4dca0
commit
7ecfab1ddd
3 changed files with 34 additions and 5 deletions
|
@ -123,6 +123,32 @@ MultiFDSendData *multifd_send_data_alloc(void)
|
|||
return g_malloc0(size_minus_payload + max_payload_size);
|
||||
}
|
||||
|
||||
void multifd_send_data_clear(MultiFDSendData *data)
|
||||
{
|
||||
if (multifd_payload_empty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (data->type) {
|
||||
default:
|
||||
/* Nothing to do */
|
||||
break;
|
||||
}
|
||||
|
||||
data->type = MULTIFD_PAYLOAD_NONE;
|
||||
}
|
||||
|
||||
void multifd_send_data_free(MultiFDSendData *data)
|
||||
{
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
multifd_send_data_clear(data);
|
||||
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static bool multifd_use_packets(void)
|
||||
{
|
||||
return !migrate_mapped_ram();
|
||||
|
@ -496,8 +522,7 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp)
|
|||
qemu_sem_destroy(&p->sem_sync);
|
||||
g_free(p->name);
|
||||
p->name = NULL;
|
||||
g_free(p->data);
|
||||
p->data = NULL;
|
||||
g_clear_pointer(&p->data, multifd_send_data_free);
|
||||
p->packet_len = 0;
|
||||
g_free(p->packet);
|
||||
p->packet = NULL;
|
||||
|
@ -695,7 +720,7 @@ static void *multifd_send_thread(void *opaque)
|
|||
(uint64_t)p->next_packet_size + p->packet_len);
|
||||
|
||||
p->next_packet_size = 0;
|
||||
multifd_set_payload_type(p->data, MULTIFD_PAYLOAD_NONE);
|
||||
multifd_send_data_clear(p->data);
|
||||
|
||||
/*
|
||||
* Making sure p->data is published before saying "we're
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue