From f9f2003762fa9dbdea5ca57f3ced315244ca0177 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Mon, 23 Jun 2025 15:46:37 +0200 Subject: [PATCH] qemu: Implement VIR_CONNECT_BASELINE_CPU_IGNORE_HOST Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6982a7a828..7c203e32fe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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, -- 2.47.2