render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From 197373d62cfb74faf62e0b1334afcb73fcf25550 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <197373d62cfb74faf62e0b1334afcb73fcf25550@dist-git>
3e5111
From: Peter Krempa <pkrempa@redhat.com>
3e5111
Date: Fri, 28 Apr 2017 10:45:17 +0200
3e5111
Subject: [PATCH] qemu: process: Don't leak priv->usbaddrs after VM restart
3e5111
3e5111
Since the private data structure is not freed upon stopping a VM, the
3e5111
usbaddrs pointer would be leaked:
3e5111
3e5111
==15388== 136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 893 of 1,019
3e5111
==15388==    at 0x4C2CF55: calloc (vg_replace_malloc.c:711)
3e5111
==15388==    by 0x54BF64A: virAlloc (viralloc.c:144)
3e5111
==15388==    by 0x5547588: virDomainUSBAddressSetCreate (domain_addr.c:1608)
3e5111
==15388==    by 0x144D38A2: qemuDomainAssignUSBAddresses (qemu_domain_address.c:2458)
3e5111
==15388==    by 0x144D38A2: qemuDomainAssignAddresses (qemu_domain_address.c:2515)
3e5111
==15388==    by 0x144ED1E3: qemuProcessPrepareDomain (qemu_process.c:5398)
3e5111
==15388==    by 0x144F51FF: qemuProcessStart (qemu_process.c:5979)
3e5111
[...]
3e5111
3e5111
(cherry picked from commit 3ab802d689796ebac6545267d5db248e13a9a0e6)
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1445627
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_process.c | 4 ++++
3e5111
 1 file changed, 4 insertions(+)
3e5111
3e5111
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
3e5111
index 5d2d0662b..c23982db6 100644
3e5111
--- a/src/qemu/qemu_process.c
3e5111
+++ b/src/qemu/qemu_process.c
3e5111
@@ -6439,6 +6439,10 @@ void qemuProcessStop(virQEMUDriverPtr driver,
3e5111
     virBitmapFree(priv->autoCpuset);
3e5111
     priv->autoCpuset = NULL;
3e5111
 
3e5111
+    /* remove address data */
3e5111
+    virDomainUSBAddressSetFree(priv->usbaddrs);
3e5111
+    priv->usbaddrs = NULL;
3e5111
+
3e5111
     /* The "release" hook cleans up additional resources */
3e5111
     if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
3e5111
         char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
3e5111
-- 
3e5111
2.12.2
3e5111