render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From e10845824c98d0996ced6a8eac5d62ac99ceedd3 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <e10845824c98d0996ced6a8eac5d62ac99ceedd3@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Fri, 7 Apr 2017 17:40:31 +0200
3e5111
Subject: [PATCH] qemu: Move qemuCaps CPU data copying into a separate function
3e5111
3e5111
This introduces virQEMUCapsHostCPUDataCopy which will later be
3e5111
refactored a bit and called twice from virQEMUCapsNewCopy.
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
(cherry picked from commit 8be4346ca5ae4b568b3e8ce3de9cf46f2e94b416)
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1444421
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_capabilities.c | 39 +++++++++++++++++++++++++--------------
3e5111
 1 file changed, 25 insertions(+), 14 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index 2bbc9253a..98a9a0f1d 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -2088,6 +2088,30 @@ virQEMUCapsNew(void)
3e5111
 }
3e5111
 
3e5111
 
3e5111
+static int
3e5111
+virQEMUCapsHostCPUDataCopy(virQEMUCapsPtr dst,
3e5111
+                           virQEMUCapsPtr src)
3e5111
+{
3e5111
+    if (src->kvmCPUModel &&
3e5111
+        !(dst->kvmCPUModel = virCPUDefCopy(src->kvmCPUModel)))
3e5111
+        return -1;
3e5111
+
3e5111
+    if (src->tcgCPUModel &&
3e5111
+        !(dst->tcgCPUModel = virCPUDefCopy(src->tcgCPUModel)))
3e5111
+        return -1;
3e5111
+
3e5111
+    if (src->kvmCPUModelInfo &&
3e5111
+        !(dst->kvmCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->kvmCPUModelInfo)))
3e5111
+        return -1;
3e5111
+
3e5111
+    if (src->tcgCPUModelInfo &&
3e5111
+        !(dst->tcgCPUModelInfo = qemuMonitorCPUModelInfoCopy(src->tcgCPUModelInfo)))
3e5111
+        return -1;
3e5111
+
3e5111
+    return 0;
3e5111
+}
3e5111
+
3e5111
+
3e5111
 virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
3e5111
 {
3e5111
     virQEMUCapsPtr ret = virQEMUCapsNew();
3e5111
@@ -2125,20 +2149,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
3e5111
             goto error;
3e5111
     }
3e5111
 
3e5111
-    if (qemuCaps->kvmCPUModel &&
3e5111
-        !(ret->kvmCPUModel = virCPUDefCopy(qemuCaps->kvmCPUModel)))
3e5111
-        goto error;
3e5111
-
3e5111
-    if (qemuCaps->tcgCPUModel &&
3e5111
-        !(ret->tcgCPUModel = virCPUDefCopy(qemuCaps->tcgCPUModel)))
3e5111
-        goto error;
3e5111
-
3e5111
-    if (qemuCaps->kvmCPUModelInfo &&
3e5111
-        !(ret->kvmCPUModelInfo = qemuMonitorCPUModelInfoCopy(qemuCaps->kvmCPUModelInfo)))
3e5111
-        goto error;
3e5111
-
3e5111
-    if (qemuCaps->tcgCPUModelInfo &&
3e5111
-        !(ret->tcgCPUModelInfo = qemuMonitorCPUModelInfoCopy(qemuCaps->tcgCPUModelInfo)))
3e5111
+    if (virQEMUCapsHostCPUDataCopy(ret, qemuCaps) < 0)
3e5111
         goto error;
3e5111
 
3e5111
     if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
3e5111
-- 
3e5111
2.12.2
3e5111