cpu_x86: Introduce <check> element for CPU models

CPU models in the CPU map may be marked with <check partial="compat"/>
to indicate a backward compatible partial check (comparing our
definition of the model with the host CPU) should be performed. Other
models will be checked using just runnability info from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2024-10-09 13:26:40 +02:00
parent 0cf9039071
commit f8ade72c2b

View File

@ -150,6 +150,7 @@ struct _virCPUx86Model {
char *name;
bool decodeHost;
bool decodeGuest;
bool compatCheck;
virCPUx86Vendor *vendor;
virCPUx86Signatures *signatures;
virCPUx86Data data;
@ -1463,6 +1464,36 @@ x86ModelCompare(virCPUx86Model *model1,
}
static int
x86ModelParseCheck(virCPUx86Model *model,
xmlXPathContextPtr ctxt)
{
g_autofree char *check = NULL;
int rc;
if ((rc = virXPathBoolean("boolean(./check)", ctxt)) <= 0)
return rc;
check = virXPathString("string(./check/@partial)", ctxt);
if (!check) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing check/@partial in CPU model %1$s"),
model->name);
return -1;
}
if (STRNEQ(check, "compat")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid check/@partial value '%1$s' in CPU model %2$s"),
check, model->name);
return -1;
}
model->compatCheck = true;
return 0;
}
static int
x86ModelParseDecode(virCPUx86Model *model,
xmlXPathContextPtr ctxt)
@ -1693,6 +1724,9 @@ x86ModelParse(xmlXPathContextPtr ctxt,
model = g_new0(virCPUx86Model, 1);
model->name = g_strdup(name);
if (x86ModelParseCheck(model, ctxt) < 0)
return -1;
if (x86ModelParseDecode(model, ctxt) < 0)
return -1;