render / rpms / libvirt

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