From ce6d1dca6d9720e6dcb4e74a84550c2326a7c494 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 9 Jun 2023 18:12:53 +0200 Subject: [PATCH] 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 --- src/qemu/qemu_driver.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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: