render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From deeb15a330b987612c8f50df1de8b2acfc2ed703 Mon Sep 17 00:00:00 2001
Message-Id: <deeb15a330b987612c8f50df1de8b2acfc2ed703@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:25:05 +0200
Subject: [PATCH] qemu_capabilities: Use virQEMUCapsGetCPUModelInfo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Most places in qemu_capabilities.c which call virQEMUCapsGetHostCPUData
actually need qemuMonitorCPUModelInfoPtr from QEMU caps. Let's use the
wrapper introduced in the previous commit instead.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 793a9293caabc9876bf7734150ba3acdd85d1649)

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <6d9804c79ffda5aed3e1ac772b7cc003e930490d.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_capabilities.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 942cbf272d..851cb73cfc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2395,7 +2395,6 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
     const char *model;
     qemuMonitorCPUModelExpansionType type;
     virDomainVirtType virtType;
-    virQEMUCapsHostCPUDataPtr cpuData;
     int ret = -1;
 
     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
@@ -2409,8 +2408,6 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
         model = "host";
     }
 
-    cpuData = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
-
     /* Some x86_64 features defined in cpu_map.xml use spelling which differ
      * from the one preferred by QEMU. Static expansion would give us only the
      * preferred spelling, thus we need to do a full expansion on the result of
@@ -2462,7 +2459,8 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
         modelInfo->migratability = true;
     }
 
-    VIR_STEAL_PTR(cpuData->info, modelInfo);
+    virQEMUCapsSetCPUModelInfo(qemuCaps, virtType, modelInfo);
+    modelInfo = NULL;
     ret = 0;
 
  cleanup:
@@ -2487,24 +2485,24 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
                           bool migratable,
                           char ***features)
 {
-    virQEMUCapsHostCPUDataPtr data;
+    qemuMonitorCPUModelInfoPtr modelInfo;
     char **list;
     size_t i;
     size_t n;
     int ret = -1;
 
     *features = NULL;
-    data = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
+    modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
 
-    if (!data->info)
+    if (!modelInfo)
         return 0;
 
-    if (VIR_ALLOC_N(list, data->info->nprops + 1) < 0)
+    if (VIR_ALLOC_N(list, modelInfo->nprops + 1) < 0)
         return -1;
 
     n = 0;
-    for (i = 0; i < data->info->nprops; i++) {
-        qemuMonitorCPUPropertyPtr prop = data->info->props + i;
+    for (i = 0; i < modelInfo->nprops; i++) {
+        qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
 
         if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
             continue;
@@ -2514,7 +2512,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
     }
 
     VIR_STEAL_PTR(*features, list);
-    if (migratable && !data->info->migratability)
+    if (migratable && !modelInfo->migratability)
         ret = 1;
     else
         ret = 0;
@@ -2915,17 +2913,17 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
                         virCPUDefPtr cpu,
                         bool migratable)
 {
-    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
+    qemuMonitorCPUModelInfoPtr modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
     int ret = 1;
 
-    if (migratable && cpuData->info && !cpuData->info->migratability)
+    if (migratable && modelInfo && !modelInfo->migratability)
         return 1;
 
     if (ARCH_IS_S390(qemuCaps->arch)) {
-        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpuData->info,
+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, modelInfo,
                                           cpu, migratable);
     } else if (ARCH_IS_X86(qemuCaps->arch)) {
-        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpuData->info,
+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, modelInfo,
                                          cpu, migratable);
     }
 
@@ -3655,8 +3653,7 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
                                   virBufferPtr buf,
                                   virDomainVirtType type)
 {
-    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
-    qemuMonitorCPUModelInfoPtr model = cpuData->info;
+    qemuMonitorCPUModelInfoPtr model = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
     const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
     size_t i;
 
-- 
2.22.0