]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Include maximum physical address size in baseline CPU
authorJiri Denemark <jdenemar@redhat.com>
Fri, 9 Jun 2023 16:12:53 +0000 (18:12 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 16 Jun 2023 10:44:54 +0000 (12:44 +0200)
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>
src/qemu/qemu_driver.c

index 857fbfb7992ceeaac0a09ecb86bcc0661e0898c6..c4bd766531e43e43cfde8d45fbde74fba90b17df 100644 (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: