From: Jiri Denemark Date: Fri, 9 Jun 2023 16:12:53 +0000 (+0200) Subject: qemu: Include maximum physical address size in baseline CPU X-Git-Tag: v9.5.0-rc1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce6d1dca6d9720e6dcb4e74a84550c2326a7c494;p=thirdparty%2Flibvirt.git qemu: Include maximum physical address size in baseline CPU The current implementation of virConnectBaselineHypervisorCPU in QEMU driver can provide a CPU definition that will not work on all hosts in case they have different maximum physical address size. So when we get the info from domain capabilities, we need to choose the smallest physical address size for the computed baseline CPU definition. https://bugzilla.redhat.com/show_bug.cgi?id=2171860 Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 857fbfb799..c4bd766531 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11778,6 +11778,8 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUDef *cpu = NULL; char *cpustr = NULL; g_auto(GStrv) features = NULL; + unsigned int physAddrSize = 0; + size_t i; virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -11845,6 +11847,21 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUExpandFeatures(arch, cpu) < 0) goto cleanup; + for (i = 0; i < ncpus; i++) { + if (!cpus[i]->addr || cpus[i]->addr->limit == 0) + continue; + + if (physAddrSize == 0 || cpus[i]->addr->limit < physAddrSize) + physAddrSize = cpus[i]->addr->limit; + } + + if (physAddrSize > 0) { + cpu->addr = g_new0(virCPUMaxPhysAddrDef, 1); + cpu->addr->mode = VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH; + cpu->addr->limit = physAddrSize; + cpu->addr->bits = -1; + } + cpustr = virCPUDefFormat(cpu, NULL); cleanup: