mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
qemu_capabilities: Translate CPU blockers
Since commit "cpu_x86: Disable blockers from unusable CPU models" (v3.8.0-99-g9c9620af1d) we explicitly disable CPU features reported by QEMU as usability blockers for a particular CPU model when creating baseline or host-model CPU definition. When QEMU changed canonical names for some features (mostly those with '_' in their names), we forgot to translate the blocker lists to names used by libvirt and the renamed features would no longer be explicitly disabled in the created CPU model even if they were reported as blockers by QEMU. For example, on a host where EPYC CPU model has the following blockers <blocker name='sha-ni'/> <blocker name='mmxext'/> <blocker name='fxsr-opt'/> <blocker name='cr8legacy'/> <blocker name='sse4a'/> <blocker name='misalignsse'/> <blocker name='osvw'/> we would fail to disable 'fxsr-opt': <cpu mode='custom' match='exact'> <model fallback='forbid'>EPYC</model> <feature policy='disable' name='sha-ni'/> <feature policy='disable' name='mmxext'/> <feature policy='disable' name='cr8legacy'/> <feature policy='disable' name='sse4a'/> <feature policy='disable' name='misalignsse'/> <feature policy='disable' name='osvw'/> <feature policy='disable' name='monitor'/> </cpu> The 'monitor' feature is disabled even though it is not reported as a blocker by QEMU because libvirt's definition of EPYC includes the feature while it is missing in EPYC definition in QEMU. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b9db1ec17d
commit
b0ff3af412
@ -2936,6 +2936,17 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitor *mon,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < defs->ncpus; i++) {
|
||||
qemuMonitorCPUDefInfo *cpu = &defs->cpus[i];
|
||||
char **blocker;
|
||||
|
||||
if (!cpu->blockers)
|
||||
continue;
|
||||
|
||||
for (blocker = cpu->blockers; *blocker; blocker++)
|
||||
virQEMUCapsCPUFeatureFromQEMUInPlace(arch, blocker);
|
||||
}
|
||||
|
||||
*cpuDefs = g_steal_pointer(&defs);
|
||||
return 0;
|
||||
}
|
||||
@ -3483,6 +3494,19 @@ virQEMUCapsCPUFeatureFromQEMU(virArch arch,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virQEMUCapsCPUFeatureFromQEMUInPlace(virArch arch,
|
||||
char **feature)
|
||||
{
|
||||
const char *tmp = virQEMUCapsCPUFeatureFromQEMU(arch, *feature);
|
||||
|
||||
if (tmp != *feature) {
|
||||
VIR_FREE(*feature);
|
||||
*feature = g_strdup(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
||||
* 1 when the caller should fall back to using virCaps *->host.cpu,
|
||||
@ -3907,7 +3931,8 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *caps,
|
||||
|
||||
|
||||
static int
|
||||
virQEMUCapsLoadCPUModels(virQEMUCapsAccel *caps,
|
||||
virQEMUCapsLoadCPUModels(virArch arch,
|
||||
virQEMUCapsAccel *caps,
|
||||
xmlXPathContextPtr ctxt,
|
||||
const char *typeStr)
|
||||
{
|
||||
@ -3978,6 +4003,8 @@ virQEMUCapsLoadCPUModels(virQEMUCapsAccel *caps,
|
||||
"capabilities cache"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
virQEMUCapsCPUFeatureFromQEMUInPlace(arch, &cpu->blockers[j]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4072,7 +4099,7 @@ virQEMUCapsLoadAccel(virQEMUCaps *qemuCaps,
|
||||
if (virQEMUCapsLoadHostCPUModelInfo(caps, ctxt, typeStr) < 0)
|
||||
return -1;
|
||||
|
||||
if (virQEMUCapsLoadCPUModels(caps, ctxt, typeStr) < 0)
|
||||
if (virQEMUCapsLoadCPUModels(qemuCaps->arch, caps, ctxt, typeStr) < 0)
|
||||
return -1;
|
||||
|
||||
if (virQEMUCapsLoadMachines(caps, ctxt, typeStr) < 0)
|
||||
@ -4534,7 +4561,8 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps,
|
||||
|
||||
|
||||
static void
|
||||
virQEMUCapsFormatCPUModels(virQEMUCapsAccel *caps,
|
||||
virQEMUCapsFormatCPUModels(virArch arch,
|
||||
virQEMUCapsAccel *caps,
|
||||
virBuffer *buf,
|
||||
const char *typeStr)
|
||||
{
|
||||
@ -4563,8 +4591,10 @@ virQEMUCapsFormatCPUModels(virQEMUCapsAccel *caps,
|
||||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
|
||||
for (j = 0; cpu->blockers[j]; j++)
|
||||
virBufferAsprintf(buf, "<blocker name='%s'/>\n", cpu->blockers[j]);
|
||||
for (j = 0; cpu->blockers[j]; j++) {
|
||||
virBufferAsprintf(buf, "<blocker name='%s'/>\n",
|
||||
virQEMUCapsCPUFeatureToQEMU(arch, cpu->blockers[j]));
|
||||
}
|
||||
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</cpu>\n");
|
||||
@ -4616,7 +4646,7 @@ virQEMUCapsFormatAccel(virQEMUCaps *qemuCaps,
|
||||
const char *typeStr = virQEMUCapsAccelStr(type);
|
||||
|
||||
virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr);
|
||||
virQEMUCapsFormatCPUModels(caps, buf, typeStr);
|
||||
virQEMUCapsFormatCPUModels(qemuCaps->arch, caps, buf, typeStr);
|
||||
virQEMUCapsFormatMachines(caps, buf, typeStr);
|
||||
|
||||
}
|
||||
|
@ -845,6 +845,10 @@ const char *
|
||||
virQEMUCapsCPUFeatureFromQEMU(virArch arch,
|
||||
const char *feature);
|
||||
|
||||
void
|
||||
virQEMUCapsCPUFeatureFromQEMUInPlace(virArch arch,
|
||||
char **feature);
|
||||
|
||||
virSEVCapability *
|
||||
virQEMUCapsGetSEVCapabilities(virQEMUCaps *qemuCaps);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user