mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
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:
parent
5030a7450b
commit
ec232c5ddc
@ -2961,11 +2961,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
|||||||
for (i = 0; i < modelInfo->nprops; i++) {
|
for (i = 0; i < modelInfo->nprops; i++) {
|
||||||
virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
|
virCPUFeatureDefPtr feature = cpu->features + cpu->nfeatures;
|
||||||
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
|
qemuMonitorCPUPropertyPtr prop = modelInfo->props + i;
|
||||||
|
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
|
||||||
|
|
||||||
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
|
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (VIR_STRDUP(feature->name, prop->name) < 0)
|
if (VIR_STRDUP(feature->name, name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!prop->value.boolean ||
|
if (!prop->value.boolean ||
|
||||||
@ -2981,7 +2982,8 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
|
|
||||||
virCPUDataPtr
|
virCPUDataPtr
|
||||||
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
||||||
|
qemuMonitorCPUModelInfoPtr model,
|
||||||
bool migratable)
|
bool migratable)
|
||||||
{
|
{
|
||||||
unsigned long long sigFamily = 0;
|
unsigned long long sigFamily = 0;
|
||||||
@ -2996,6 +2998,7 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
|||||||
|
|
||||||
for (i = 0; i < model->nprops; i++) {
|
for (i = 0; i < model->nprops; i++) {
|
||||||
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
qemuMonitorCPUPropertyPtr prop = model->props + i;
|
||||||
|
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
|
||||||
|
|
||||||
switch (prop->type) {
|
switch (prop->type) {
|
||||||
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:
|
||||||
@ -3003,23 +3006,23 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
|||||||
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
(migratable && prop->migratable == VIR_TRISTATE_BOOL_NO))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virCPUx86DataAddFeature(data, prop->name) < 0)
|
if (virCPUx86DataAddFeature(data, name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
case QEMU_MONITOR_CPU_PROPERTY_STRING:
|
||||||
if (STREQ(prop->name, "vendor") &&
|
if (STREQ(name, "vendor") &&
|
||||||
virCPUx86DataSetVendor(data, prop->value.string) < 0)
|
virCPUx86DataSetVendor(data, prop->value.string) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
case QEMU_MONITOR_CPU_PROPERTY_NUMBER:
|
||||||
if (STREQ(prop->name, "family"))
|
if (STREQ(name, "family"))
|
||||||
sigFamily = prop->value.number;
|
sigFamily = prop->value.number;
|
||||||
else if (STREQ(prop->name, "model"))
|
else if (STREQ(name, "model"))
|
||||||
sigModel = prop->value.number;
|
sigModel = prop->value.number;
|
||||||
else if (STREQ(prop->name, "stepping"))
|
else if (STREQ(name, "stepping"))
|
||||||
sigStepping = prop->value.number;
|
sigStepping = prop->value.number;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3057,7 +3060,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|||||||
if (!model)
|
if (!model)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!(data = virQEMUCapsGetCPUModelX86Data(model, migratable)))
|
if (!(data = virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratable)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
||||||
|
@ -77,7 +77,8 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|||||||
qemuMonitorCPUModelInfoPtr modelInfo);
|
qemuMonitorCPUModelInfoPtr modelInfo);
|
||||||
|
|
||||||
virCPUDataPtr
|
virCPUDataPtr
|
||||||
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
|
||||||
|
qemuMonitorCPUModelInfoPtr model,
|
||||||
bool migratable);
|
bool migratable);
|
||||||
|
|
||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
|
@ -935,7 +935,7 @@ cpuTestJSONSignature(const void *arg)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
|
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
|
||||||
if (!(hostData = virQEMUCapsGetCPUModelX86Data(modelInfo, false)))
|
if (!(hostData = virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = cpuTestCompareSignature(data, hostData);
|
ret = cpuTestCompareSignature(data, hostData);
|
||||||
|
Loading…
Reference in New Issue
Block a user