From 5ad5d48df150a4025eb7628596f3715ba4a91eb1 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 30 Jul 2021 10:34:50 +0200
Subject: [PATCH 098/108] tests: Don't leak cpu defs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There are cpu definitions that are allocated in
qemuTestDriverInit() but are missing corresponding
virCPUDefFree() call in qemuTestDriverFree(). It's safe to call
the free function because the definitions contain a refcounter
and thus even if they were still in use the refcounter would be
just decreased.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 73890139bfa248e3a714feb5566144510c3e97dc)
---
 tests/testutilsqemu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 6c43f07015..0e932877e8 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -317,6 +317,11 @@ void qemuTestDriverFree(virQEMUDriver *driver)
     virObjectUnref(driver->caps);
     virObjectUnref(driver->config);
     virObjectUnref(driver->securityManager);
+
+    virCPUDefFree(cpuDefault);
+    virCPUDefFree(cpuHaswell);
+    virCPUDefFree(cpuPower8);
+    virCPUDefFree(cpuPower9);
 }
 
 int qemuTestCapsCacheInsert(virFileCachePtr cache,
-- 
2.33.0

