render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c480ed
From f047006a60d92f9c5e66ac9c2c532f8ac4c2ba28 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <f047006a60d92f9c5e66ac9c2c532f8ac4c2ba28@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:25:56 +0200
c480ed
Subject: [PATCH] qemu: Translate feature names from query-cpu-model-expansion
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
By default query-cpu-model-expansion only reports canonical names of all
c480ed
CPU features. We do some magic and call the command twice to get all
c480ed
possible spellings of the features, but being able to consume canonical
c480ed
names will allow us to drop this magic.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit ec232c5ddc3cc47651a815dcf4cff7cd31910b3e)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <5a50943665bc9df69bb99c25763f0b99a7364d8c.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_capabilities.c | 19 +++++++++++--------
c480ed
 src/qemu/qemu_capspriv.h     |  3 ++-
c480ed
 tests/cputest.c              |  2 +-
c480ed
 3 files changed, 14 insertions(+), 10 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c480ed
index c48d66b39b..88c651ea7b 100644
c480ed
--- a/src/qemu/qemu_capabilities.c
c480ed
+++ b/src/qemu/qemu_capabilities.c
c480ed
@@ -2868,11 +2868,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
c480ed
     for (i = 0; i < modelInfo->nprops; i++) {
c480ed
         virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
c480ed
         qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
c480ed
+        const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
c480ed
 
c480ed
         if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
c480ed
             continue;
c480ed
 
c480ed
-        if (VIR_STRDUP(feature->name, prop->name) < 0)
c480ed
+        if (VIR_STRDUP(feature->name, name) < 0)
c480ed
             return -1;
c480ed
 
c480ed
         if (!prop->value.boolean ||
c480ed
@@ -2888,7 +2889,8 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
c480ed
 
c480ed
 
c480ed
 virCPUDataPtr
c480ed
-virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
c480ed
+virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
c480ed
+                              qemuMonitorCPUModelInfoPtr model,
c480ed
                               bool migratable)
c480ed
 {
c480ed
     unsigned long long sigFamily = 0;
c480ed
@@ -2903,6 +2905,7 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
c480ed
 
c480ed
     for (i = 0; i < model->nprops; i++) {
c480ed
         qemuMonitorCPUPropertyPtr prop = model->props + i;
c480ed
+        const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
c480ed
 
c480ed
         switch (prop->type) {
c480ed
         case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
c480ed
@@ -2910,23 +2913,23 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
c480ed
                 (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
c480ed
                 continue;
c480ed
 
c480ed
-            if (virCPUx86DataAddFeature(data, prop->name) < 0)
c480ed
+            if (virCPUx86DataAddFeature(data, name) < 0)
c480ed
                 goto cleanup;
c480ed
 
c480ed
             break;
c480ed
 
c480ed
         case QEMU_MONITOR_CPU_PROPERTY_STRING:
c480ed
-            if (STREQ(prop->name, "vendor") &&
c480ed
+            if (STREQ(name, "vendor") &&
c480ed
                 virCPUx86DataSetVendor(data, prop->value.string) < 0)
c480ed
                 goto cleanup;
c480ed
             break;
c480ed
 
c480ed
         case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
c480ed
-            if (STREQ(prop->name, "family"))
c480ed
+            if (STREQ(name, "family"))
c480ed
                 sigFamily = prop->value.number;
c480ed
-            else if (STREQ(prop->name, "model"))
c480ed
+            else if (STREQ(name, "model"))
c480ed
                 sigModel = prop->value.number;
c480ed
-            else if (STREQ(prop->name, "stepping"))
c480ed
+            else if (STREQ(name, "stepping"))
c480ed
                 sigStepping = prop->value.number;
c480ed
             break;
c480ed
 
c480ed
@@ -2964,7 +2967,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
c480ed
     if (!model)
c480ed
         return 1;
c480ed
 
c480ed
-    if (!(data = virQEMUCapsGetCPUModelX86Data(model, migratable)))
c480ed
+    if (!(data = virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratable)))
c480ed
         goto cleanup;
c480ed
 
c480ed
     if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
c480ed
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
c480ed
index c3b7f934a9..b17deb01d7 100644
c480ed
--- a/src/qemu/qemu_capspriv.h
c480ed
+++ b/src/qemu/qemu_capspriv.h
c480ed
@@ -85,7 +85,8 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
c480ed
                            qemuMonitorCPUModelInfoPtr modelInfo);
c480ed
 
c480ed
 virCPUDataPtr
c480ed
-virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
c480ed
+virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
c480ed
+                              qemuMonitorCPUModelInfoPtr model,
c480ed
                               bool migratable);
c480ed
 
c480ed
 virCPUDefPtr
c480ed
diff --git a/tests/cputest.c b/tests/cputest.c
c480ed
index e62cda34b7..1ce50caccd 100644
c480ed
--- a/tests/cputest.c
c480ed
+++ b/tests/cputest.c
c480ed
@@ -941,7 +941,7 @@ cpuTestJSONSignature(const void *arg)
c480ed
         goto cleanup;
c480ed
 
c480ed
     modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
c480ed
-    if (!(hostData = virQEMUCapsGetCPUModelX86Data(modelInfo, false)))
c480ed
+    if (!(hostData = virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, false)))
c480ed
         goto cleanup;
c480ed
 
c480ed
     ret = cpuTestCompareSignature(data, hostData);
c480ed
-- 
c480ed
2.22.0
c480ed