]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Implement VIR_CONNECT_BASELINE_CPU_IGNORE_HOST
authorJiri Denemark <jdenemar@redhat.com>
Mon, 23 Jun 2025 13:46:37 +0000 (15:46 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 18 Jul 2025 09:56:14 +0000 (11:56 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index 6982a7a828b34519bbb5d2ae8e71ba58502e0a91..7c203e32fec83c4e5832f1826d05de811cc74a10 100644 (file)
@@ -11964,13 +11964,20 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
     size_t i;
 
     virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
-                  VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
+                  VIR_CONNECT_BASELINE_CPU_MIGRATABLE |
+                  VIR_CONNECT_BASELINE_CPU_IGNORE_HOST, NULL);
 
     if (virConnectBaselineHypervisorCPUEnsureACL(conn) < 0)
         goto cleanup;
 
     migratable = !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE);
 
+    if ((flags & VIR_CONNECT_BASELINE_CPU_IGNORE_HOST) && ncpus < 2) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("ignoring host is only allowed when computing baseline from multiple CPUs"));
+        goto cleanup;
+    }
+
     if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_AUTO)))
         goto cleanup;
 
@@ -11993,14 +12000,19 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn,
     }
 
     if (ARCH_IS_X86(arch)) {
-        int rc = virQEMUCapsGetCPUFeatures(qemuCaps, virttype,
-                                           migratable, &features);
-        if (rc < 0)
-            goto cleanup;
-        if (features && rc == 0) {
-            /* We got only migratable features from QEMU if we asked for them,
-             * no further filtering in virCPUBaseline is desired. */
-            migratable = false;
+        if (flags & VIR_CONNECT_BASELINE_CPU_IGNORE_HOST) {
+            VIR_DEBUG("Not adding host's features as VIR_CONNECT_BASELINE_CPU_IGNORE_HOST was set");
+            g_clear_pointer(&cpuModels, virObjectUnref);
+        } else {
+            int rc = virQEMUCapsGetCPUFeatures(qemuCaps, virttype,
+                                               migratable, &features);
+            if (rc < 0)
+                goto cleanup;
+            if (features && rc == 0) {
+                /* We got only migratable features from QEMU if we asked for them,
+                 * no further filtering in virCPUBaseline is desired. */
+                migratable = false;
+            }
         }
 
         if (!(cpu = virCPUBaseline(arch, cpus, ncpus, cpuModels,