render / rpms / libvirt

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