qemu: fix memleak in qemuDomainAttachDeviceLive()

During disk hot plugging, qemuDomainAttachDeviceLive() adds the new
disk to the device list of the VM object. However, hot plugging
cdroms and floppies only updates the src variable of the original
disk device, so the newly generated disk object needs to be freed.

Signed-off-by: Jin Yan <jinyan12@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jin Yan 2020-07-13 21:24:04 +02:00 committed by Michal Privoznik
parent 7187b8e2b6
commit 2f470a4fb1

View File

@ -1115,6 +1115,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
return -1;
disk->src = NULL;
virDomainDiskDefFree(disk);
return 0;
}