]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Introduce <check> element for CPU models
authorJiri Denemark <jdenemar@redhat.com>
Wed, 9 Oct 2024 11:26:40 +0000 (13:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 23 Oct 2024 14:00:44 +0000 (16:00 +0200)
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>
src/cpu/cpu_x86.c

index 7cf158e25b59e7e42e380b4e18557d537958b615..70893f8a62fca5c83a79b7dae3aea77e8547ae9c 100644 (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;