]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Replace big condition in virQEMUCapsCPUFilterFeatures with array
authorJiri Denemark <jdenemar@redhat.com>
Tue, 8 Oct 2024 10:26:44 +0000 (12:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 9 Oct 2024 12:46:51 +0000 (14:46 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_capabilities.c

index 1d7ac9803d9e4f9744d119873e83c8e85aa69c24..f930ad2acf1b464fae76856ec6ff9c3c85220ec4 100644 (file)
@@ -3531,22 +3531,26 @@ virQEMUCapsProbeQMPSGXCapabilities(virQEMUCaps *qemuCaps,
  * QEMU never supported them or they were dropped as they never did anything
  * useful.
  */
+const char *ignoredFeatures[] = {
+    "cmt", "mbm_total", "mbm_local", /* never supported by QEMU */
+    "osxsave", "ospke",              /* dropped from QEMU */
+};
+
 bool
 virQEMUCapsCPUFilterFeatures(const char *name,
                              virCPUFeaturePolicy policy G_GNUC_UNUSED,
                              void *opaque)
 {
     virArch *arch = opaque;
+    size_t i;
 
     if (!ARCH_IS_X86(*arch))
         return true;
 
-    if (STREQ(name, "cmt") ||
-        STREQ(name, "mbm_total") ||
-        STREQ(name, "mbm_local") ||
-        STREQ(name, "osxsave") ||
-        STREQ(name, "ospke"))
-        return false;
+    for (i = 0; i < G_N_ELEMENTS(ignoredFeatures); i++) {
+        if (STREQ(name, ignoredFeatures[i]))
+            return false;
+    }
 
     return true;
 }