c480ed
From deeb15a330b987612c8f50df1de8b2acfc2ed703 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <deeb15a330b987612c8f50df1de8b2acfc2ed703@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:25:05 +0200
c480ed
Subject: [PATCH] qemu_capabilities: Use virQEMUCapsGetCPUModelInfo
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Most places in qemu_capabilities.c which call virQEMUCapsGetHostCPUData
c480ed
actually need qemuMonitorCPUModelInfoPtr from QEMU caps. Let's use the
c480ed
wrapper introduced in the previous commit instead.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit 793a9293caabc9876bf7734150ba3acdd85d1649)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <6d9804c79ffda5aed3e1ac772b7cc003e930490d.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_capabilities.c | 31 ++++++++++++++-----------------
c480ed
 1 file changed, 14 insertions(+), 17 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c480ed
index 942cbf272d..851cb73cfc 100644
c480ed
--- a/src/qemu/qemu_capabilities.c
c480ed
+++ b/src/qemu/qemu_capabilities.c
c480ed
@@ -2395,7 +2395,6 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
c480ed
     const char *model;
c480ed
     qemuMonitorCPUModelExpansionType type;
c480ed
     virDomainVirtType virtType;
c480ed
-    virQEMUCapsHostCPUDataPtr cpuData;
c480ed
     int ret = -1;
c480ed
 
c480ed
     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
c480ed
@@ -2409,8 +2408,6 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
c480ed
         model = "host";
c480ed
     }
c480ed
 
c480ed
-    cpuData = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
c480ed
-
c480ed
     /* Some x86_64 features defined in cpu_map.xml use spelling which differ
c480ed
      * from the one preferred by QEMU. Static expansion would give us only the
c480ed
      * preferred spelling, thus we need to do a full expansion on the result of
c480ed
@@ -2462,7 +2459,8 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
c480ed
         modelInfo->migratability = true;
c480ed
     }
c480ed
 
c480ed
-    VIR_STEAL_PTR(cpuData->info, modelInfo);
c480ed
+    virQEMUCapsSetCPUModelInfo(qemuCaps, virtType, modelInfo);
c480ed
+    modelInfo = NULL;
c480ed
     ret = 0;
c480ed
 
c480ed
  cleanup:
c480ed
@@ -2487,24 +2485,24 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
c480ed
                           bool migratable,
c480ed
                           char ***features)
c480ed
 {
c480ed
-    virQEMUCapsHostCPUDataPtr data;
c480ed
+    qemuMonitorCPUModelInfoPtr modelInfo;
c480ed
     char **list;
c480ed
     size_t i;
c480ed
     size_t n;
c480ed
     int ret = -1;
c480ed
 
c480ed
     *features = NULL;
c480ed
-    data = virQEMUCapsGetHostCPUData(qemuCaps, virtType);
c480ed
+    modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
c480ed
 
c480ed
-    if (!data->info)
c480ed
+    if (!modelInfo)
c480ed
         return 0;
c480ed
 
c480ed
-    if (VIR_ALLOC_N(list, data->info->nprops + 1) < 0)
c480ed
+    if (VIR_ALLOC_N(list, modelInfo->nprops + 1) < 0)
c480ed
         return -1;
c480ed
 
c480ed
     n = 0;
c480ed
-    for (i = 0; i < data->info->nprops; i++) {
c480ed
-        qemuMonitorCPUPropertyPtr prop = data->info->props + i;
c480ed
+    for (i = 0; i < modelInfo->nprops; i++) {
c480ed
+        qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
c480ed
 
c480ed
         if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
c480ed
             continue;
c480ed
@@ -2514,7 +2512,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
c480ed
     }
c480ed
 
c480ed
     VIR_STEAL_PTR(*features, list);
c480ed
-    if (migratable && !data->info->migratability)
c480ed
+    if (migratable && !modelInfo->migratability)
c480ed
         ret = 1;
c480ed
     else
c480ed
         ret = 0;
c480ed
@@ -2915,17 +2913,17 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
c480ed
                         virCPUDefPtr cpu,
c480ed
                         bool migratable)
c480ed
 {
c480ed
-    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
c480ed
+    qemuMonitorCPUModelInfoPtr modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
c480ed
     int ret = 1;
c480ed
 
c480ed
-    if (migratable && cpuData->info && !cpuData->info->migratability)
c480ed
+    if (migratable && modelInfo && !modelInfo->migratability)
c480ed
         return 1;
c480ed
 
c480ed
     if (ARCH_IS_S390(qemuCaps->arch)) {
c480ed
-        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpuData->info,
c480ed
+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, modelInfo,
c480ed
                                           cpu, migratable);
c480ed
     } else if (ARCH_IS_X86(qemuCaps->arch)) {
c480ed
-        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpuData->info,
c480ed
+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, modelInfo,
c480ed
                                          cpu, migratable);
c480ed
     }
c480ed
 
c480ed
@@ -3655,8 +3653,7 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
c480ed
                                   virBufferPtr buf,
c480ed
                                   virDomainVirtType type)
c480ed
 {
c480ed
-    virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
c480ed
-    qemuMonitorCPUModelInfoPtr model = cpuData->info;
c480ed
+    qemuMonitorCPUModelInfoPtr model = virQEMUCapsGetCPUModelInfo(qemuCaps, type);
c480ed
     const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
c480ed
     size_t i;
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed