qemu: Translate feature names from query-cpu-model-expansion

By default query-cpu-model-expansion only reports canonical names of all
CPU features. We do some magic and call the command twice to get all
possible spellings of the features, but being able to consume canonical
names will allow us to drop this magic.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2019-06-17 13:54:53 +02:00
parent 5030a7450b
commit ec232c5ddc
3 changed files with 14 additions and 10 deletions

View File

@ -2961,11 +2961,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
for (i = 0; i < modelInfo->nprops; i++) {
virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
continue;
if (VIR_STRDUP(feature->name, prop->name) < 0)
if (VIR_STRDUP(feature->name, name) < 0)
return -1;
if (!prop->value.boolean ||
@ -2981,7 +2982,8 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
virCPUDataPtr
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
qemuMonitorCPUModelInfoPtr model,
bool migratable)
{
unsigned long long sigFamily = 0;
@ -2996,6 +2998,7 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
for (i = 0; i < model->nprops; i++) {
qemuMonitorCPUPropertyPtr prop = model->props + i;
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
switch (prop->type) {
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
@ -3003,23 +3006,23 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
continue;
if (virCPUx86DataAddFeature(data, prop->name) < 0)
if (virCPUx86DataAddFeature(data, name) < 0)
goto cleanup;
break;
case QEMU_MONITOR_CPU_PROPERTY_STRING:
if (STREQ(prop->name, "vendor") &&
if (STREQ(name, "vendor") &&
virCPUx86DataSetVendor(data, prop->value.string) < 0)
goto cleanup;
break;
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
if (STREQ(prop->name, "family"))
if (STREQ(name, "family"))
sigFamily = prop->value.number;
else if (STREQ(prop->name, "model"))
else if (STREQ(name, "model"))
sigModel = prop->value.number;
else if (STREQ(prop->name, "stepping"))
else if (STREQ(name, "stepping"))
sigStepping = prop->value.number;
break;
@ -3057,7 +3060,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
if (!model)
return 1;
if (!(data = virQEMUCapsGetCPUModelX86Data(model, migratable)))
if (!(data = virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratable)))
goto cleanup;
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)

View File

@ -77,7 +77,8 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
qemuMonitorCPUModelInfoPtr modelInfo);
virCPUDataPtr
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
qemuMonitorCPUModelInfoPtr model,
bool migratable);
virCPUDefPtr

View File

@ -935,7 +935,7 @@ cpuTestJSONSignature(const void *arg)
goto cleanup;
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
if (!(hostData = virQEMUCapsGetCPUModelX86Data(modelInfo, false)))
if (!(hostData = virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, false)))
goto cleanup;
ret = cpuTestCompareSignature(data, hostData);