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 <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2023-06-09 18:12:53 +02:00
parent be1b7d5b18
commit ce6d1dca6d

View File

@ -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: