Thank you Michal
---
Best wishes
Yi Wang
原始邮件
发件人: <mprivozn@xxxxxxxxxx>;
收件人:汪翼10129963; <libvir-list@xxxxxxxxxx>;
抄送人:刘建军10033482;徐熙00121931;
日 期 :2017年05月24日 23:00
主 题 :Re: [libvirt] [PATCH] qemu: Fix memory leak inqemuDomainUpdateMemoryDeviceInfo
On 05/25/2017 04:20 AM, Yi Wang wrote:
> The @meminfo allocated in qemuMonitorGetMemoryDeviceInfo may be lost when
> exit monitor failed. Luckily we can free it according to rc.
>
> Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx>
> ---
> src/qemu/qemu_domain.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index c8dc748..c34ec5a 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -5767,8 +5767,11 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
>
> rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo);
>
> - if (qemuDomainObjExitMonitor(driver, vm) < 0)
> + if (qemuDomainObjExitMonitor(driver, vm) < 0) {
> + if (0 == rc)
We don't use this style in libvirt. Moreover, there's no real need for
the check as virHashFree() accepts NULL happily.
> + virHashFree(meminfo);
> return -1;
> + }
>
> /* if qemu doesn't support the info request, just carry on */
> if (rc == -2)
>
I've fixed that, ACKed and pushed.
Michal
> The @meminfo allocated in qemuMonitorGetMemoryDeviceInfo may be lost when
> exit monitor failed. Luckily we can free it according to rc.
>
> Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx>
> ---
> src/qemu/qemu_domain.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index c8dc748..c34ec5a 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -5767,8 +5767,11 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
>
> rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo);
>
> - if (qemuDomainObjExitMonitor(driver, vm) < 0)
> + if (qemuDomainObjExitMonitor(driver, vm) < 0) {
> + if (0 == rc)
We don't use this style in libvirt. Moreover, there's no real need for
the check as virHashFree() accepts NULL happily.
> + virHashFree(meminfo);
> return -1;
> + }
>
> /* if qemu doesn't support the info request, just carry on */
> if (rc == -2)
>
I've fixed that, ACKed and pushed.
Michal
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list