Blob Blame History Raw
From 393675b4e08f2ff8a685d9bd02a83079d32e6eee Mon Sep 17 00:00:00 2001
Message-Id: <393675b4e08f2ff8a685d9bd02a83079d32e6eee@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 7 Apr 2017 17:43:59 +0200
Subject: [PATCH] qemu: Introduce virQEMUCapsHostCPUDataClear

To keep freeing of host CPU data in one place.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit b0605e848724c5dc478382398b734398abff674c)

https://bugzilla.redhat.com/show_bug.cgi?id=1444421

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_capabilities.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 98a9a0f1d..8e7cbb590 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2112,6 +2112,21 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
 }
 
 
+static void
+virQEMUCapsHostCPUDataClear(virQEMUCapsPtr qemuCaps)
+{
+    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
+    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
+    qemuCaps->kvmCPUModelInfo = NULL;
+    qemuCaps->tcgCPUModelInfo = NULL;
+
+    virCPUDefFree(qemuCaps->kvmCPUModel);
+    virCPUDefFree(qemuCaps->tcgCPUModel);
+    qemuCaps->kvmCPUModel = NULL;
+    qemuCaps->tcgCPUModel = NULL;
+}
+
+
 virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
 {
     virQEMUCapsPtr ret = virQEMUCapsNew();
@@ -2198,10 +2213,7 @@ void virQEMUCapsDispose(void *obj)
 
     VIR_FREE(qemuCaps->gicCapabilities);
 
-    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
-    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
-    virCPUDefFree(qemuCaps->kvmCPUModel);
-    virCPUDefFree(qemuCaps->tcgCPUModel);
+    virQEMUCapsHostCPUDataClear(qemuCaps);
 }
 
 void
@@ -4074,15 +4086,7 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps)
     VIR_FREE(qemuCaps->gicCapabilities);
     qemuCaps->ngicCapabilities = 0;
 
-    qemuMonitorCPUModelInfoFree(qemuCaps->kvmCPUModelInfo);
-    qemuMonitorCPUModelInfoFree(qemuCaps->tcgCPUModelInfo);
-    qemuCaps->kvmCPUModelInfo = NULL;
-    qemuCaps->tcgCPUModelInfo = NULL;
-
-    virCPUDefFree(qemuCaps->kvmCPUModel);
-    virCPUDefFree(qemuCaps->tcgCPUModel);
-    qemuCaps->kvmCPUModel = NULL;
-    qemuCaps->tcgCPUModel = NULL;
+    virQEMUCapsHostCPUDataClear(qemuCaps);
 }
 
 
-- 
2.12.2