[PATCH] qemu: fix memleaks in qemuDomainAttachDeviceLive()

Michal Privoznik mprivozn at redhat.com
Mon Jul 13 20:04:26 UTC 2020


On 7/13/20 11:39 AM, Jin Yan wrote:
>  From e46e168f9767b8b291f23217fc7a62163c82eaf8 Mon Sep 17 00:00:00 2001
> From: Jin Yan <jinyan12 at huawei.com>
> Date: Tue, 7 Jul 2020 21:58:52 +0800
> Subject: [PATCH] qemu: fix memleaks in qemuDomainAttachDeviceLive()
> 
> During disk hotplugging, qemuDomainAttachDeviceLive() add the new
> disk to the device list of the VM object. However, hotplugging
> cdroms and floppies only updates the src variable of the original
> disk device, so the newly generated disk object needs to be released.
> 
> Signed-off-by: Jin Yan <jinyan12 at huawei.com>
> ---
>   src/qemu/qemu_hotplug.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 3954ad1109..40092b499d 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1115,6 +1115,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr 
> driver,
>               return -1;
> 
>           disk->src = NULL;
> +        virDomainDiskDefFree(disk);
>           return 0;
>       }
> 

This patch is corrupted, please use git-send-email next time. But since 
the diff is trivial to apply I did the change by hand.

Nice catch! Pushed.

Reviewed-by: Michal Privoznik <mprivozn at redhat.com>

Congratulations on your first libvirt contribution!

Michal




More information about the libvir-list mailing list