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@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 19 +++++++++++-------- src/qemu/qemu_capspriv.h | 3 ++- tests/cputest.c | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c742838383..ada2bae18f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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) diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index 3c129cbf6c..255722d8d1 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -78,7 +78,8 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps, qemuMonitorCPUModelInfoPtr modelInfo); virCPUDataPtr -virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model, +virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps, + qemuMonitorCPUModelInfoPtr model, bool migratable); virCPUDefPtr diff --git a/tests/cputest.c b/tests/cputest.c index e176739965..6e28e05756 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -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); -- 2.22.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list