[PATCH v2 1/3] spapr_pci: Fix memory leak of vmstate_spapr_pci

2020-12-28 Thread g00517791
From: Jinhao Gao When VM migrate VMState of spapr_pci, the field(msi_devs) of spapr_pci having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free memory of msi_devs in SaveStateEntry of spapr_pci after QEMUFile save VMState of spapr_pci, it may result in memory leak of msi_devs.

[PATCH v2 3/3] vmstate: Fix memory leak in vmstate_handle_alloc()

2020-12-28 Thread g00517791
From: Jinhao Gao Some memory allocated for fields having a flag of VMS_ALLOC in SaveState may not free before VM load vmsd in migration. So we pre-free memory before allocation in vmstate_handle_alloc() to avoid memleaks. Signed-off-by: Jinhao Gao Signed-off-by: Michael S. Tsirkin --- migrati

[PATCH v2 2/3] savevm: Fix memory leak of vmstate_configuration

2020-12-28 Thread g00517791
From: Jinhao Gao When VM migrate VMState of configuration, the fields(name and capabilities) of configuration having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free memory of capabilities in SaveState after save VMState of configuration, or the dst doesn't free memory of name

[PATCH v2 0/3] Fix memory leak of some device state in migration

2020-12-28 Thread g00517791
From: Jinhao Gao For some device state having some fields of VMS_ALLOC flag, they don't free memory allocated for the fields in vmstate_save_state and vmstate_load_state. We add funcs or sentences of free memory before and after VM saves or loads device state to avoid memory leak. v2 - Drop pat

[PATCH 6/8] vmbus: Fix memory leak of vmstate_vmbus_chan_req

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of vmbus/vmbus_chan_req, the field(msg) of vmbus/vmbus_chan_req having a flag of VMS_ALLOC needs to allocate memory. If the dst doesn't free memory which has been allocated for SaveStateEntry of vmbus/vmbus_chan_req before dst loads device state, it may re

[PATCH 3/8] spapr: Fix memory leak of vmstate_spapr_event_entry

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of spapr_event_log_entry, the field(extended_log) of spapr_event_log_entry having a flag of VMS_ALLOC needs to allocate memory. If the dst doesn't free memory which has been allocated for SaveStateEntry of spapr_event_log_entry before dst loads device stat

[PATCH 4/8] spapr_pci: Fix memory leak of vmstate_spapr_pci

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of spapr_pci, the field(msi_devs) of spapr_pci having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free memory of msi_devs in SaveStateEntry of spapr_pci after QEMUFile save VMState of spapr_pci, it may result in memory leak of msi_devs.

[PATCH 8/8] dbus-vmstate: Fix memory leak of dbus_vmstate

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of dbus_vmstate, the field(data) of dbus_vmstate having a flag of VMS_ALLOC needs to allocate memory. If the dst doesn't free memory which has been allocated for SaveStateEntry of dbus_vmstate before dst loads device state, it may result that the pointer o

[PATCH 1/8] vmbus: Fix memory leak of vmstate_gpadl

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of vmbus/gpadl, the field(gfns) of vmbus/ gpadl having a flag of VMS_ALLOC needs to allocate memory. If the dst doesn't free memory which has been allocated for SaveStateEntry of vmbus/gpadl before dst loads device state, it may result that the pointer of

[PATCH 5/8] savevm: Fix memory leak of vmstate_configuration

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of configuration, the fields(name and capabilities) of configuration having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free memory of capabilities in SaveState after save VMState of configuration, or the dst doesn't free memory of name

[PATCH 7/8] tpm_emulator: Fix memory leak of vmstate_tpm_emulator

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of tpm-emulator, the fields(state_blobs. permanent.buffer, state_blobs.volatil.buffer and state_blobs.savestate. buffer) of tpm-emulator having a flag of VMS_ALLOC need to allocate memory. If the dst doesn't free memory which has been allocated for SaveSta

[PATCH 2/8] virtio-net: Fix memory leak of vmstate_virtio_net_rss

2020-12-26 Thread g00517791
From: Jinhao Gao When VM migrate VMState of virtio-net-device/rss, the field(rss_data. indirections_table) of virtio-net-device/rss having a flag of VMS_ALLOC needs to allocate memory. If the dst doesn't free memory which has bee n allocated for SaveStateEntry of virtio-net-device/rss before dst

[PATCH 0/8] Fix memory leak of some device state in migration

2020-12-26 Thread g00517791
From: Jinhao Gao For some device state having some fields of VMS_ALLOC flag, they don't free memory allocated for the fields in vmstate_save_state and vmstate _load_state. We add funcs or sentences of free memory before allocation of memory or after load of memory to avoid memory leak. Jinhao